/* ===== Tokens ===== */
:root {
  --bg: #0e0f12;
  --bg-2: #15171c;
  --fg: #e8ecf2;
  --fg-dim: #aab0bc;
  --accent: #4c93f4;
  --accent-2: #6ea8ff;
  --line: rgba(255,255,255,.08);
  --radius: 14px;
  --radius-lg: 22px;
  --font-ui: "Inter", "Cantarell", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Mono", Menlo, monospace;
  --shadow-lg: 0 30px 80px -20px rgba(0,0,0,.6), 0 6px 22px -8px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  color: var(--fg);
  background: radial-gradient(1200px 600px at 50% -10%, #1a2742 0%, var(--bg) 55%) no-repeat, var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
h1, h2, h3 { letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 4.5vw, 3.6rem); line-height: 1.05; margin: 0 0 1rem; }
h2 { font-size: clamp(1.6rem, 2.5vw, 2.2rem); margin: 0 0 .75rem; }
p { line-height: 1.55; color: var(--fg-dim); }

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 4vw, 2.5rem);
  position: sticky; top: 0;
  backdrop-filter: blur(14px);
  background: rgba(14,15,18,.6);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 600; }
.brand-mark {
  width: 26px; height: 26px;
  background: url(assets/touchshell.svg) center/contain no-repeat;
  filter: drop-shadow(0 2px 6px rgba(76,147,244,.35));
}
.brand-name { font-size: 1.05rem; }
.site-nav { display: flex; gap: 1.6rem; }
.site-nav a { color: var(--fg-dim); text-decoration: none; font-size: .95rem; transition: color .15s; }
.site-nav a:hover { color: var(--fg); }

/* ===== Hero ===== */
.hero {
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 4vw, 2.5rem) 3rem;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(380px, 1.4fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}
.hero-copy .lede {
  font-size: 1.15rem;
  max-width: 32ch;
  margin: 0 0 1.75rem;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: .8rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .85rem 1.3rem;
  border-radius: 999px;
  font-weight: 600; font-size: .95rem;
  text-decoration: none;
  transition: transform .12s ease, background .12s, border-color .12s;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { border-color: var(--line); color: var(--fg); background: rgba(255,255,255,.02); }
.btn-ghost:hover { border-color: rgba(255,255,255,.2); }

.ego-badge,
.github-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 84px;
  /* visible-card aspect ratio of the EGO badge SVG (white card is 415u wide x 175u tall
     inside a 456 x 212 viewBox) — Source uses the same so both badges are the same size */
  aspect-ratio: 415 / 175;
  border-radius: 6px;
  line-height: 0;
  text-decoration: none;
  overflow: hidden;
  transition: transform .12s ease, filter .12s, background .12s, border-color .12s;
}
.ego-badge img {
  position: absolute;
  display: block;
  /* render the SVG slightly oversized & nudged so its built-in transparent padding is
     clipped by the container, leaving the white card flush to the edges */
  width: calc(456 / 415 * 100%);
  height: calc(212 / 175 * 100%);
  left: calc(-20 / 415 * 100%);
  top: calc(-17 / 175 * 100%);
  max-width: none;
}
.ego-badge:hover { filter: brightness(1.1); }
.ego-badge:active,
.github-badge:active { transform: translateY(1px); }

.github-badge {
  background: #15171c;
  border: 1px solid var(--line);
  color: var(--fg);
  gap: 0.7rem;
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  line-height: 1;
  padding: 0 1.3rem;
}
.github-badge svg { display: block; width: 28px; height: 28px; }
.github-badge:hover { background: #1d2026; border-color: rgba(255,255,255,.18); }

.hero-hint {
  margin-top: 1.5rem;
  font-size: .95rem;
  color: var(--accent-2);
  display: flex; align-items: center; gap: .5rem;
}

/* ===== Stage / device frame ===== */
.stage {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  perspective: 1200px;
}
.device {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-lg);
  padding: 10px;
  background: linear-gradient(160deg, #2c313a 0%, #1a1d22 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Device fullscreen button (bottom-left of bezel) */
.device-fullscreen-btn {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  animation: deviceFsBtnWobble 7s ease-in-out infinite;
  transform-origin: 50% 50%;
}
.device-fullscreen-btn:hover {
  background: rgba(0,0,0,.6);
  color: #fff;
  border-color: rgba(255,255,255,.22);
  animation: none;
  transform: rotate(0);
}
.device-fullscreen-btn svg {
  display: block;
  width: 16px; height: 16px;
}
.device-fullscreen-btn .icon-expand   { display: block; }
.device-fullscreen-btn .icon-collapse { display: none; }
.device.is-fullscreen .device-fullscreen-btn .icon-expand   { display: none; }
.device.is-fullscreen .device-fullscreen-btn .icon-collapse { display: block; }

/* The button sits still most of the cycle, then wobbles briefly. */
@keyframes deviceFsBtnWobble {
  0%, 90%, 100%       { transform: rotate(0); }
  91%, 95%            { transform: rotate(-9deg); }
  93%, 97%            { transform: rotate(9deg); }
  99%                 { transform: rotate(-3deg); }
}

/* Browser fullscreen state — fullscreen the whole .stage so the control bar
   comes along. Device shrinks to fit viewport while preserving aspect ratio. */
.stage.is-fullscreen,
.stage:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: #000;
  padding: max(2vh, 16px) max(2vw, 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.stage.is-fullscreen .device,
.stage:fullscreen .device {
  /* width is the smaller of: available viewport width OR aspect-derived from height-budget */
  width: min(calc(100vw - 4vw), calc((100vh - 6rem) * 1.6));
  height: auto;     /* aspect-ratio 16/10 derives height from width */
  max-height: calc(100vh - 6rem);
  flex: 0 1 auto;
}
.stage.is-fullscreen .sim-controls,
.stage:fullscreen .sim-controls {
  flex: 0 0 auto;
}
.shell {
  position: relative;
  width: 100%; height: 100%;
  border-radius: calc(var(--radius-lg) - 10px);
  overflow: hidden;
  background: #1a1d22;
  isolation: isolate;
  touch-action: none;
  user-select: none;
}

/* ===== Top panel ===== */
.panel {
  position: absolute; top: 0; left: 0; right: 0;
  height: 28px;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  color: #fff;
  font-size: 12px;
  z-index: 5;
  border-bottom: 1px solid rgba(255,255,255,.04);
  /* match the inner shell's rounded corners so backdrop-filter clips cleanly */
  border-top-left-radius: calc(var(--radius-lg) - 10px);
  border-top-right-radius: calc(var(--radius-lg) - 10px);
}
.panel button {
  background: transparent; color: inherit; border: 0; padding: 4px 8px;
  border-radius: 6px; font: inherit; cursor: default;
}
button.panel-clock {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1;
}
.panel-workspaces {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px !important;
  border-radius: 999px !important;
}
.ws-pip {
  display: block;
  width: 5px; height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  transition: width .25s cubic-bezier(.2,.7,.2,1), background .2s;
}
.ws-pip.active {
  width: 14px;
  background: rgba(255,255,255,.95);
}
.panel-tray { display: flex; gap: 8px; align-items: center; }
.tray-icon {
  width: 16px; height: 16px;
  display: inline-block;
  background-color: rgba(255,255,255,.95);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.tray-icon[data-icon="wifi"] {
  -webkit-mask-image: url(assets/icon-wifi.svg);
          mask-image: url(assets/icon-wifi.svg);
}
.tray-icon[data-icon="vol"] {
  -webkit-mask-image: url(assets/icon-volume.svg);
          mask-image: url(assets/icon-volume.svg);
}
.tray-icon[data-icon="bat"] {
  -webkit-mask-image: url(assets/icon-battery.svg);
          mask-image: url(assets/icon-battery.svg);
}

/* ===== Stage layer (workspaces, dash, overview) ===== */
.stage-layer {
  position: absolute; inset: 0;
  overflow: hidden;
}

.workspaces {
  position: absolute; inset: 0;
  display: flex;
  transform: translateX(0);
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
  will-change: transform;
}
.shell.dragging-h .workspaces { transition: none; }
.workspace {
  flex: 0 0 100%;
  position: relative;
  height: 100%;
  transform-origin: 50% 50%;
  will-change: transform;
}

.wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(700px 400px at 20% 30%, #355a8c 0%, transparent 60%),
    radial-gradient(600px 400px at 80% 70%, #2a3f6b 0%, transparent 60%),
    linear-gradient(135deg, #2a3a5a 0%, #1a2238 100%);
}

/* ===== Windows ===== */
.window {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--w); height: var(--h);
  background: #2b2d31;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.05);
  display: flex; flex-direction: column;
}
.window-header {
  height: 32px;
  background: #3a3d44;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(0,0,0,.25);
  flex-shrink: 0;
}
.window-header.dark { background: #1f2024; }
.window-title { font-size: 11px; font-weight: 600; color: #e0e3eb; }
.window-close { font-size: 16px; color: #aab; line-height: 1; }
.window-body { flex: 1; display: flex; min-height: 0; }
.files-body { background: #2b2d31; }
.sidebar { width: 32%; background: #232529; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.side-item { font-size: 9px; color: #c8cdd6; padding: 4px 6px; border-radius: 4px; }
.side-item:first-child { background: rgba(76,147,244,.28); color: #fff; }
.files-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  align-content: start;
}
.file {
  aspect-ratio: 1;
  background: linear-gradient(160deg, #4a4e57 0%, #36393f 100%);
  border-radius: 6px;
}
.term-body {
  background: #131418;
  color: #d8dce4;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 10px 12px;
  display: block;
  overflow: hidden;
}
.term-body p { margin: 0 0 4px; color: #d8dce4; line-height: 1.4; }
.term-prompt { color: #6ea8ff; }
.term-cursor {
  display: inline-block;
  width: 6px; height: 11px;
  background: #d8dce4;
  vertical-align: -1px;
  animation: blink 1s steps(2,end) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.web-body { background: #2b2d31; flex-direction: column; }
.web-bar { height: 22px; background: #1f2024; border-radius: 4px; margin: 8px; }
.web-content { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.web-line { height: 7px; border-radius: 3px; background: rgba(255,255,255,.1); }
.web-line.w70 { width: 70%; }
.web-line.w50 { width: 50%; }
.web-line.w90 { width: 90%; }
.web-line.w40 { width: 40%; }

/* ===== Simulation control bar ===== */
.sim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  justify-content: center;
  padding: 1rem 0.5rem 0;
}
.sim-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 4px 2px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--fg-dim);
  cursor: pointer;
  transition: color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sim-toggle:hover { color: var(--fg); }
.sim-toggle:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.sim-toggle:disabled:hover { color: var(--fg-dim); }
.sim-toggle-track {
  position: relative;
  width: 32px;
  height: 18px;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  transition: background .15s ease;
  flex-shrink: 0;
}
.sim-toggle-pip {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #d0d4dc;
  border-radius: 50%;
  transition: transform .18s cubic-bezier(.2,.7,.2,1), background .15s ease;
}
.sim-toggle[aria-checked="true"]                 { color: var(--fg); }
.sim-toggle[aria-checked="true"] .sim-toggle-track { background: var(--accent); }
.sim-toggle[aria-checked="true"] .sim-toggle-pip   { transform: translateX(14px); background: #fff; }

/* ===== Action bar (visible when toggled on) ===== */
.action-bar {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 30%;
  height: 4px;
  background: rgba(255,255,255,.55);
  border-radius: 2px;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.shell.action-bar-visible .action-bar { opacity: 1; }

/* ===== Fullscreen TextEdit window (workspace 2 when "Fullscreen apps" is on) ===== */
.window-maximized {
  position: absolute !important;
  /* default: below panel, above action bar (vars updated by modifier classes) */
  top: 28px;
  left: 0;
  right: 0;
  bottom: var(--ws-bottom-inset, 0px);
  width: auto !important;
  height: auto !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transition: top .25s ease, bottom .25s ease;
}
.shell.action-bar-visible { --ws-bottom-inset: 12px; }
.shell.panel-auto-hide[data-current-ws="2"] .window-maximized { top: 0; }
.shell.panel-auto-hide[data-current-ws="2"] .panel {
  transform: translateY(-100%);
  transition: transform .25s ease;
}
.panel { transition: transform .25s ease; }
.fullscreen-textedit {
  background: #fafafa;
  color: #1a1a1a;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 14px 18px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.55;
  gap: 0;
  overflow: hidden;
  text-align: left;
}
.fullscreen-textedit p { margin: 0; color: #1a1a1a; }

/* Closable TextEdit window — only visible when in overview / app-grid */
.textedit-window {
  display: none;
  transition: transform .25s cubic-bezier(.2,.7,.2,1), opacity .25s ease;
  will-change: transform, opacity;
}
.shell[data-mode="overview"]  .textedit-window,
.shell[data-mode="app-grid"]  .textedit-window {
  display: flex;
}
.textedit-window.dragging { transition: none; }
.textedit-window.closing {
  transform: translateY(-160%) !important;
  opacity: 0;
  pointer-events: none;
}
.textedit-body {
  background: #2b2d31;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
}
.textedit-prompt {
  margin: 0;
  color: #d8dce4;
  font-size: 12px;
  font-style: italic;
  line-height: 1.4;
  font-family: var(--font-mono);
}

/* Dismissible desktop notification banner */
.banner {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  width: min(70%, 260px);
  background: rgba(28,30,36,.94);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.6);
  z-index: 7;
  color: var(--fg);
  will-change: transform, opacity;
  transition: transform .3s cubic-bezier(.2,.7,.2,1), opacity .3s ease;
}
.banner.dragging { transition: none; }
.banner.dismissed,
.banner.hidden {
  transform: translateX(-50%) translateY(-180%);
  opacity: 0;
  pointer-events: none;
}
.banner-head { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 1px; }
.banner-app { font-size: 9px; color: rgba(255,255,255,.55); font-weight: 600; letter-spacing: .02em; }
.banner-title { font-size: 12px; font-weight: 600; color: #fff; }
.banner-body { font-size: 11px; color: var(--fg-dim); }

/* Shade entry — swipe-left to dismiss */
.notif.dismissible {
  will-change: transform, opacity;
  transition: transform .3s cubic-bezier(.2,.7,.2,1), opacity .25s ease;
}
.notif.dismissible.dragging { transition: none; }
.notif.dismissible.dismissed {
  transform: translateX(-110%);
  opacity: 0;
  pointer-events: none;
}

/* App grid (mode = app-grid) — opaque overlay with square placeholder app tiles.
   Top padding reserves space for the workspace thumbnails so tiles don't overlap them. */
.app-grid {
  position: absolute;
  inset: 0;
  background: #1a1d22;
  display: grid;
  grid-template-columns: repeat(4, 64px);
  grid-template-rows: repeat(3, 64px);
  gap: 22px;
  /* CSS padding-% is relative to container WIDTH; on a 16:10 shell 17% of width = ~27% of height,
     enough to clear the thumbnail row up top */
  padding: 17% 8% 4%;
  justify-content: center;
  align-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 3;
}
.app-grid-tile {
  background: #3a3d44;
  border-radius: 14px;
}
.shell[data-mode="app-grid"] .app-grid {
  opacity: 1;
  pointer-events: auto;
}
.shell[data-mode="app-grid"] .dash {
  opacity: 0;
  pointer-events: none;
}
.shell[data-mode="app-grid"] .workspace {
  transform: scale(0.55);
}

/* ===== Overview state ===== */
.shell[data-overview] .workspace {
  transform: scale(var(--overview-scale, 1));
  transition: transform .4s cubic-bezier(.2,.7,.2,1);
}
.shell[data-overview="full"] .workspace { --overview-scale: 0.55; }
.shell[data-overview="partial"] .workspace {
  --overview-scale: calc(1 - var(--overview-progress, 0) * 0.45);
  transition: none;
}

.overview-workspaces {
  position: absolute;
  top: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  display: flex; gap: 10px;
  padding: 8px;
  background: rgba(0,0,0,.35);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .4s cubic-bezier(.2,.7,.2,1), opacity .3s;
  z-index: 4;
}
.thumb {
  position: relative;
  overflow: hidden;
  width: 60px;
  height: 38px;
  background:
    radial-gradient(80px 50px at 25% 35%, #355a8c 0%, transparent 60%),
    radial-gradient(70px 50px at 80% 65%, #2a3f6b 0%, transparent 60%),
    linear-gradient(135deg, #2a3a5a 0%, #1a2238 100%);
  border-radius: 6px;
  border: 2px solid transparent;
  transition: width .25s cubic-bezier(.2,.7,.2,1), height .25s cubic-bezier(.2,.7,.2,1), border-color .15s ease;
}
.thumb.active { border-color: rgba(255,255,255,.85); }
/* In app-grid mode, keep thumbs visible and scale them up */
.shell[data-mode="app-grid"] .thumb { width: 110px; height: 68px; }
/* Mini-window placeholders inside each thumbnail */
.thumb-win {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  background: var(--c, #3a3d44);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.shell[data-overview] .overview-workspaces {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.dash {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%) translateY(140%);
  display: flex; gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,.4);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: transform .4s cubic-bezier(.2,.7,.2,1), opacity .3s;
  z-index: 4;
}
.dash-app {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(160deg, #4c93f4 0%, #2b5fb5 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2);
}
.dash-app:nth-child(2) { background: linear-gradient(160deg, #f0843a 0%, #c25a1c 100%); }
.dash-app:nth-child(3) { background: linear-gradient(160deg, #5fb86b 0%, #2f7c3a 100%); }
.dash-app:nth-child(4) { background: linear-gradient(160deg, #b85fb8 0%, #6c2f6c 100%); }
.dash-app:nth-child(5) { background: linear-gradient(160deg, #e2c34a 0%, #aa8a1c 100%); }
.dash-app.dash-sep { background: rgba(255,255,255,.15); width: 2px; border-radius: 1px; }
.dash-app.dash-grid {
  background:
    radial-gradient(circle at 25% 25%, #fff 14%, transparent 16%),
    radial-gradient(circle at 75% 25%, #fff 14%, transparent 16%),
    radial-gradient(circle at 25% 75%, #fff 14%, transparent 16%),
    radial-gradient(circle at 75% 75%, #fff 14%, transparent 16%),
    rgba(255,255,255,.15);
}
.shell[data-overview]:not([data-mode="app-grid"]) .dash {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ===== Popovers (QS / Calendar) ===== */
.popover {
  position: absolute;
  top: 36px;
  background: rgba(28,30,36,.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.6);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity .25s, transform .25s cubic-bezier(.2,.7,.2,1);
  z-index: 6;
  color: #e8ecf2;
}
.popover.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.popover-qs { right: 8px; width: 280px; }
.qs-slider { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.qs-slider-icon {
  width: 18px; height: 18px;
  display: inline-block;
  background-color: rgba(255,255,255,.9);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  flex-shrink: 0;
}
.qs-slider-icon[data-icon="vol"]        { -webkit-mask-image: url(assets/icon-volume.svg);     mask-image: url(assets/icon-volume.svg); }
.qs-slider-icon[data-icon="brightness"] { -webkit-mask-image: url(assets/icon-brightness.svg); mask-image: url(assets/icon-brightness.svg); }
.qs-slider-track {
  flex: 1; height: 6px;
  background: rgba(255,255,255,.1);
  border-radius: 3px;
  overflow: hidden;
}
.qs-slider-fill { height: 100%; background: #e8ecf2; }

.qs-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.qs-tile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.06);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  transition: background .15s ease, color .15s ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
}
.qs-tile:hover { background: rgba(255,255,255,.1); }
.qs-tile.on {
  background: rgba(108,168,255,.32);
  color: #fff;
}
.qs-tile.on:hover { background: rgba(108,168,255,.4); }
.qs-tile-icon {
  width: 14px; height: 14px;
  display: inline-block;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
.qs-tile-icon[data-icon="wifi"]        { -webkit-mask-image: url(assets/icon-wifi.svg);        mask-image: url(assets/icon-wifi.svg); }
.qs-tile-icon[data-icon="bluetooth"]   { -webkit-mask-image: url(assets/icon-bluetooth.svg);   mask-image: url(assets/icon-bluetooth.svg); }
.qs-tile-icon[data-icon="night-light"] { -webkit-mask-image: url(assets/icon-night-light.svg); mask-image: url(assets/icon-night-light.svg); }
.qs-tile-icon-inline { background: transparent !important; }
.qs-tile-icon-inline svg { width: 14px; height: 14px; display: block; }
.qs-tile-icon-brand {
  background: url(assets/touchshell.svg) center/contain no-repeat;
  -webkit-mask-image: none; mask-image: none;
  background-color: transparent;
}
.qs-tile-label { flex: 1; white-space: nowrap; }
.qs-tile-chev {
  color: rgba(255,255,255,.55);
  font-size: 14px;
  line-height: 1;
}

/* Touchshell sub-panel (revealed when its tile is tapped) */
.qs-subpanel {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,.045);
  border-radius: 14px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  transition: max-height .25s cubic-bezier(.2,.7,.2,1), opacity .15s, padding .25s;
}
.qs-subpanel.open {
  max-height: 280px;
  opacity: 1;
  padding-top: 12px;
  padding-bottom: 12px;
}
.qs-subpanel-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.qs-subpanel-header .qs-tile-icon-brand { width: 18px; height: 18px; }
.qs-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 11px;
  color: var(--fg);
}
.qs-sub-toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: rgba(255,255,255,.15);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease;
}
.qs-sub-pip {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #d0d4dc;
  border-radius: 50%;
  transition: transform .18s cubic-bezier(.2,.7,.2,1), background .15s ease;
}
.qs-sub-toggle[aria-checked="true"] { background: var(--accent); }
.qs-sub-toggle[aria-checked="true"] .qs-sub-pip {
  transform: translateX(14px);
  background: #fff;
}
.qs-sub-toggle:disabled { opacity: 0.45; cursor: not-allowed; }

.popover-cal { left: 50%; transform: translateX(-50%) translateY(-10px); width: 260px; }
.popover-cal.open { transform: translateX(-50%) translateY(0); }
.cal-header { font-size: 12px; font-weight: 600; margin-bottom: 8px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 10px; text-align: center; color: var(--fg-dim); }
.cal-grid span { padding: 4px 0; border-radius: 4px; }
.cal-grid .cal-dow { color: rgba(255,255,255,.45); font-weight: 600; }
.cal-grid .cal-day { color: var(--fg); }
.cal-grid .other-month { color: rgba(255,255,255,.25); }
.cal-grid .today { background: var(--accent); color: #fff; }
.notif-list { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.notif {
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex; flex-direction: column;
}
.notif-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notif-icon {
  width: 12px;
  height: 12px;
  display: inline-block;
  flex-shrink: 0;
  object-fit: contain;
}
/* For symbolic single-path icons, use mask-image so we can tint with currentColor */
.notif-icon[data-icon="files"] {
  background-color: rgba(255,255,255,.6);
  -webkit-mask-image: url(assets/icon-files.svg);
          mask-image: url(assets/icon-files.svg);
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
}
/* Touchshell logo is a multi-color mosaic; render the real <img> with filters to desaturate it */
img.notif-icon[data-icon="touchshell"] {
  filter: grayscale(1) brightness(1.5) contrast(.85) opacity(.7);
}
.notif-app  { font-size: 9px; color: rgba(255,255,255,.55); font-weight: 600; letter-spacing: .02em; }
.notif-body { font-size: 10px; color: #d8dce4; }

/* ===== Hint overlay ===== */
.hint {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity .25s;
  width: 140px;
  /* JS sets left/top to the anchor point; this translate centers the wrapper around it */
  transform: translate(-50%, -50%);
}
.hint.show { opacity: 1; }
/* "flip" variant: caption above the icon so the icon visually sits at the bottom of the wrapper */
.hint.flip { flex-direction: column-reverse; }
.hint img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
  flex-shrink: 0;
  animation: hintPulseUp 1.7s ease-in-out infinite;
}
/* "emphasis" variant: bigger icon + brighter glow (animation comes from direction) */
.hint.emphasis img {
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 0 14px rgba(108,168,255,.55)) drop-shadow(0 2px 8px rgba(0,0,0,.7));
}
/* direction-specific pulse (icon rocks toward its swipe direction) */
.hint[data-direction="up"]    img { animation-name: hintPulseUp;    }
.hint[data-direction="down"]  img { animation-name: hintPulseDown;  }
.hint[data-direction="left"]  img { animation-name: hintPulseLeft;  }
.hint[data-direction="right"] img { animation-name: hintPulseRight; }
@keyframes hintPulseUp    { 0%, 100% { transform: translateY( 6px); } 50% { transform: translateY(-6px); } }
@keyframes hintPulseDown  { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY( 6px); } }
@keyframes hintPulseLeft  { 0%, 100% { transform: translateX( 8px); } 50% { transform: translateX(-8px); } }
@keyframes hintPulseRight { 0%, 100% { transform: translateX(-8px); } 50% { transform: translateX( 8px); } }
.hint span {
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 10px;
  text-align: center;
  line-height: 1.35;
  max-width: 100%;
  text-wrap: balance;
}

/* ===== Mobile fallback ===== */
.mobile-fallback { display: none; }
@media (max-width: 760px), (pointer: coarse) and (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .device, .sim-controls { display: none; }
  .mobile-fallback {
    display: block;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #15171c;
    box-shadow: var(--shadow-lg);
  }
  .mobile-fallback video {
    width: 100%; height: auto; display: block;
    aspect-ratio: 16 / 10; object-fit: cover; background: #000;
  }
  .mobile-fallback-caption {
    margin: 0; padding: .9rem 1.1rem;
    font-size: .9rem; color: var(--fg-dim);
    border-top: 1px solid var(--line);
  }
}

/* ===== Features section ===== */
.features {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(3rem, 6vw, 5rem) clamp(1rem, 4vw, 2.5rem);
}
.section-lede { margin: 0 0 2.5rem; }
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}
.feature-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.feature-card video {
  width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #000;
  display: block;
  cursor: zoom-in;
}
.feature-meta { padding: 1rem 1.2rem 1.2rem; }
.feature-meta h3 { margin: 0 0 .4rem; font-size: 1.1rem; }
.feature-meta p { margin: 0 0 .6rem; font-size: .92rem; }
.feature-default {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(76,147,244,.12);
  color: var(--accent-2);
  border: 1px solid rgba(76,147,244,.25);
}

/* ===== Install ===== */
.install {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 4rem) clamp(1rem, 4vw, 2.5rem) 5rem;
}
.install-cards {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.25rem;
  margin: 1.5rem 0 1rem;
}
@media (max-width: 720px) { .install-cards { grid-template-columns: 1fr; } }
.install-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.install-card h3 { margin: 0 0 .4rem; }
.install-card .install-note { margin-top: auto; padding-top: 1rem; }
.install-ego-badge {
  margin-top: 1.25rem;
  align-self: flex-start;
  height: 110px;
  width: auto;
  display: block;
}

.code-block { position: relative; margin: .8rem 0 0; }
.code-block pre {
  margin: 0;
  background: #0b0c10;
  padding: 1rem 1rem .9rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.6;
  color: #d8dce4;
  border: 1px solid rgba(255,255,255,.04);
}
.code-block code { font-family: inherit; }

/* shell syntax highlighting */
.lang-shell .tok-cmd  { color: #e6c071; font-weight: 600; }
.lang-shell .tok-sub  { color: #c8cdd6; }
.lang-shell .tok-flag { color: #f08caf; }
.lang-shell .tok-url  { color: #6ea8ff; text-decoration: underline; text-decoration-color: rgba(110,168,255,.3); }
.lang-shell .tok-path { color: #b6e3a5; }
.lang-shell .tok-cont { color: #6b7280; }

.code-copy {
  position: absolute;
  top: .4rem;
  right: .4rem;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--fg-dim);
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-size: .7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, width .15s;
  overflow: hidden;
  white-space: nowrap;
}
.code-copy:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: var(--fg); }
.code-copy.copied {
  width: 72px;
  color: #b6e3a5;
  border-color: rgba(182,227,165,.35);
  background: rgba(182,227,165,.08);
}
.code-copy svg { display: block; flex-shrink: 0; }
.code-copy-label {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  margin-left: 0;
  transition: max-width .15s, opacity .12s, margin-left .15s;
}
.code-copy.copied .code-copy-label {
  max-width: 60px;
  opacity: 1;
  margin-left: .3rem;
}
.install-note { font-size: .9rem; color: var(--fg-dim); margin: .5rem 0 0; }

/* ===== Footer ===== */
.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding: 2.5rem 1rem 3rem;
  font-size: .85rem;
  color: var(--fg-dim);
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--accent-2); }
.manifesto-badge {
  display: inline-flex;
  line-height: 0;
  transition: opacity .15s ease;
  opacity: 0.85;
}
.manifesto-badge:hover { opacity: 1; }
.manifesto-badge img { width: 180px; height: auto; display: block; }
.copyright { margin: 0; font-size: .82rem; color: var(--fg-dim); }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 9, 12, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  animation: lb-fade .18s ease;
}
.lightbox[hidden] { display: none !important; }
@keyframes lb-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: min(1100px, 92vw);
  width: 100%;
}
.lightbox-stage video {
  width: 100%;
  max-height: 78vh;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  transition: transform .28s cubic-bezier(.2,.7,.2,1), opacity .2s ease;
}
.lightbox-stage.slide-out-left video  { transform: translateX(-12vw); opacity: 0; }
.lightbox-stage.slide-out-right video { transform: translateX( 12vw); opacity: 0; }
.lightbox-stage.slide-in-right video  { transform: translateX( 12vw); opacity: 0; transition: none; }
.lightbox-stage.slide-in-left video   { transform: translateX(-12vw); opacity: 0; transition: none; }
.lightbox-stage.slide-settle video    { transform: translateX(0); opacity: 1; }
.lightbox-caption {
  text-align: center;
  max-width: 60ch;
}
.lightbox-caption h3 {
  margin: 0 0 .35rem;
  font-size: 1.15rem;
  color: var(--fg);
}
.lightbox-caption p { margin: 0; color: var(--fg-dim); font-size: .95rem; line-height: 1.5; }

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--fg);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255,255,255,.16);
  border-color: rgba(255,255,255,.25);
}
.lightbox-close:active,
.lightbox-nav:active { transform: scale(0.96); }

.lightbox-close {
  top: clamp(.75rem, 2vw, 1.5rem);
  right: clamp(.75rem, 2vw, 1.5rem);
}
.lightbox-prev { left: clamp(.5rem, 2vw, 2rem); top: 50%; transform: translateY(-50%); }
.lightbox-next { right: clamp(.5rem, 2vw, 2rem); top: 50%; transform: translateY(-50%); }
.lightbox-prev:active { transform: translateY(-50%) scale(0.96); }
.lightbox-next:active { transform: translateY(-50%) scale(0.96); }

@media (max-width: 640px) {
  .lightbox-prev { left: .25rem; }
  .lightbox-next { right: .25rem; }
  .lightbox-close { top: .5rem; right: .5rem; }
}

/* prevent page scroll when lightbox open */
body.lightbox-open { overflow: hidden; }

/* ===== Touch text-action FAB + bar + OSK mock ===== */

/* Editable textedit content needs user-select; shell sets `none` by default. */
.fullscreen-textedit[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
  outline: none;
}
.fullscreen-textedit[contenteditable="true"]::selection { background: rgba(76,147,244,.35); }

/* Floating action button — bottom-right corner of the shell */
.ts-fab {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: rgba(40,40,40,.95);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  color: #fff;
  display: none;
  align-items: center; justify-content: center;
  padding: 0;
  z-index: 7;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s ease, transform .15s ease;
  cursor: pointer;
}
.shell.fab-visible .ts-fab { display: inline-flex; opacity: .55; transform: scale(1); }
.shell.fab-visible .ts-fab:hover { opacity: 1; }
.ts-fab:active { transform: scale(.94); }

/* Action bar that pops above the FAB */
.ts-fab-bar {
  position: absolute;
  right: 14px;
  bottom: 56px; /* sits above the FAB (36px + ~14px gap) */
  background: rgba(40,40,40,.95);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: 4px;
  display: none;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  z-index: 8;
  opacity: 0;
  transform-origin: 100% 100%;
  transform: scale(.6);
  transition: opacity .15s ease, transform .15s ease;
}
.shell.fab-bar-open .ts-fab-bar { display: inline-flex; opacity: 1; transform: scale(1); }
.ts-fab-btn {
  background: transparent;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.ts-fab-btn:hover { background: rgba(255,255,255,.08); }
.ts-fab-btn[disabled] { opacity: .4; cursor: default; }
.ts-fab-btn[disabled]:hover { background: transparent; }

/* OSK mock — pushes up from bottom of the shell */
.ts-osk {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(28,30,34,.98);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 6px 8px 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 9;
  transform: translateY(100%);
  transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
.shell.osk-open .ts-osk { display: flex; transform: translateY(0); }
.ts-osk-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0 2px 2px;
}
.ts-osk-hide {
  background: transparent;
  color: rgba(255,255,255,.7);
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ts-osk-hide:hover { background: rgba(255,255,255,.08); color: #fff; }
.ts-osk-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}
.ts-osk-row span {
  flex: 1;
  min-width: 0;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  font-family: var(--font-ui);
  user-select: none;
}
.ts-osk-indent { padding: 0 12px; }
.ts-osk-wide { flex: 1.5 !important; background: rgba(255,255,255,.04) !important; }
.ts-osk-bottom .ts-osk-meta { flex: 0.8; background: rgba(255,255,255,.04); }
.ts-osk-bottom .ts-osk-space { flex: 4; background: rgba(255,255,255,.08); }

/* FAB action toast */
.ts-fab-toast {
  position: absolute;
  left: 50%;
  bottom: 70px;
  transform: translate(-50%, 4px);
  background: rgba(20,20,20,.92);
  color: #fff;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .01em;
  opacity: 0;
  pointer-events: none;
  z-index: 9;
  transition: opacity .15s ease, transform .15s ease;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.ts-fab-toast.show { opacity: 1; transform: translate(-50%, 0); }
