/* ═══ LIQUID GLASS DESIGN SYSTEM ═══ */
/* Light mode (default) — WHITE / frosted glass */
:root {
  --bg: #ffffff;
  --bg-gradient: linear-gradient(180deg, #ffffff 0%, #f0f2f5 100%);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-hover: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.95);
  --glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.03);
  --glass-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.04);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 1);
  --card: rgba(255, 255, 255, 0.65);
  --card-hover: rgba(255, 255, 255, 0.85);
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --accent-glow: rgba(99, 102, 241, 0.2);
  --accent-text: #4f46e5;
  --text: #1a1a2e;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 22px;
  --blur: 24px;
  --safe-top: env(safe-area-inset-top, 20px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --hairline: rgba(0, 0, 0, 0.05);
  --hairline-strong: rgba(0, 0, 0, 0.08);
  --surface-solid: #ffffff;
  --modal-bg: rgba(0, 0, 0, 0.2);
  --terminal-bg: rgba(20, 20, 30, 0.92);
  --terminal-text: #a7f3d0;
  --scrollbar: rgba(99, 102, 241, 0.3);
  --scrollbar-hover: rgba(99, 102, 241, 0.5);
  --chip-bg: rgba(255, 255, 255, 0.6);
  --chip-border: rgba(0, 0, 0, 0.06);
  --sparkline-stroke: rgba(99, 102, 241, 0.6);
  --sparkline-fill: rgba(99, 102, 241, 0.1);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0f;
    --bg-gradient: linear-gradient(180deg, #0a0a0f 0%, #12121a 100%);
    --glass: rgba(30, 30, 42, 0.55);
    --glass-hover: rgba(40, 40, 55, 0.7);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.2);
    --glass-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.3);
    --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --card: rgba(30, 30, 42, 0.5);
    --card-hover: rgba(40, 40, 55, 0.7);
    --accent: #818cf8;
    --accent-soft: rgba(129, 140, 248, 0.15);
    --accent-glow: rgba(129, 140, 248, 0.3);
    --accent-text: #a5b4fc;
    --text: #e5e7eb;
    --text-dim: #9ca3af;
    --text-faint: #6b7280;
    --green: #34d399;
    --orange: #fbbf24;
    --red: #f87171;
    --hairline: rgba(255, 255, 255, 0.06);
    --hairline-strong: rgba(255, 255, 255, 0.1);
    --surface-solid: #1a1a2e;
    --modal-bg: rgba(0, 0, 0, 0.6);
    --terminal-bg: rgba(10, 10, 15, 0.95);
    --terminal-text: #6ee7b7;
    --scrollbar: rgba(129, 140, 248, 0.3);
    --scrollbar-hover: rgba(129, 140, 248, 0.5);
    --chip-bg: rgba(255, 255, 255, 0.06);
    --chip-border: rgba(255, 255, 255, 0.1);
    --sparkline-stroke: rgba(129, 140, 248, 0.7);
    --sparkline-fill: rgba(129, 140, 248, 0.12);
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══ SCREENS ═══ */
.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen.active { display: block; animation: liquid-glass-in 0.3s ease-out both; }

/* ═══ ANIMATIONS ═══ */

/* Liquid Glass entrance — opacity fade, mobile-safe */
@keyframes liquid-glass-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* App tiles stagger on home grid */
@keyframes tile-stagger-in {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}
.app-icon {
  animation: tile-stagger-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.app-icon:nth-child(1) { animation-delay: 0ms; }
.app-icon:nth-child(2) { animation-delay: 40ms; }
.app-icon:nth-child(3) { animation-delay: 80ms; }
.app-icon:nth-child(4) { animation-delay: 120ms; }
.app-icon:nth-child(5) { animation-delay: 160ms; }
.app-icon:nth-child(6) { animation-delay: 200ms; }
.app-icon:nth-child(7) { animation-delay: 240ms; }
.app-icon:nth-child(8) { animation-delay: 280ms; }
.app-icon:nth-child(9) { animation-delay: 320ms; }
.app-icon:nth-child(10) { animation-delay: 360ms; }
.app-icon:nth-child(11) { animation-delay: 400ms; }

/* ─── Pixel Grid Loader ─────────────────────────────────── */
.pixel-loader {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 36px;
  height: 36px;
}
.pixel-loader span {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--glass-border);
  border: 1px solid var(--glass-border);
  animation: pixel-flip 0.9s infinite ease-in-out;
}
.pixel-loader span:nth-child(1) { animation-delay: 0s; }
.pixel-loader span:nth-child(2) { animation-delay: 0.1s; }
.pixel-loader span:nth-child(3) { animation-delay: 0.2s; }
.pixel-loader span:nth-child(4) { animation-delay: 0.3s; }
.pixel-loader span:nth-child(5) { animation-delay: 0.4s; }
.pixel-loader span:nth-child(6) { animation-delay: 0.5s; }
.pixel-loader span:nth-child(7) { animation-delay: 0.6s; }
.pixel-loader span:nth-child(8) { animation-delay: 0.7s; }
.pixel-loader span:nth-child(9) { animation-delay: 0.8s; }
@keyframes pixel-flip {
  0%, 100% { opacity: 0.15; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); background: var(--accent); border-color: var(--accent); }
}

/* Centered pixel loader — no text, just the animation */
.pixel-loader-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 80px;
}

/* ─── Shimmer Skeletons ────────────────────────────────── */
@keyframes shimmer-sweep {
  0%   { background-position: -150% 0; }
  100% { background-position: 250% 0; }
}
.shimmer-block {
  background: linear-gradient(90deg,
    var(--hairline) 0%,
    var(--hairline-strong) 50%,
    var(--hairline) 100%);
  background-size: 200% 100%;
  animation: shimmer-sweep 1.4s infinite linear;
  border-radius: 8px;
}
.skeleton-book {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  align-items: center;
}
.skeleton-book .shimmer-block { height: 14px; }
.skeleton-book .skeleton-title { width: 60%; }
.skeleton-book .skeleton-meta { width: 35%; height: 10px; margin-top: 4px; }
.skeleton-music {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  align-items: center;
}
.skeleton-music .shimmer-block { height: 12px; }
.skeleton-music .skeleton-title { width: 50%; }
.skeleton-music .skeleton-meta { width: 25%; height: 10px; margin-top: 4px; }
.skeleton-file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  padding: 8px 0;
}
.skeleton-file {
  aspect-ratio: 1;
  border-radius: var(--radius);
}

/* Reduced motion: respect user preference */
@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .app-icon { animation: none !important; }
  .pixel-loader span { animation-duration: 2s; }
}

/* ─── About Panel ───────────────────────────────────────── */
.about-changelog {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}
.about-changelog h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.about-changelog ul {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.about-changelog li {
  padding: 2px 0 2px 16px;
  position: relative;
}
.about-changelog li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent);
}
.about-blurb {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 4px 0;
}

/* ═══ TOP BAR (clock + notification bell) ═══ */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px 4px;
}

.top-bar-left {
  flex: 1;
}

.clock {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}

/* Notification bell */
.notif-bell {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: all 0.15s;
  flex-shrink: 0;
}

.notif-bell:active { transform: scale(0.9); }
.notif-bell svg { color: var(--text-dim); }

.notif-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--surface-solid);
  display: none;
}

.notif-badge.visible { display: block; }

/* Notification panel (dropdown) */
.notif-panel {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  right: 16px;
  left: 16px;
  max-width: 420px;
  margin-left: auto;
  background: var(--glass);
  backdrop-filter: blur(40px) saturate(1.5);
  -webkit-backdrop-filter: blur(40px) saturate(1.5);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow-lg), var(--glass-inset);
  z-index: 50;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.notif-panel.open {
  max-height: 70vh;
  opacity: 1;
}

.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
  font-size: 15px;
  font-weight: 600;
}

.notif-clear {
  background: none;
  border: none;
  color: var(--accent-text);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}

.notif-list {
  padding: 0 18px 14px;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
  line-height: 1.5;
  align-items: flex-start;
}

.notif-item:last-child { border-bottom: none; }

.notif-item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.notif-item-icon.info { background: var(--accent); }
.notif-item-icon.warning { background: var(--orange); }
.notif-item-icon.error { background: var(--red); }
.notif-item-icon.success { background: var(--green); }

.notif-item-body {
  flex: 1;
  min-width: 0;
}

.notif-item-text {
  color: var(--text);
  margin-bottom: 2px;
}

.notif-item-time {
  font-size: 11px;
  color: var(--text-faint);
}

.notif-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 24px 0;
}

/* ═══ STATUS CHIPS (Kali-style) ═══ */
.status-chips {
  display: flex;
  gap: 8px;
  padding: 8px 24px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.status-chips::-webkit-scrollbar { display: none; }

.stat-chip {
  flex-shrink: 0;
  background: var(--chip-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 62px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.stat-chip:active { transform: scale(0.94); }

.stat-chip-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.stat-chip-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* Color coding for values */
.stat-chip.warn .stat-chip-value { color: var(--orange); }
.stat-chip.danger .stat-chip-value { color: var(--red); }

/* Mini sparkline graph mode */
.stat-chip .chip-sparkline {
  display: none;
}

.stat-chip.graph-mode .chip-percent {
  display: none;
}

.stat-chip.graph-mode .chip-sparkline {
  display: block;
}

.chip-sparkline svg {
  display: block;
}

/* Graph mode wrapper with labels */
.chip-graph-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
}

.chip-graph-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: baseline;
}

.chip-graph-name {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.chip-graph-val {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.chip-graph-axis {
  font-size: 8px;
  color: var(--text-faint);
  opacity: 0.6;
}

.chip-graph-empty {
  font-size: 13px;
  color: var(--text-faint);
  padding: 8px 0;
}

/* ═══ LEGACY STATUS BAR (kept for reference, unused) ═══ */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 10px;
}

.status-info {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  line-height: 1.5;
}

/* ═══ APP GRID ═══ */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 30px 24px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.app-icon:active { transform: scale(0.88); }

.app-icon-visual {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-inset);
}

.app-icon-visual svg {
  color: var(--text);
  transition: color 0.2s;
}

.app-icon:active .app-icon-visual svg {
  transform: scale(0.9);
}

.app-label {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══ APP HEADER ═══ */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--hairline);
  z-index: 10;
}

.app-header h2 {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Screen title SVG icon */
.screen-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.screen-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.screen-title-icon svg {
  color: var(--accent);
}

/* Navigation arrows (CSS-drawn) */
.nav-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: middle;
}

.nav-arrow.prev {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid currentColor;
  margin-right: 4px;
}

.nav-arrow.next {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  margin-left: 4px;
}

/* Play button SVG */
.play-btn svg { color: white; }

/* Cover art SVG */
.cover-art svg {
  filter: drop-shadow(0 8px 24px var(--accent-glow));
}

/* Agent status dot (CSS circle, no text needed) */
.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.agent-status-dot.ready { background: var(--green); }
.agent-status-dot.error { background: var(--red); }
.agent-status-dot.paused { background: var(--orange); }
.agent-status-dot.unknown { background: var(--text-faint); }

/* Fooocus generate button icon */
.fooocus-gen-icon {
  display: inline-flex;
  vertical-align: middle;
  margin-right: 4px;
}

.app-header .back-btn {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--accent-text);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.app-header .back-btn:active {
  transform: scale(0.95);
  background: var(--glass-hover);
}

#reader-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══ BOOK LIST ═══ */
.book-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.book-item {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: all 0.2s;
}

.book-item:active {
  transform: scale(0.98);
  background: var(--glass-hover);
}

.book-item-info { flex: 1; min-width: 0; }

.book-item-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.book-item-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.book-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.book-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.book-status.ready {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.book-status.generating {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
}

.book-status.new {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.settings-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.settings-btn:active { color: var(--accent); transform: scale(0.9); }

/* ═══ BOOK MODE BAR ═══ */
.book-mode-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--hairline);
}

.mode-btn {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-glow);
  color: var(--accent-text);
}

.mode-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ═══ CHAPTER NAV ═══ */
.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--hairline);
}

.chapter-nav-btn {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.chapter-nav-btn:active { transform: scale(0.95); }
.chapter-nav-btn:disabled { opacity: 0.3; cursor: default; }

.chapter-nav-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ═══ READER PANE ═══ */
.reader-pane {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
}

.reader-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--hairline);
  gap: 8px;
}

.reader-ctrl-btn {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.reader-ctrl-btn:active { transform: scale(0.95); opacity: 0.7; }

.reader-font-size {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.reader-text {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  line-height: 1.8;
  color: var(--text);
  font-size: 18px;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.reader-text::-webkit-scrollbar { width: 6px; }
.reader-text::-webkit-scrollbar-track { background: transparent; }
.reader-text::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; }
.reader-text::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

.reader-word {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.1s;
}

.reader-word:active { background: var(--accent-soft); }

.reader-word.bookmarked {
  background: rgba(245, 158, 11, 0.15);
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
}

/* ═══ BOOKMARK PANEL ═══ */
.bookmark-list-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 50vh;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-top: 1px solid var(--glass-border);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px 24px;
  z-index: 10;
  overflow-y: auto;
  box-shadow: var(--glass-shadow-lg);
}

.bookmark-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}

.bookmark-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}

.bookmark-word {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-ch {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}

.bookmark-goto {
  background: var(--accent-soft);
  border: 1px solid var(--accent-glow);
  color: var(--accent-text);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.bookmark-del {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: var(--red);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* ═══ AUDIO PANE ═══ */
.audio-pane { padding: 16px; }

.audio-pane .cover-art {
  text-align: center;
  padding: 20px;
}

.cover-art {
  text-align: center;
  line-height: 1;
  padding: 16px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-title-display {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

/* ═══ PLAYER CONTROLS ═══ */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 0;
}

.player-btn {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--text);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
}

.player-btn:active {
  transform: scale(0.88);
  background: var(--glass-hover);
}

.play-btn {
  width: 68px;
  height: 68px;
  background: var(--accent);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.play-btn:active {
  background: var(--accent);
  transform: scale(0.92);
}

/* ═══ PROGRESS BAR ═══ */
.progress-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--hairline-strong);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ═══ CHAPTER DROPDOWN ═══ */
.chapter-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.chapter-dropdown-header label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.resume-hint {
  font-size: 11px;
  color: var(--accent-text);
  font-weight: 600;
}

#chapter-dropdown {
  width: 100%;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  margin-bottom: 8px;
  box-shadow: var(--glass-shadow);
}

#chapter-dropdown:focus {
  outline: none;
  border-color: var(--accent);
}

#chapter-dropdown option {
  background: var(--surface-solid);
  color: var(--text);
  padding: 8px;
}

#chapter-dropdown option.completed {
  color: var(--green);
  font-weight: 600;
}

#chapter-dropdown option.current {
  color: var(--accent-text);
  font-weight: 700;
}

#chapter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#chapter-buttons::-webkit-scrollbar { display: none; }

.chapter-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.chapter-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
  border-color: transparent;
}

.chapter-btn.done {
  background: rgba(16, 185, 129, 0.1);
  color: var(--green);
}

.chapter-btn.done.active {
  background: var(--accent);
  color: white;
}

.chapter-btn.pending { opacity: 0.4; cursor: default; }

/* ═══ TRANSCRIPT ═══ */
.transcript-box {
  width: 100%;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  margin-bottom: 12px;
  box-shadow: var(--glass-shadow);
}

.transcript-box::-webkit-scrollbar { width: 6px; }
.transcript-box::-webkit-scrollbar-track { background: transparent; }
.transcript-box::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; }
.transcript-box::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

.transcript-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-dim);
  user-select: text;
  -webkit-user-select: text;
}

.transcript-text .tw {
  border-radius: 3px;
  padding: 1px 1px;
  transition: all 0.15s;
}

.transcript-text .tw.active {
  color: white;
  background: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.transcript-text .tw.spoken {
  color: var(--text);
}

.transcript-text .highlight {
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 0;
}

/* ═══ UNIVERSE ═══ */
.universe-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#universe-canvas {
  width: 100%;
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
}
.universe-detail {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px;
  min-height: 60px;
  font-size: 0.85rem;
}
.universe-add-bar {
  display: flex;
  gap: 8px;
}
.universe-add-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: var(--glass-bg);
  color: var(--text);
  font-size: 0.9rem;
}
.universe-add-bar button {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.universe-rescan-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

/* ═══ OSINT PRIVACY WATCHER ═══ */
.osint-content { padding: 20px; max-width: 600px; margin: 0 auto; }
.osint-section { margin-bottom: 24px; }
.osint-section h3 { font-size: 14px; color: var(--text-dim); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.osint-profiles { display: flex; flex-direction: column; gap: 10px; }
.osint-profile-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.osint-profile-card:hover { border-color: rgba(99,102,241,0.4); }
.osint-profile-header { display: flex; justify-content: space-between; align-items: center; }
.osint-profile-chevron { color: var(--text-dim); font-size: 0.8rem; }
.osint-profile-expanded { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--glass-border); }
.osint-scan-btn.delete { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.osint-profile-scans { margin-top: 10px; font-size: 0.8rem; }

/* Scan modal */
.osint-scan-modal {
  position: fixed; inset: 0; z-index: 10001;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.osint-scan-modal-content {
  background: var(--bg); border: 1px solid var(--glass-border);
  border-radius: 16px; width: 90%; max-width: 500px;
  max-height: 85vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.osint-scan-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--glass-border);
}
.osint-scan-modal-header h3 { font-size: 1.1rem; }
.osint-scan-modal-close {
  background: none; border: none; font-size: 1.5rem;
  color: var(--text-dim); cursor: pointer; line-height: 1;
}
.osint-scan-modal-body { padding: 16px 20px; }
.osint-scan-task {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 12px; margin-bottom: 10px;
}
.osint-scan-task-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; flex-wrap: wrap; gap: 4px;
}
.osint-scan-task-name { font-weight: 600; font-size: 0.9rem; }
.osint-scan-task-status { font-size: 0.78rem; color: var(--text-dim); }
.osint-progress-bar {
  height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px;
  overflow: hidden; margin-bottom: 8px;
}
.osint-progress-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 1s linear;
}
.osint-scan-view-btn {
  padding: 6px 14px; border: none; border-radius: 8px;
  background: var(--accent); color: white; font-size: 0.8rem;
  cursor: pointer; font-weight: 600;
}

/* Finding rows */
.osint-finding-row {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.osint-finding-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.osint-confidence-badge {
  font-size: 0.65rem; padding: 2px 8px; border-radius: 6px;
  font-weight: 700; letter-spacing: 0.05em;
}
.osint-finding-source { font-size: 0.7rem; color: var(--text-dim); }
.osint-finding-link {
  display: block; font-size: 0.85rem; color: var(--accent);
  text-decoration: none; margin-bottom: 4px; word-break: break-all;
}
.osint-finding-link:hover { text-decoration: underline; }
.osint-finding-snippet {
  font-size: 0.75rem; color: var(--text-dim); line-height: 1.4;
  padding: 4px 0; border-top: 1px solid var(--glass-border);
}
.osint-profile-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.osint-profile-info { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.osint-profile-info span { background: var(--glass-bg); padding: 2px 8px; border-radius: 8px; }
.osint-profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.osint-scan-btn {
  padding: 6px 14px; border-radius: 10px; border: 1px solid var(--glass-border);
  background: var(--accent); color: white; font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.osint-scan-btn.deep { background: #ef4444; }
.osint-scan-btn:hover { opacity: 0.85; }
.osint-add-profile {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 14px; padding: 14px;
}
.osint-add-profile input {
  padding: 10px; border-radius: 10px; border: 1px solid var(--glass-border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.osint-add-profile button {
  padding: 10px; border-radius: 10px; border: none;
  background: var(--accent); color: white; font-size: 14px; cursor: pointer;
}
.osint-empty { color: var(--text-dim); font-size: 13px; padding: 20px; text-align: center; }
.osint-scanning { color: var(--accent); font-size: 14px; padding: 20px; text-align: center; animation: pulse 1.5s infinite; }
.osint-summary-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.osint-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 12px;
  padding: 12px 16px; min-width: 80px;
}
.osint-stat-num { font-size: 24px; font-weight: 700; color: var(--accent); }
.osint-stat-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.osint-result-section { margin-bottom: 16px; }
.osint-result-section h4 { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.osint-broker-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 10px; margin-bottom: 4px;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
}
.osint-broker-row.found { border-color: #ef444440; }
.osint-broker-name { flex: 1; font-size: 13px; }
.osint-badge { font-size: 10px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.osint-badge.found { background: #ef444420; color: #ef4444; }
.osint-badge.safe { background: #22c55e20; color: #22c55e; }
.osint-optout { font-size: 11px; color: var(--accent); text-decoration: none; }
.osint-optout:hover { text-decoration: underline; }
.osint-username-row { padding: 10px 12px; background: var(--glass-bg); border-radius: 10px; margin-bottom: 6px; }
.osint-site-link { font-size: 12px; margin-left: 16px; margin-top: 4px; }
.osint-site-link a { color: var(--accent); text-decoration: none; }
.osint-exposure-row { font-size: 13px; padding: 6px 12px; display: flex; align-items: center; gap: 8px; }
.osint-scan-row {
  display: flex; gap: 12px; padding: 10px 14px; cursor: pointer;
  background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 10px; margin-bottom: 6px; font-size: 12px;
}
.osint-scan-row:hover { border-color: var(--accent); }
.osint-error { color: #ef4444; font-size: 14px; padding: 20px; }

/* ═══ SYSTEM MONITOR ═══ */
.system-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--glass-shadow), var(--glass-inset);
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
}

.stat-bar {
  width: 100%;
  height: 8px;
  background: var(--hairline-strong);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s;
}

.process-card {
  margin: 0 20px 20px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  overflow: hidden;
}

.process-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.process-count {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 12px;
}

.process-list-head, .process-row {
  display: grid;
  grid-template-columns: 1fr 56px 48px 48px;
  gap: 8px;
  align-items: center;
  padding: 0 16px;
}

.process-list-head {
  padding-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.process-col-num { text-align: right; }
.process-col-pid { text-align: right; }

.process-list {
  max-height: 46vh;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-overflow-scrolling: touch;
}

.process-row {
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 12.5px;
  border-top: 1px solid var(--hairline-strong);
}

.process-row:first-child { border-top: none; }

.process-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-pid { color: var(--text-dim); }

.process-num { font-variant-numeric: tabular-nums; }
.process-num.warn { color: var(--orange); }
.process-num.danger { color: var(--red); }

.process-loading, .process-error {
  padding: 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.process-error { color: var(--red); }

/* ═══ TERMINAL ═══ */
.terminal-content { padding: 20px; height: calc(100% - 60px); display: flex; flex-direction: column; }

/* xterm.js container */
.xterm-container {
  flex: 1;
  background: #0d0d12;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 8px;
  overflow: hidden;
  min-height: 400px;
}
.xterm-container .xterm {
  height: 100%;
}
.xterm-container .xterm-viewport {
  background-color: #0d0d12 !important;
}

/* Mobile key bar */
.term-keybar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 0 4px;
  justify-content: center;
}
.term-key {
  min-width: 38px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: var(--glass-bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.term-key:active {
  background: var(--accent);
  color: white;
  transform: scale(0.95);
}
.term-key-wide {
  min-width: 56px;
}

/* Terminal tabs */
.terminal-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.terminal-tab {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.terminal-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.terminal-output {
  background: var(--terminal-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--terminal-text);
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 20px;
}

.command-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.command-buttons button {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 14px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.command-buttons button:active {
  transform: scale(0.96);
  background: var(--glass-hover);
}

.terminal-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.terminal-input {
  flex: 1;
  background: var(--terminal-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--terminal-text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  outline: none;
  -webkit-appearance: none;
}

.terminal-input:focus { border-color: var(--accent); }

.terminal-input::placeholder {
  color: rgba(110, 231, 183, 0.3);
}

.terminal-send-btn {
  background: var(--accent);
  border: none;
  color: white;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* ═══ MODAL ═══ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  justify-content: center;
  align-items: flex-end;
  padding: 20px;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

.modal-content {
  background: var(--glass);
  backdrop-filter: blur(40px) saturate(1.5);
  -webkit-backdrop-filter: blur(40px) saturate(1.5);
  border: 1px solid var(--glass-border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--glass-shadow-lg), var(--glass-inset);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.modal-close:active { transform: scale(0.9); }

/* ═══ SETTINGS SECTIONS ═══ */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ═══ VOICE CARDS ═══ */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.voice-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 8px 10px;
  text-align: center;
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: var(--glass-shadow);
}

.voice-card:active { transform: scale(0.95); }

.voice-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.voice-icon { font-size: 22px; line-height: 1; }

.voice-name {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

.voice-active-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 8px;
  margin-top: 2px;
}

/* ═══ CHAPTER STATUS (settings) ═══ */
.chapter-status-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: none;
}

.chapter-status-list::-webkit-scrollbar { display: none; }

.chapter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.chapter-row.done {
  background: rgba(16, 185, 129, 0.06);
  color: var(--green);
}

.chapter-row-num {
  width: 22px;
  font-weight: 700;
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}

.chapter-row-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.chapter-row-size {
  font-size: 10px;
  opacity: 0.6;
  flex-shrink: 0;
}

.chapter-none {
  font-size: 13px;
  color: var(--text-dim);
  padding: 8px 0;
  text-align: center;
}

/* ═══ GENERATE BUTTONS ═══ */
.gen-controls {
  display: flex;
  gap: 10px;
}

.gen-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  flex: 1;
  text-align: center;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.gen-btn:active { opacity: 0.8; transform: scale(0.97); }

.gen-btn.stop {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
  box-shadow: none;
}

.gen-status {
  font-size: 13px;
  color: var(--text-dim);
}

/* ═══ GENERATION BANNER ═══ */
.gen-banner {
  width: 100%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-glow);
  border-radius: 12px;
  padding: 12px 16px;
  text-align: center;
}

.gen-banner-title {
  font-size: 13px;
  color: var(--accent-text);
  margin-bottom: 8px;
}

.gen-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--hairline-strong);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.gen-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s;
}

.gen-banner-sub {
  font-size: 11px;
  color: var(--text-dim);
}

/* ═══ AGENTS SCREEN ═══ */
.agents-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 6px;
  margin-top: 4px;
}

.agent-activity-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 4px;
  box-shadow: var(--glass-shadow);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 160px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
}

.activity-item:last-child { border-bottom: none; }

.activity-dir {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  flex-shrink: 0;
}

.activity-dir.in { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.activity-dir.out { background: rgba(52, 211, 153, 0.12); color: #34d399; }

.activity-time {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 45px;
}

.activity-text {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-item.in .activity-text { color: var(--text); }

/* ─── Agent Cards ─── */
.agent-note {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0 2px;
  font-style: italic;
}

.agent-status {
  font-size: 10px;
  flex-shrink: 0;
}
.agent-status.ready { color: var(--green); }
.agent-status.error { color: var(--red); }
.agent-status.paused { color: var(--orange); }
.agent-status.unknown { color: var(--text-dim); }

.agent-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: opacity 0.15s;
}

.agent-card:active { opacity: 0.8; }

.agent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.agent-expand {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: auto;
  transition: transform 0.2s;
}

.agent-detail { display: none; }
.agent-detail.open { display: block; }

.agent-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.agent-avatar.nika { background: linear-gradient(135deg, #6366f1, #a78bfa); }
.agent-avatar.hermy { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.agent-avatar.decloud { background: linear-gradient(135deg, #10b981, #34d399); }
.agent-avatar.pengy { background: linear-gradient(135deg, #3b82f6, #60a5fa); }

.agent-info { flex: 1; min-width: 0; }

.agent-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-tag {
  font-size: 10px;
  font-weight: 600;
  background: var(--hairline-strong);
  color: var(--text-dim);
  padding: 2px 7px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.agent-platform {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Toggle switch */
.job-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.job-toggle input { opacity: 0; width: 0; height: 0; }

.job-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--hairline-strong);
  border-radius: 20px;
  transition: 0.2s;
}

.job-toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.job-toggle input:checked + .job-toggle-slider { background: var(--green); }
.job-toggle input:checked + .job-toggle-slider:before { transform: translateX(16px); }

.job-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--hairline);
  border-radius: 10px;
  font-size: 12px;
}

.job-row.error { background: rgba(239, 68, 68, 0.06); }

.job-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.job-dot.ok { background: var(--green); }
.job-dot.error { background: var(--red); }
.job-dot.paused { background: var(--orange); }

.job-info { flex: 1; min-width: 0; }

.job-name {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-schedule {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.job-last {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-top: 1px;
}

.job-next {
  font-size: 10px;
  color: var(--accent-text);
  margin-top: 1px;
}

.job-error {
  font-size: 10px;
  color: var(--red);
  margin-top: 2px;
  word-break: break-all;
}

.agent-summary {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 0 2px;
}

/* ═══ SUMMARY MODAL ═══ */
.summary-modal-content {
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.sofar-btn {
  margin-left: auto;
  background: var(--accent-soft) !important;
  border-color: var(--accent-glow) !important;
  color: var(--accent-text) !important;
  font-weight: 600;
  white-space: nowrap;
}

.summary-loading {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  display: flex;
  gap: 16px;
  color: var(--text-dim);
}

.summary-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.summary-body {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.summary-body::-webkit-scrollbar { width: 6px; }
.summary-body::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; }

.summary-tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-tab {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.summary-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-glow);
  color: var(--accent-text);
}

.summary-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  padding: 4px 0 16px;
  white-space: pre-wrap;
}

.summary-qa-section {
  margin-top: 16px;
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
}

.summary-qa-header {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.summary-chat {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
  margin-bottom: 10px;
}

.summary-chat::-webkit-scrollbar { width: 4px; }
.summary-chat::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }

.summary-msg {
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

.summary-msg.user {
  background: var(--accent-soft);
  color: var(--text);
  margin-left: 20px;
}

.summary-msg.ai {
  background: var(--hairline);
  color: var(--text);
  margin-right: 20px;
}

.summary-msg.ai.loading {
  color: var(--text-dim);
  font-style: italic;
}

.summary-ask-row {
  display: flex;
  gap: 8px;
}

/* Summary ask input inherits terminal-input but adapts colors */
.summary-ask-row .terminal-input {
  background: var(--glass);
  color: var(--text);
  border-color: var(--glass-border);
}

.summary-ask-row .terminal-input::placeholder {
  color: var(--text-faint);
}

/* ═══ LEGO FILE BROWSER ═══ */
.lego-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--hairline);
}

.lego-crumb {
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}

.lego-crumb:active { background: var(--accent-soft); }
.lego-crumb.active { color: var(--accent-text); font-weight: 600; }

.lego-crumb-sep {
  color: var(--text-faint);
  font-size: 12px;
}

.lego-view-toggle {
  margin-left: auto;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  width: 34px;
  height: 30px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lego-view-toggle:active { transform: scale(0.9); }

/* Grid mode */
.lego-list.lego-grid {
  padding: 12px 12px 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.lego-card {
  cursor: pointer;
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
  border: none;
  transition: transform 0.15s;
}

.lego-card:active {
  transform: scale(0.96);
}

.lego-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lego-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lego-thumb-placeholder {
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.lego-thumb-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.lego-card-info {
  padding: 8px 10px 10px;
}

.lego-card-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.lego-card-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* List mode */
.lego-list:not(.lego-grid) {
  padding: 8px 12px 40px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lego-list:not(.lego-grid) .lego-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.lego-list:not(.lego-grid) .lego-thumb-wrap {
  width: 48px;
  height: 48px;
  aspect-ratio: unset;
  border-radius: 10px;
  flex-shrink: 0;
}

.lego-list:not(.lego-grid) .lego-thumb-placeholder {
  opacity: 0.4;
}

.lego-list:not(.lego-grid) .lego-thumb-badge {
  width: 18px;
  height: 18px;
  font-size: 9px;
  bottom: 2px;
  right: 2px;
}

.lego-list:not(.lego-grid) .lego-card-info {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
}

.lego-list:not(.lego-grid) .lego-card-name {
  font-size: 14px;
  font-weight: 500;
}

.lego-list:not(.lego-grid) .lego-card-meta {
  font-size: 11px;
  margin-top: 1px;
}

/* Image viewer */
.lego-image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.lego-image-viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  pointer-events: auto;
  z-index: 200;
}

.lego-image-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  z-index: 210;
}

.ollama-model-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--hairline);
}

.ollama-model-bar select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.ollama-model-info {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.ollama-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  height: calc(100dvh - 160px);
}

.ollama-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}

.ollama-welcome {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 15px;
}

.ollama-msg {
  margin-bottom: 12px;
  display: flex;
}

.ollama-msg.user {
  justify-content: flex-end;
}

.ollama-msg-content {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ollama-msg.user .ollama-msg-content {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.ollama-msg.assistant .ollama-msg-content {
  background: var(--glass);
  border: 1px solid var(--hairline);
  border-bottom-left-radius: 4px;
}

.ollama-typing {
  color: var(--text-dim);
  font-style: italic;
}

.ollama-code {
  background: rgba(0,0,0,0.1);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 13px;
  margin: 6px 0;
}

.ollama-inline-code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.ollama-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--hairline);
  align-items: flex-end;
}

.ollama-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  color: var(--text);
  font-size: 14px;
  resize: none;
  min-height: 40px;
  max-height: 120px;
}

.ollama-send-btn, .ollama-stop-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ollama-stop-btn {
  background: var(--red, #ef4444);
}

/* ─── Fooocus ─── */
.fooocus-content {
  padding: 16px;
  padding-bottom: 60px;
}

.fooocus-status-bar {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

.fooocus-status-bar.online {
  background: rgba(34, 197, 94, 0.1);
  color: rgb(22, 163, 74);
}

.fooocus-status-bar.offline {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red, #ef4444);
}

.fooocus-prompt-section {
  margin-bottom: 12px;
}

.fooocus-prompt {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  color: var(--text);
  font-size: 15px;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}

.fooocus-params {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.fooocus-param {
  flex: 1;
}

.fooocus-param label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.fooocus-param select, .fooocus-param input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  color: var(--text);
  font-size: 13px;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.fooocus-generate-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  transition: transform 0.1s;
}

.fooocus-generate-btn:active { transform: scale(0.98); }
.fooocus-generate-btn:disabled { opacity: 0.5; }

.fooocus-progress {
  margin-bottom: 16px;
}

.fooocus-progress-text {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 8px;
}

.fooocus-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--hairline);
  overflow: hidden;
}

.fooocus-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.fooocus-result {
  margin-bottom: 20px;
}

.fooocus-result img {
  width: 100%;
  border-radius: 12px;
  display: block;
  margin-bottom: 8px;
}

.fooocus-gallery-section {
  margin-top: 20px;
}

.fooocus-gallery-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.fooocus-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.fooocus-gallery-item {
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
}

.fooocus-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Swipe Mode ─── */
/* Load more progress */
.lego-loading {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
}

.lego-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  border: 3px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lego-spin 0.8s linear infinite;
}

@keyframes lego-spin {
  to { transform: rotate(360deg); }
}

.lego-loading-text {
  font-size: 13px;
  color: var(--text-dim);
}

.lego-load-more {
  grid-column: 1 / -1;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 12px;
}

.lego-load-more:active {
  background: var(--accent-soft);
}

.lego-load-more-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.lego-load-more-bar {
  width: 200px;
  max-width: 80%;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline-strong);
  margin: 0 auto;
  overflow: hidden;
}

.lego-load-more-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ═══ VOICE SYSTEM ═══ */

/* Floating orb button */
.voice-orb {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow), var(--glass-inset);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.3s;
}
.voice-orb:active { transform: scale(0.92); }

/* AI Spread Menu */
.ai-spread-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.ai-spread-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.ai-spread-item {
  position: absolute;
  width: 72px; height: 72px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 18px;
  background: var(--bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  cursor: pointer;
  opacity: 0;
  transform: translate(0, 0) scale(0.15);
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--delay, 0s);
}
.ai-spread-item.show {
  opacity: 1;
  transform: translate(var(--tx), var(--ty)) scale(1);
}
/* Collapse: snap back to center, no stagger */
.ai-spread-overlay:not(.active) .ai-spread-item {
  transition-delay: 0s;
  transform: translate(0, 0) scale(0.15);
  opacity: 0;
}
.ai-spread-item.show:active {
  transform: translate(var(--tx), var(--ty)) scale(0.88);
}
.ai-spread-item-visual {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
}
.ai-spread-item-visual svg {
  width: 26px; height: 26px;
}
.ai-spread-item-label {
  font-size: 0.68rem;
  color: var(--text);
  margin-top: 3px;
  font-weight: 600;
}
.app-icon.ai-spread-active .app-icon-visual {
  transform: scale(0.9);
  opacity: 0.5;
  transition: all 0.3s ease;
}

/* Journal app */
.journal-tabs {
  display: flex; gap: 0; padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
}
.journal-tab {
  padding: 8px 20px; border: none; background: none;
  color: var(--text-dim); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.journal-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.journal-panel { padding: 16px; }
.journal-voice-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px; padding: 32px 16px;
}
.journal-record-btn {
  width: 72px; height: 72px; border-radius: 50%;
  border: 3px solid var(--glass-border); cursor: pointer;
  background: var(--glass);
  color: var(--text); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  transition: transform 0.15s, background 0.2s;
  font-size: 0.65rem; font-weight: 600;
  position: relative;
}
.journal-record-btn:active { transform: scale(0.93); }
.journal-record-btn.recording {
  background: #ef4444; border-color: #ef4444;
  color: white;
  animation: vj-pulse 1.2s ease-in-out infinite;
}
.journal-voice-status {
  font-size: 0.82rem; color: var(--text-dim);
  text-align: center; max-width: 350px;
  min-height: 1.2em;
}

/* Legos 3D */
.legos-content {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  position: relative;
}
#legos-canvas {
  flex: 1;
  display: block;
  width: 100%;
  touch-action: none;
}
.legos-counter {
  font-size: 0.78rem; color: var(--text-dim);
  font-weight: 500; margin-left: auto;
}
.legos-fab-row {
  position: absolute;
  bottom: 20px; right: 20px;
  display: flex; gap: 12px;
  z-index: 10;
}
.legos-fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.legos-fab:active { transform: scale(0.9); }
.legos-fab-add {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.legos-fab-add:active { transform: scale(0.9); }
.legos-fab-delete.active {
  background: #ef4444; color: white; border-color: transparent;
  box-shadow: 0 4px 20px rgba(239,68,68,0.3);
  animation: legos-delete-pulse 1.5s ease-in-out infinite;
}
@keyframes legos-delete-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(239,68,68,0.3); }
  50% { box-shadow: 0 4px 28px rgba(239,68,68,0.5); }
}

/* Keep voice-journal-btn CSS for compatibility */
.voice-journal-btn { display: none !important; }
@keyframes vj-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* vj-toast still used */
.vj-toast {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--text);
  z-index: 10002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 280px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.vj-toast.show {
  opacity: 1;
}

.voice-orb:active {
  transform: scale(0.92);
}

.voice-orb-inner {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes voice-orb-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), 0 0 0 0 rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 4px 30px rgba(99, 102, 241, 0.5), 0 0 0 12px rgba(99, 102, 241, 0); }
}

/* Voice overlay */
.voice-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.voice-overlay.active {
  display: flex;
}

.voice-overlay-bg {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.voice-overlay-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px;
  padding-top: max(20px, env(safe-area-inset-top, 0px));
}

/* Animated orb in overlay */
.voice-anim {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-anim-core {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  z-index: 2;
  transition: transform 0.3s, box-shadow 0.3s;
}

.voice-anim-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.4);
  animation: voice-ring 2s ease-out infinite;
}

.voice-anim-ring2 { animation-delay: 0.5s; }
.voice-anim-ring3 { animation-delay: 1s; }

@keyframes voice-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* States */
.voice-anim-idle .voice-anim-core {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.voice-anim-listening .voice-anim-core {
  background: linear-gradient(135deg, #ef4444, #f87171);
  transform: scale(1.15);
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
  animation: voice-listen-pulse 1s ease-in-out infinite;
}

.voice-anim-listening .voice-anim-ring {
  border-color: rgba(239, 68, 68, 0.5);
}

@keyframes voice-listen-pulse {
  0%, 100% { transform: scale(1.15); }
  50% { transform: scale(1.25); }
}

.voice-anim-thinking .voice-anim-core {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.7), rgba(251, 191, 36, 0.6));
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.25), inset 0 0 15px rgba(255, 255, 255, 0.15);
  animation: voice-think-breathe 2s ease-in-out infinite;
  position: relative;
}

.voice-anim-thinking .voice-anim-core::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent 70%);
  animation: voice-think-shimmer 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes voice-think-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 25px rgba(245, 158, 11, 0.2), inset 0 0 15px rgba(255, 255, 255, 0.12); }
  50% { transform: scale(1.1); box-shadow: 0 0 45px rgba(245, 158, 11, 0.35), inset 0 0 20px rgba(255, 255, 255, 0.2); }
}

@keyframes voice-think-shimmer {
  0%, 100% { opacity: 0.3; transform: rotate(0deg); }
  50% { opacity: 0.6; transform: rotate(180deg); }
}

.voice-anim-speaking .voice-anim-core {
  background: linear-gradient(135deg, #22c55e, #4ade80);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
  animation: voice-speak-pulse 0.6s ease-in-out infinite;
}

@keyframes voice-speak-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Status text */
.voice-status {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  min-height: 1.5em;
}

/* Transcript */
.voice-transcript {
  font-size: 1.3rem;
  color: white;
  text-align: center;
  min-height: 2em;
  max-width: 100%;
  opacity: 0;
  transition: opacity 0.3s;
}

.voice-transcript:not(:empty) {
  opacity: 1;
}

/* Response */
.voice-response {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  min-height: 1.5em;
  max-width: 100%;
  line-height: 1.5;
  opacity: 0;
  transition: opacity 0.3s;
  cursor: pointer;
}

.voice-response:not(:empty) {
  opacity: 1;
}

.voice-response.fade-out {
  opacity: 0;
  transition: opacity 1s ease-out;
}

/* Confirmation */
.voice-confirm {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.voice-confirm-text {
  color: white;
  font-size: 0.95rem;
  line-height: 1.5;
}

.voice-confirm-text strong {
  color: #fbbf24;
}

.voice-confirm-buttons {
  display: flex;
  gap: 12px;
}

.voice-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.voice-btn:active { transform: scale(0.96); }

.voice-btn-yes {
  background: rgba(34, 197, 94, 0.25);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.voice-btn-no {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Settings */
.voice-settings {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.voice-setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.voice-setting-row label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.voice-setting-row select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 12px;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
}

.voice-setting-row select:focus {
  border-color: rgba(99, 102, 241, 0.6);
}

/* Controls */
.voice-controls {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.voice-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  min-width: 90px;
  min-height: 72px;
}

.voice-control-btn:active { transform: scale(0.95); }
.voice-control-btn:hover { background: rgba(255, 255, 255, 0.12); }

.voice-control-icon { font-size: 1.6rem; display: flex; align-items: center; justify-content: center; }
.voice-control-icon svg { color: currentColor; }
.voice-control-label { font-size: 0.75rem; opacity: 0.7; }

.voice-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Mute button states */
#voice-mute-btn.muted {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}

#voice-mute-btn:not(.muted) {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.35);
}

/* Dark mode adjustments */
@media (prefers-color-scheme: light) {
  .voice-overlay-bg {
    background: rgba(255, 255, 255, 0.9);
  }
  .voice-status { color: rgba(0, 0, 0, 0.8); }
  .voice-transcript { color: rgba(0, 0, 0, 0.9); }
  .voice-response { color: rgba(0, 0, 0, 0.6); }
  .voice-confirm {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
  }
  .voice-confirm-text { color: rgba(0, 0, 0, 0.8); }
  .voice-settings {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
  }
  .voice-setting-row label { color: rgba(0, 0, 0, 0.5); }
  .voice-setting-row select {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.85);
  }
  .voice-control-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.8);
  }
  .voice-control-btn:hover { background: rgba(0, 0, 0, 0.08); }
  .voice-mode-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.6);
  }
  .voice-mode-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #6366f1;
  }
  .voice-chat-msg.user {
    background: rgba(99, 102, 241, 0.12);
    color: rgba(0, 0, 0, 0.8);
  }
  .voice-chat-msg.assistant {
    background: rgba(0, 0, 0, 0.04);
    color: rgba(0, 0, 0, 0.7);
  }
  .voice-chat-input {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.85);
  }
  .voice-chat-send {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
  }
  .chat-history-content {
    background: rgba(255, 255, 255, 0.98);
  }
  .chat-history-header h3 { color: rgba(0, 0, 0, 0.8); }
  .chat-history-item.user { background: rgba(99, 102, 241, 0.08); }
  .chat-history-item.assistant { background: rgba(0, 0, 0, 0.04); }
  .chat-history-role { color: rgba(0, 0, 0, 0.5); }
  .chat-history-text { color: rgba(0, 0, 0, 0.75); }
  .chat-history-empty { color: rgba(0, 0, 0, 0.4); }
}

/* ═══ VOICE MODE TOGGLE ═══ */

.voice-mode-toggle {
  display: flex;
  gap: 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
}

.voice-mode-btn {
  flex: 1;
  padding: 14px 24px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.voice-mode-btn.active {
  background: rgba(99, 102, 241, 0.25);
  color: #818cf8;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* ═══ VOICE VIEW ═══ */

.voice-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* ═══ VOICE CAPABILITIES ═══ */

.voice-capabilities {
  width: 100%;
  max-width: 400px;
}

.voice-caps-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
}

.voice-caps-toggle:active { transform: scale(0.97); }
.voice-caps-toggle:hover { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.75); }
.voice-caps-toggle.open &::after { transform: rotate(90deg); }

.voice-caps-list {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  padding: 0 12px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.voice-caps-list.open {
  max-height: 320px;
  opacity: 1;
  padding: 12px;
}

.voice-cap-item {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

@media (prefers-color-scheme: light) {
  .voice-caps-toggle {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.02);
    color: rgba(0, 0, 0, 0.5);
  }
  .voice-caps-toggle:hover { background: rgba(0, 0, 0, 0.05); color: rgba(0, 0, 0, 0.7); }
  .voice-cap-item {
    color: rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
  }
}

/* ═══ TEXT VIEW ═══ */

.text-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 12px;
}

.voice-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  scroll-behavior: smooth;
}

.voice-chat-messages:empty::before {
  content: 'Type a message to chat with AI';
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  padding: 40px 0;
  font-size: 0.9rem;
}

.voice-chat-msg {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 85%;
  word-wrap: break-word;
}

.voice-chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.voice-chat-msg.assistant {
  align-self: flex-start;
  background: var(--glass);
  border: 1px solid var(--hairline);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.voice-chat-typing {
  opacity: 0.5;
  font-style: italic;
}

.voice-chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.voice-chat-input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--glass);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  min-height: 48px;
}

.voice-chat-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
}

.voice-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.voice-chat-send {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.3);
  color: #818cf8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, background 0.2s;
}

.voice-chat-send:active { transform: scale(0.9); }
.voice-chat-send:hover { background: rgba(99, 102, 241, 0.4); }

/* ═══ CHAT HISTORY MODAL ═══ */

.chat-history-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-history-content {
  background: rgba(20, 20, 28, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-history-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
}

.chat-history-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-history-close:active { transform: scale(0.9); }

.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-history-item {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-history-item.user {
  align-self: flex-end;
  max-width: 85%;
  background: rgba(99, 102, 241, 0.15);
  border-bottom-right-radius: 4px;
}

.chat-history-item.assistant {
  align-self: flex-start;
  max-width: 85%;
  background: rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
}

.chat-history-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.5;
  margin-bottom: 4px;
}

.chat-history-text {
  color: rgba(255, 255, 255, 0.8);
}

.chat-history-empty {
  text-align: center;
  padding: 40px 0;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.9rem;
}

/* ═══ PROJECTS SECTION ═══ */
.projects-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 24px 4px;
  margin-top: 6px;
}

.projects-divider-line {
  flex: 1;
  height: 1px;
  background: var(--hairline-strong);
}

.projects-divider-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  white-space: nowrap;
}

.projects-list {
  padding: 6px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Project Card (home screen) ─── */
.project-card {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-card:active {
  transform: scale(0.98);
  background: var(--glass-hover);
}

.project-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.project-card-title {
  flex: 1;
  min-width: 0;
}

.project-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-domain {
  font-size: 12px;
  color: var(--accent-text);
  text-decoration: none;
}

.project-card-domain:active { opacity: 0.6; }

.project-card-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.project-card-status.deployed {
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
}

.project-card-status.pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--orange);
}

.project-card-status.loading {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.project-card-status svg {
  flex-shrink: 0;
}

.project-card-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tech-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  color: var(--text-dim);
}

.project-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  min-height: 18px;
}

.project-card-footer svg {
  flex-shrink: 0;
  color: var(--text-faint);
}

.project-card-commit-msg {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Project Detail Screen ─── */
.project-detail-content {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.project-detail-header {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--glass-shadow), var(--glass-inset);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-detail-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.project-detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.project-detail-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.project-detail-domain {
  font-size: 14px;
  color: var(--accent-text);
  text-decoration: none;
  margin-top: 2px;
  display: inline-block;
}

.project-detail-domain:active { opacity: 0.6; }

.project-detail-stats {
  display: flex;
  gap: 10px;
}

.project-stat {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  flex: 1;
}

.project-stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.project-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.project-detail-links {
  display: flex;
  gap: 10px;
}

.project-link-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.15s;
}

.project-link-btn:active {
  transform: scale(0.97);
  background: var(--glass-hover);
}

.project-link-btn svg {
  color: var(--accent);
  flex-shrink: 0;
}

.project-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.project-card-body {
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.commit-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}

.commit-row:last-child { border-bottom: none; }

.commit-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-soft);
}

.commit-body {
  flex: 1;
  min-width: 0;
}

.commit-msg {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 2px;
  word-break: break-word;
}

.commit-meta {
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  align-items: center;
}

.commit-author {
  font-weight: 600;
  color: var(--text-dim);
}

.project-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.project-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
/* ═══ SETTINGS APP ═══ */
.settings-tabs {
  display: flex; gap: 0; padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
  overflow-x: auto; white-space: nowrap;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  padding: 8px 16px; border: none; background: none;
  color: var(--text-dim); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.settings-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-body { padding: 16px; max-width: 600px; margin: 0 auto; }
.settings-group {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 16px; padding: 16px; margin-bottom: 12px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.settings-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 0.85rem;
}
.settings-value { color: var(--text-dim); font-size: 0.82rem; }
.settings-theme-row { display: flex; gap: 12px; }
.theme-option {
  flex: 1; border: 2px solid var(--glass-border); border-radius: 14px;
  padding: 12px 8px; background: var(--glass); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.2s;
}
.theme-option.selected { border-color: var(--accent); }
.theme-preview { width: 40px; height: 40px; border-radius: 10px; }
.theme-preview.light { background: linear-gradient(135deg, #fff, #f0f2f5); border: 1px solid #ddd; }
.theme-preview.dark { background: linear-gradient(135deg, #0a0a0f, #1a1a2e); }
.theme-preview.auto { background: linear-gradient(135deg, #fff 50%, #0a0a0f 50%); }
.theme-option span { font-size: 0.75rem; color: var(--text-dim); }
.settings-device-list, .settings-usage-list, .settings-logs-view {
  max-height: 400px; overflow-y: auto;
}
.settings-device-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.settings-device-icon { font-size: 1.4rem; }
.settings-device-info { flex: 1; }
.settings-device-name { font-weight: 600; font-size: 0.85rem; }
.settings-device-ip { font-size: 0.72rem; color: var(--text-dim); }
.settings-device-status { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.settings-device-status.online { color: var(--green); background: rgba(16,185,129,0.1); }
.settings-device-status.offline { color: var(--text-dim); }
.settings-usage-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--hairline);
}
.settings-usage-app { font-weight: 600; font-size: 0.85rem; }
.settings-usage-stats { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-dim); }
.settings-log-row {
  display: flex; gap: 8px; padding: 4px 0; font-size: 0.72rem;
  font-family: monospace; border-bottom: 1px solid var(--hairline);
}
.log-time { color: var(--text-dim); white-space: nowrap; }
.log-level { font-weight: 700; width: 50px; }
.log-msg { flex: 1; word-break: break-all; }
.level-error .log-level, .level-err .log-level { color: var(--red); }
.level-warn .log-level { color: var(--orange); }
.level-info .log-level { color: var(--accent); }
.settings-empty { padding: 20px; text-align: center; color: var(--text-dim); font-size: 0.85rem; }
.settings-export-btn {
  margin-top: 12px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text); font-size: 0.8rem; cursor: pointer; font-weight: 600;
  transition: background 0.2s;
}
.settings-export-btn:active { background: var(--glass-hover); }

.settings-feedback-btn {
  margin-top: 8px; padding: 12px 20px;
  background: var(--accent); border: none; border-radius: 10px;
  color: white; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.settings-feedback-btn:hover { opacity: 0.9; transform: translateY(-1px); }

.settings-save-btn {
  margin-top: 12px; padding: 10px 16px;
  background: var(--accent); border: none; border-radius: 10px;
  color: white; font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s;
}
.settings-save-btn:hover { opacity: 0.9; }

.settings-input {
  padding: 8px 12px;
  background: var(--card); border: 1px solid var(--glass-border);
  border-radius: 8px; color: var(--text);
  font-size: 0.85rem; font-family: inherit;
  width: 200px;
}
.settings-input:focus { outline: none; border-color: var(--accent); }

.settings-note {
  margin-top: 8px; font-size: 0.75rem;
  color: var(--text-dim); font-style: italic;
}
.settings-note-ok { color: var(--accent, #4a9); font-style: normal; }
.settings-note-err { color: var(--red, #e55); font-style: normal; }

/* About — made by + socials */
.about-madeby { margin-top: 8px; font-size: 0.8rem; color: var(--text); font-weight: 600; }
.about-socials { display: flex; gap: 12px; margin-top: 4px; }
.about-social-link {
  font-size: 0.7rem; color: var(--text-dim); text-decoration: none;
  border-bottom: 1px solid transparent; transition: border-color 0.2s, color 0.2s;
}
.about-social-link:hover { color: var(--text); border-bottom-color: var(--text-dim); }

/* Forced dark mode via data-theme */
:root[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-gradient: linear-gradient(180deg, #0a0a0f 0%, #12121a 100%);
  --glass: rgba(30, 30, 42, 0.55);
  --glass-hover: rgba(40, 40, 55, 0.7);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.3), 0 0 1px rgba(0, 0, 0, 0.2);
  --glass-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.3);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --card: rgba(30, 30, 42, 0.5);
  --card-hover: rgba(40, 40, 55, 0.7);
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.15);
  --accent-glow: rgba(129, 140, 248, 0.3);
  --accent-text: #a5b4fc;
  --text: #e5e7eb;
  --text-dim: #9ca3af;
  --text-faint: #6b7280;
  --green: #34d399;
  --orange: #fbbf24;
  --red: #f87171;
  --hairline: rgba(255, 255, 255, 0.06);
  --hairline-strong: rgba(255, 255, 255, 0.1);
  --surface-solid: #1a1a2e;
  --modal-bg: rgba(0, 0, 0, 0.6);
  --terminal-bg: rgba(10, 10, 15, 0.95);
  --terminal-text: #6ee7b7;
  --scrollbar: rgba(129, 140, 248, 0.3);
  --scrollbar-hover: rgba(129, 140, 248, 0.5);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --chip-border: rgba(255, 255, 255, 0.1);
  --sparkline-stroke: rgba(129, 140, 248, 0.7);
  --sparkline-fill: rgba(129, 140, 248, 0.12);
}

/* Forced light mode via data-theme */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-gradient: linear-gradient(180deg, #ffffff 0%, #f0f2f5 100%);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-hover: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.95);
  --glass-shadow: 0 2px 16px rgba(0, 0, 0, 0.04), 0 0 1px rgba(0, 0, 0, 0.03);
  --glass-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.04);
  --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 1);
  --card: rgba(255, 255, 255, 0.65);
  --card-hover: rgba(255, 255, 255, 0.85);
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --accent-glow: rgba(99, 102, 241, 0.2);
  --accent-text: #4f46e5;
  --text: #1a1a2e;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --hairline: rgba(0, 0, 0, 0.05);
  --hairline-strong: rgba(0, 0, 0, 0.08);
  --surface-solid: #ffffff;
  --modal-bg: rgba(0, 0, 0, 0.2);
  --terminal-bg: rgba(20, 20, 30, 0.92);
  --terminal-text: #a7f3d0;
  --scrollbar: rgba(99, 102, 241, 0.3);
  --scrollbar-hover: rgba(99, 102, 241, 0.5);
  --chip-bg: rgba(255, 255, 255, 0.6);
  --chip-border: rgba(0, 0, 0, 0.06);
  --sparkline-stroke: rgba(99, 102, 241, 0.6);
  --sparkline-fill: rgba(99, 102, 241, 0.1);
}


/* ═══ LOGIN SCREEN ═══ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.login-logo {
  margin-bottom: 8px;
  opacity: 0.9;
}
.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.login-dots {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}
.login-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  transition: all 0.15s ease;
}
.login-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}
.login-error {
  height: 20px;
  font-size: 13px;
  color: var(--red);
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}
.login-error.show {
  opacity: 1;
}
.login-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 16px;
}
.login-key {
  aspect-ratio: 1.6;
  border: none;
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: background 0.12s, transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.login-key:active {
  background: var(--accent-soft);
  transform: scale(0.95);
}
.login-key-sub {
  font-size: 9px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.login-key-blank {
  visibility: hidden;
}
.login-key-go {
  color: white;
  background: var(--accent);
  border: none;
}
.login-key-go:active {
  opacity: 0.85;
  transform: scale(0.94);
}
.login-key-back {
  color: var(--text-dim);
}
.login-key-back:active {
  background: var(--accent-soft);
}
/* Shake animation for wrong PIN */
@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-12px); }
  30%, 60%, 90% { transform: translateX(12px); }
}
.login-card.shake {
  animation: login-shake 0.4s ease;
}

/* ═══ DESKTOP MODE ═══ */
body.desktop-mode .app-grid {
  max-width: 700px;
  margin: 0 auto;
}
body.desktop-mode .status-chips {
  max-width: 700px;
  margin: 0 auto;
}
body.desktop-mode .top-bar {
  max-width: 700px;
  margin: 0 auto;
}
body.desktop-mode .notif-bell[aria-label="Refresh"] {
  display: none;
}
body.desktop-mode .app-icon {
  outline: none;
}
body.desktop-mode .app-icon.desktop-focus .app-icon-visual {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px var(--accent), var(--glass-shadow-lg);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s;
}
body.desktop-mode .app-icon.desktop-focus .app-label {
  color: var(--text);
  font-weight: 700;
}


/* ═══ MUSIC PLAYER ═══ */
.music-content {
  display: flex; flex-direction: column;
  height: calc(100vh - 60px);
  max-width: 600px; margin: 0 auto;
}
.music-list {
  flex: 1; overflow-y: auto; padding: 8px;
}
.music-empty {
  padding: 40px 20px; text-align: center;
  color: var(--text-dim); font-size: 0.85rem;
}
.music-song-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  cursor: pointer; transition: background 0.15s;
  margin-bottom: 4px;
}
.music-song-row:active { background: var(--accent-soft); }
.music-song-row.playing {
  background: var(--accent-soft);
}
.music-song-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); flex-shrink: 0;
}
.music-song-thumb {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); flex-shrink: 0; overflow: hidden;
}
.music-song-thumb.has-art {
  border-color: transparent;
}
.music-song-row.playing .music-song-icon {
  color: var(--accent);
}
.music-song-info { flex: 1; min-width: 0; }
.music-song-name {
  font-weight: 600; font-size: 0.88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-song-meta {
  font-size: 0.72rem; color: var(--text-dim); margin-top: 2px;
}

/* Player bar */
.music-player {
  padding: 14px 16px; border-top: 1px solid var(--glass-border);
  background: var(--glass); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.music-player-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.music-player-title {
  font-weight: 600; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; margin-right: 12px;
}
.music-player-time {
  font-size: 0.72rem; color: var(--text-dim); white-space: nowrap;
}
.music-progress-bar {
  height: 4px; background: var(--hairline-strong);
  border-radius: 2px; cursor: pointer; margin-bottom: 12px;
}
.music-progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  width: 0%; transition: width 0.1s linear;
}
.music-controls {
  display: flex; align-items: center; justify-content: center; gap: 24px;
}
.music-btn {
  border: none; background: none; cursor: pointer;
  color: var(--text); padding: 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background 0.15s, transform 0.15s;
}
.music-btn:active { transform: scale(0.9); }
.music-btn-play {
  width: 48px; height: 48px;
  background: var(--accent); color: white;
}
.music-btn-play:active { transform: scale(0.9); }


/* ═══ DESKTOP LAYOUT ═══ */
/* Wider grid, horizontal feel, bigger app icons */
body.desktop-mode #home-screen {
  padding-top: 8vh;
}
body.desktop-mode .top-bar {
  max-width: 720px;
  margin: 0 auto;
  padding-top: 4vh;
}
body.desktop-mode .clock {
  font-size: 56px;
}
body.desktop-mode .status-chips {
  max-width: 720px;
  margin: 24px auto 0;
}
body.desktop-mode .app-grid {
  max-width: 720px;
  margin: 0 auto;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px;
  padding: 48px 24px;
  justify-content: center;
}
body.desktop-mode .app-icon-visual {
  width: 80px;
  height: 80px;
  border-radius: 22px;
}
body.desktop-mode .app-label {
  font-size: 12px;
}
body.desktop-mode .screen {
  max-width: 900px;
  margin: 0 auto;
}
/* Side-by-side layouts where it makes sense */
body.desktop-mode .music-content,
body.desktop-mode #book-list,
body.desktop-mode #osint-screen,
body.desktop-mode #system-screen {
  max-width: 700px;
  margin: 0 auto;
}
body.desktop-mode .legos-content {
  max-width: 1000px;
  margin: 0 auto;
}
/* Refresh button hidden on desktop */
body.desktop-mode .notif-bell[aria-label="Refresh"] {
  display: none !important;
}
/* Keyboard nav focus ring */
body.desktop-mode .app-icon {
  outline: none;
}
body.desktop-mode .app-icon.desktop-focus .app-icon-visual {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px var(--accent), var(--glass-shadow-lg);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
body.desktop-mode .app-icon.desktop-focus .app-label {
  color: var(--text);
  font-weight: 700;
}


/* Music artwork */
.music-song-thumb {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); flex-shrink: 0; overflow: hidden;
}
.music-song-thumb.has-art {
  border-color: transparent;
}
.music-thumb-img {
  width: 100%; height: 100%; border-radius: 10px;
  object-fit: cover; display: block;
}
.music-song-artist {
  font-size: 0.75rem; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-song-more {
  color: var(--text-dim); padding: 8px; cursor: pointer;
  display: flex; align-items: center; flex-shrink: 0;
  border-radius: 50%; transition: background 0.15s;
}
.music-song-more:active { background: var(--accent-soft); }
.music-player-artist {
  font-size: 0.75rem; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-player-art {
  width: 44px; height: 44px; border-radius: 10px;
  object-fit: cover; flex-shrink: 0;
  background: var(--glass);
}
.music-player-text { flex: 1; min-width: 0; }

/* ═══ SETTINGS ═══ */
.settings-content { padding: 20px; max-width: 600px; margin: 0 auto; }
.settings-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--glass-border); margin-bottom: 20px; }
.settings-tab { flex: 1; padding: 12px 16px; border: none; background: none; cursor: pointer; color: var(--text-dim); font-weight: 500; font-size: 0.85rem; border-bottom: 2px solid transparent; transition: color 0.2s, border-color 0.2s; }
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; }
.settings-option { padding: 10px 0; display: flex; align-items: center; }
.settings-option label { display: flex; align-items: center; cursor: pointer; font-size: 0.88rem; gap: 8px; }
.settings-option input[type="radio"] { cursor: pointer; }
.devices-list, .usage-stats, .logs-list { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.device-item, .usage-item, .log-item { padding: 12px; border-bottom: 1px solid var(--hairline); font-size: 0.85rem; }
.device-item:last-child, .usage-item:last-child, .log-item:last-child { border-bottom: none; }
.device-name { font-weight: 600; }
.device-meta { color: var(--text-dim); font-size: 0.75rem; margin-top: 4px; }
.usage-item-name { font-weight: 600; }
.usage-item-stats { color: var(--text-dim); font-size: 0.75rem; margin-top: 4px; }
.log-item { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-item.error { color: #ef4444; }
.log-item.warn { color: #f59e0b; }
.log-item.info { color: var(--text); }
.settings-btn { padding: 10px 20px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--glass); color: var(--text); cursor: pointer; font-weight: 600; font-size: 0.85rem; transition: background 0.2s; }

/* ─── Empty States ────────────────────────────────────────────── */
.empty-state {
  padding: 50px 24px; text-align: center;
  color: var(--text-dim);
}
.empty-icon {
  font-size: 3rem; margin-bottom: 16px;
  opacity: 0.6;
}
.empty-state h3 {
  color: var(--text); font-size: 1.1rem; font-weight: 700;
  margin: 0 0 8px 0;
}
.empty-state p {
  font-size: 0.85rem; margin: 0 0 4px 0;
  line-height: 1.5;
}
.empty-hint {
  color: var(--text-dim); opacity: 0.6; font-size: 0.75rem !important;
  margin-top: 12px !important;
}

/* ─── Onboarding Banner ───────────────────────────────────────── */
.onboarding-banner {
  padding: 20px 24px; text-align: center;
  background: var(--accent-soft);
  border-radius: 16px; margin: 16px;
}
.onboarding-banner h3 {
  font-size: 1rem; font-weight: 700; margin: 0 0 8px 0;
  color: var(--text);
}
.onboarding-banner p {
  font-size: 0.8rem; margin: 0 0 12px 0;
  color: var(--text-dim); line-height: 1.5;
}
.onboarding-banner .btn {
  display: inline-block; padding: 10px 24px;
  border-radius: 10px; font-weight: 600; font-size: 0.85rem;
  background: var(--accent); color: white;
  border: none; cursor: pointer;
  transition: transform 0.1s;
}
.onboarding-banner .btn:active { transform: scale(0.96); }
.settings-btn:hover { background: var(--accent-soft); }
.lego-image-action {
  position: absolute;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  z-index: 210;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.lego-image-action:active { transform: scale(0.9); }

.lego-image-shred {
  right: 20px;
  background: rgba(239, 68, 68, 0.8);
}

.lego-image-poof {
  right: 78px;
  background: rgba(99, 102, 241, 0.8);
}

.lego-image-save {
  left: 20px;
  background: rgba(34, 197, 94, 0.8);
}

/* ─── Ollama Chat ─── */

.lego-swipe {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
}

.lego-swipe-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--safe-top) 16px 12px;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--hairline);
}

.lego-swipe-close {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.lego-swipe-info {
  font-size: 14px;
  color: var(--text-dim);
  flex: 1;
}

.lego-swipe-card-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.lego-swipe-card {
  position: relative;
  max-width: 420px;
  width: 100%;
  max-height: 100%;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  background: rgba(0,0,0,0.06);
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}

.lego-swipe-card.swiping {
  transition: none;
}

.lego-swipe-card.fly-left {
  transform: translateX(-150vw) rotate(-30deg);
  opacity: 0;
  transition: transform 0.4s ease-out, opacity 0.4s;
}

.lego-swipe-card.fly-right {
  transform: translateX(150vw) rotate(30deg);
  opacity: 0;
  transition: transform 0.4s ease-out, opacity 0.4s;
}

.lego-swipe-card.fly-up {
  transform: translateY(-150vh) scale(0.5);
  opacity: 0;
  transition: transform 0.4s ease-out, opacity 0.4s;
}

.lego-swipe-card img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.lego-swipe-card-name {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--glass);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}

.lego-swipe-hint {
  position: absolute;
  top: 20px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.lego-swipe-hint-left {
  left: 20px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  transform: rotate(-15deg);
}

.lego-swipe-hint-right {
  right: 20px;
  background: rgba(99, 102, 241, 0.9);
  color: white;
  transform: rotate(15deg);
}

.lego-swipe-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 18px;
  padding: 40px;
}

.lego-swipe-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px calc(var(--safe-bottom) + 20px);
}

.lego-swipe-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.lego-swipe-btn:active { transform: scale(0.85); }

.lego-swipe-btn-trash {
  background: rgba(239, 68, 68, 0.15);
}

.lego-swipe-btn-shred {
  background: rgba(239, 68, 68, 0.3);
  width: 56px;
  height: 56px;
}

.lego-swipe-btn-poof {
  background: rgba(99, 102, 241, 0.15);
}

