*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #1a1a24;
  --bg-window: #1e1e2e;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-glow: rgba(108, 92, 231, 0.4);
  --danger: #ff3b30;
  --success: #34c759;
  --font: 'Noto Sans SC', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text);
  user-select: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ===== BOOT ===== */
#boot-screen {
  background: #000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.boot-content { text-align: center; z-index: 2; }
.boot-logo {
  font-family: var(--mono);
  font-size: 2rem;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 2rem;
  animation: flicker 4s infinite;
}
.boot-bar {
  width: 280px;
  height: 3px;
  background: #222;
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 1rem;
}
.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s;
}
.boot-text {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.boot-glitch {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(108, 92, 231, 0.03) 2px,
    rgba(108, 92, 231, 0.03) 4px
  );
  pointer-events: none;
  animation: scanline 8s linear infinite;
}

/* ===== LOGIN ===== */
#login-screen {
  align-items: center;
  justify-content: center;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.15), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(255, 59, 48, 0.08), transparent 50%),
    linear-gradient(160deg, #0d0d14, #1a1028);
}
.login-panel {
  position: relative;
  background: rgba(30, 30, 46, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 3rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a29bfe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 auto 1rem;
}
.login-panel h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.login-hint { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-clue-hint { color: var(--text-dim); font-size: 0.75rem; margin-top: 1rem; opacity: 0.6; }

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#login-form input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
#login-form input:focus { border-color: var(--accent); }
#login-form button {
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
#login-form button:hover { background: #7c6cf0; }
#login-form button:active { transform: scale(0.98); }
.login-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }

/* ===== DESKTOP ===== */
#desktop { flex-direction: column; }
.desktop-wallpaper {
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='%230a0a12'/%3E%3Cpath d='M30 0v60M0 30h60' stroke='%23151520' stroke-width='0.5'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #0f0f1a 0%, #1a1028 40%, #0d1520 100%);
}
.desktop-icons {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  bottom: calc(48px + 0.75rem);
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.25rem 0.35rem;
  z-index: 2;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-right: 0.25rem;
}
.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  cursor: pointer;
  width: 76px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.desktop-icon:hover { background: rgba(255,255,255,0.08); }
.desktop-icon.locked { opacity: 0.5; }
.desktop-icon .icon-img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.desktop-icon span {
  font-size: 0.68rem;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ===== WINDOWS ===== */
.window-layer {
  position: absolute;
  inset: 0;
  bottom: 48px;
  pointer-events: none;
  z-index: 10;
}
.window {
  position: absolute;
  background: var(--bg-window);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  min-width: 400px;
  min-height: 300px;
  pointer-events: all;
  overflow: hidden;
  resize: both;
}
.window.focused { border-color: var(--accent); box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--accent); }
.window-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  gap: 0.5rem;
}
.window-header:active { cursor: grabbing; }
.window-title { flex: 1; font-size: 0.85rem; }
.window-controls { display: flex; gap: 0.35rem; }
.window-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.window-btn.close { background: #ff5f57; }
.window-btn.minimize { background: #febc2e; }
.window-btn.maximize { background: #28c840; }
.window-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ===== TASKBAR ===== */
.taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: rgba(15, 15, 25, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  z-index: 100;
}
.taskbar-start {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background 0.15s;
}
.taskbar-start:hover { background: rgba(255,255,255,0.1); }
.taskbar-apps { flex: 1; display: flex; gap: 0.25rem; }
.taskbar-app {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(255,255,255,0.05);
  transition: background 0.15s;
}
.taskbar-app:hover, .taskbar-app.active { background: rgba(108, 92, 231, 0.3); }
.taskbar-clock {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0 0.5rem;
}

.start-menu {
  position: absolute;
  bottom: 52px;
  left: 0.5rem;
  width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
  z-index: 200;
  overflow: hidden;
}
.start-menu-header {
  padding: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}
.start-menu-apps {
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
}
.start-menu-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: background 0.15s;
}
.start-menu-app:hover { background: rgba(255,255,255,0.08); }

/* ===== PHONE DOCK ===== */
.phone-dock {
  position: absolute;
  bottom: 60px;
  right: 1rem;
  z-index: 50;
}
.phone-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: rgba(30, 30, 46, 0.9);
  cursor: pointer;
  font-size: 1.5rem;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}
.phone-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--accent-glow);
}
.phone-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== PHONE SCREEN ===== */
#phone-screen {
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
}
.phone-frame {
  width: 320px;
  height: 640px;
  background: #111;
  border-radius: 36px;
  border: 3px solid #333;
  overflow: hidden;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.phone-notch {
  width: 120px;
  height: 28px;
  background: #111;
  border-radius: 0 0 16px 16px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.phone-status {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 1.5rem;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.phone-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100% - 60px);
  padding: 2rem;
  text-align: center;
}
.phone-lock-date { color: var(--text-dim); font-size: 0.9rem; }
.phone-lock-time { font-size: 3rem; font-weight: 300; margin: 0.5rem 0 2rem; }
.phone-lock-form { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }
.phone-lock-form input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-family: var(--mono);
  text-align: center;
  font-size: 1.1rem;
  outline: none;
}
.phone-lock-form button {
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.phone-lock-error { color: var(--danger); font-size: 0.8rem; min-height: 1em; }

.phone-home { height: calc(100% - 60px); display: flex; flex-direction: column; }
.phone-apps {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 2rem 1.5rem;
  align-content: start;
}
.phone-app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.65rem;
}
.phone-app-icon .p-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.15s;
}
.phone-app-icon:hover .p-icon { transform: scale(1.08); }
.phone-app-view {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
.phone-dock-bar {
  padding: 0.75rem;
  text-align: center;
  border-top: 1px solid var(--border);
}
.phone-dock-bar button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.phone-dock-bar button:hover { opacity: 1; }

/* ===== APP CONTENT STYLES ===== */
.app-sidebar-layout {
  display: flex;
  height: 100%;
  min-height: 280px;
}
.app-sidebar {
  width: 200px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
}
.app-main { flex: 1; overflow-y: auto; padding: 0.75rem; min-width: 0; }

.mobile-back-btn {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.list-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}
.list-item:hover, .list-item.active { background: rgba(108, 92, 231, 0.15); }
.list-item .item-title { font-size: 0.85rem; }
.list-item .item-meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.15rem; }
.list-item.unread .item-title { font-weight: 600; }
.list-item.unread::before {
  content: '●';
  color: var(--accent);
  margin-right: 0.35rem;
  font-size: 0.6rem;
}

.mail-body, .note-content, .browser-content, .file-content {
  padding: 0.5rem;
}
.mail-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}
.mail-header h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.mail-meta { font-size: 0.75rem; color: var(--text-dim); }

.chat-layout { display: flex; height: 100%; min-height: 280px; }
.chat-contacts { width: 160px; border-right: 1px solid var(--border); }
.chat-contact {
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.chat-contact:hover, .chat-contact.active { background: rgba(108, 92, 231, 0.15); }
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.chat-messages { flex: 1; overflow-y: auto; padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.chat-bubble {
  max-width: 75%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.chat-bubble.them { background: rgba(255,255,255,0.08); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-bubble.me { background: rgba(108, 92, 231, 0.3); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-time { font-size: 0.65rem; color: var(--text-dim); margin-top: 0.15rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
  font-size: 0.65rem;
  transition: transform 0.15s;
  position: relative;
  overflow: hidden;
}
.photo-thumb:hover { transform: scale(1.03); }
.photo-view {
  text-align: center;
}
.photo-view .photo-large {
  width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.photo-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: left;
  background: rgba(0,0,0,0.3);
  padding: 0.75rem;
  border-radius: 8px;
  white-space: pre-line;
}

.file-tree .folder, .file-tree .file {
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.file-tree .folder:hover, .file-tree .file:hover { background: rgba(255,255,255,0.05); }
.file-tree .indent { padding-left: 1.25rem; }

.encrypt-prompt {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
}
.encrypt-prompt input {
  width: 100%;
  padding: 0.5rem;
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-family: var(--mono);
  outline: none;
}
.encrypt-prompt button {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.encrypt-error { color: var(--danger); font-size: 0.8rem; }

.browser-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.browser-tab {
  padding: 0.35rem 0.75rem;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.05);
}
.browser-tab.active { background: rgba(108, 92, 231, 0.2); }
.browser-url {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(0,0,0,0.3);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.settings-list { display: flex; flex-direction: column; gap: 0.75rem; }
.settings-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  font-size: 0.85rem;
}
.settings-label { color: var(--text-dim); }

.shadow-log {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 2;
}
.shadow-log .log-line { opacity: 0; animation: fadeInLog 0.5s forwards; }

.creepy-text {
  color: var(--danger);
  animation: textGlitch 3s infinite;
}

/* ===== NOTIFICATIONS ===== */
.notification-area {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.notification {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  max-width: 300px;
  font-size: 0.8rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slideIn 0.4s ease;
  pointer-events: all;
}
.notification.creepy {
  border-color: var(--danger);
  background: rgba(40, 10, 10, 0.95);
}

/* ===== ENDING ===== */
#ending-screen {
  align-items: center;
  justify-content: center;
  background: #000;
  flex-direction: column;
  padding: 2rem;
}
.ending-content {
  max-width: 600px;
  text-align: center;
  line-height: 2;
  font-size: 1rem;
  animation: fadeIn 2s;
}
.ending-content h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--danger);
}
.ending-restart {
  margin-top: 3rem;
  padding: 0.75rem 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.ending-restart:hover { border-color: var(--accent); color: var(--text); }

/* ===== SCARE ===== */
.scare-overlay[hidden] {
  display: none !important;
}
.scare-overlay:not([hidden]) {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scareFlash 0.15s;
}
.scare-face {
  font-size: 8rem;
  animation: scareShake 0.3s;
}

/* ===== ANIMATIONS ===== */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.3; }
  94% { opacity: 1; }
  96% { opacity: 0.5; }
  97% { opacity: 1; }
}
@keyframes scanline {
  0% { transform: translateY(0); }
  100% { transform: translateY(100vh); }
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInLog {
  to { opacity: 1; }
}
@keyframes textGlitch {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; transform: translateX(1px); }
  51% { transform: translateX(-1px); }
}
@keyframes scareFlash {
  0% { background: #fff; }
  100% { background: #000; }
}
@keyframes scareShake {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-10px, 5px); }
  75% { transform: translate(10px, -5px); }
}

/* Glitch effect on desktop */
.desktop-glitch {
  animation: desktopGlitch 0.3s;
}
@keyframes desktopGlitch {
  0% { filter: none; }
  20% { filter: hue-rotate(90deg) brightness(1.5); transform: translateX(-3px); }
  40% { filter: hue-rotate(-90deg); transform: translateX(3px); }
  60% { filter: brightness(0.5); }
  100% { filter: none; transform: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== MOBILE ===== */
@media (max-width: 768px) {
  .login-panel {
    padding: 1.75rem 1.25rem;
    margin: 0 1rem;
  }

  .desktop-icons {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    bottom: calc(48px + env(safe-area-inset-bottom, 0px) + 0.5rem);
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.25rem;
    width: auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .desktop-icon {
    width: calc(25% - 0.25rem);
    min-width: 68px;
    padding: 0.35rem 0.2rem;
  }

  .desktop-icon .icon-img {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
    border-radius: 10px;
  }

  .desktop-icon span {
    font-size: 0.62rem;
    line-height: 1.2;
  }

  .window-layer {
    bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  .window,
  .window.window-mobile {
    position: absolute !important;
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    min-width: 0 !important;
    height: calc(100dvh - 64px - env(safe-area-inset-bottom, 0px)) !important;
    left: 8px !important;
    top: 8px !important;
    resize: none !important;
    border-radius: 12px;
  }

  .window-body {
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  .window-header {
    padding: 0.65rem 0.75rem;
    cursor: default;
  }

  .window-btn {
    width: 14px;
    height: 14px;
  }

  .window-btn.maximize { display: none; }

  .taskbar {
    height: calc(48px + env(safe-area-inset-bottom, 0px));
    padding: 0 0.5rem env(safe-area-inset-bottom, 0px);
    left: 0;
    right: 0;
    width: 100%;
  }

  .taskbar-app {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 0.35rem 0.5rem;
  }

  .taskbar-clock {
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .start-menu {
    width: calc(100vw - 1rem);
    left: 0.5rem;
    right: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
  }

  .phone-dock {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    right: 0.75rem;
  }

  .phone-toggle {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  #phone-screen {
    padding: 0.75rem;
  }

  .phone-frame {
    width: min(100%, 360px);
    height: min(82dvh, 680px);
    border-radius: 28px;
  }

  .phone-apps {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 1.25rem 1rem;
  }

  .phone-app-icon .p-icon {
    width: 46px;
    height: 46px;
    font-size: 1.25rem;
  }

  /* 邮件 / 聊天：手机端主从切换 */
  .mobile-back-btn { display: inline-block; }

  .app-sidebar-layout.mobile-list .app-main { display: none; }
  .app-sidebar-layout.mobile-detail .app-sidebar { display: none; }
  .app-sidebar-layout.mobile-list,
  .app-sidebar-layout.mobile-detail {
    flex-direction: column;
    min-height: 0;
  }
  .app-sidebar-layout.mobile-list .app-sidebar,
  .app-sidebar-layout.mobile-detail .app-main {
    width: 100%;
    flex: 1;
    max-height: none;
    border-right: none;
  }

  .chat-layout.mobile-list .chat-messages { display: none; }
  .chat-layout.mobile-detail .chat-contacts { display: none; }
  .chat-layout.mobile-list,
  .chat-layout.mobile-detail {
    flex-direction: column;
    min-height: 0;
  }
  .chat-layout.mobile-list .chat-contacts,
  .chat-layout.mobile-detail .chat-messages {
    width: 100%;
    flex: 1;
    max-height: none;
    border-right: none;
  }

  .app-sidebar,
  .chat-contacts {
    width: 100%;
    flex-shrink: 1;
  }

  .list-item { padding: 0.85rem 0.75rem; }
  .list-item .item-title { font-size: 0.9rem; }

  .chat-bubble { max-width: 88%; font-size: 0.9rem; }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .browser-tabs { flex-wrap: wrap; }

  .mail-header h3 {
    font-size: 0.95rem;
    word-break: break-word;
  }

  .mail-body,
  .note-content,
  .browser-content,
  .file-content {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .ending-content {
    padding: 0 1rem;
    font-size: 0.95rem;
    line-height: 1.8;
  }
}

@media (max-width: 380px) {
  .desktop-icon {
    width: calc(33.33% - 0.2rem);
    min-width: 60px;
  }

  .desktop-icon .icon-img {
    width: 38px;
    height: 38px;
  }
}
