/* Bulava mobile prototype — colours, radii, type scale and motion curves are the macOS
   app's own tokens, carried over verbatim rather than re-picked. */

:root {
  --window:        #E7E7E8;
  --content:       #F6F6F7;
  --chrome:        #E6E6E8;
  --chrome-sunken: #DDDDE0;
  --panel:         #FFFFFF;
  --panel-muted:   #EFEFF1;
  --panel-raised:  #E6E6E8;
  --field:         #FFFFFF;
  --panel-on-chrome:#FFFFFF;

  --hover:          rgba(0,0,0,.045);
  --selected:       rgba(75,117,16,.13);
  --selected-border:rgba(60,95,13,.24);

  --text:      #202023;
  --text-2:    #626268;
  --text-3:    #64646B;
  --text-faint:#7C7C84;

  --line:        rgba(0,0,0,.075);
  --line-strong: rgba(0,0,0,.14);

  --brand-lime:  #C7F183;
  --brand-field: #16291C;

  --accent:      #4B7510;
  --accent-emph: #3C5F0D;
  --accent-soft: rgba(75,117,16,.10);
  --on-accent:   #FFFFFF;

  --green: #1F6B41; --green-soft: rgba(31,107,65,.09);
  --orange:#8A4E12; --orange-soft:rgba(138,78,18,.09);
  --red:   #A83B36; --red-soft:   rgba(168,59,54,.09);
  --blue:  #3475BB; --blue-soft:  rgba(52,117,187,.09);

  --track:    rgba(0,0,0,.07);
  --terminal: #1A1A1C;
  --on-terminal: #D5D5DA;
  --on-terminal-dim: #9A9AA2;

  --shadow-resting: 0 4px 10px rgba(43,43,46,.035);
  --shadow-float:   0 1px 2px rgba(43,43,46,.03), 0 12px 26px rgba(43,43,46,.085);
  --shadow-modal:   0 1px 3px rgba(43,43,46,.05), 0 26px 60px rgba(43,43,46,.17);

  --r-modal: 14px; --r-card: 12px; --r-panel: 10px;
  --r-control: 7px; --r-chip: 6px; --r-badge: 5px;
  --gutter: 16px; --card-pad: 15px; --section-gap: 18px;

  --ease: cubic-bezier(.25,.46,.45,.94);
  --t-hover: .15s; --t-standard: .25s; --t-expand: .28s; --t-surface: .34s;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, monospace;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --window:        #171718;
  --content:       #19191A;
  --chrome:        #272729;
  --chrome-sunken: #2D2D2F;
  --panel:         #242426;
  --panel-muted:   #2B2B2E;
  --panel-raised:  #323235;
  --field:         #29292C;
  --panel-on-chrome:#2E2E31;

  --hover:          rgba(255,255,255,.055);
  --selected:       rgba(199,241,131,.15);
  --selected-border:rgba(199,241,131,.32);

  --text:      #F2F2F3;
  --text-2:    #B5B5BB;
  --text-3:    #92929A;
  --text-faint:#7C7C83;

  --line:        rgba(255,255,255,.075);
  --line-strong: rgba(255,255,255,.13);

  --accent:      #B4E76D;
  --accent-emph: #C7F183;
  --accent-soft: rgba(199,241,131,.13);
  --on-accent:   #16291C;

  --green: #69C58C; --green-soft: rgba(105,197,140,.12);
  --orange:#E8A45D; --orange-soft:rgba(232,164,93,.13);
  --red:   #EF7770; --red-soft:   rgba(239,119,112,.12);
  --blue:  #70A9F4; --blue-soft:  rgba(112,169,244,.12);

  --track:    rgba(255,255,255,.07);
  --terminal: #111112;

  --shadow-resting: 0 4px 10px rgba(0,0,0,.07);
  --shadow-float:   0 1px 2px rgba(0,0,0,.06), 0 12px 26px rgba(0,0,0,.17);
  --shadow-modal:   0 1px 3px rgba(0,0,0,.10), 0 26px 60px rgba(0,0,0,.34);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --window:#171718; --content:#19191A; --chrome:#272729; --chrome-sunken:#2D2D2F;
    --panel:#242426; --panel-muted:#2B2B2E; --panel-raised:#323235; --field:#29292C;
    --panel-on-chrome:#2E2E31;
    --hover:rgba(255,255,255,.055); --selected:rgba(199,241,131,.15);
    --selected-border:rgba(199,241,131,.32);
    --text:#F2F2F3; --text-2:#B5B5BB; --text-3:#92929A; --text-faint:#7C7C83;
    --line:rgba(255,255,255,.075); --line-strong:rgba(255,255,255,.13);
    --accent:#B4E76D; --accent-emph:#C7F183; --accent-soft:rgba(199,241,131,.13);
    --on-accent:#16291C;
    --green:#69C58C; --green-soft:rgba(105,197,140,.12);
    --orange:#E8A45D; --orange-soft:rgba(232,164,93,.13);
    --red:#EF7770; --red-soft:rgba(239,119,112,.12);
    --blue:#70A9F4; --blue-soft:rgba(112,169,244,.12);
    --track:rgba(255,255,255,.07); --terminal:#111112;
    --shadow-resting:0 4px 10px rgba(0,0,0,.07);
    --shadow-float:0 1px 2px rgba(0,0,0,.06), 0 12px 26px rgba(0,0,0,.17);
    --shadow-modal:0 1px 3px rgba(0,0,0,.10), 0 26px 60px rgba(0,0,0,.34);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--window);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Stage (only on a wide screen) ---------- */

.stage { display: none; }

.device {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--content);
  overflow: hidden;
}

@media (min-width: 900px) {
  body { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; min-height: 100dvh; }
  .stage {
    display: flex; flex-direction: column; gap: 20px;
    padding: 56px 40px; align-self: center; max-width: 420px;
  }
  .stage h1 { font-size: 26px; letter-spacing: -.03em; font-weight: 600; margin: 0; }
  .stage p { font-size: 14.5px; line-height: 1.6; color: var(--text-3); margin: 0; }
  .stage .mark { display: flex; align-items: center; gap: 9px; }
  .stage .mark b { font-size: 16px; letter-spacing: -.02em; font-weight: 600; }
  .stage .mark b span { color: var(--text-faint); font-weight: 600; }
  .stage-links { display: flex; flex-wrap: wrap; gap: 8px; }
  .stage-note {
    font-size: 12.5px; line-height: 1.55; color: var(--text-faint);
    border-left: 2px solid var(--line-strong); padding-left: 11px;
  }
  .device-wrap { display: grid; place-items: center; padding: 28px; min-height: 100dvh; }
  .device {
    width: 390px; height: 844px; max-height: calc(100dvh - 56px);
    border-radius: 44px; box-shadow: var(--shadow-modal);
    border: 9px solid #0E0E0F; outline: 1px solid var(--line-strong);
  }
}

/* ---------- App shell ---------- */

.app {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--content);
  overflow: hidden;
}

.statusbar {
  flex: none; height: env(safe-area-inset-top, 0px);
  min-height: 0;
  background: var(--chrome);
}
@media (min-width: 900px) {
  .statusbar {
    height: 44px; display: flex; align-items: flex-end; justify-content: space-between;
    padding: 0 26px 5px; font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  }
  .statusbar .glyphs { display: flex; align-items: center; gap: 5px; }
}
.statusbar .clock, .statusbar .glyphs { display: none; }
@media (min-width: 900px) { .statusbar .clock, .statusbar .glyphs { display: flex; } }

/* ---------- Top bar ---------- */

.topbar {
  flex: none; display: flex; align-items: center; gap: 2px;
  height: 52px; padding: 0 6px 0 4px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
.topbar .title { flex: 1 1 auto; min-width: 0; padding: 0 6px; }
.topbar .title b {
  display: block; font-size: 16px; font-weight: 600; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .title .sub {
  display: flex; align-items: center; gap: 5px; margin-top: 1px;
  font-size: 11.5px; color: var(--text-faint);
  white-space: nowrap; overflow: hidden;
}
.topbar .title .sub span { overflow: hidden; text-overflow: ellipsis; }

.iconbtn {
  flex: none; width: 38px; height: 38px; border-radius: var(--r-control);
  display: grid; place-items: center; color: var(--text-2);
  transition: background var(--t-hover) var(--ease), color var(--t-hover) var(--ease);
}
.iconbtn:active { background: var(--hover); }
.iconbtn[aria-pressed="true"] { background: var(--selected); color: var(--accent-emph); }
.iconbtn:disabled { opacity: .35; cursor: default; }

/* ---------- Connection banner ---------- */

.conn {
  flex: none; display: none; align-items: center; gap: 8px;
  padding: 8px var(--gutter); font-size: 12.5px; line-height: 1.35;
  border-bottom: 1px solid var(--line);
}
.conn[data-state="reconnecting"],
.conn[data-state="asleep"],
.conn[data-state="stale"],
.conn[data-state="unpaired"] { display: flex; }
.conn[data-state="reconnecting"] { background: var(--blue-soft);   color: var(--blue); }
.conn[data-state="asleep"]       { background: var(--orange-soft); color: var(--orange); }
.conn[data-state="stale"]        { background: var(--panel-muted);  color: var(--text-3); }
.conn[data-state="unpaired"]     { background: var(--red-soft);    color: var(--red); }
.conn b { font-weight: 600; }
.conn .grow { flex: 1 1 auto; min-width: 0; }
.conn button {
  flex: none; font-size: 12px; font-weight: 600; padding: 4px 9px;
  border-radius: var(--r-chip); background: var(--panel); color: inherit;
  border: 1px solid var(--line);
}

/* ---------- Screens ---------- */

.screens { position: relative; flex: 1 1 auto; min-height: 0; }
.screen {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  opacity: 0; visibility: hidden; transform: translateX(14px);
  transition: opacity var(--t-standard) var(--ease),
              transform var(--t-standard) var(--ease),
              visibility 0s linear var(--t-standard);
}
.screen.is-active {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--t-standard) var(--ease),
              transform var(--t-standard) var(--ease),
              visibility 0s;
}
.screen-head { padding: 22px var(--gutter) 14px; }
.screen-head h2 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.03em; }
.screen-head p { margin: 7px 0 0; font-size: 14px; line-height: 1.55; color: var(--text-3); }

.eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: .072em;
  text-transform: uppercase; color: var(--text-faint);
}

/* ---------- Cards / rows ---------- */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-resting);
}
.list { margin: 0 var(--gutter); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 13px var(--card-pad); text-align: left;
  transition: background var(--t-hover) var(--ease);
}
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--hover); }
.row .grow { display: block; flex: 1 1 auto; min-width: 0; }
.row .lbl { display: block; font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.row .meta { display: block; font-size: 12.5px; color: var(--text-faint); margin-top: 2px; line-height: 1.4; }
.row .chev { flex: none; color: var(--text-faint); }
.row .glyph { flex: none; width: 26px; display: grid; place-items: center; color: var(--text-2); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 7px; border-radius: var(--r-badge); white-space: nowrap;
}
.tag.ok    { background: var(--green-soft);  color: var(--green); }
.tag.warn  { background: var(--orange-soft); color: var(--orange); }
.tag.bad   { background: var(--red-soft);    color: var(--red); }
.tag.info  { background: var(--blue-soft);   color: var(--blue); }
.tag.quiet { background: var(--panel-muted); color: var(--text-3); }
.tag.acc   { background: var(--accent-soft); color: var(--accent-emph); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--r-control);
  font-size: 14px; font-weight: 600; letter-spacing: -.01em;
  background: var(--panel-raised); border: 1px solid var(--line);
  transition: transform var(--t-hover) var(--ease), background var(--t-hover) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.quiet { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.wide { width: 100%; }

/* ---------- Products ---------- */

.products { display: grid; gap: 10px; padding: 0 var(--gutter); }
.product {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: var(--card-pad); text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-resting);
  transition: transform var(--t-hover) var(--ease);
}
.product:active { transform: scale(.985); }
.product .icon {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-panel);
  display: grid; place-items: center;
}
.product .name { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.product .grow { display: block; flex: 1 1 auto; min-width: 0; }
.product .status { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--text-faint); }

/* ---------- Chat feed ---------- */

.feed { padding: 14px var(--gutter) 4px; display: flex; flex-direction: column; gap: 18px; }

.msg-user {
  align-self: flex-end; max-width: 86%;
  background: var(--panel-muted); border: 1px solid var(--line);
  border-radius: var(--r-card); padding: 11px 13px;
  font-size: 15.5px; line-height: 1.5; letter-spacing: -.005em;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .att {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 8px;
  font-size: 12px; color: var(--text-faint);
  border: 1px solid var(--line); border-radius: var(--r-chip); padding: 3px 7px;
}

.turn { display: flex; flex-direction: column; gap: 10px; }
.prose { font-size: 15.5px; line-height: 1.62; letter-spacing: -.005em; word-break: break-word; }
.prose p { margin: 0 0 .75em; }
.prose p:last-child { margin: 0; }
.prose ul { margin: 0 0 .75em; padding-left: 1.15em; }
.prose li { margin: .28em 0; }
.prose code {
  font-family: var(--mono); font-size: .86em;
  background: var(--panel-muted); border: 1px solid var(--line);
  border-radius: var(--r-badge); padding: 1px 4px;
}
.prose strong { font-weight: 600; }

.acts { display: flex; flex-direction: column; gap: 2px; }
.act {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-3); line-height: 1.4;
}
.act .dot { flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--text-faint); opacity: .55; }
.act .obj { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }
.act.running .dot { background: var(--accent); opacity: 1; animation: breathe 1s var(--ease) infinite alternate; }
.act.failed .dot { background: var(--red); opacity: 1; }
@keyframes breathe { from { opacity: .35; } to { opacity: 1; } }

.blk {
  border: 1px solid var(--line); border-radius: var(--r-panel);
  background: var(--panel); overflow: hidden;
}
.blk-head {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel-muted); font-size: 12.5px; color: var(--text-2);
}
.blk-head b { font-weight: 600; color: var(--text); }
.blk-body { padding: 12px; font-size: 14.5px; line-height: 1.58; color: var(--text-2); }
.blk.error { border-color: var(--red-soft); background: var(--red-soft); }
.blk.error .blk-body { color: var(--red); }

.filerow { display: flex; align-items: center; gap: 9px; padding: 11px 12px; font-size: 13.5px; }
.filerow .path { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .plus { color: var(--green); font-variant-numeric: tabular-nums; font-size: 12px; }
.filerow .minus { color: var(--red); font-variant-numeric: tabular-nums; font-size: 12px; }

.frames { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
.frame { border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; background: var(--panel-muted); }
.frame .cap { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); padding: 6px 8px 0; }
.frame .shot { aspect-ratio: 3/4; display: grid; place-items: center; margin: 6px 8px 8px; border-radius: var(--r-chip); border: 1px solid var(--line); }

.evt {
  display: flex; align-items: center; gap: 8px; align-self: center;
  font-size: 12.5px; color: var(--text-faint); text-align: center;
}

/* question card */
.ask {
  border: 1px solid var(--selected-border); border-radius: var(--r-card);
  background: var(--panel); box-shadow: var(--shadow-resting); overflow: hidden;
}
.ask-head { padding: 13px var(--card-pad) 0; }
.ask-head .k { display: flex; align-items: center; gap: 6px; color: var(--accent-emph); }
.ask-head h4 { margin: 8px 0 0; font-size: 16px; font-weight: 600; letter-spacing: -.015em; line-height: 1.35; }
.ask-head .sit { margin: 7px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--text-3); }
.ask-opts { padding: 13px var(--card-pad) 6px; display: grid; gap: 7px; }
.ask-opt {
  width: 100%; text-align: left; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--r-panel);
  background: var(--panel-muted); transition: background var(--t-hover) var(--ease), border-color var(--t-hover) var(--ease);
}
.ask-opt:active { background: var(--selected); border-color: var(--selected-border); }
.ask-opt .t { font-size: 14.5px; font-weight: 500; letter-spacing: -.01em; }
.ask-opt .d { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.45; }
.ask-opt.rec { border-color: var(--selected-border); background: var(--accent-soft); }
.ask-foot {
  padding: 8px var(--card-pad) 12px;
  font-size: 11.5px; color: var(--text-faint); line-height: 1.5;
  display: flex; align-items: flex-start; gap: 6px;
}
.ask-foot .mono { font-family: var(--mono); font-size: 11px; }

/* report card */
.reportcard {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: var(--card-pad); border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--panel); box-shadow: var(--shadow-resting);
}
.reportcard:active { background: var(--hover); }

/* phase line above composer */
.phase {
  display: flex; align-items: center; gap: 8px;
  margin: 0 var(--gutter) 10px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--r-panel);
  background: var(--panel); font-size: 13px; color: var(--text-2);
}
.phase.attention { border-color: var(--selected-border); background: var(--accent-soft); color: var(--accent-emph); }
.phase .spin { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Composer ---------- */

.composer {
  flex: none; padding: 8px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--chrome); border-top: 1px solid var(--line);
}
.composer.is-hidden { display: none; }
.composer .session {
  display: flex; align-items: center; gap: 6px; padding: 0 2px 7px;
  font-size: 11.5px; color: var(--text-faint);
}
.composer .surface {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--field); border: 1px solid var(--line-strong);
  border-radius: var(--r-modal); padding: 5px 5px 5px 6px;
}
.composer textarea {
  flex: 1 1 auto; min-width: 0; resize: none; border: 0; outline: 0; background: none;
  font-family: var(--font); font-size: 16px; line-height: 1.4; letter-spacing: -.005em;
  color: var(--text); padding: 8px 2px; max-height: 120px;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  transition: transform var(--t-hover) var(--ease), opacity var(--t-hover) var(--ease);
}
.send:active { transform: scale(.94); }
.send:disabled { background: var(--panel-raised); color: var(--text-faint); }

/* ---------- Drawer ---------- */

.scrim {
  position: absolute; inset: 0; background: rgba(0,0,0,.34);
  opacity: 0; visibility: hidden; z-index: 40;
  transition: opacity var(--t-surface) var(--ease), visibility 0s linear var(--t-surface);
}
.scrim.is-open { opacity: 1; visibility: visible; transition: opacity var(--t-surface) var(--ease), visibility 0s; }

.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: 84%; max-width: 310px; z-index: 41;
  background: var(--chrome); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(-102%);
  transition: transform var(--t-surface) var(--ease);
  padding-top: env(safe-area-inset-top, 0px);
}
.drawer.is-open { transform: none; }
.drawer-brand { display: flex; align-items: center; gap: 9px; padding: 16px 14px 10px; }
.drawer-brand .wm { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.drawer-brand .wm span { color: var(--text-faint); }
.drawer-brand .beta { font-size: 9px; font-weight: 600; letter-spacing: .04em; color: var(--text-faint); }
.drawer-search {
  display: flex; align-items: center; gap: 7px; margin: 0 12px 12px; height: 34px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--chrome-sunken); color: var(--text-faint); font-size: 13px;
}
.drawer-scroll { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 10px; }
.drawer-sect { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 4px; }
.nav {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 8px; border-radius: var(--r-chip); text-align: left;
  font-size: 14.5px; font-weight: 500; letter-spacing: -.01em;
}
.nav:active { background: var(--hover); }
.nav[aria-current="true"] { background: var(--selected); }
.nav .glyph { flex: none; width: 20px; display: grid; place-items: center; color: var(--text-2); }
.nav .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .n { flex: none; font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.subnav {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px 7px 30px; border-radius: var(--r-chip); text-align: left;
  font-size: 13.5px; color: var(--text-2);
}
.subnav:active { background: var(--hover); }
.subnav[aria-current="true"] { background: var(--selected); color: var(--text); }
.subnav .grow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drawer-foot { flex: none; border-top: 1px solid var(--line); padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
.limit { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-2); margin-bottom: 7px; }
.limit .bar { flex: 1 1 auto; height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.limit .bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.limit .pct { flex: none; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Sheet ---------- */

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 42;
  max-height: 92%; display: flex; flex-direction: column;
  background: var(--content);
  border-radius: var(--r-modal) var(--r-modal) 0 0;
  border-top: 1px solid var(--line-strong);
  box-shadow: var(--shadow-modal);
  transform: translateY(101%);
  transition: transform var(--t-surface) var(--ease);
}
.sheet.is-open { transform: none; }
.sheet-grip { flex: none; display: grid; place-items: center; padding: 8px 0 2px; }
.sheet-grip i { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px var(--gutter) 10px; }
.sheet-head h3 { flex: 1 1 auto; margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 0 0 calc(18px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Full-screen surface (report, search, pairing) ---------- */

.surface {
  position: absolute; inset: 0; z-index: 45;
  background: var(--content);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity var(--t-surface) var(--ease), transform var(--t-surface) var(--ease),
              visibility 0s linear var(--t-surface);
  padding-top: env(safe-area-inset-top, 0px);
}
.surface.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity var(--t-surface) var(--ease), transform var(--t-surface) var(--ease), visibility 0s;
}
.surface-bar {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: 52px; padding: 0 6px; border-bottom: 1px solid var(--line); background: var(--chrome);
}
.surface-bar b { flex: 1 1 auto; font-size: 15.5px; font-weight: 600; letter-spacing: -.02em; padding-left: 6px; }
.surface-body { flex: 1 1 auto; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* report document */
.doc { padding: 26px var(--gutter) 0; max-width: 680px; margin: 0 auto; }
.doc h1 { margin: 0 0 12px; font-size: 27px; font-weight: 600; letter-spacing: -.035em; line-height: 1.18; }
.doc .lede { font-size: 15.5px; line-height: 1.62; color: var(--text-2); margin: 0 0 22px; }
.doc h2 { margin: 26px 0 10px; font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.doc p { font-size: 15px; line-height: 1.65; color: var(--text-2); margin: 0 0 12px; }
.doc .crit { display: flex; gap: 9px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.doc .crit .st { flex: none; margin-top: 1px; }

/* search */
.searchfield {
  display: flex; align-items: center; gap: 8px; margin: 10px var(--gutter);
  height: 40px; padding: 0 11px; border-radius: var(--r-control);
  background: var(--field); border: 1px solid var(--line-strong);
}
.searchfield input {
  flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: none;
  font-family: var(--font); font-size: 16px; color: var(--text);
}

/* pairing */
.pair { padding: 26px var(--gutter) 0; text-align: center; }
.pair h2 { margin: 0 0 8px; font-size: 24px; font-weight: 600; letter-spacing: -.03em; }
.pair p { margin: 0 auto 22px; font-size: 14.5px; line-height: 1.6; color: var(--text-3); max-width: 300px; }
.qr {
  width: 208px; height: 208px; margin: 0 auto 20px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-resting);
}
.steps { text-align: left; margin: 22px var(--gutter) 0; }
.step { display: flex; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.step .num {
  flex: none; width: 21px; height: 21px; border-radius: 50%; margin-top: 1px;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-emph);
}
.step .t { font-size: 14.5px; font-weight: 500; letter-spacing: -.01em; }
.step .d { font-size: 13px; color: var(--text-faint); margin-top: 3px; line-height: 1.5; }

/* ---------- Permission tiers ---------- */

.tier { margin: 0 var(--gutter) var(--section-gap); }
.tier > .eyebrow { display: block; margin: 0 2px 8px; }
.tier .note { font-size: 12.5px; line-height: 1.5; color: var(--text-faint); margin: 0 2px 9px; }

.check { display: flex; align-items: flex-start; gap: 11px; padding: 13px var(--card-pad); }
.check + .check { border-top: 1px solid var(--line); }
.check .st { flex: none; margin-top: 1px; }
.check .grow { display: block; flex: 1 1 auto; min-width: 0; }
.check .lbl { display: block; font-size: 14.5px; font-weight: 500; letter-spacing: -.01em; line-height: 1.35; }
.check .why { display: block; font-size: 12.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.5; }
.check .act { display: block; margin-top: 9px; }

/* ---------- Toast ---------- */

.toast {
  position: absolute; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  transform: translate(-50%, 12px); opacity: 0; visibility: hidden;
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: var(--r-modal);
  background: var(--panel-on-chrome); border: 1px solid var(--line);
  box-shadow: var(--shadow-float);
  font-size: 13.5px; line-height: 1.4;
  transition: opacity var(--t-standard) var(--ease), transform var(--t-standard) var(--ease),
              visibility 0s linear var(--t-standard);
}
.toast.is-open {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
  transition: opacity var(--t-standard) var(--ease), transform var(--t-standard) var(--ease), visibility 0s;
}
.toast .ic { flex: none; }
.toast.ok .ic { color: var(--green); }
.toast.bad .ic { color: var(--red); }
.toast.info .ic { color: var(--blue); }

/* ---------- Demo panel ---------- */

.demo-note {
  margin: 0 var(--gutter) 12px; padding: 11px 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-panel);
  font-size: 12.5px; line-height: 1.55; color: var(--text-faint);
}
/* An inline link inside prose is still something a thumb has to hit. */
.demo-note a, .demo-note button {
  display: inline-block; padding: 7px 0; margin: -4px 0;
  color: var(--accent); font-weight: 600; text-decoration: none;
}
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 0 var(--gutter) 6px; }
.seg button {
  padding: 11px 10px; border-radius: var(--r-panel); text-align: left;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 13.5px; font-weight: 500; letter-spacing: -.01em;
}
.seg button[aria-pressed="true"] { border-color: var(--selected-border); background: var(--selected); }
.seg button small { display: block; margin-top: 3px; font-size: 11.5px; font-weight: 400; color: var(--text-faint); line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
