/* MERIDIAN base stylesheet: tokens, shell, shared components (C1 split from styles.css; rules unchanged). */
/* =========================================================
   MERIDIAN — design tokens
   A calm/alert/crisis posture system. No external assets.
   ========================================================= */
@font-face {
  font-family: "Open Sans";
  src: url("../assets/fonts/opensans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("../assets/fonts/roboto-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("../assets/fonts/roboto-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("../assets/fonts/roboto-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-ui: "Open Sans", "Segoe UI", Arial, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;

  --bg: #f8f9fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --surface-3: #e8eaed;
  --border: #d8dde3;
  --border-strong: #b9c2cc;
  --text: #202122;
  --muted: #54595d;
  --faint: #62676d;

  --brand: #3366cc;
  --brand-soft: #eaf3ff;
  --accent: #1670c4;
  --accent-contrast: #ffffff;
  --warn: #9a5b00; /* 5.4:1 on white (AA); #b26a00 was 4.2 */
  --warn-soft: #fff4d6;
  --danger: #b32424;
  --danger-soft: #fdeaea;
  --ok: #0d6350;

  --map-land-1: #e7efe9;
  --map-land-2: #dbe8df;
  --map-grid: #cfdcd3;
  --map-road: #9fb8a7;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow: 0 24px 60px rgba(16, 24, 40, 0.18);
  --shadow-soft: 0 10px 30px rgba(16, 24, 40, 0.10);
  --ring-color: #1d8feb;
  --ring: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ring-color);

  /* P9 scheme tokens for the shell chrome (top bar, rail, menus): white in every light posture, as before */
  --chrome: #fff;
  --chrome-text: #202122;
  --chrome-hover: #f1f3f5;
  --chrome-active: #eaf3ff;
  --chrome-active-line: #cfe3ff;
  --chrome-active-text: #174ea6;
  --chrome-mark: #1d8feb;
  --primary: #1670c4;
  --primary-hover: #135fa6;
  --on-primary: #fff;
  --alarm: #c7361f;
  --on-fill: #fff; /* text on a --brand / --danger / --ok fill */
  --scrim: rgba(4, 8, 11, 0.66);
  --hover-shade: rgba(127, 127, 127, 0.12);
  --demo-tint: #fff4d6;
  --demo-text: #5a4300;
  --demo-line: #e6c765;
  --demo-btn-line: #8a6d00;
  --demo-btn: #fff;
  --diagram-stage: #e9edf2;

  color-scheme: light;
}

[data-theme="alert"] {
  --bg: #fdf9f0;
  --bg-elev: #fffdf8;
  --surface: #fffdf8;
  --surface-2: #f7f0e1;
  --surface-3: #efe4cd;
  --border: #e3d5b8;
  --border-strong: #cdb98f;
  --text: #2a2418;
  --muted: #6b5c43;
  --faint: #6f6149;
  --brand: #a15c00;
  --brand-soft: #fdefd4;
  --accent: #955800;
  --accent-contrast: #ffffff;
  --warn: #8a5200;
  --warn-soft: #fbe8c0;
  --danger: #a33b00;
  --danger-soft: #fde9dd;
  --ok: #2e6122;
  --map-land-1: #f1e6cf;
  --map-land-2: #e7d8ba;
  --map-grid: #dccbaa;
  --map-road: #b59a6a;
}

[data-theme="crisis"] {
  --bg: #fdf5f5;
  --bg-elev: #fffafa;
  --surface: #fffafa;
  --surface-2: #f9eaea;
  --surface-3: #f2dcdc;
  --border: #eccaca;
  --border-strong: #d9a8a8;
  --text: #2a1616;
  --muted: #6d4a4a;
  --faint: #8c6666;
  --brand: #b32424;
  --brand-soft: #fdeaea;
  --accent: #c62828;
  --accent-contrast: #ffffff;
  --warn: #8a5200;
  --warn-soft: #fbe8c0;
  --danger: #b32424;
  --danger-soft: #fbdcdc;
  --ok: #1f6324;
  --map-land-1: #f5e2e2;
  --map-land-2: #edd2d2;
  --map-grid: #e2c2c2;
  --map-road: #c79a9a;
}

/* =========================================================
   P9 dark scheme (data-scheme="dark" on <html>, set by src/scheme-boot.js before the first paint).
   Designed, not inverted: elevation = lighter surface, text never pure white, accents lifted to AA on the
   dark surfaces. The posture (data-theme) still tints the dark scheme: 2 schemes x 3 postures.
   ========================================================= */
[data-scheme="dark"] {
  --bg: #101317;
  --bg-elev: #181c21;
  --surface: #181c21;
  --surface-2: #20252b;
  --surface-3: #2a3038;
  --border: #343b45;
  --border-strong: #4d5765;
  --text: #e6e9ed;
  --muted: #b0b8c2;
  --faint: #9aa3ae;
  --brand: #8ab4ff;
  --brand-soft: #1a2b45;
  --accent: #6aaef5;
  --accent-contrast: #0b1520;
  --warn: #f2b155;
  --warn-soft: #3a2a10;
  --danger: #ff8f87;
  --danger-soft: #3f1c1c;
  --ok: #5fd0a0;
  --map-land-1: #17211c;
  --map-land-2: #1d2a23;
  --map-grid: #2a3a31;
  --map-road: #4c6656;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --ring-color: #8ab4ff;
  --chrome: var(--surface);
  --chrome-text: var(--text);
  --chrome-hover: var(--surface-3);
  --chrome-active: var(--brand-soft);
  --chrome-active-line: color-mix(in srgb, var(--brand) 40%, transparent);
  --chrome-active-text: var(--brand);
  --chrome-mark: var(--brand);
  --primary: var(--accent);
  --primary-hover: color-mix(in srgb, var(--accent) 85%, #fff);
  --on-primary: var(--accent-contrast);
  --alarm: #ff8f87;
  --on-fill: #0d1014;
  --scrim: rgba(0, 0, 0, 0.72);
  --hover-shade: rgba(255, 255, 255, 0.08);
  --demo-tint: #33290f;
  --demo-text: #f3dc9a;
  --demo-line: #6b5717;
  --demo-btn-line: #b8993a;
  --demo-btn: var(--surface-2);
  --diagram-stage: #1b1f24;
  color-scheme: dark;
}
[data-scheme="dark"][data-theme="alert"] {
  --bg: #14110b;
  --bg-elev: #1c1811;
  --surface: #1c1811;
  --surface-2: #252016;
  --surface-3: #2f281c;
  --border: #3d3424;
  --border-strong: #5d4f36;
  --text: #eee6d6;
  --muted: #c8b99e;
  --faint: #ad9e83;
  --brand: #f2b45e;
  --brand-soft: #3a2a10;
  --accent: #f2a945;
  --accent-contrast: #1a1206;
  --warn: #f2b155;
  --warn-soft: #3a2a10;
  --danger: #ff9a6e;
  --danger-soft: #3f2114;
  --ok: #93d283;
  --map-land-1: #221c11;
  --map-land-2: #2a2316;
  --map-grid: #3a301e;
  --map-road: #6b5a3a;
  --ring-color: #f2b45e;
}
[data-scheme="dark"][data-theme="crisis"] {
  --bg: #160e0f;
  --bg-elev: #1f1516;
  --surface: #1f1516;
  --surface-2: #291c1e;
  --surface-3: #342427;
  --border: #452d31;
  --border-strong: #684349;
  --text: #f1e5e6;
  --muted: #cfb2b5;
  --faint: #b39599;
  --brand: #ff8f87;
  --brand-soft: #421c1c;
  --accent: #ff8077;
  --accent-contrast: #1a0808;
  --warn: #f2b155;
  --warn-soft: #3a2a10;
  --danger: #ff8f87;
  --danger-soft: #421c1c;
  --ok: #82d18c;
  --map-land-1: #241517;
  --map-land-2: #2c1a1d;
  --map-grid: #3d2529;
  --map-road: #6e464c;
  --ring-color: #ff8f87;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a { color: var(--brand); }

h1, h2, h3, h4, p { margin: 0; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-xs);
}

.icon { flex: none; display: block; }
.flip { transform: rotate(180deg); }

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

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.empty-note { color: var(--faint); font-size: 13px; padding: 12px 0; }

/* ---------- App layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "rail main";
  height: 100vh;
  height: 100dvh;
}

/* ---------- Top bar ---------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--brand-soft);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; letter-spacing: 0.04em; }
.brand-text small { font-size: 10px; color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; }

.chapter-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 0;
}
.chapter-chip strong { font-size: 12px; letter-spacing: 0.06em; }
.chapter-phase { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.chapter-clock { font-family: var(--font-mono); font-size: 11px; color: var(--accent); background: var(--brand-soft); padding: 2px 7px; border-radius: 999px; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(99, 214, 154, 0.14); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- Exercise switcher (the exercise chip opens it when the user is in more than one exercise) ---------- */
.exercise-menu { position: relative; min-width: 0; display: flex; }
.chapter-chip.is-switch { cursor: pointer; font: inherit; color: inherit; text-align: left; }
.chapter-chip.is-switch:hover { border-color: var(--border-strong); }
.chapter-chip.is-switch:focus-visible { box-shadow: var(--ring); outline: none; }
.chip-caret { display: inline-flex; color: var(--muted); }
.chip-caret .icon { transform: rotate(90deg); }
.chapter-chip.is-switch[aria-expanded="true"] .chip-caret .icon { transform: rotate(-90deg); }
.exercise-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: min(360px, calc(100vw - 32px));
  max-height: min(70vh, 520px); overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.exercise-pop-title { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 2px 4px; }
.exercise-card {
  display: flex; flex-direction: column; gap: 4px; width: 100%; min-height: 44px;
  padding: 10px 12px; text-align: left; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xs); cursor: pointer;
}
.exercise-card:hover { border-color: var(--accent); }
.exercise-card:focus-visible { box-shadow: var(--ring); outline: none; }
.exercise-card.is-current { border-color: var(--accent); background: var(--brand-soft); }
.exercise-card-head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.exercise-card-head strong { font-size: 14px; }
.exercise-abbrev { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.exercise-class { font-size: 10.5px; letter-spacing: 0.08em; color: var(--muted); }
.exercise-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.exercise-clock { font-family: var(--font-mono); }
.exercise-status { font-weight: 600; }
.exercise-status.status-active { color: var(--ok); }
.exercise-status.status-planning { color: var(--brand); }
.exercise-status.status-closed, .exercise-status.status-archived { color: var(--faint); }
/* the picker after sign-in sits on the login background */
.exercise-picker .login-content { max-width: 440px; }
.exercise-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.exercise-picker .exercise-card { background: rgba(255, 255, 255, 0.97); border-color: #c9d6e2; color: #202122; }
.exercise-picker .exercise-card:hover { border-color: #1d8feb; }
.exercise-picker .exercise-class, .exercise-picker .exercise-meta, .exercise-picker .exercise-abbrev { color: #54595d; }

.search-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  min-width: 180px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger kbd, .palette-input-wrap kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--bg);
}

.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 16px; height: 16px;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 999px;
  padding: 0 4px;
}

.primary-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  font-size: 12.5px; font-weight: 650;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 9px;
  border: 1px solid transparent;
}
.primary-btn:hover { filter: brightness(1.07); }

.persona-menu { position: relative; }
.persona-menu summary { list-style: none; }
.persona-menu summary::-webkit-details-marker { display: none; }
.persona-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.persona-chip:hover { border-color: var(--border-strong); }
.persona-copy { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.persona-copy strong { font-size: 12px; }
.persona-copy small { font-size: 10px; color: var(--muted); }

.avatar {
  width: 32px; height: 32px;
  flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #08120f;
  background: var(--avatar, var(--brand));
  border-radius: 50%;
  letter-spacing: 0.02em;
}
.avatar.small { width: 26px; height: 26px; font-size: 9.5px; }

.persona-list {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 260px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.popover-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); padding: 6px 8px 4px; }
.persona-list button {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  text-align: left;
  border-radius: 8px;
}
.persona-list button:hover, .persona-list button.is-active { background: var(--surface-3); }
.persona-list button span:nth-child(2) { display: flex; flex-direction: column; line-height: 1.2; flex: 1; }
.persona-list button strong { font-size: 12px; }
.persona-list button small { font-size: 10.5px; color: var(--muted); }

/* ---------- Notifications ---------- */
.menu-anchor { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 320px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
  overflow: hidden;
}
.popover-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.text-btn { display: inline-flex; align-items: center; gap: 5px; color: var(--brand); font-size: 11.5px; font-weight: 600; }
.text-btn:hover { text-decoration: underline; }
.notification-list { max-height: 320px; overflow: auto; }
.notification { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.notification.is-unread { background: var(--brand-soft); }
.notification p { font-size: 12px; }
.notification small { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.notification-dot { width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.notification.is-unread .notification-dot { background: var(--accent); }

/* ---------- Rail ---------- */
.rail {
  grid-area: rail;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.rail-btn {
  width: 62px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 9px 4px;
  color: var(--muted);
  border-radius: 10px;
  border: 1px solid transparent;
}
.rail-btn span { font-size: 9.5px; letter-spacing: 0.02em; }
.rail-btn:hover { color: var(--text); background: var(--surface); }
.rail-btn.is-active {
  color: var(--accent);
  background: var(--brand-soft);
  border-color: var(--border-strong);
}
.rail-spacer { flex: 1; }
.rail-foot { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; }

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--faint)); display: inline-block; }
.status-dot.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(99, 214, 154, 0.14); }
.status-dot.done { background: var(--ok); }
.status-dot.ready { background: var(--warn); }

/* ---------- Workspace ---------- */
.workspace {
  grid-area: main;
  overflow-y: auto;
  padding: 22px 26px 40px;
  scrollbar-gutter: stable;
}

.impersonation-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin-bottom: 16px;
  padding: 9px 13px;
  font-size: 12px;
  color: var(--text);
  background: var(--warn-soft);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--warn);
  border-radius: 9px;
}
.impersonation-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.impersonation-note { color: var(--muted); margin-left: auto; font-size: 11px; }

.module-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
.module-head h1 { font-size: 26px; letter-spacing: -0.01em; line-height: 1.15; }
.module-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.module-meta { display: flex; gap: 7px; flex-wrap: wrap; }
.meta-pill {
  font-size: 10.5px; color: var(--muted);
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

/* ---------- Buttons / cards ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 11px;
  font-size: 12px; font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { background: var(--surface-3); }
.btn-accent { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.btn-accent:hover { filter: brightness(1.07); background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 5px 8px; font-size: 11px; }

.side-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.side-card h3 { font-size: 12.5px; margin-bottom: 10px; }
.side-card p { font-size: 12px; color: var(--muted); }
.side-card .eyebrow { margin-bottom: 6px; }

/* ---------- Inject panel ---------- */
.inject-panel {
  position: fixed; top: 64px; right: 0; bottom: 0;
  width: 380px;
  padding: 18px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  overflow-y: auto;
  z-index: 30;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(18px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: 18px; margin-top: 2px; }
.panel-note { font-size: 11.5px; color: var(--muted); margin: 8px 0 14px; }
.inject-list { display: flex; flex-direction: column; gap: 9px; }
.inject-card {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.inject-card.is-fired { opacity: 0.62; }
.inject-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.inject-time { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent); }
.inject-card h3 { font-size: 13px; margin-bottom: 3px; }
.inject-card p { font-size: 11.5px; color: var(--muted); margin-bottom: 9px; }
.inject-card .btn { width: 100%; }

.panel-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; margin-top: 8px; }
.segmented button { padding: 6px 4px; font-size: 11px; color: var(--muted); border-radius: 6px; }
.segmented button.is-active { background: var(--surface-3); color: var(--text); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 0; }
.facts div { padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.facts dt { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); }
.facts dd { margin: 2px 0 0; font-size: 12px; font-weight: 600; }

/* ---------- Palette ---------- */
.palette-backdrop {
  position: fixed; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: fade-in 0.12s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.palette {
  width: min(620px, 92vw);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette-input-wrap { display: flex; align-items: center; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input-wrap input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 14px; }
.palette-results { max-height: 52vh; overflow: auto; padding: 6px; }
.palette-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; text-align: left; border-radius: 8px; }
.palette-item:hover { background: var(--surface-3); }
.palette-icon { width: 30px; height: 30px; display: grid; place-items: center; color: var(--accent); background: var(--brand-soft); border-radius: 8px; }
.palette-copy { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.palette-copy strong { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-copy small { font-size: 10.5px; color: var(--muted); }
.palette-empty { padding: 18px; text-align: center; color: var(--faint); font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 22px; bottom: 22px;
  padding: 10px 14px;
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  box-shadow: var(--shadow);
  z-index: 80;
  animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 65; padding: 20px; }
.modal { width: min(560px, 94vw); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .chapter-phase { display: none;  }
}

@media (max-width: 900px) {
  .search-trigger span, .search-trigger kbd, .persona-copy { display: none;  }
  .search-trigger { min-width: 0; padding: 8px;  }
  .brand { min-width: 0;  }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "top" "rail" "main";  }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px;  }
  .chapter-chip { order: 3; width: 100%;  }
  .exercise-menu { order: 3; width: 100%;  }
  .topbar-actions { margin-left: 0; width: 100%; justify-content: flex-end;  }
  .rail { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 8px;  }
  .rail-btn { min-width: 60px;  }
  .rail-spacer, .rail-foot { display: none;  }
  .workspace { padding: 16px 14px 30px;  }
  .module-head { flex-direction: column; align-items: flex-start;  }
  .module-head h1 { font-size: 22px;  }
  .inject-panel { top: 0; width: 100%;  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important;  }
}

/* =========================================================
   CLASSIC LIGHT SKIN
   Matches the reference GUI language: white shell, 2-column
   app rail, Open Sans, blue/red accents, black consent banner,
   and a full-bleed login scene.
   ========================================================= */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app-shell {
  height: auto;
  flex: 1;
  min-height: 0;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
}

/* ---------- Cookie banner ---------- */
.cookie-banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 12px 26px;
  background: #000;
  color: #fff;
  z-index: 95;
}
.cookie-text {
  max-width: 980px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: #fff;
}
.cookie-link {
  display: inline;
  padding: 0;
  color: #fff;
  text-decoration: underline;
  font-size: 13px;
}
.cookie-link:hover { color: #ffe66d; }
.cookie-consent {
  background: #f1d600;
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 22px;
  border-radius: 2px;
  white-space: nowrap;
}
.cookie-consent:hover { background: #ffe733; }

/* ---------- Login ---------- */
.login-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* content centres by margin: auto, so a page taller than the phone still scrolls to its top */
  padding: 52px 20px max(20px, env(safe-area-inset-bottom));
  color: #fff;
  background:
    radial-gradient(900px 520px at 18% 12%, rgba(29, 143, 235, 0.38), transparent 62%),
    radial-gradient(900px 520px at 82% 88%, rgba(17, 76, 160, 0.48), transparent 62%),
    linear-gradient(160deg, #020b18 0%, #04284d 52%, #010a15 100%);
}
.login-scene { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.login-scene svg { width: 100%; height: 100%; opacity: 0.9; }
.login-content { position: relative; z-index: 1; width: 100%; max-width: 360px; margin: auto 0; text-align: center; }
.login-screen.is-demo .login-content { max-width: 440px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 4px; }
.login-mark {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  color: #8fd0ff;
  background: rgba(10, 40, 80, 0.65);
  border: 1px solid rgba(120, 200, 255, 0.45);
  border-radius: 14px;
  box-shadow: 0 0 30px rgba(29, 143, 235, 0.35);
}
.login-brand-text { display: flex; flex-direction: column; text-align: left; line-height: 1.05; }
.login-brand-text strong { font-size: 20px; letter-spacing: 0.04em; color: #fff; }
.login-brand-text small { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: #8fb8dd; }
.login-exercise { font-size: 10.5px; letter-spacing: 0.22em; color: #7fb2e6; margin: 14px 0 18px; }
.login-title { font-size: 26px; font-weight: 600; margin-bottom: 18px; color: #fff; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 14px;
  color: #202122;
  background: #fff;
  border: 1px solid #c9d6e2;
  border-radius: 3px;
  outline: none;
}
.login-form input:focus { border-color: #1d8feb; box-shadow: 0 0 0 3px rgba(29, 143, 235, 0.25); }
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: #72777d; padding: 6px; border-radius: 6px;
}
.eye-btn:hover { background: #eef2f6; color: #202122; }
.login-error {
  font-size: 12px;
  color: #ffe3e3;
  background: rgba(179, 36, 36, 0.38);
  border: 1px solid rgba(255, 120, 120, 0.55);
  padding: 8px 10px;
  border-radius: 4px;
  text-align: left;
}
.login-row { display: flex; justify-content: flex-end; margin-top: -2px; }
.login-link { color: #cfe3ff; font-size: 11px; letter-spacing: 0.06em; font-weight: 600; }
.login-link:hover { text-decoration: underline; }
.login-submit {
  height: 48px;
  width: 100%;
  background: #c7361f;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-radius: 3px;
  margin-top: 2px;
}
.login-submit:hover { background: #d83a22; }
.login-register {
  color: #fff;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 8px;
}
.login-register:hover { text-decoration: underline; }
.login-hint { margin-top: 16px; font-size: 11px; color: #8fb8dd; }
.login-footer {
  position: relative; /* in the flow, under the form: never on top of an error box on a short phone screen */
  flex: none;
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  z-index: 1;
}
.login-footer .login-link { color: #cfe3ff; font-size: 12px; font-weight: 500; min-height: 44px; padding: 0 8px; }
.login-row .login-link { min-height: 44px; padding: 0 2px; }
.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;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
  gap: 14px;
  padding: 0 16px;
}
.brand-text strong { color: var(--chrome-text); }
.brand-text small { color: var(--faint); }
.brand-mark { background: var(--chrome-active); border-color: var(--chrome-active-line); color: var(--chrome-mark); }
.chapter-chip { background: var(--chrome-active); border-color: var(--chrome-active-line); }
.chapter-chip strong { color: var(--chrome-active-text); }
.chapter-clock { background: var(--chrome); color: var(--chrome-active-text); border: 1px solid var(--chrome-active-line); }
.search-trigger { background: var(--chrome-hover); border-color: var(--border); color: var(--muted); }
.search-trigger kbd { background: var(--chrome); }
.primary-btn { background: var(--primary); color: var(--on-primary); }
.primary-btn:hover { background: var(--primary-hover); filter: none; }
.badge { background: var(--alarm); color: var(--on-fill); }
.persona-chip { background: var(--chrome); }
.icon-btn:hover { background: var(--chrome-hover); border-color: var(--border); }
.popover, .persona-list { background: var(--chrome); border-color: var(--border); }
.persona-list button:hover, .persona-list button.is-active { background: var(--chrome-hover); }
.notification.is-unread { background: var(--chrome-active); }

/* ---------- Rail ---------- */
.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.rail-apps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rail-btn {
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
}
.rail-btn:hover { background: var(--chrome-hover); }
.rail-btn.is-active { background: var(--chrome-active); border-color: var(--chrome-active-line); }
.rail-btn.is-active .rail-label { color: var(--chrome-active-text); }
.app-tile {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}
.app-wire { background: conic-gradient(from 210deg, #4285f4, #34a853, #fbbc05, #ea4335, #4285f4); }
.app-pulse { background: #0f1419; }
.app-dispatch { background: #0f6cbd; }
.app-atlas { background: #0f9d58; }
.app-operations { background: #f4b400; color: #3b2f00; }
.app-timeline { background: #7b1fa2; }
.rail-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.rail-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail-profile { display: flex; align-items: center; gap: 9px; }
.rail-profile-copy { display: flex; flex-direction: column; line-height: 1.2; }
.rail-profile-copy strong { font-size: 12px; }
.rail-profile-copy small { font-size: 10.5px; color: var(--muted); }
.rail-signout {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--muted);
  border-radius: 7px;
}
.rail-signout:hover { background: var(--chrome-hover); color: var(--text); }
.rail-live {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--faint);
}

/* ---------- Workspace ---------- */
.workspace { background: var(--bg); padding: 22px 24px 40px; }
.meta-pill { background: var(--surface); border-color: var(--border); }
.side-card { background: var(--surface); border-color: var(--border); }

/* ---------- Responsive classic ---------- */
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 232px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .app-tile { width: 48px; height: 48px; }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "top" "rail" "main"; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .chapter-chip { order: 3; width: 100%; }
  .topbar-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .rail { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--border); }
  .rail-apps { display: flex; gap: 6px; }
  .rail-btn { min-width: 70px; padding: 6px 4px; }
  .app-tile { width: 44px; height: 44px; border-radius: 11px; }
  .rail-label { font-size: 10px; }
  .rail-bottom { display: none; }
  .cookie-banner { padding: 10px 14px; gap: 10px; }
  .cookie-text { font-size: 11.5px; }
  .login-screen { padding: 20px 16px max(12px, env(safe-area-inset-bottom)); }
  .login-footer { margin-top: 18px; }
  .login-screen.is-demo .login-mark { width: 44px; height: 44px; border-radius: 11px; }
  .login-screen.is-demo .login-exercise { margin: 8px 0 10px; }
  .login-screen.is-demo .login-title { font-size: 22px; margin-bottom: 10px; }
  .workspace { padding: 16px 14px 30px; }
}

/* ---------- App logos and tools rail ---------- */
.app-logo { width: 50px; height: 50px; object-fit: contain; display: block; }
.rail-tools { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.rail-tools-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); margin-bottom: 6px; }
.rail-tools-grid { display: grid; grid-template-columns: 1fr; gap: 2px; }
.rail-tool { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: var(--muted); font-size: 11.5px; }
.rail-tool:hover { background: var(--chrome-hover); color: var(--text); }
.rail-tool.is-active { background: var(--chrome-active); color: var(--chrome-active-text); }
.rail-tool-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--chrome-hover); flex: none; }
.rail-tool.is-active .rail-tool-icon { background: var(--chrome); }

/* ---------- Mobile tools + logos ---------- */
@media (max-width: 720px) {
  .app-logo { width: 40px; height: 40px; }
  .rail-tools { margin: 0; padding: 0; border: none; }
  .rail-tools-label { display: none; }
  .rail-tools-grid { display: flex; gap: 4px; }
  .rail-tool { min-width: auto; padding: 6px; }
  .rail-tool-label { display: none; }
}

/* =========================================================
   REAL-APP FLOWS
   ========================================================= */

/* --- C11 Timeline: shell polish. The simulation badge (one per shell, asserted by tests/shots.py) and the rail's unread counts. */
.sim-badge { flex: none; display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.rail-btn, .rail-tool { position: relative; }
.rail-count { position: absolute; top: 2px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: var(--on-fill); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
@media (max-width: 720px) { .sim-badge { font-size: 10px; padding: 0 6px; } }

/* --- Demo mode (docs/DEMO.md): banner, one-click sign-in, guide. Shown only when /api/demo/config answers. */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 16px; background: var(--demo-tint); color: var(--demo-text); border-bottom: 1px solid var(--demo-line); font-size: 14px; }
.demo-banner .demo-guide-open { margin-left: auto; padding: 4px 12px; border: 1px solid var(--demo-btn-line); border-radius: 6px; background: var(--demo-btn); color: var(--demo-text); cursor: pointer; }
.demo-signin { margin: 4px 0 16px; text-align: left; }
.demo-signin-title { margin: 0 0 8px; font-size: 14px; color: #dbeaff; text-align: center; }
/* the buttons sit on the dark sign-in page: their colours are set here, never inherited (2026-11-17: an inherited white
   label on the light --surface card made all eight buttons empty white boxes on an iPhone) */
.demo-signin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-signin-btn { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; min-height: 56px; padding: 8px 26px 8px 12px; border: 1px solid rgba(143, 208, 255, 0.4); border-radius: 10px; background: rgba(6, 30, 60, 0.82); color: #fff; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.demo-signin-btn::after { content: '\203A'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 22px; line-height: 1; color: #8fd0ff; }
.demo-signin-btn:hover, .demo-signin-btn:focus-visible { background: rgba(14, 58, 110, 0.95); border-color: #8fd0ff; }
.demo-signin-btn:focus-visible { outline: 2px solid #8fd0ff; outline-offset: 2px; }
.demo-signin-btn:active { transform: scale(0.99); }
.demo-signin-btn small { font-size: 12px; line-height: 1.3; color: #bcd6f2; }
.demo-signin-label { font-size: 14.5px; font-weight: 600; color: #fff; }
.login-account { margin-top: 4px; text-align: left; }
.login-account > summary { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; color: #cfe3ff; font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
.login-account > summary::-webkit-details-marker { display: none; }
.login-account > summary::after { content: '\25BE'; font-size: 12px; }
.login-account[open] > summary::after { content: '\25B4'; }
.login-account[open] > .login-form { margin-top: 6px; }
.demo-guide-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 900; }
.demo-guide { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); overflow: auto; padding: 16px 20px max(16px, env(safe-area-inset-bottom)); background: var(--surface, #fff); color: var(--text, #202122); box-shadow: -6px 0 24px rgba(0, 0, 0, 0.25); z-index: 901; }
.demo-guide header { display: flex; align-items: center; justify-content: space-between; }
.demo-guide h3 { margin: 16px 0 6px; font-size: 15px; }
.demo-guide li { margin: 0 0 6px; font-size: 14px; }
.demo-guide-note { font-size: 12px; opacity: 0.75; }
.demo-reset { margin-top: 12px; padding: 8px 14px; border-radius: 6px; border: 1px solid #b03030; background: #fff; color: #b03030; cursor: pointer; }
/* NORTHERN LANTERN seats (sign-in page, dark background: colours set here) and the showcase guide */
.demo-showcase { margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(143, 208, 255, 0.3); }
.demo-seat-group { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 6px; margin: 0 0 6px; }
.demo-seat-group-name { font-size: 12.5px; font-weight: 600; color: #cfe3ff; }
.demo-seat-row { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-seat-btn { min-height: 44px; padding: 6px 12px; border: 1px solid rgba(143, 208, 255, 0.4); border-radius: 8px; background: rgba(6, 30, 60, 0.82); color: #fff; font-size: 13.5px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.demo-seat-btn:hover, .demo-seat-btn:focus-visible { background: rgba(14, 58, 110, 0.95); border-color: #8fd0ff; }
.demo-seat-btn:focus-visible { outline: 2px solid #8fd0ff; outline-offset: 2px; }
.demo-steps small { display: block; font-size: 12px; opacity: 0.75; }
.demo-autoplay { display: flex; gap: 8px; }
.demo-autoplay button { min-height: 44px; padding: 6px 12px; border: 1px solid #5b6470; border-radius: 6px; background: #fff; color: #202122; cursor: pointer; }
.demo-autoplay button[aria-pressed="true"] { background: #1f6fb2; border-color: #1f6fb2; color: #fff; }
@media (max-width: 480px) { .demo-seat-group { grid-template-columns: 1fr; gap: 4px; } .demo-seat-btn { flex: 1 1 30%; } }
/* phone: one row (the sign-in page and the app header already name the exercise) */
@media (max-width: 480px) { .demo-banner { flex-wrap: nowrap; padding: 6px 12px; font-size: 13px; } .demo-banner-ex { display: none; } .demo-banner .demo-guide-open { flex: none; min-height: 36px; } .demo-signin-grid { grid-template-columns: 1fr; gap: 6px; } .demo-signin-btn { min-height: 52px; } }

/* server-mode upload pickers: a native file input is ~250 px wide; on phones it must shrink with its row */
.upload-widget, .upload-pick { min-width: 0; max-width: 100%; }
.upload-pick input[type="file"] { max-width: 100%; }

/* T1: native app chrome. The platform heading is visually hidden above the social apps (each draws its own top bar). */
.module-head.is-native { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; padding: 0; }
/* File pickers look like the product's own button, never the browser's "Choose File". */
.upload-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.upload-pick:hover { background: var(--hover-shade); }
.upload-pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.upload-status:empty { display: none; }
time[title] { cursor: default; }

/* P7-T4 diagram viewer: an image attachment full screen with pan and zoom (modules/viewer.js) */
.diagram-viewer { position: fixed; inset: 0; z-index: 950; display: flex; flex-direction: column; background: #0d1117; }
.diagram-viewer-bar { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: #161b22; color: #fff; }
.diagram-viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.diagram-viewer-tools { display: flex; gap: 6px; flex: none; }
.diagram-viewer-tools button { min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid #5b6470; border-radius: 8px; background: #fff; color: #1b1f24; font-size: 16px; cursor: pointer; }
.diagram-viewer-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab; background: var(--diagram-stage); }
.diagram-viewer-img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.attach-open { margin-left: 6px; min-height: 32px; padding: 2px 10px; }
/* the showcase guide's steps: links and buttons alike, left-aligned */
.demo-steps .demo-link { display: block; min-height: 44px; padding: 10px 0 0; border: 0; background: none; color: #1f5f99; font: inherit; text-align: left; text-decoration: underline; cursor: pointer; }

/* P9 colour scheme control in the user menu (Light / Dark / System) */
.scheme-choice { padding: 2px 0 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.scheme-seg { display: flex; gap: 4px; margin: 0 8px; }
.scheme-seg button { flex: 1; min-height: 36px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.scheme-seg button:hover { color: var(--text); background: var(--chrome-hover); }
.scheme-seg button.is-active { background: var(--chrome-active); border-color: var(--chrome-active-line); color: var(--chrome-active-text); }

/* P9 dark scheme: the few shell parts that kept light-only colours (the demo guide drawer's buttons and links, the
   diagram viewer's tool buttons). The sign-in page, the exercise picker on it, the cookie banner and the diagram
   viewer are one dark look in both schemes and keep their colours. */
[data-scheme="dark"] .demo-reset { border-color: var(--danger); background: var(--surface-2); color: var(--danger); }
[data-scheme="dark"] .demo-autoplay button { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
[data-scheme="dark"] .demo-autoplay button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
[data-scheme="dark"] .demo-steps .demo-link { color: var(--brand); }
[data-scheme="dark"] .demo-guide-backdrop { background: rgba(0, 0, 0, 0.6); }
[data-scheme="dark"] .diagram-viewer-tools button { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
[data-scheme="dark"] .avatar { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08); } /* light avatar colours keep an edge on dark */
[data-scheme="dark"] img[src$="logos/x.svg"] { filter: invert(1); } /* the X mark is near-black ink: white on the dark rail, as X draws it */
