/* desktop.css — backdrop, meta bar, windows, terminal, mobile */

/* ── Animatable gradient center positions ── */
@property --gx1 { syntax: '<percentage>'; inherits: true; initial-value: 20%; }
@property --gy1 { syntax: '<percentage>'; inherits: true; initial-value: 30%; }
@property --gx2 { syntax: '<percentage>'; inherits: true; initial-value: 80%; }
@property --gy2 { syntax: '<percentage>'; inherits: true; initial-value: 70%; }
@property --gx3 { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
@property --gy3 { syntax: '<percentage>'; inherits: true; initial-value: 95%; }
@property --gx4 { syntax: '<percentage>'; inherits: true; initial-value: 65%; }
@property --gy4 { syntax: '<percentage>'; inherits: true; initial-value: 15%; }

/* ── Animated backdrop ── */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 75% 60% at var(--gx1) var(--gy1), var(--grad-1) 0%, transparent 70%),
    radial-gradient(ellipse 65% 55% at var(--gx2) var(--gy2), var(--grad-2) 0%, transparent 70%),
    radial-gradient(ellipse 55% 70% at var(--gx3) var(--gy3), var(--grad-3) 0%, transparent 65%),
    radial-gradient(ellipse 50% 50% at var(--gx4) var(--gy4), var(--grad-4) 0%, transparent 62%),
    var(--bg);
  transition: background var(--transition);
  animation: drift-sky 30s ease-in-out infinite;
}

.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--texture);
  background-size: var(--texture-size, 20px 20px);
  pointer-events: none;
}

/* ── Meta bar — macOS-style menu bar ── */
.meta {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 30px;
  font-size: 13px;
  line-height: 1;
  color: var(--text);
  z-index: 1000;
  pointer-events: none;
}

[data-theme="dark"]  .meta { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
[data-theme="light"] .meta { text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55); }

[data-theme="dark"]  .meta svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); }
[data-theme="light"] .meta svg { filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.55)); }

.meta > * { pointer-events: auto; }

.meta-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.os-icon {
  display: flex;
  align-items: center;
  color: var(--text);
}

.os-icon svg { display: block; }

.menu-doc {
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.menu-clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--text);
}

.terminal-toggle { display: none; }

.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  height: 30px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition);
}

.theme-toggle #themeIcon { display: flex; align-items: center; }
.theme-toggle svg { display: block; }

.theme-toggle:hover { opacity: 0.7; }

.appearance-toggle {
  background: none;
  border: none;
  padding: 0;
  height: 30px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition);
}
.appearance-toggle:hover { opacity: 0.7; }
.appearance-toggle svg { display: block; }

.sound-toggle {
  background: none;
  border: none;
  padding: 0;
  height: 30px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition);
}
.sound-toggle:hover { opacity: 0.7; }
.sound-toggle svg { display: block; }
.sound-toggle #soundIcon { display: flex; align-items: center; }

/* ── Drop menu ── */
.drop-menu {
  position: fixed;
  z-index: 9000;
  width: fit-content;
  min-width: 148px;
  padding: 4px;
  border-radius: 10px;
  backdrop-filter: blur(48px) saturate(200%);
  -webkit-backdrop-filter: blur(48px) saturate(200%);
  box-shadow: 0 12px 48px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.06);
}
[data-theme="dark"]  .drop-menu {
  background: rgba(36, 36, 38, 0.62);
  border: 0.5px solid rgba(255,255,255,0.10);
}
[data-theme="light"] .drop-menu {
  background: rgba(246, 246, 248, 0.72);
  border: 0.5px solid rgba(0,0,0,0.09);
}

.drop-menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 140px;
  padding: 5px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}
[data-theme="dark"]  .drop-menu-item:hover { background: rgba(255,255,255,0.09); }
[data-theme="light"] .drop-menu-item:hover { background: rgba(0,0,0,0.06); }
.drop-menu-item.active { color: var(--accent); }

.drop-menu-item-label { flex: 1; }

.drop-menu-arrow {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  line-height: 1;
}

.drop-menu-check {
  display: flex;
  align-items: center;
  color: var(--accent);
  margin-left: auto;
  flex-shrink: 0;
}

.drop-menu-item-desc {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Desktop surface ── */
.desktop {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

/* ── Base window ── */
.window {
  position: absolute;
  background: var(--bg-window);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-radius: var(--radius-window);
  box-shadow: var(--shadow-window);
  display: flex;
  flex-direction: column;
  min-width: 300px;
  min-height: 160px;
  overflow: hidden;
  transition: box-shadow var(--transition), border-color 0.55s ease;
  animation: windowOpen 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ── Default sizing for content windows ──
 * Every non-terminal window gets a sane width/height so long content
 * scrolls inside the window instead of growing it off-screen. Override
 * per-window via JS-set inline style if a specific page needs different.
 */
.window:not(.terminal) {
  width: 620px;
  max-width: calc(100vw - 16px);
  height: min(640px, calc(100vh - 60px));
  max-height: calc(100vh - 50px);
}

/* Glass rim — a 1px gradient ring (bright top-left, dim bottom-right) clipped
   via mask-composite, simulating light catching the window edge. */
.window::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-window);
  padding: 1px;
  background: var(--window-rim);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 10;
}

.window.rainbow-tint {
  transition: box-shadow var(--transition);
}
.window.rainbow-tint .window-title {
  transition: none;
  animation: windowOpen 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.window.focused {
  box-shadow: var(--shadow-window-focus);
}

/* Full screen — fills the desktop below the menu bar. Restored via JS. */
.window.fullscreen {
  left: 8px !important;
  top: 38px !important;
  width: calc(100vw - 16px) !important;
  height: calc(100vh - 46px) !important;
  transition: left 0.22s ease, top 0.22s ease, width 0.22s ease, height 0.22s ease;
}
/* When the dock is visible, pull the fullscreen window up so it doesn't overlap */
body:has(.window-dock.active) .window.fullscreen {
  height: calc(100vh - 46px - 106px) !important;
}

/* Dock — a frosted glass tray of app-style tiles at the bottom. */
.window-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  display: flex;
  gap: 8px;
  padding: 13px 14px 20px;   /* extra bottom for the active dots */
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-window-solid) 62%, transparent);
  backdrop-filter: blur(40px) saturate(170%);
  -webkit-backdrop-filter: blur(40px) saturate(170%);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.42),
    0 2px 8px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Glass rim — same trick as windows: a 1px gradient ring that catches the light. */
.window-dock::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: var(--window-rim);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.window-dock.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* All dock tiles share the same neutral glass tile with an accent-colored icon
   — like the very first version of the dock. */
.dock-tile {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--border-strong) 90%, transparent);
  background: color-mix(in srgb, var(--bg-title) 90%, transparent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  /* slide-in animation: tile starts below + transparent, slides up + fades in */
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.16s ease,
    background 0.16s ease;
}

.dock-tile.shown {
  opacity: 1;
  transform: translateY(0);
}

.dock-tile svg {
  width: 22px;
  height: 22px;
  transition: transform 0.16s ease;
}

.dock-tile:hover {
  color: var(--text);
  background: var(--bg-input);
}
.dock-tile.shown:hover {
  transform: translateY(-4px);
}
.dock-tile.shown:active {
  transform: translateY(-1px);
}

/* Active-window indicator — a glowing white dot below each focused tile. */
.dock-dot {
  position: absolute;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffffff;
  opacity: 0;
  transition: opacity 0.16s ease, box-shadow 0.16s ease;
}
.dock-tile.focused .dock-dot {
  opacity: 1;
  box-shadow:
    0 0 4px rgba(255, 255, 255, 0.9),
    0 0 8px rgba(255, 255, 255, 0.45);
}

[data-theme="light"] .dock-dot { background: #0c0c14; }
[data-theme="light"] .dock-tile.focused .dock-dot {
  box-shadow:
    0 0 4px rgba(12, 12, 20, 0.85),
    0 0 8px rgba(12, 12, 20, 0.4);
}

/* Minimized tile reads slightly dimmer */
.dock-tile.minimized {
  opacity: 0.85;
}
.dock-tile.minimized .dock-dot { opacity: 0; }

/* Hover tooltip above each tile, macOS-style — instant, with arrow. */
.tile-tooltip {
  position: absolute;
  bottom: calc(100% + 11px);
  left: 50%;
  background: var(--bg-window-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  z-index: 20;
}
.tile-tooltip::before,
.tile-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  width: 0;
  height: 0;
  border: 6px solid transparent;
}
/* arrow border (matches the tooltip border) */
.tile-tooltip::before {
  top: 100%;
  transform: translateX(-50%);
  border-top-color: var(--border-strong);
}
/* arrow fill (matches the tooltip background) — 1px shorter to leave the border peeking */
.tile-tooltip::after {
  top: calc(100% - 1px);
  transform: translateX(-50%);
  border-top-color: var(--bg-window-solid);
  border-width: 5px;
  margin-left: 1px;
}
.dock-tile:hover .tile-tooltip {
  opacity: 1;
}

/* Light-mode dock — tiles need more contrast or they all blend into the frost. */
[data-theme="light"] .dock-tile {
  background: color-mix(in srgb, var(--accent) 12%, #ffffff);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .dock-tile:hover {
  background: color-mix(in srgb, var(--accent) 22%, #ffffff);
  box-shadow:
    0 6px 14px rgba(20, 30, 60, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.dock-tile svg {
  width: 21px;
  height: 21px;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.4));
}

.dock-tile:hover {
  transform: translateY(-5px);
  filter: brightness(1.1) saturate(1.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 8px 16px rgba(0, 0, 0, 0.28);
}

.dock-tile:active {
  transform: translateY(-2px);
}

/* Light-mode dock chrome — keep the frost readable on light wallpapers. */
[data-theme="light"] .window-dock {
  background: color-mix(in srgb, var(--bg-window) 45%, transparent);
  box-shadow:
    0 16px 40px rgba(20, 30, 60, 0.18),
    0 2px 8px rgba(20, 30, 60, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

@keyframes windowOpen {
  from { opacity: 0; transform: translateY(9px) scale(0.975); }
  to   { opacity: 1; transform: none; }
}

/* ── Window title bar ── */
.window-title {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  background: var(--bg-title);
  border-bottom: 1px solid var(--border);
  cursor: move;
  transition: background-color 0.55s ease;
  user-select: none;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.window-controls {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.win-btn {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: filter var(--transition);
}

.win-btn svg {
  width: 12px;
  height: 12px;
  display: block;
}

.win-close { background: #ff5f57; }
.win-min   { background: #febc2e; }
.win-full  { background: #28c840; }

/* lights dim when the window isn't focused — macOS behavior */
.window:not(.focused) .win-btn { background: var(--border-strong); }

/* glyphs reveal on hover over the cluster */
.window.focused .window-controls:hover .win-btn { color: rgba(0, 0, 0, 0.78); }
.win-btn:active { filter: brightness(0.85); }
.win-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.window-title .name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: color var(--transition);
}

.window.focused .window-title .name {
  color: var(--text-secondary);
}

/* ── Window body ── */
.window-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 22px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* Non-terminal windows get editorial typography.
   .stage-content (the mobile content stage) shares all of these. */
.window:not(.terminal) .window-body,
.stage-content {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: -0.01em;
}

.window-body::-webkit-scrollbar { width: 4px; }
.window-body::-webkit-scrollbar-track { background: transparent; }
.window-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.window-body p, .stage-content p { margin-bottom: 12px; }
.window-body p:last-child, .stage-content p:last-child { margin-bottom: 0; }
.window-body strong, .stage-content strong { color: var(--text); font-weight: 600; }
.window-body em, .stage-content em { font-style: italic; }
.window-body code, .stage-content code { color: var(--accent); font-family: var(--font-mono); font-size: 0.88em; }

.window-body h2, .stage-content h2 {
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 20px 0 8px;
  font-weight: 600;
}
.window-body h2:first-child, .stage-content h2:first-child { margin-top: 0; }

.window-body ul, .stage-content ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.window-body li, .stage-content li {
  padding-left: 14px;
  margin-bottom: 4px;
  position: relative;
}
.window-body li::before, .stage-content li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent-dim);
}

/* ── Terminal window ── */
.window.terminal {
  width: 600px;
  height: 380px;
}

.window.terminal .window-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.term-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 15px 17px;
  font-size: 13px;
  line-height: 1.52;
  color: var(--text-secondary);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.boot-ok {
  color: #4da86a;
  font-weight: 500;
}

.help-cmd {
  color: var(--accent);
  display: inline-block;
  min-width: 96px;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -2px;
  transition: background var(--transition), color var(--transition);
}
.help-cmd:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.boot-banner {
  margin: 4px 0 10px;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.05;
  color: var(--accent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  animation: bootBannerIn 0.45s ease-out;
}
.term-line:has(.boot-banner) {
  word-break: normal;
  overflow: visible;
}


@keyframes bootBannerIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: none; }
}

.term-scroll::-webkit-scrollbar { width: 3px; }
.term-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.term-line {
  margin-bottom: 5px;
  word-break: break-word;
}
.term-line:last-child { margin-bottom: 0; }

.term-line.echo { color: var(--text-muted); }
.term-line.echo .prompt { color: var(--accent); }
.term-line.echo .cmd   { color: var(--text); }
.term-line.sys  { color: var(--accent); }
.term-line.err  { color: #e8584b; }
.term-line.dim  { color: var(--text-muted); }
.term-line.hint { color: var(--text-muted); font-size: 11px; margin-top: 8px; }
.term-line.div  { border-top: 1px solid var(--border-strong); margin: 3px 0 5px; height: 0; overflow: hidden; }

/* ── Command chips (mobile) ── */
.cmd-chips {
  display: none;
  gap: 7px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cmd-chips::-webkit-scrollbar { display: none; }

.cmd-chip {
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition);
}

.cmd-chip:hover,
.cmd-chip:active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* ── Terminal input row ── */
.term-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  flex-shrink: 0;
}

.term-prompt {
  color: var(--accent);
  font-size: 15px;
  user-select: none;
  line-height: 1;
}

.term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  caret-color: var(--accent);
}

.term-input::placeholder { color: var(--text-muted); }

/* ── Slime mascot ── */
.slime {
  display: block;
  position: relative;
  width: 48px;
  height: 48px;
  background-image: url('../assets/Slime.png');
  background-size: 192px 144px; /* 1× native sheet */
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.slime::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 5px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  filter: blur(3px);
}

/* Row 2 walk frames: 4 × 48px wide, at y = -48px */
@keyframes slime-walk {
  from { background-position:    0  -48px; }
  to   { background-position: -192px -48px; }
}
/* Row 3 dead frames — sprite has 3 frames (upright → squashed → flat);
   the 4th column at -144 is blank, so we stop on frame 2 (-96) */
@keyframes slime-dead {
  0%   { background-position:    0   -96px; }
  33%  { background-position:  -48px -96px; }
  66%  { background-position:  -96px -96px; }
  100% { background-position:  -96px -96px; }
}
/* Revive: dead in reverse, starting on the flat frame to match dead's hold */
@keyframes slime-revive {
  0%   { background-position:  -96px -96px; }
  33%  { background-position:  -48px -96px; }
  66%  { background-position:    0   -96px; }
  100% { background-position:    0   -96px; }
}

/* idle: same walk frames but slower — still alive, just chilling */
.slime.idle   { animation: slime-walk   1.4s steps(4)    infinite; }
.slime.walk   { animation: slime-walk  0.55s steps(4)    infinite; }
.slime.dead   { animation: slime-dead   0.9s steps(1, end) forwards; }
.slime.revive { animation: slime-revive 0.9s steps(1, end) forwards; }

/* ── Slime sparkles (max-scale slimes + the secret /slime sparkle) ── */
.slime-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.slime-sparkles span {
  position: absolute;
  font-size: 14px;
  line-height: 1;
  color: #fff;
  opacity: 0;
  filter: brightness(6) drop-shadow(0 0 3px rgba(0,0,0,0.8));
  animation: slime-sparkle 1.8s ease-in-out infinite;
}

/* positions set randomly by JS — only delays are fixed here */
.slime-sparkles span:nth-child(1) { animation-delay: 0s;    }
.slime-sparkles span:nth-child(2) { animation-delay: 0.45s; }
.slime-sparkles span:nth-child(3) { animation-delay: 0.90s; }
.slime-sparkles span:nth-child(4) { animation-delay: 1.35s; }

@keyframes slime-sparkle {
  0%   { opacity: 0;   transform: scale(0)    rotate(0deg);   }
  25%  { opacity: 1;   transform: scale(1.3)  rotate(30deg);  }
  55%  { opacity: 0.7; transform: scale(0.85) rotate(-10deg); }
  78%  { opacity: 0.9; transform: scale(1.1)  rotate(20deg);  }
  100% { opacity: 0;   transform: scale(0)    rotate(45deg);  }
}

/* ── Theme picker ── */
.theme-picker { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }

.theme-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s;
}
.theme-picker-row:hover,
.theme-picker-row.focused { background: var(--bg-card); }
.theme-picker-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.theme-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.9;
}

/* Per-palette swatch colors — reference --swatch-* tokens from themes.css */
.theme-swatch-sky    { background: var(--swatch-sky); }
.theme-swatch-forest { background: var(--swatch-forest); }
.theme-swatch-tide   { background: var(--swatch-tide); }
.theme-swatch-bloom  { background: var(--swatch-bloom); }
.theme-swatch-dusk   { background: var(--swatch-dusk); }
.theme-swatch-earth  { background: var(--swatch-earth); }
.theme-swatch-stone  { background: var(--swatch-stone); }

.theme-picker-name {
  color: var(--text);
  min-width: 68px;
  font-weight: 500;
}
.theme-picker-row.active .theme-picker-name { color: var(--accent); }

.theme-picker-desc { color: var(--text-muted); flex: 1; }

.theme-picker-check { color: var(--accent); font-size: 11px; }

/* ── Resize handles ── */
.resize-handle {
  position: absolute;
  z-index: 20;
}

.resize-handle.n  { top: 0;    left: 10px;  right: 10px; height: 5px; cursor: n-resize; }
.resize-handle.s  { bottom: 0; left: 10px;  right: 10px; height: 5px; cursor: s-resize; }
.resize-handle.e  { right: 0;  top: 10px; bottom: 10px;  width:  5px; cursor: e-resize; }
.resize-handle.w  { left: 0;   top: 10px; bottom: 10px;  width:  5px; cursor: w-resize; }
.resize-handle.ne { top: 0;    right: 0;  width: 14px; height: 14px;  cursor: ne-resize; }
.resize-handle.nw { top: 0;    left: 0;   width: 14px; height: 14px;  cursor: nw-resize; }
.resize-handle.se { bottom: 0; right: 0;  width: 14px; height: 14px;  cursor: se-resize; }
.resize-handle.sw { bottom: 0; left: 0;   width: 14px; height: 14px;  cursor: sw-resize; }

/* ── Mobile layout ── */
/* ════════════════════════════════════════════════════════════
   Mobile app shell (≤768px) — a scrollable content stage, a
   pull-up terminal drawer, and a fixed bottom bar. No windows,
   no top bar. Desktop (>768px) is untouched.
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Backdrop drift animation is expensive on mobile — kills it to save battery. */
  .backdrop { animation: none; }

  /* no top bar on mobile */
  .meta { display: none; }

  /* #desktop becomes the app shell */
  .desktop {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: auto;
  }

  /* ── The content stage ── */
  .mobile-stage {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px;
    /* padding-bottom is set by syncMobileBarHeight() to clear the bar + slimes */
  }
  .stage-content { animation: stageIn 0.22s ease both; }
  @keyframes stageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
  }

  /* home card */
  .stage-content.home { padding-top: 8vh; }
  .home-brand {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.02em;
  }
  .home-brand span { color: var(--accent); }
  .home-sub {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    letter-spacing: 0.02em;
  }
  .home-hint {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-top: 1.5rem;
    max-width: 30ch;
  }
  .home-hint .home-grab { color: var(--accent); font-size: 11px; }
  .home-hint .home-cmd {
    font-family: var(--font-mono);
    color: #fff;
    background: #14172a;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.92em;
    font-weight: 500;
  }

  /* ── Fixed bottom bar: grabber + chips + input ── */
  .mobile-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    background: var(--bg-window-solid);
    border-top: 1px solid var(--border-strong);
    padding-bottom: env(safe-area-inset-bottom);
    transition: transform 0.12s ease-out;
  }
  .mobile-bar .term-input-row {
    border-top: 1px solid var(--border);
  }

  /* When the keyboard is open, lock stage scroll so the input stays put. */
  body.kb-open .mobile-stage {
    overflow: hidden;
  }

  .drawer-grabber {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
  }
  .drawer-grabber span {
    width: 34px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
    transition: background var(--transition);
  }
  .drawer-grabber:active span { background: var(--accent); }

  /* chips + input sit transparent inside the bar */
  .cmd-chips {
    display: flex;
    background: transparent;
    border-top: none;
    padding: 2px 12px 8px;
  }
  .term-input-row {
    background: transparent;
    border-top: 1px solid var(--border);
    padding: 11px 16px;
  }
  /* prevent iOS Safari from auto-zooming on input focus */
  .term-input { font-size: 16px; }

  /* ── Terminal drawer — terminal mode, pulled up over the stage ── */
  .terminal-drawer {
    --kb-offset: 0px;   /* set by JS when the iOS keyboard rises */
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 950;
    height: 62dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-window-solid);
    border-top: 1px solid var(--border-strong);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.28);
    transform: translateY(calc(110% + var(--kb-offset)));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: 140px; /* clear the fixed bar below */
    overscroll-behavior: contain;
  }
  .terminal-drawer.open { transform: translateY(var(--kb-offset)); }
  .terminal-drawer .term-scroll {
    flex: 1;
    padding: 18px 17px;
    overscroll-behavior: contain;
  }

  .drawer-close {
    position: absolute;
    top: 10px; right: 12px;
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
  }
  .drawer-close:active { color: var(--text); }

  /* scrim behind the open drawer */
  .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(0,0,0,0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .drawer-scrim.open { opacity: 1; pointer-events: auto; }

  /* ── Toast — transient confirmations above the bar ── */
  .mobile-toast {
    position: fixed;
    left: 50%;
    bottom: 124px;
    z-index: 1100;
    max-width: calc(100vw - 32px);
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    background: var(--bg-window-solid);
    border: 1px solid var(--border-strong);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .mobile-toast svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
  }
  .mobile-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
