/* ═════════════════════════════════════════════════════════════════════════════
   POPOUT — app.css

   Two jobs, in this order:
     1. THE DESIGN TOKENS. One :root block, kebab-case custom properties,
        grouped by comment banner (house style §7). dash.css and every future
        stylesheet consume these and define no raw hex of their own.
     2. The reset + the marketing / sign-in page at the APP_HOST root.

   No @import: an @import is a second serial round trip before first paint, and
   the shell can simply <link> both files. No web fonts either — the type stack
   is the system stack, which is already on the device, renders at 0 ms and
   costs no layout shift. §9.5's dashboard CSP is `default-src 'none'` with
   `font-src 'self'`, so a CDN font would be blocked anyway; not asking for one
   is better than being refused one.
   ═════════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── brand ────────────────────────────────────────────────────────────── */
  --ink-950: #07080f;      /* page under everything */
  --ink-900: #0c0e18;
  --ink-800: #141826;
  --ink-700: #1c2133;
  --ink-600: #262c42;
  --ink-500: #333a55;

  --accent:      #6d5cff;  /* popout violet — the one saturated colour */
  --accent-2:    #8b7dff;
  --accent-dim:  #3a3270;
  --accent-ink:  #ffffff;
  --cyan:        #2fd4c4;  /* "opened the app" — the metric we sell */
  --amber:       #f0b429;
  --danger:      #f2545b;
  --ok:          #34c98a;

  /* ── text ─────────────────────────────────────────────────────────────── */
  --text:      #f2f4fb;
  --text-2:    #b9c0d8;
  --muted:     #7b849f;
  --muted-2:   #5a6280;

  /* ── surfaces ─────────────────────────────────────────────────────────── */
  --bg:        var(--ink-950);
  --surface:   var(--ink-900);
  --surface-2: var(--ink-800);
  --card:      var(--ink-800);
  --line:      #232941;
  --line-2:    #2f374f;
  --scrim:     rgba(4, 5, 12, .68);

  /* ── type ─────────────────────────────────────────────────────────────── */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* ── shape ────────────────────────────────────────────────────────────── */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* ── depth ────────────────────────────────────────────────────────────── */
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .22);
  --shadow-float: 0 10px 34px rgba(0, 0, 0, .48);

  /* ── layout ───────────────────────────────────────────────────────────── */
  --gutter: 18px;
  --app-max: 1180px;
  --rail: 232px;             /* desktop side rail */
  --tabbar: 60px;            /* mobile bottom tab bar */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  /* ── motion ───────────────────────────────────────────────────────────── */
  --t-fast: 120ms;
  --t: 180ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* Respect the OS preference. Not decoration: a dashboard someone opens at
   09:00 on a phone in daylight is unreadable at 4% luminance. */
@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f6f7fb;
    --surface:   #ffffff;
    --surface-2: #f1f3f9;
    --card:      #ffffff;
    --line:      #e2e6f0;
    --line-2:    #d3d9e8;
    --text:      #10131f;
    --text-2:    #3b4257;
    --muted:     #6a7288;
    --muted-2:   #8d94a8;
    --accent-dim: #ded9ff;
    --scrim:     rgba(16, 19, 31, .38);
    --shadow-soft: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .06);
    --shadow-float: 0 10px 34px rgba(16, 24, 40, .16);
  }
}

/* ═══ reset ══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
p { margin: 0 0 .8em; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }

/* ═══ shared primitives (used by both the marketing page and the shell) ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 42px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
/* Icons are inline SVG with no intrinsic size (js/dash-core.js icon()), so the
   button sizes them. Without this they collapse to zero and silently vanish. */
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-sm svg { width: 14px; height: 14px; }
.btn:hover { background: var(--ink-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(242, 84, 91, .12); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .hint.err { color: var(--danger); }
.field .hint.ok { color: var(--ok); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; min-height: 42px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color var(--t-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; }
.textarea { min-height: 84px; resize: vertical; }
.input.mono { font-family: var(--mono); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-ok       { background: rgba(52, 201, 138, .14); color: var(--ok); border-color: rgba(52, 201, 138, .3); }
.pill-warn     { background: rgba(240, 180, 41, .14); color: var(--amber); border-color: rgba(240, 180, 41, .3); }
.pill-danger   { background: rgba(242, 84, 91, .14); color: var(--danger); border-color: rgba(242, 84, 91, .3); }
.pill-accent   { background: rgba(109, 92, 255, .16); color: var(--accent-2); border-color: rgba(109, 92, 255, .34); }
.pill-muted    { background: transparent; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-soft);
}
/* ── THERE IS NOT ONE `style=` ATTRIBUTE IN ANY POPOUT HTML FILE ──────────
   §9.5's policy for this origin is `style-src 'self'` with no 'unsafe-inline',
   and that directive governs the STYLE ATTRIBUTE: a `style="display:none"` in
   markup — or an `el.setAttribute('style', …)` from script — is DISCARDED by
   the browser, silently, with the element simply ignoring every declaration.
   (Measured against this exact policy: setAttribute gave computed
   `display:block`; the same declarations via the CSSOM gave `display:none`.)

   So: state that HTML needs at load time is a class, like the two below;
   anything genuinely dynamic is written through the CSSOM from script, which
   `script-src 'self'` already governs and CSP does not treat as inline style.
   See the `style` branch of el() in js/dash-core.js. */
.hide { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ═══ marketing + sign-in (public/index.html) ════════════════════════════ */
.mk {
  max-width: 980px; margin: 0 auto;
  padding: calc(28px + var(--sat)) var(--gutter) 64px;
}
.mk-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 48px; }
.mk-logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.mk-logo:hover { text-decoration: none; }
.mk-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--accent) 0%, var(--cyan) 130%);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
/* The glyph is an arrow leaving a container — see server/scripts/generate-icons.js,
   which draws the identical geometry for the PNG icons. Sized as a percentage so
   the mark scales with the tile wherever it is reused. stroke inherits the tile's
   `color`, so there is one white to change, not two. */
.mk-mark svg { width: 63%; height: 63%; display: block; }
.mk-hero { display: grid; gap: 40px; grid-template-columns: 1fr; align-items: start; }
.mk-hero h1 { font-size: clamp(30px, 7vw, 46px); letter-spacing: -.03em; margin-bottom: 16px; }
.mk-hero h1 em { font-style: normal; color: var(--accent-2); }
.mk-lede { font-size: 17px; color: var(--text-2); max-width: 46ch; }
.mk-points { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; }
.mk-points li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); font-size: 14.5px; }
.mk-points b { color: var(--text); font-weight: 650; }
.mk-tick { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--cyan); }

.auth { padding: 22px; }
.auth h2 { font-size: 19px; margin-bottom: 4px; }
.auth .sub { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.auth-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r); margin-bottom: 18px; }
.auth-tabs button {
  flex: 1; padding: 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font-weight: 650; font-size: 13.5px; cursor: pointer;
}
.auth-tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-soft); }
.auth-msg { font-size: 13px; margin: 0 0 12px; padding: 9px 11px; border-radius: var(--r-sm); }
.auth-msg.err { background: rgba(242, 84, 91, .12); color: var(--danger); }
.auth-msg.ok  { background: rgba(52, 201, 138, .12); color: var(--ok); }
.auth-alt { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.mk-foot { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }

@media (min-width: 860px) {
  .mk-hero { grid-template-columns: 1.15fr .85fr; gap: 56px; }
  .mk { padding-top: calc(40px + var(--sat)); }
}
