/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio, geometry.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* functional inline SVG icons opt into bounded geometry; content SVGs keep their own */
  .od-icon { display: inline-block; inline-size: var(--od-icon-size, 1em); block-size: var(--od-icon-size, 1em); flex: none; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */

/* ============================================================
   Design tokens — light, clean product dashboard
   ============================================================ */
:root {
  --bg-0: #f8f9fa;          /* page ground (Docs grey) */
  --bg-1: #ffffff;          /* panels, cards */
  --bg-2: #ffffff;          /* cards */
  --bg-3: #f1f3f4;          /* inset tiles, hover */
  --bg-4: #e8eaed;          /* pressed, tracks */
  --line: #dadce0;
  --line-strong: #c4c7cc;
  --text: #202124;
  --text-2: #3c4043;
  --text-3: #5f6368;
  --text-inverse: #ffffff;

  --navy: #1a73e8;          /* Google blue, primary action */
  --navy-strong: #1765cc;
  --navy-dim: #e8f0fe;

  --alice: #7b5ad8;
  --alice-strong: #5c3fbf;
  --alice-dim: #f0ebfb;
  --alice-line: #d3c6f1;
  --lab: #12808a;
  --lab-strong: #0b6a73;
  --lab-dim: #e4f5f6;
  --lab-line: #b5e0e4;
  --box: #b06000;
  --box-dim: #fef3e2;
  --box-line: #f5d8a8;

  --ok: #188038;
  --ok-dim: #e6f4ea;
  --ok-line: #b7dfc3;
  --warn: #b06000;
  --warn-dim: #fef7e0;
  --warn-line: #f3d99a;
  --bad: #c5221f;
  --bad-dim: #fce8e6;
  --bad-line: #f5c2bf;

  --font-display: "Google Sans", "Product Sans", "Roboto", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-body: "Roboto", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --radius-sm: 8px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.08);
  --shadow-md: 0 1px 3px rgba(60, 64, 67, 0.30), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --shadow-lg: 0 8px 10px 1px rgba(60, 64, 67, 0.14), 0 3px 14px 2px rgba(60, 64, 67, 0.12), 0 5px 5px -3px rgba(60, 64, 67, 0.20);

  --dur-fast: 160ms;
  --dur-med: 260ms;
  --dur-slow: 400ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.6, 0, 0.8, 0.4);

  --topbar-h: 56px;
  --side-w: 360px;
  --focus: 0 0 0 2px #ffffff, 0 0 0 4px var(--navy);
  --party: var(--navy);
  --party-dim: var(--navy-dim);
  --party-line: #c2d7f7;
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--navy); }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: rgba(31, 59, 99, 0.18); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.eyebrow { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }

/* ============================================================
   Buttons, chips, inputs
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 36px; padding: 0 var(--sp-4);
  border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--bg-1); color: var(--navy);
  font-family: var(--font-display); font-weight: 500; font-size: var(--fs-sm); letter-spacing: 0.01em; cursor: pointer; white-space: nowrap;
  box-shadow: none;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--navy-dim); border-color: var(--line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--navy); color: var(--text-inverse); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-strong); border-color: var(--navy-strong); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.btn-icon { width: 36px; padding: 0; border-radius: 50%; }
.btn-icon.btn-sm { width: 32px; }
.btn-alice { background: var(--alice-dim); border-color: var(--alice-line); color: var(--alice-strong); }
.btn-alice:hover { background: #e3e4f8; border-color: var(--alice); }
.btn-lab { background: var(--lab-dim); border-color: var(--lab-line); color: var(--lab-strong); }
.btn-lab:hover { background: #d9eef0; border-color: var(--lab); }
.btn-danger { background: var(--bad-dim); border-color: var(--bad-line); color: var(--bad); }
.btn-danger:hover { background: #f9dcd8; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 500; line-height: 1; letter-spacing: 0.01em;
  background: var(--bg-1); color: var(--text-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip-ok { background: var(--ok-dim); color: var(--ok); border-color: var(--ok-line); }
.chip-warn { background: var(--warn-dim); color: var(--warn); border-color: var(--warn-line); }
.chip-bad { background: var(--bad-dim); color: var(--bad); border-color: var(--bad-line); }
.chip-alice { background: var(--alice-dim); color: var(--alice-strong); border-color: var(--alice-line); }
.chip-lab { background: var(--lab-dim); color: var(--lab-strong); border-color: var(--lab-line); }
.chip-box { background: var(--box-dim); color: var(--box); border-color: var(--box-line); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip .dot.pulse { animation: pulse 1.6s ease-in-out infinite; }

.input, .textarea, .select {
  width: 100%; min-height: 40px; padding: 8px 14px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-sm);
}
.input:focus-visible, .textarea:focus-visible { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 59, 99, 0.12); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.field-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field-help { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; }

.seg { display: inline-flex; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 3px; gap: 2px; }
.seg button {
  min-height: 30px; padding: 0 14px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-2);
  font-family: var(--font-display); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.seg button:hover { color: var(--text); background: var(--bg-3); }
.seg button[aria-pressed="true"] { background: var(--navy-dim); color: var(--navy); box-shadow: none; border: 0; }
.seg button[aria-pressed="true"][data-side="alice"] { color: var(--alice-strong); }
.seg button[aria-pressed="true"][data-side="openbrain"] { color: var(--lab-strong); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.avatar-alice { background: var(--alice); color: #ffffff; }
.avatar-openbrain { background: var(--lab); color: #ffffff; }
.avatar-agent { background: var(--bg-4); color: var(--text-2); }
.avatar-box { background: var(--box-dim); color: var(--box); border: 1px solid var(--box-line); }
.avatar-lg { width: 44px; height: 44px; font-size: 18px; }

.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--sp-4); box-shadow: none; }
.card-sub { background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-3); }
.divider { height: 1px; background: var(--line); margin: var(--sp-3) 0; }
.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 8px 12px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-3); margin: 0; }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.hash { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); overflow-wrap: anywhere; }

/* ============================================================
   App shell
   ============================================================ */
.app { display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr); height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--sp-4);
  background: var(--bg-1); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; color: #ffffff; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); letter-spacing: -0.01em; white-space: nowrap; }
.brand-session { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); }
.attest-pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--ok-dim); border: 1px solid var(--ok-line); color: var(--ok); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.attest-pill:hover { background: #d9efe2; }
.attest-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
.attest-pill.is-checking { background: var(--warn-dim); border-color: var(--warn-line); color: var(--warn); }
.drawer-toggle { display: none; }

.workspace {
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
  min-height: 0; position: relative;
}

/* ============================================================
   Party panels
   ============================================================ */
.party {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0; background: var(--bg-1); position: relative;
}
.party[data-side="alice"] { border-right: 1px solid var(--line); --party: var(--alice); --party-strong: var(--alice-strong); --party-dim: var(--alice-dim); --party-line: var(--alice-line); }
.party[data-side="openbrain"] { border-left: 1px solid var(--line); --party: var(--lab); --party-strong: var(--lab-strong); --party-dim: var(--lab-dim); --party-line: var(--lab-line); }

.party-head { padding: var(--sp-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--sp-3); }
.party-head .who { display: flex; align-items: center; gap: 10px; }
.party-head .who .name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); }
.party-head .who .role { font-size: var(--fs-xs); color: var(--text-3); }
.party-head .you { margin-left: auto; }
.agent-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-3); border: 1px solid var(--line); }
.agent-row .agent-name { font-size: var(--fs-sm); font-weight: 500; }
.agent-row .agent-meta { font-size: var(--fs-xs); color: var(--text-3); }
.agent-row .change { margin-left: auto; }

.chat { overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); background: var(--bg-1); }
.msg { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.msg .avatar { width: 28px; height: 28px; font-size: 12px; }
.msg-body { display: grid; gap: 4px; }
.msg-meta { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: 8px; }
.msg-meta b { color: var(--text-2); font-weight: 600; }
.msg-text { font-size: var(--fs-sm); line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.msg-text p + p { margin-top: 6px; }
.msg-user .msg-text { background: var(--navy-dim); border: 0; border-radius: 16px 16px 16px 4px; padding: 8px 14px; justify-self: start; max-width: 100%; }
.msg-agent .msg-text { color: var(--text-2); }
.msg-system { grid-template-columns: 1fr; }
.msg-system .msg-text { font-size: var(--fs-xs); color: var(--text-3); text-align: center; padding: 4px 0; }

.file-card {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius-sm); background: var(--bg-1); border: 1px solid var(--line);
  transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-med) var(--ease-out), opacity var(--dur-med) var(--ease-out);
}
.file-card .ficon { width: 34px; height: 34px; border-radius: 8px; background: var(--bg-3); display: grid; place-items: center; color: var(--text-2); border: 1px solid var(--line); }
.file-card .fname { font-size: var(--fs-sm); font-weight: 500; }
.file-card .fmeta { font-size: var(--fs-xs); color: var(--text-3); }
.file-card.is-sent { border-color: var(--box-line); background: var(--box-dim); }
.file-card.is-sent .ficon { background: #ffffff; color: var(--box); border-color: var(--box-line); }
.file-card.is-encrypting { animation: encrypt var(--dur-slow) var(--ease-out); }
.file-card.is-sent .fmeta { color: var(--box); }
.file-card .factions { display: flex; gap: 6px; }

.composer { border-top: 1px solid var(--line); padding: var(--sp-3) var(--sp-4); display: grid; gap: var(--sp-2); background: var(--bg-1); }
.composer-row { display: flex; gap: 8px; align-items: end; }
.composer textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; border-radius: 20px; }
.dropzone {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-pill); padding: 8px 14px;
  display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--text-3); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--party); background: var(--party-dim); color: var(--text-2); }
.dropzone input { display: none; }
.files-section { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); display: grid; gap: var(--sp-2); max-height: 260px; overflow-y: auto; background: var(--bg-3); }
.files-section .section-head { display: flex; align-items: center; justify-content: space-between; }
.files-list { display: grid; gap: 8px; }
.empty-note { font-size: var(--fs-xs); color: var(--text-3); padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--bg-1); }

/* Private / redacted treatment */
.party.is-private > .party-head, .party.is-private > .chat, .party.is-private > .composer, .party.is-private > .files-section { display: none; }
.party.is-private { grid-template-rows: minmax(0, 1fr); }
.seg-short { display: none; }
.veil { display: none; }
.party.is-private .veil {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; height: 100%; position: relative;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(22, 36, 58, 0.02) 3px 4px),
    var(--bg-3);
}
.veil-head { padding: var(--sp-4); border-bottom: 1px solid var(--line); display: grid; gap: var(--sp-3); background: var(--bg-1); }
.veil-body { padding: var(--sp-4); display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.veil-foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line); display: grid; gap: 8px; background: var(--bg-1); }
.ghost-row { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
.ghost-row .avatar { width: 28px; height: 28px; border-radius: 7px; background: var(--bg-4); border: 1px solid var(--line); }
.ghost-lines { display: grid; gap: 6px; }
.ghost-bar {
  height: 10px; border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-4), var(--line-strong) 40%, var(--bg-4));
  filter: blur(2.5px); opacity: 0.9;
}
.ghost-bar.tall { height: 36px; border-radius: 6px; }
.ghost-bar.short { width: 40%; }
.ghost-text { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-3); filter: blur(3px); user-select: none; letter-spacing: 0.08em; line-height: 1.6; overflow-wrap: anywhere; opacity: 0.7; }
.veil-badge {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.veil-badge .lockcard {
  pointer-events: auto; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--sp-5); width: min(280px, 86%); text-align: center; display: grid; gap: 10px; justify-items: center;
  box-shadow: var(--shadow-md);
}
.veil-badge .lockicon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--party-dim); border: 1px solid var(--party-line); color: var(--party-strong); }
.veil-badge h4 { font-size: var(--fs-md); }
.veil-badge p { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }

/* ============================================================
   Centre workspace
   ============================================================ */
.center { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: var(--bg-0); }
.tabbar { display: flex; align-items: flex-end; gap: 8px; padding: 6px 16px 0; border-bottom: 1px solid var(--line); background: var(--bg-1); overflow-x: auto; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  min-height: 44px; padding: 0 12px; margin-bottom: -1px;
  border: 0; border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0;
  background: transparent;
  font-family: var(--font-display);
  color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--text); background: var(--bg-3); }
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); background: transparent; }
.tab .count { min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--bg-4); color: var(--text-2); font-size: 11px; font-weight: 500; display: inline-grid; place-items: center; }
.tab .count.hot { background: var(--warn-dim); color: var(--warn); }
.tabbar .spacer { flex: 1; }
.tab-panels { min-height: 0; position: relative; }
.tab-panel { display: none; height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5); }
.tab-panel.is-active { display: block; animation: fadein var(--dur-med) var(--ease-out); }
.panel-inner { max-width: 1080px; margin: 0 auto; display: grid; gap: var(--sp-5); }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.panel-title .lead { font-size: var(--fs-sm); color: var(--text-2); max-width: 64ch; margin-top: 4px; }

/* ---- Box tab ---- */
.box-status { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.stat { padding: 14px 16px; background: var(--bg-1); border-radius: var(--radius-lg); box-shadow: none; }
.stat .k { font-size: var(--fs-sm); color: var(--text-2); order: 2; }
.stat .v { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin-top: 0; order: 1; line-height: 1.2; }
.stat .v.ok { color: var(--ok); }
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }

.submissions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.sub-card { padding: var(--sp-4); display: grid; gap: 10px; }
.sub-card[data-side="alice"] { border-top: 3px solid var(--alice); }
.sub-card[data-side="openbrain"] { border-top: 3px solid var(--lab); }
.sub-card .head { display: flex; align-items: center; gap: 10px; }
.sub-card .head .t { font-family: var(--font-display); font-weight: 600; }
.sub-card .head .s { font-size: var(--fs-xs); color: var(--text-3); }
.cipher-chip {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-3); border: 1px solid var(--line);
}
.cipher-chip .ci { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: #ffffff; color: var(--box); border: 1px solid var(--box-line); }
.cipher-chip .cn { font-size: var(--fs-sm); font-weight: 500; }
.cipher-chip .cm { font-size: var(--fs-xs); font-family: var(--font-mono); color: var(--text-3); }
.cipher-chip .cn.blur { filter: blur(4px); user-select: none; color: var(--text-3); }

.graph-wrap { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.graph { width: 100%; height: auto; display: block; }
.graph .stage-bg { fill: var(--bg-3); stroke: var(--line); }
.graph .stage-bg.input { stroke: var(--box-line); fill: var(--box-dim); }
.graph .stage-bg.query { stroke: var(--lab-line); fill: var(--lab-dim); }
.graph .stage-bg.output { stroke: var(--alice-line); fill: var(--alice-dim); }
.graph .stage-label { font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: 0.1em; fill: var(--text-3); }
.graph .edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.graph .edge.alice { stroke: var(--alice); opacity: 0.6; }
.graph .edge.lab { stroke: var(--lab); opacity: 0.6; }
.graph .edge.active { stroke-dasharray: 6 6; animation: dash 1s linear infinite; stroke: var(--navy); opacity: 1; }
.graph .pill { fill: #ffffff; stroke-width: 1.5; }
.graph .pill.alice { stroke: var(--alice); }
.graph .pill.lab { stroke: var(--lab); }
.graph .pill-text { font-family: var(--font-body); font-size: 12px; font-weight: 600; fill: var(--text); text-anchor: middle; }
.graph .pill-sub { font-family: var(--font-mono); font-size: 10px; fill: var(--text-3); text-anchor: middle; }
.graph .node { cursor: pointer; }
.graph .node circle.ring { fill: #ffffff; stroke: var(--line-strong); stroke-width: 2; transition: stroke var(--dur-fast) var(--ease-out); }
.graph .node.running circle.ring { stroke: var(--navy); animation: ringpulse 1s ease-in-out infinite; }
.graph .node.passed circle.ring { stroke: var(--ok); }
.graph .node.failed circle.ring { stroke: var(--bad); }
.graph .node.is-selected circle.ring { stroke: var(--text); stroke-width: 2.5; }
.graph .node text.num { font-family: var(--font-mono); font-size: 13px; font-weight: 600; fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.graph .node text.label { font-family: var(--font-body); font-size: 11px; fill: var(--text-2); text-anchor: middle; }
.graph .node .badge { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.graph .node.passed .badge, .graph .node.failed .badge { opacity: 1; }
.graph .node.passed .badge circle { fill: var(--ok); }
.graph .node.failed .badge circle { fill: var(--bad); }
.graph .node .badge path { stroke: #ffffff; stroke-width: 1.8; fill: none; }
.graph .out-box { fill: #ffffff; stroke: var(--line-strong); stroke-width: 1.5; }
.graph .out-box.alice { stroke: var(--alice); }
.graph .out-box.lab { stroke: var(--lab); }
.graph .out-text { font-family: var(--font-body); font-size: 11px; font-weight: 600; fill: var(--text-2); text-anchor: middle; }

.graph-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-3); }
.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); display: inline-block; background: #fff; }
.graph-legend i.run { border-color: var(--navy); }
.graph-legend i.pass { border-color: var(--ok); }
.graph-legend i.fail { border-color: var(--bad); }

.node-detail { display: grid; gap: 10px; }
.node-detail .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.node-detail pre { margin: 0; padding: 12px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.55; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }

.run-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.run-bar .scenario { display: flex; align-items: center; gap: 8px; }
.run-bar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.readiness { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-3); }
.readiness span { display: inline-flex; align-items: center; gap: 6px; }
.readiness .ok { color: var(--ok); }
.readiness .no { color: var(--text-3); }

.outputs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.output-card { display: grid; gap: 12px; }
.output-card[data-side="alice"] { border-top: 3px solid var(--alice); }
.output-card[data-side="openbrain"] { border-top: 3px solid var(--lab); }
.output-card .head { display: flex; align-items: center; gap: 10px; }
.output-card .head .t { font-family: var(--font-display); font-weight: 600; }
.output-card table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.output-card th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 6px 0; border-bottom: 1px solid var(--line); }
.output-card td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.output-card td.n { font-family: var(--font-mono); text-align: right; }
.bar { height: 8px; border-radius: 4px; background: var(--bg-4); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--navy); transition: width var(--dur-slow) var(--ease-out); }
.bar.alice > i { background: var(--alice); }
.output-card .withheld { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--bad-dim); border: 1px solid var(--bad-line); font-size: var(--fs-sm); }
.output-card .withheld b { color: var(--bad); }
.output-card .released-note { font-size: var(--fs-xs); color: var(--text-3); }
.output-card .blurred { filter: blur(5px); user-select: none; pointer-events: none; }

.appeal-card { display: grid; gap: 12px; border-color: var(--warn-line); background: #fffdf7; }
.appeal-card .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.appeal-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.appeal-option { text-align: left; display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-1); border: 1px solid var(--line-strong); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.appeal-option:hover { border-color: var(--warn); background: var(--warn-dim); }
.appeal-option .t { font-weight: 600; font-size: var(--fs-sm); }
.appeal-option .d { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.appeal-option:disabled { opacity: 0.5; cursor: not-allowed; }

.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; padding: 8px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 8px; top: 24px; bottom: -4px; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-item .pt { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--text-3); }
.tl-item.ok .pt { background: var(--ok-dim); border-color: var(--ok-line); color: var(--ok); }
.tl-item.bad .pt { background: var(--bad-dim); border-color: var(--bad-line); color: var(--bad); }
.tl-item.warn .pt { background: var(--warn-dim); border-color: var(--warn-line); color: var(--warn); }
.tl-item .tt { font-size: var(--fs-sm); }
.tl-item .ts { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); }

/* ---- Plan tab ---- */
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-5); align-items: start; }
.doc { padding: 56px 64px; display: grid; gap: var(--sp-4); position: relative; border: 0; box-shadow: var(--shadow-sm), 0 0 0 1px rgba(60, 64, 67, 0.08); border-radius: 4px; }
.doc-head { display: grid; gap: 6px; padding-bottom: var(--sp-4); border-bottom: 1px solid var(--line); }
.doc-head .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-3); }
.doc h2 { font-size: var(--fs-xl); }
.doc h3 { font-size: var(--fs-md); margin-top: var(--sp-3); display: flex; align-items: center; gap: 8px; }
.doc h3 .stage-tag { font-family: var(--font-mono); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line); }
.doc h3 .stage-tag.input { background: var(--box-dim); color: var(--box); border-color: var(--box-line); }
.doc h3 .stage-tag.query { background: var(--lab-dim); color: var(--lab-strong); border-color: var(--lab-line); }
.doc h3 .stage-tag.output { background: var(--alice-dim); color: var(--alice-strong); border-color: var(--alice-line); }
.doc-body { font-size: var(--fs-md); line-height: 1.7; color: var(--text); max-width: 68ch; }
.doc-body[contenteditable="true"]:focus-visible { box-shadow: none; outline: 1px dashed var(--line-strong); outline-offset: 8px; border-radius: 4px; }
.doc-body p + p { margin-top: 10px; }
.doc-body ul { margin: 8px 0 0; padding-left: 22px; }
.doc-body li + li { margin-top: 4px; }
.doc-body pre { margin: 10px 0 0; padding: 12px 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.6; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.doc-body blockquote { margin: 10px 0 0; padding: 10px 14px; border-left: 2px solid var(--line-strong); color: var(--text-2); font-style: normal; background: var(--bg-3); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.hl { border-radius: 2px; padding: 1px 0; cursor: pointer; transition: background var(--dur-fast) var(--ease-out); border-bottom: 0; }
.hl-alice { background: #ede6fb; box-shadow: inset 0 -2px 0 var(--alice); }
.hl-openbrain { background: #dcf2f4; box-shadow: inset 0 -2px 0 var(--lab); }
.hl.is-active { background: #fde293; box-shadow: inset 0 -2px 0 #f9ab00; }
.hl.is-resolved { background: transparent; box-shadow: inset 0 -1px 0 var(--line-strong); opacity: 0.8; }
.sel-pop {
  position: absolute; display: none; z-index: 5; transform: translate(-50%, -100%);
  background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 4px; gap: 4px;
  box-shadow: var(--shadow-md);
}
.sel-pop.is-open { display: flex; }

.comments { display: grid; gap: var(--sp-3); position: sticky; top: 0; }
.comments .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.comment { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-1); border: 1px solid var(--line); cursor: pointer; box-shadow: none; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.comment:hover { box-shadow: var(--shadow-sm); }
.comment .meta::before { content: attr(data-initial); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-4); color: var(--text-2); font-weight: 600; font-size: 12px; flex: none; }
.comment[data-side="alice"] .meta::before { background: var(--alice); color: #fff; content: "A"; }
.comment[data-side="openbrain"] .meta::before { background: var(--lab); color: #fff; content: "O"; }
.comment.is-active { background: var(--bg-1); border-color: transparent; box-shadow: var(--shadow-md); transform: translateX(-6px); }
.comment.is-resolved { opacity: 0.6; }
.comment .meta { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--text-3); }
.comment .meta b { color: var(--text); font-weight: 600; }
.comment .quote { font-size: var(--fs-xs); color: var(--text-3); border-left: 2px solid var(--line-strong); padding-left: 8px; font-style: italic; overflow-wrap: anywhere; }
.comment .text { font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.comment .suggest { display: grid; gap: 4px; font-size: var(--fs-xs); font-family: var(--font-mono); padding: 8px; background: var(--bg-3); border-radius: 4px; border: 1px solid var(--line); }
.comment .suggest .del { color: var(--bad); text-decoration: line-through; }
.comment .suggest .ins { color: var(--ok); }
.comment .replies { display: grid; gap: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.comment .reply { font-size: var(--fs-xs); color: var(--text-2); }
.comment .reply b { color: var(--text); }
.comment .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.comment-form { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-1); border: 1px solid transparent; box-shadow: var(--shadow-md); }
.comment-form .textarea { border-radius: 16px; padding: 10px 14px; }

.signoff { display: grid; gap: 12px; }
.signoff .sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sig { display: grid; grid-template-columns: 32px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); background: var(--bg-3); border: 1px solid var(--line); }
.sig .n { font-size: var(--fs-sm); font-weight: 600; }
.sig .s { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); }
.sig.is-signed { border-color: var(--ok-line); background: var(--ok-dim); }
.sig.is-signed .s { color: var(--ok); }
.sig.is-stale { border-color: var(--warn-line); background: var(--warn-dim); }
.sig.is-stale .s { color: var(--warn); }

/* ---- Attestation tab ---- */
.attest-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-4); padding: var(--sp-5); border-color: var(--ok-line); background: #f7fcf9; }
.attest-hero.is-checking { border-color: var(--warn-line); background: #fffcf5; }
.attest-hero .big { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--ok-dim); border: 1px solid var(--ok-line); color: var(--ok); }
.attest-hero.is-checking .big { background: var(--warn-dim); border-color: var(--warn-line); color: var(--warn); }
.attest-hero h2 { font-size: var(--fs-xl); }
.attest-hero .sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px; }
.attest-hero .sub .mono { color: var(--text-3); }
.guarantees { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--sp-3); }
.guarantee { display: grid; gap: 8px; padding: 14px; }
.guarantee .head { display: flex; align-items: center; gap: 10px; }
.guarantee .head .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--ok-dim); color: var(--ok); border: 1px solid var(--ok-line); }
.guarantee .head .t { font-size: var(--fs-sm); font-weight: 500; }
.guarantee .head .t b { color: var(--ok); font-weight: 600; }
.guarantee .d { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.guarantee .ts { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }
.chain { display: grid; gap: 0; }
.chain-step { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 14px; padding: 12px 0; position: relative; }
.chain-step::before { content: ""; position: absolute; left: 13px; top: 40px; bottom: -4px; width: 1px; background: var(--line); }
.chain-step:last-child::before { display: none; }
.chain-step .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; font-weight: 600; background: var(--ok-dim); color: var(--ok); border: 1px solid var(--ok-line); }
.chain-step.is-checking .n { background: var(--warn-dim); color: var(--warn); border-color: var(--warn-line); animation: pulse 1s ease-in-out infinite; }
.chain-step.is-pending .n { background: var(--bg-3); color: var(--text-3); border-color: var(--line-strong); }
.chain-step .t { font-size: var(--fs-sm); font-weight: 600; }
.chain-step .d { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.chain-step .h { margin-top: 6px; }
.chain-step .st { font-size: 11px; color: var(--ok); font-family: var(--font-mono); margin-top: 4px; }
.chain-step.is-checking .st { color: var(--warn); }
.chain-step.is-pending .st { color: var(--text-3); }
.attest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.conn-meter { display: grid; gap: 6px; }
.conn-meter .row { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-3); }
.conn-meter .bar > i { background: var(--ok); }

/* ---- Ledger ---- */
.ledger { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ledger th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-3); }
.ledger td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ledger td.seq, .ledger td.ts, .ledger td.h { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.ledger td.h { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.ledger tr.is-new td { animation: rowin var(--dur-slow) var(--ease-out); }
.ev { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--bg-3); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.ev.ok { background: var(--ok-dim); color: var(--ok); border-color: var(--ok-line); }
.ev.bad { background: var(--bad-dim); color: var(--bad); border-color: var(--bad-line); }
.ev.warn { background: var(--warn-dim); color: var(--warn); border-color: var(--warn-line); }
.ev.alice { background: var(--alice-dim); color: var(--alice-strong); border-color: var(--alice-line); }
.ev.lab { background: var(--lab-dim); color: var(--lab-strong); border-color: var(--lab-line); }

/* ---- Invite tab ---- */
.invite-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); align-items: start; }
.qr-card { display: grid; gap: 14px; justify-items: center; text-align: center; }
.qr-frame { padding: 12px; background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-md); display: grid; place-items: center; }
.qr-frame canvas { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.code-big { font-family: var(--font-mono); font-size: var(--fs-2xl); font-weight: 600; letter-spacing: 0.12em; color: var(--text); }
.link-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.link-row .input { font-family: var(--font-mono); font-size: var(--fs-xs); background: var(--bg-3); }
.party-status { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pstat { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 10px; align-items: center; padding: 10px; border-radius: var(--radius-sm); background: var(--bg-3); border: 1px solid var(--line); }
.pstat .n { font-size: var(--fs-sm); font-weight: 600; }
.pstat .s { font-size: var(--fs-xs); color: var(--text-3); }
.pstat.is-joined { border-color: var(--ok-line); background: var(--ok-dim); }
.pstat.is-joined .s { color: var(--ok); }
.agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.agent-opt { text-align: left; display: grid; gap: 4px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-1); border: 1px solid var(--line-strong); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.agent-opt:hover { border-color: var(--text-3); background: var(--bg-3); }
.agent-opt { border-radius: var(--radius-lg); }
.agent-opt[aria-pressed="true"] { border-color: var(--party, var(--navy)); background: var(--party-dim, var(--navy-dim)); box-shadow: inset 0 0 0 1px var(--party, var(--navy)); }
.agent-opt .n { font-size: var(--fs-sm); font-weight: 600; }
.agent-opt .m { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); }
.agent-opt .d { font-size: var(--fs-xs); color: var(--text-2); }

/* ============================================================
   Onboarding overlay
   ============================================================ */
.overlay { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(22, 36, 58, 0.45); backdrop-filter: blur(4px); padding: var(--sp-4); }
.overlay.is-open { display: grid; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg-1); border: 0; border-radius: 28px; padding: var(--sp-6); display: grid; gap: var(--sp-5); box-shadow: var(--shadow-lg); animation: modalin var(--dur-med) var(--ease-out); }
.modal-head { display: grid; gap: 6px; }
.modal-head .step-ind { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.modal-head p { font-size: var(--fs-sm); color: var(--text-2); max-width: 56ch; }
.side-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.side-opt { text-align: left; display: grid; gap: 8px; padding: 14px; border-radius: var(--radius-md); background: var(--bg-1); border: 1px solid var(--line-strong); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.side-opt:hover { border-color: var(--text-3); background: var(--bg-3); }
.side-opt { border-radius: var(--radius-lg); }
.side-opt[aria-pressed="true"] { border-color: var(--navy); background: var(--navy-dim); box-shadow: inset 0 0 0 1px var(--navy); }
.side-opt .n { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-md); }
.side-opt .d { font-size: var(--fs-xs); color: var(--text-2); line-height: 1.5; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step { display: none; }
.step.is-active { display: grid; gap: var(--sp-4); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { padding: 12px 16px; border-radius: 4px; background: #323232; color: #ffffff; border: 0; font-size: var(--fs-sm); box-shadow: var(--shadow-md); animation: toastin var(--dur-med) var(--ease-out); display: flex; gap: 10px; align-items: center; max-width: 360px; }
.toast.ok .od-icon { color: #81c995; }
.toast.warn .od-icon { color: #fdd663; }
.toast.bad .od-icon { color: #f28b82; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes modalin { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rowin { from { background: var(--warn-dim); } to { background: transparent; } }
@keyframes dash { to { stroke-dashoffset: -12; } }
@keyframes ringpulse { 0%, 100% { stroke-opacity: 1; } 50% { stroke-opacity: 0.4; } }
@keyframes encrypt { 0% { transform: translateX(0); filter: blur(0); } 40% { transform: translateX(6px); filter: blur(2px); } 100% { transform: translateX(0); filter: blur(0); } }

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  :root { --side-w: 300px; }
  .box-status { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .plan-layout { grid-template-columns: minmax(0,1fr) 260px; }
}
@media (max-width: 1024px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .party { position: absolute; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 20; transform: translateX(-100%); transition: transform var(--dur-med) var(--ease-out); }
  .party[data-side="alice"] { left: 0; }
  .party[data-side="openbrain"] { right: 0; transform: translateX(100%); }
  .party.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .drawer-toggle { display: inline-flex; }
  .topbar-center { justify-content: flex-start; }
  .plan-layout, .invite-grid, .attest-grid, .submissions, .outputs { grid-template-columns: minmax(0,1fr); }
  .comments { position: static; }
  .guarantees { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-session, .attest-pill .label, .seg .seg-label { display: none; }
  .seg .seg-short { display: inline; }
  .tab-panel { padding: var(--sp-4); }
  .modal { padding: var(--sp-5); }
  .side-grid, .agent-grid, .appeal-options, .signoff .sigs, .party-status { grid-template-columns: minmax(0,1fr); }
  .box-status { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .doc { padding: var(--sp-4); }
  .kv { grid-template-columns: minmax(0,1fr); }
}
