/*
 * Adam Global Mandates Room
 * Colours and typefaces are the website's own (app/globals.css): deep blue,
 * mid blue, sand; Montserrat for headings, Poppins for text. Fonts are served
 * from this origin so the page makes no request to anyone else.
 */

@font-face { font-family: 'Poppins'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/poppins-400.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/poppins-600.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/poppins-700.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/montserrat-700.woff2') format('woff2'); }

:root {
  --agn-mid-blue: #083c83;
  --agn-deep-blue: #203c63;
  --agn-sand: #c4bd97;

  --bg: #f5f4ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #203c63;
  --text: #27374e;
  --muted: #5f686d;
  --faint: #8b959a;
  --line: #e3e6e6;
  --line-strong: #cdd3d3;
  --brand: #083c83;
  --brand-hover: #0a4899;
  --brand-ink: #ffffff;
  --brand-soft: #e9eff9;
  --sand: #c4bd97;
  --sand-soft: #f3f1e6;
  --sand-ink: #6a6236;
  --good: #1d6e4b;
  --good-soft: #e4f3eb;
  --warn: #8a5a08;
  --warn-soft: #fbf1dc;
  --bad: #9f2d2d;
  --bad-soft: #f9e8e8;
  --rail-top: #203c63;
  --rail-bottom: #162c4a;
  --rail-ink: #eef2f8;
  --rail-muted: #a8b7cc;
  --rail-line: rgba(255, 255, 255, 0.1);
  --rail-hover: rgba(255, 255, 255, 0.08);
  --rail-on: rgba(255, 255, 255, 0.14);
  --shadow: 0 1px 2px rgba(15, 29, 48, 0.05), 0 10px 28px rgba(15, 29, 48, 0.07);
  --shadow-lg: 0 24px 70px rgba(15, 29, 48, 0.22);
  --radius: 12px;
  --radius-sm: 8px;
  --head: 'Montserrat', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  --sans: 'Poppins', 'Avenir Next', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --rail-width: 264px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0a1424;
  --surface: #111e33;
  --surface-2: #0e1a2d;
  --ink: #f1f4f8;
  --text: #d5deea;
  --muted: #9aa8b8;
  --faint: #6f7f92;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.19);
  --brand: #8fb4ee;
  --brand-hover: #a7c4f2;
  --brand-ink: #0a1424;
  --brand-soft: rgba(122, 165, 227, 0.15);
  --sand-soft: rgba(196, 189, 151, 0.13);
  --sand-ink: #d9d2ad;
  --good: #7fd3ab;
  --good-soft: rgba(79, 191, 141, 0.15);
  --warn: #ecc56b;
  --warn-soft: rgba(224, 164, 58, 0.15);
  --bad: #f0a3a3;
  --bad-soft: rgba(224, 108, 108, 0.17);
  --rail-top: #0c1a30;
  --rail-bottom: #081120;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
#root { height: 100%; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; color: var(--ink); line-height: 1.2; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.5rem, 2.4vw, 2rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol, dl, dd { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
strong, .strong { font-weight: 600; color: var(--ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.icon { flex: none; vertical-align: -0.18em; }
.muted { color: var(--muted); }
.small { font-size: 0.87rem; }
.pad { padding: 20px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; opacity: 0; }
.noscript { max-width: 480px; margin: 20vh auto; padding: 24px; text-align: center; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

/* --------------------------------------------------------------- controls */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 0.93rem; line-height: 1; cursor: pointer; white-space: nowrap; transition: background 0.12s, border-color 0.12s, transform 0.06s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { border-color: var(--line-strong); background: transparent; }
.btn.ghost:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn.quiet { background: transparent; color: var(--muted); padding: 0 10px; }
.btn.quiet:hover { background: var(--brand-soft); color: var(--ink); }
.btn.danger { background: var(--bad); color: #fff; }
:root[data-theme='dark'] .btn.danger { background: #b84646; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 0.86rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand-ink); border-top-color: transparent; animation: spin 0.7s linear infinite; }
.btn.ghost.is-busy::after, .btn.quiet.is-busy::after { border-color: var(--brand); border-top-color: transparent; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover, .icon-btn.on { background: var(--brand-soft); color: var(--brand); }
.link { border: 0; background: none; padding: 0; color: var(--brand); cursor: pointer; font-weight: 600; }
.link:hover { text-decoration: underline; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.chip.blue { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.chip.sand { background: var(--sand-soft); border-color: transparent; color: var(--sand-ink); }
.chip.good { background: var(--good-soft); border-color: transparent; color: var(--good); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.chip-x { display: inline-grid; place-items: center; border: 0; background: none; padding: 0; margin-left: 2px; cursor: pointer; color: inherit; }
.sealed { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--sand-soft); color: var(--sand-ink); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sand); color: #2a2710; font-size: 0.72rem; font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sand); flex: none; }

.avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--sand-soft); color: var(--sand-ink); font: 700 0.82rem var(--head); letter-spacing: 0.02em; }
.avatar.sm { width: 30px; height: 30px; font-size: 0.68rem; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-text { min-width: 0; }
.person-name { font-weight: 600; color: var(--ink); line-height: 1.3; }
.person-sub { color: var(--muted); font-size: 0.85rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 0.82rem; font-weight: 600; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.field-optional { font-weight: 400; color: var(--faint); font-size: 0.78rem; }
.field-hint { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color 0.12s, box-shadow 0.12s; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
.textarea { resize: vertical; line-height: 1.5; min-height: 80px; }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-lg { min-height: 48px; font-size: 1rem; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 46px; }
.input-affix { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; }
.input-affix:hover { color: var(--brand); }
.counter { display: block; text-align: right; font-size: 0.76rem; color: var(--faint); margin-top: 4px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; max-width: 100%; flex-wrap: wrap; }
.seg-item { border: 0; background: transparent; padding: 8px 14px; border-radius: 7px; font-weight: 600; font-size: 0.87rem; color: var(--muted); cursor: pointer; }
.seg-item.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 29, 48, 0.14); }
.seg-item:disabled { cursor: not-allowed; opacity: 0.6; }
:root[data-theme='dark'] .seg-item.on { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input, .step input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check-text { display: flex; flex-direction: column; gap: 2px; font-weight: 600; color: var(--ink); font-size: 0.92rem; }
.check-hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }
.form-error { color: var(--bad); font-size: 0.88rem; font-weight: 600; }
.warn-text { color: var(--warn); }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface); font: 600 0.72rem var(--sans); color: var(--muted); }
.kbd-group { display: inline-flex; gap: 3px; }

.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--text); font-size: 0.9rem; line-height: 1.5; text-decoration: none; }
.notice > .icon { margin-top: 3px; color: var(--brand); }
.notice.good { background: var(--good-soft); } .notice.good > .icon { color: var(--good); }
.notice.warn { background: var(--warn-soft); } .notice.warn > .icon { color: var(--warn); }
.notice.bad { background: var(--bad-soft); } .notice.bad > .icon { color: var(--bad); }
a.notice:hover { text-decoration: none; filter: brightness(0.98); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-title { font-size: 1rem; }
.sub-title { font: 600 0.78rem var(--sans); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.kicker { font: 600 0.76rem var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--sand-ink); margin-bottom: 6px; }
.section { margin-top: 30px; }
.section-title { font: 600 0.78rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
.section-more { margin-top: 14px; font-weight: 600; font-size: 0.9rem; }
.section-more a { display: inline-flex; align-items: center; gap: 6px; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 44px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); grid-column: 1 / -1; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--sand-soft); color: var(--sand-ink); margin-bottom: 4px; }
.empty p { max-width: 46ch; }
.empty .btn { margin-top: 8px; }
.sealed-text { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px 14px; border-left: 3px solid var(--sand); background: var(--sand-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text); line-height: 1.6; }
.sealed-text.loading { color: var(--faint); font-style: italic; }
.sealed-text.failed { border-left-color: var(--bad); background: var(--bad-soft); }

/* ---------------------------------------------------------------- overlays */

.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10, 20, 36, 0.5); backdrop-filter: blur(3px); display: flex; animation: fade 0.14s ease-out; }
.modal-backdrop { align-items: flex-start; justify-content: center; padding: 7vh 16px 24px; overflow-y: auto; }
.drawer-backdrop { justify-content: flex-end; }
.modal, .drawer { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.modal { width: min(540px, 100%); border-radius: 14px; max-height: none; animation: rise 0.16s ease-out; }
.modal.wide { width: min(780px, 100%); }
.drawer { width: min(560px, 100%); height: 100%; animation: slide 0.2s ease-out; }
.overlay-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding: 22px 24px 14px; }
.overlay-head h2 { font-size: 1.25rem; }
.overlay-sub { color: var(--muted); margin-top: 5px; font-size: 0.92rem; }
.overlay-body { padding: 6px 24px 22px; overflow-y: auto; flex: 1; }
.overlay-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.overlay-text { line-height: 1.6; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.toast-wrap { position: fixed; z-index: 90; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; background: #14253d; color: #f1f4f8; box-shadow: var(--shadow-lg); font-size: 0.92rem; animation: rise 0.18s ease-out; transition: opacity 0.25s, transform 0.25s; }
.toast .icon { margin-top: 2px; }
.toast.good .icon { color: #8fd8b4; } .toast.bad .icon { color: #f0a3a3; } .toast.info .icon { color: #a9c3ec; }
.toast.leaving { opacity: 0; transform: translateY(8px); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; border: 0; background: none; padding: 12px 14px; font-weight: 600; font-size: 0.93rem; color: var(--muted); cursor: pointer; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand); }
.tab.on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }
.tab-count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--sand); color: #2a2710; font-size: 0.7rem; font-weight: 700; }

/* -------------------------------------------------------------------- gate */

.gate { min-height: 100%; height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px 16px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--agn-mid-blue) 14%, transparent), transparent 70%), var(--bg); }
.gate-card { width: min(480px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 34px 34px 30px; }
.gate-card h1 { font-size: 1.55rem; margin-bottom: 10px; }
.gate-card .lead { color: var(--muted); margin-bottom: 22px; line-height: 1.6; }
.gate-brand { display: flex; align-items: center; gap: 12px; color: var(--agn-mid-blue); margin-bottom: 26px; }
:root[data-theme='dark'] .gate-brand { color: var(--brand); }
.gate-brand-name { font: 700 0.95rem var(--head); letter-spacing: 0.14em; color: var(--ink); }
.gate-brand-sub { font-size: 0.78rem; color: var(--sand-ink); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; }
.gate-foot { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.82rem; text-align: center; }
.gate-note { margin-top: 18px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.gate-loading { display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--muted); }
.gate-loading .brand-mark { color: var(--agn-mid-blue); }
.demo-note { margin-top: 16px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--sand-soft); color: var(--sand-ink); font-size: 0.84rem; }
.points { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.points li { display: flex; gap: 12px; align-items: flex-start; }
.points li > .icon { color: var(--brand); margin-top: 3px; }
.points li div { display: flex; flex-direction: column; }
.points li span { color: var(--muted); font-size: 0.9rem; }
.meter { display: flex; flex-direction: column; gap: 6px; margin-top: -6px; }
.meter-track { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter-bar { height: 100%; width: 0; border-radius: 99px; background: var(--bad); transition: width 0.2s, background 0.2s; }
.meter-bar.s1 { width: 25%; } .meter-bar.s2 { width: 50%; background: #c98a1a; } .meter-bar.s3 { width: 75%; background: var(--good); } .meter-bar.s4 { width: 100%; background: var(--good); }
.meter-text { display: flex; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.meter-label { font-weight: 600; color: var(--ink); }
.suggestion { display: flex; gap: 8px; align-items: center; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--sand-soft); color: var(--sand-ink); font-size: 0.85rem; }
.recovery-key { font: 600 0.88rem/1.7 var(--mono); letter-spacing: 0.02em; text-align: center; padding: 18px 14px; border-radius: var(--radius-sm); background: var(--sand-soft); border: 1px dashed var(--sand); color: var(--ink); margin-bottom: 14px; overflow-wrap: anywhere; user-select: all; }
.gate-card .check { margin: 18px 0; }

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

.app { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); height: 100%; }
.rail { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 12px; background: linear-gradient(180deg, var(--rail-top), var(--rail-bottom)); color: var(--rail-ink); overflow-y: auto; min-height: 0; }
.rail a { color: inherit; text-decoration: none; }
.rail-brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 18px; color: #fff; }
.rail-brand-name { font: 700 0.86rem var(--head); letter-spacing: 0.15em; }
.rail-brand-sub { font-size: 0.7rem; color: var(--agn-sand); letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-link { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; font-weight: 600; font-size: 0.93rem; color: var(--rail-ink); }
.rail-link:hover { background: var(--rail-hover); }
.rail-link.on { background: var(--rail-on); color: #fff; }
.rail-link .badge { margin-left: auto; }
.rail-back { font-weight: 400; font-size: 0.84rem; color: var(--rail-muted); }
.rail-back:hover { color: #fff; }
.rail-rooms { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; }
.rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 4px 10px; font: 600 0.7rem var(--sans); text-transform: uppercase; letter-spacing: 0.12em; color: var(--rail-muted); }
.rail .icon-btn { color: var(--rail-muted); width: 30px; height: 30px; }
.rail .icon-btn:hover { background: var(--rail-hover); color: #fff; }
.rail-room { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: center; padding: 8px 10px; border-radius: 8px; }
.rail-room:hover { background: var(--rail-hover); }
.rail-room.on { background: var(--rail-on); }
.rail-room-title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-column: 1; }
.rail-room-sub { font-size: 0.76rem; color: var(--rail-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-column: 1; }
.rail-room .dot, .rail-room-warn { grid-column: 2; grid-row: 1 / span 2; }
.rail-room-warn { color: #f0a3a3; }
.rail-room.closed .rail-room-title { color: var(--rail-muted); }
.rail-empty { padding: 6px 10px; font-size: 0.82rem; color: var(--rail-muted); line-height: 1.45; }
.rail-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--rail-line); margin-top: 8px; }
.demo-ribbon { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: rgba(196, 189, 151, 0.16); color: #e5dfbf !important; font-size: 0.78rem; line-height: 1.4; }
.demo-ribbon .icon { margin-top: 2px; }
.rail-me { display: flex; align-items: center; gap: 10px; padding: 8px 6px 2px 8px; }
.rail-me .avatar { width: 34px; height: 34px; background: rgba(196, 189, 151, 0.22); color: #ebe5c6; font-size: 0.72rem; }
.rail-me-text { min-width: 0; flex: 1; }
.rail-me-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-me-sub { font-size: 0.74rem; color: var(--rail-muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.topbar-brand { display: none; align-items: center; gap: 8px; font: 700 0.9rem var(--head); color: var(--ink); }
.topbar-brand .brand-mark { color: var(--agn-mid-blue); }
.search-trigger { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 420px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--faint); cursor: pointer; text-align: left; font-size: 0.9rem; }
.search-trigger span:first-of-type { flex: 1; }
.search-trigger:hover { border-color: var(--brand); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar-sealed { margin-right: 8px; }
.topbar-lock { display: none; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 0.78rem; font-weight: 600; margin-right: 6px; }
.view { flex: 1; overflow-y: auto; min-height: 0; outline: none; scroll-behavior: smooth; }
.view-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 60vh; color: var(--muted); }
.bottom-nav { display: none; }
.veil { display: none; }
body.veiled .veil { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; border: 0; background: var(--rail-bottom); color: #eef2f8; font: 600 1.05rem var(--sans); cursor: pointer; }
body.veiled .veil small { font-weight: 400; color: var(--rail-muted); }
body.veiled .app > :not(.veil), body.veiled .backdrop, body.veiled .viewer { filter: blur(18px); }

.page { width: min(100% - 56px, 1060px); margin: 0 auto; padding: 30px 0 70px; }
.page.wide { width: min(100% - 56px, 1260px); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-sub { color: var(--muted); margin-top: 6px; font-size: 1rem; max-width: 70ch; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tab-head { margin: 22px 0 16px; align-items: flex-end; }
.tab-head h2 { font-size: 1.2rem; margin-bottom: 4px; }
.tab-head p { max-width: 64ch; }

/* palette and pickers */
.palette-modal .overlay-head { display: none; }
.palette-modal .overlay-body { padding: 10px; }
.palette-input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 50px; font-size: 1.02rem; box-shadow: none !important; }
.palette-list { max-height: 50vh; overflow-y: auto; padding-top: 6px; display: flex; flex-direction: column; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; color: var(--text); }
.palette-item .icon { color: var(--muted); }
.palette-item.on, .palette-item:hover { background: var(--brand-soft); }
.palette-label { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-hint { color: var(--faint); font-size: 0.8rem; white-space: nowrap; }
.pick-results { display: flex; flex-direction: column; margin-top: 6px; }
.pick-row { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.pick-row:hover { background: var(--brand-soft); }
.pick-chosen { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.pick-chosen:empty { display: none; }
.pick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-chip { border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 0.84rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.pick-chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ------------------------------------------------------------------- brief */

.action-list { overflow: hidden; }
.action-row { display: flex; align-items: center; gap: 14px; padding: 15px 18px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.action-row:last-child { border-bottom: 0; }
.action-row:hover { background: var(--surface-2); text-decoration: none; }
.action-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); flex: none; }
.action-row.bad .action-icon { background: var(--bad-soft); color: var(--bad); }
.action-list.quiet .action-icon { background: var(--surface-2); color: var(--faint); }
.action-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.action-title { font-weight: 600; color: var(--ink); }
.action-detail { color: var(--muted); font-size: 0.87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-row > .icon { color: var(--faint); }
.grid-rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.grid-listings { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 8px; }
.how-step { position: relative; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.how-step .icon { color: var(--brand); }
.how-step p { color: var(--muted); font-size: 0.9rem; }
.how-num { position: absolute; top: 14px; right: 16px; font: 700 1.6rem var(--head); color: var(--line-strong); }

.room-card, .listing-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; color: inherit; text-decoration: none; transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s; }
.room-card:hover, .listing-card:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: 0 2px 4px rgba(15, 29, 48, 0.06), 0 16px 36px rgba(15, 29, 48, 0.11); }
.room-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.room-card-title { font: 700 1.05rem var(--head); color: var(--ink); }
.room-card-sub { color: var(--muted); font-size: 0.86rem; }
.room-card-step { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.room-card-step-text { font-weight: 600; color: var(--ink); font-size: 0.92rem; line-height: 1.35; }
.room-card-foot { display: flex; justify-content: space-between; margin-top: auto; padding-top: 6px; }
.room-card.closed { opacity: 0.75; }
.waiting { font: 600 0.7rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 5px; }
.waiting.you { background: var(--brand); color: var(--brand-ink); }
.waiting.them { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.waiting.none { background: var(--sand-soft); color: var(--sand-ink); }
.mini-track { display: flex; gap: 4px; }
.mini-track span { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.mini-track span.done { background: var(--good); }
.mini-track span.current { background: var(--brand); }

.listing-card { border-top: 3px solid var(--agn-mid-blue); }
.listing-card.seek { border-top-color: var(--sand); }
:root[data-theme='dark'] .listing-card { border-top-color: var(--brand); }
:root[data-theme='dark'] .listing-card.seek { border-top-color: var(--sand); }
.listing-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 24px; }
.listing-kind { font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-right: auto; }
.listing-priority { color: var(--sand-ink); display: inline-flex; }
.listing-codename { font: 700 0.82rem var(--head); letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); }
.listing-headline { font-size: 1.08rem; line-height: 1.3; }
.listing-summary { color: var(--muted); font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.listing-facts { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; color: var(--text); }
.listing-facts span { display: flex; gap: 8px; align-items: center; }
.listing-facts .icon { color: var(--faint); }
.listing-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.listing-foot > .muted { white-space: nowrap; flex: none; }
.listing-foot .principal { flex: 1; }
.listing-foot .principal > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.principal { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; font-weight: 600; color: var(--ink); min-width: 0; }
.sealed-principal { color: var(--sand-ink); }

/* ------------------------------------------------------------------ market */

.filters { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .select { width: auto; min-width: 150px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search-input { padding-left: 36px; min-width: 230px; }
.result-count { margin: 4px 0 12px; }
.grid-listings + .empty { margin-top: 0; }
.detail { display: flex; flex-direction: column; gap: 20px; }
.detail-kind { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: 600 0.76rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.detail-summary { font-size: 1.02rem; line-height: 1.65; }
.highlights { display: flex; flex-direction: column; gap: 8px; }
.highlights li { display: flex; gap: 10px; align-items: flex-start; }
.highlights .icon { color: var(--good); margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.fact dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.fact dd { font-weight: 600; color: var(--ink); }
.sealed-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm); background: var(--sand-soft); color: var(--sand-ink); }
.sealed-box .icon { margin-top: 3px; }
.sealed-box strong { color: var(--sand-ink); }
.principal-box .person { margin-bottom: 6px; }
.detail p + p, .detail p + .sealed-text, .detail .sub-title + p { margin-top: 6px; }
.detail-action { position: sticky; bottom: -22px; padding: 16px 0 6px; background: linear-gradient(180deg, transparent, var(--surface) 28%); }

/* ----------------------------------------------------------------- compose */

.compose { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.compose-preview { position: sticky; top: 20px; }
.preview-card .listing-card { pointer-events: none; }

/* ------------------------------------------------------------------ intros */

.intro-list { margin-top: 20px; }
.intro-card { display: flex; flex-direction: column; gap: 14px; }
.intro-card.highlight { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent), var(--shadow); }
.intro-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.intro-codename { font: 700 1.02rem var(--head); color: var(--ink); }
.intro-meta { display: flex; gap: 10px; align-items: center; }
.intro-context { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.86rem; color: var(--muted); }
.intro-context span { display: inline-flex; gap: 6px; align-items: center; }
.note-block { display: flex; flex-direction: column; gap: 6px; }
.note-label { display: flex; gap: 6px; align-items: center; font: 600 0.74rem var(--sans); text-transform: uppercase; letter-spacing: 0.07em; color: var(--sand-ink); }
.consequences { display: flex; flex-direction: column; gap: 12px; }
.consequences li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.5; }
.consequences .icon { color: var(--brand); margin-top: 3px; }

/* -------------------------------------------------------------------- room */

.room { padding-top: 24px; padding-bottom: 22px; }
.room-title-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.room-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-head .notice { margin-bottom: 12px; }
.track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 0 16px; padding: 16px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); counter-reset: none; }
.track-step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.track-step::before { content: ''; position: absolute; top: 13px; right: 50%; width: 100%; height: 2px; background: var(--line-strong); }
.track-step:first-child::before { display: none; }
.track-step.done::before, .track-step.current::before { background: var(--good); }
.track-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); color: var(--faint); font: 700 0.74rem var(--head); }
.track-step.done .track-dot { background: var(--good); border-color: var(--good); color: #fff; }
:root[data-theme='dark'] .track-step.done .track-dot { color: #0a1424; }
.track-step.current .track-dot { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.track-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); line-height: 1.25; }
.track-step.done .track-label, .track-step.current .track-label { color: var(--ink); }

.next-step { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: 22px 24px; margin: 22px 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); box-shadow: var(--shadow); }
.next-step.you { border-left-color: var(--brand); background: linear-gradient(90deg, var(--brand-soft), var(--surface) 55%); }
.next-step.none { border-left-color: var(--sand); }
.next-step-text { flex: 1; min-width: 260px; }
.next-step-tag { font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.next-step.you .next-step-tag { color: var(--brand); }
.next-step h2 { font-size: 1.3rem; margin: 4px 0 6px; }
.next-step p { color: var(--muted); max-width: 70ch; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.brief-entry { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.activity { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.activity li { display: flex; gap: 12px; align-items: flex-start; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sand); margin-top: 8px; flex: none; }
.glance { display: flex; flex-direction: column; gap: 4px; }
.glance .card-title { margin-bottom: 8px; }
.glance-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px; border: 0; border-radius: 8px; background: none; color: var(--text); text-align: left; cursor: pointer; text-decoration: none; }
.glance-row:hover { background: var(--surface-2); text-decoration: none; }
.glance-row > .icon { color: var(--muted); }
.glance-label { flex: 1; font-weight: 600; color: var(--ink); }
.glance-value { font: 700 1.05rem var(--head); color: var(--ink); padding: 8px 0 0; border-top: 1px solid var(--line); margin-top: 6px; font-variant-numeric: tabular-nums; }
.legal-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 0.86rem/1.65 var(--sans); max-height: 40vh; overflow-y: auto; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.signatures { display: flex; flex-direction: column; gap: 10px; }
.signatures li { display: flex; gap: 12px; align-items: flex-start; }
.signatures .icon { color: var(--good); margin-top: 3px; }
.digest { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--sand-soft); color: var(--sand-ink); font-size: 0.84rem; }
.digest code { margin-left: auto; font-weight: 600; }
.people-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.member-card { display: flex; flex-direction: column; gap: 10px; }
.key-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.key-line code, .safety-code { font: 600 0.9rem var(--mono); color: var(--ink); letter-spacing: 0.03em; }
.safety-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.safety { margin: 8px 0; }
.former { margin-top: 24px; }
.issue-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; list-style: disc; padding-left: 18px; }
.record { overflow: hidden; margin-top: 16px; }
.record-row { display: grid; grid-template-columns: 56px 190px minmax(0, 1fr) 70px; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); align-items: center; font-size: 0.9rem; }
.record-row:last-child { border-bottom: 0; }
.record-head { font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface-2); }
.record-sig { color: var(--good); display: flex; justify-content: flex-end; }
.record-row.bad { background: var(--bad-soft); }
.record-row.bad .record-sig { color: var(--bad); }

/* messages */
.messages { display: flex; flex-direction: column; height: calc(100vh - 392px); height: calc(100dvh - 392px); min-height: 360px; margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.msg-list { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; }
.msg-start { display: flex; gap: 8px; align-items: center; justify-content: center; align-self: center; padding: 6px 14px; margin-bottom: 14px; border-radius: 999px; background: var(--sand-soft); color: var(--sand-ink); font-size: 0.8rem; font-weight: 600; text-align: center; }
.msg-day { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; color: var(--faint); font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; }
.msg-day::before, .msg-day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg-system { display: flex; gap: 8px; align-items: center; align-self: center; padding: 4px 0; margin: 4px 0; color: var(--muted); font-size: 0.82rem; }
.msg-system .icon { color: var(--sand); }
.msg-system time { color: var(--faint); font-size: 0.74rem; }
.msg { display: flex; gap: 10px; max-width: min(74%, 640px); margin-top: 10px; }
.msg.grouped { margin-top: 2px; padding-left: 40px; }
.msg.mine { align-self: flex-end; padding-left: 0; }
.msg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-author { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.msg-bubble { padding: 10px 14px; border-radius: 4px 14px 14px 14px; background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.msg.mine .msg-bubble { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); border-radius: 14px 4px 14px 14px; }
.msg-time { font-size: 0.7rem; color: var(--faint); }
.msg-compose { display: flex; gap: 10px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.msg-input { resize: none; max-height: 180px; }
.msg-hint { padding: 0 16px 8px; font-size: 0.74rem; color: var(--faint); background: var(--surface-2); }

/* documents */
.documents { position: relative; min-height: 300px; }
.documents.dropping::after { content: 'Drop to encrypt and share'; position: absolute; inset: 0; display: grid; place-items: center; border: 2px dashed var(--brand); border-radius: var(--radius); background: color-mix(in srgb, var(--brand-soft) 90%, transparent); color: var(--brand); font: 700 1.1rem var(--head); z-index: 5; }
.doc-tier { margin-top: 20px; }
.doc-list { overflow: hidden; }
.doc-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.doc-row:last-child { border-bottom: 0; }
.doc-row:hover { background: var(--surface-2); }
.doc-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); flex: none; }
.doc-text { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 0.83rem; color: var(--muted); }
.doc-views { display: flex; gap: 6px; align-items: center; font-size: 0.8rem; color: var(--sand-ink); margin-top: 2px; }
.doc-actions { display: flex; align-items: center; gap: 6px; color: var(--faint); }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-list li { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.file-list li span:first-of-type { flex: 1; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { display: flex; flex-direction: column; gap: 6px; }
.upload-progress .meter-bar { width: 0; }
.upload-label { font-size: 0.82rem; color: var(--muted); }
.viewer { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; background: #0a1424; color: #eef2f8; animation: fade 0.14s ease-out; }
.viewer-bar { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 18px; background: #101d32; border-bottom: 1px solid rgba(255, 255, 255, 0.1); flex-wrap: wrap; }
.viewer-title { display: flex; gap: 12px; align-items: center; min-width: 0; }
.viewer-title div { display: flex; flex-direction: column; min-width: 0; }
.viewer-title strong { color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-title span { color: #9aa8b8; font-size: 0.8rem; }
.viewer .icon-btn { color: #c2cbd6; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.viewer .sealed { background: rgba(196, 189, 151, 0.16); color: #e0d9b6; }
.viewer .chip { background: rgba(255, 255, 255, 0.08); border-color: transparent; color: #c2cbd6; }
.viewer-stage { position: relative; flex: 1; min-height: 0; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.viewer-loading, .viewer-none { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; color: #c2cbd6; text-align: center; padding: 30px; }
.viewer-none .muted { color: #9aa8b8; }
.viewer-image { max-width: 100%; height: auto; margin: 24px auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); user-select: none; -webkit-user-drag: none; }
.viewer-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-text { margin: 24px; padding: 28px 32px; width: min(900px, 100%); background: #fff; color: #1b2a40; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 0.88rem/1.6 var(--mono); }
.watermark { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around; gap: 70px 50px; padding: 30px; }
.watermark span { transform: rotate(-24deg); white-space: nowrap; font: 600 0.82rem var(--sans); color: rgba(128, 134, 142, 0.3); user-select: none; mix-blend-mode: difference; }

/* terms */
.terms-card { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.terms-card.current.open { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.terms-card.current.accepted { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.terms-card.past { box-shadow: none; opacity: 0.86; }
.terms-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.terms-head h3 { font-size: 1.15rem; }
.terms-table { display: flex; flex-direction: column; }
.terms-line { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 16px; padding: 11px 10px; border-top: 1px solid var(--line); align-items: baseline; }
.terms-line dt { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.terms-line dd { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.terms-line.changed { background: var(--warn-soft); border-radius: 6px; border-top-color: transparent; }
.changed-tag { font: 600 0.68rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); }
.terms-value { font: 700 1.3rem var(--head); font-variant-numeric: tabular-nums; }
.conditions { list-style: disc; padding-left: 18px; font-weight: 400; display: flex; flex-direction: column; gap: 3px; }
.terms-note { display: flex; flex-direction: column; gap: 6px; }
.terms-response { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--good-soft); }
.terms-response.declined { background: var(--bad-soft); }
.terms-response .sealed-text { margin-top: 8px; }
.terms-response.accepted > .icon { color: var(--good); } .terms-response.declined > .icon { color: var(--bad); }
.indicative { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 0.83rem; }
.indicative .icon { margin-top: 3px; }
.agreed-banner { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius); background: var(--good-soft); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); margin-bottom: 14px; }
.agreed-banner > .icon { color: var(--good); margin-top: 2px; }
.agreed-banner strong { color: var(--ink); font-size: 1.02rem; }
.agreed-banner p { color: var(--muted); font-size: 0.87rem; margin-top: 3px; }
.terms-card + .stack-lg, .steps + .stack-lg { margin-top: 30px; }
.steps { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.step-list { display: flex; flex-direction: column; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.step-text { flex: 1; min-width: 0; }
.step-title { font-weight: 600; color: var(--ink); }
.step.done .step-title { text-decoration: line-through; color: var(--muted); }
.step-add { display: grid; grid-template-columns: minmax(0, 1fr) 150px 160px auto; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }

/* security */
.sec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; margin-top: 4px; }
.sec-grid + .section { margin-top: 30px; }
.section + .sec-grid { margin-top: 30px; }
.vis-table { overflow: hidden; }
.vis-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: center; font-size: 0.92rem; }
.vis-row:last-child { border-bottom: 0; }
.vis-head { font: 600 0.72rem var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: var(--surface-2); }
.vis-what { font-weight: 600; color: var(--ink); }
.can { display: inline-flex; gap: 7px; align-items: center; font-weight: 600; font-size: 0.86rem; }
.can.no { color: var(--good); } .can.yes { color: var(--warn); } .can.meta { color: var(--muted); }
.plain-list { display: flex; flex-direction: column; gap: 14px; }
.plain-list li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.55; }
.plain-list .icon { color: var(--brand); margin-top: 4px; }

/* ------------------------------------------------------------------ narrow */

@media (max-width: 1080px) {
  .overview-grid, .compose { grid-template-columns: minmax(0, 1fr); }
  .compose-preview { position: static; order: -1; }
  .topbar-sealed { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rail { display: none; }
  .topbar { padding: 10px 16px; }
  .topbar-brand { display: flex; }
  .topbar-lock { display: inline-grid; }
  .search-trigger { max-width: none; }
  .search-trigger span:first-of-type, .search-trigger .kbd-group { display: none; }
  .search-trigger { flex: none; width: 40px; padding: 0; justify-content: center; margin-left: auto; }
  .topbar-actions { margin-left: 0; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--muted); font-size: 0.66rem; font-weight: 600; text-decoration: none; border-radius: 8px; }
  .bottom-nav a.on { color: var(--brand); }
  .bottom-nav .badge, .bottom-nav .dot { position: absolute; top: 2px; right: calc(50% - 22px); }
  .page, .page.wide { width: calc(100% - 32px); padding-top: 20px; }
  .how, .people-grid, .sec-grid, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .track { grid-template-columns: repeat(6, minmax(98px, 1fr)); overflow-x: auto; padding: 14px 6px; scrollbar-width: none; }
  .track-label { font-size: 0.68rem; }
  .terms-line { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .record-row { grid-template-columns: 34px minmax(0, 1fr) 28px; }
  .record-row > :nth-child(2) { display: none; }
  .vis-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .vis-head { display: none; }
  .step-add { grid-template-columns: minmax(0, 1fr); }
  .messages { height: calc(100dvh - 318px); min-height: 320px; }
  .msg { max-width: 88%; }
  .filters .select { min-width: 0; flex: 1; }
  .filters-right { width: 100%; }
  .search-box { width: 100%; } .search-input { min-width: 0; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { width: 100%; border-radius: 16px 16px 0 0; max-height: 94vh; }
  .gate-card { padding: 26px 22px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .next-step { padding: 18px; }
  .page-head { align-items: flex-start; }
}

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

@media print {
  body { overflow: visible; background: #fff; }
  .gate { background: #fff; height: auto; }
  .gate-card { box-shadow: none; border: 0; }
  .gate-card .btn, .gate-card .check, .gate-foot, .toast-wrap { display: none !important; }
}
