/* Patent Assassin workbench. Light only. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sunk: #efece5;
  --ink: #16181b;
  --ink-2: #3d4248;
  --muted: #6b7077;
  --faint: #9a9da2;
  --line: #e3dfd6;
  --line-2: #d2ccbf;

  --accent: #0e5a5f;
  --accent-ink: #0a4549;
  --accent-tint: #e6efee;
  --accent-line: #b9d1cf;

  --ok: #2e6a4c;
  --ok-tint: #e5efe8;
  --ok-line: #bcd5c5;
  --high: #7a4311;
  --high-tint: #f5e9da;
  --high-line: #e3c8a6;
  --med: #896812;
  --med-tint: #f4eed9;
  --med-line: #dfd1a4;
  --low: #4b5967;
  --low-tint: #e9ecf0;
  --low-line: #cbd2da;

  --r: 7px;
  --r-s: 6px;
  --shadow: 0 1px 2px rgba(22, 24, 27, 0.04), 0 1px 1px rgba(22, 24, 27, 0.03);
  --sans: "Inter", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --t: 150ms ease;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0 0 0.75em; }
img, iframe { max-width: 100%; }
::selection { background: #cfe1df; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; margin: 8px 0 0; }
.ta-r { text-align: right; }
.cap::first-letter { text-transform: uppercase; }
.inline { display: inline; margin: 0; }
.sep { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--faint); margin: 0 9px; vertical-align: middle; }
.row-gap { display: flex; gap: 8px; align-items: center; }
.wrap-row { flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.stack-s > * + * { margin-top: 12px; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 28px; }
.main { padding-top: 28px; padding-bottom: 80px; }
.narrow { max-width: 560px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark svg { width: 24px; height: 24px; display: block; }
.brand-mark rect { fill: var(--accent); }
.brand-mark path { fill: none; stroke: var(--bg); stroke-width: 2.6; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav-link { color: var(--ink-2); padding: 6px 10px; border-radius: var(--r-s); font-weight: 500; font-size: 13.5px; }
.nav-link:hover { background: var(--sunk); color: var(--ink); text-decoration: none; }
.nav-link.is-active { color: var(--ink); }
.nav-btn { background: none; border: 0; font: inherit; cursor: pointer; }
.demo-strip { background: var(--med-tint); color: var(--med); border-bottom: 1px solid var(--med-line); font-size: 12px; text-align: center; padding: 5px 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: 500 13.5px/1 var(--sans); white-space: nowrap; cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); border-color: #bfb8aa; text-decoration: none; color: var(--ink); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .subtab:focus-visible, .linklike:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunk); border-color: transparent; }
.btn.btn-quiet { color: var(--muted); padding-left: 0; }
.btn.btn-quiet:hover { background: transparent; color: var(--high); }
.btn-warn { background: var(--high); border-color: var(--high); color: #fff; }
.btn-warn:hover { background: #643609; border-color: #643609; color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-s); }
.btn-block { width: 100%; }
.btn.is-busy { pointer-events: none; opacity: 0.8; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; text-underline-offset: 2px; }

/* type */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-family: var(--serif); font-size: 30px; line-height: 1.15; font-weight: 600; }
.page-sub { color: var(--muted); margin: 6px 0 0; font-size: 13.5px; }
.crumbs { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; overflow-wrap: anywhere; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.lede { color: var(--ink-2); font-size: 15px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }

/* alerts */
.alert { border: 1px solid; border-radius: var(--r); padding: 10px 14px; margin: 0 0 16px; font-size: 13.5px; }
.alert-err { background: var(--high-tint); border-color: var(--high-line); color: var(--high); }
.alert-warn { background: var(--med-tint); border-color: var(--med-line); color: #6e540e; }
.alert-info { background: var(--accent-tint); border-color: var(--accent-line); color: var(--accent-ink); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 5px; font-size: 12px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
.st-done, .st-complete { color: var(--ok); background: var(--ok-tint); border-color: var(--ok-line); }
.st-running, .st-queued { color: var(--accent); background: var(--accent-tint); border-color: var(--accent-line); }
.st-failed { color: var(--high); background: var(--high-tint); border-color: var(--high-line); }
.st-needs_input, .st-stale { color: #6e540e; background: var(--med-tint); border-color: var(--med-line); }
.st-ready, .st-new, .st-pending, .st-skipped { color: var(--low); background: var(--low-tint); border-color: var(--low-line); }
.lvl { display: inline-block; font: 600 10.5px/1 var(--sans); letter-spacing: 0.06em; padding: 4px 6px; border-radius: 4px; border: 1px solid; }
.lv-high { color: var(--high); background: var(--high-tint); border-color: var(--high-line); }
.lv-med { color: #7a5c0c; background: var(--med-tint); border-color: var(--med-line); }
.lv-low { color: var(--low); background: var(--low-tint); border-color: var(--low-line); }
.badge-ok, .badge-dim { display: inline-block; font: 500 10.5px/1 var(--sans); padding: 3px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.badge-ok { color: var(--ok); background: var(--ok-tint); }
.badge-dim { color: var(--muted); background: var(--sunk); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: var(--sunk); color: var(--ink-2); margin: 0 4px 4px 0; }
.tags { display: inline-flex; flex-wrap: wrap; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; font: 14px/1.5 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 8px 11px; transition: border-color var(--t), box-shadow var(--t);
}
input[type=text], input[type=password], input[type=search], select { height: 36px; padding-top: 0; padding-bottom: 0; }
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 90, 95, 0.12); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
::placeholder { color: var(--faint); }
.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.label { display: block; font-weight: 500; font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.hint { display: block; color: var(--muted); font-size: 12.5px; margin: -2px 0 6px; }
.mono-area, .code-area { font: 12.5px/1.6 var(--mono); }
.code-area { background: var(--surface-2); tab-size: 2; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.segmented { display: inline-flex; padding: 3px; background: var(--sunk); border-radius: 8px; margin-bottom: 20px; gap: 2px; }
.seg { padding: 6px 14px; border-radius: 6px; color: var(--ink-2); font-weight: 500; font-size: 13.5px; }
.seg:hover { text-decoration: none; color: var(--ink); }
.seg.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.fsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 22px 6px; margin-bottom: 16px; }
.fsec-title { font-family: var(--serif); font-size: 18px; margin-bottom: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.form-side .panel { padding: 18px; }
.panel-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 14px; }
.sticky { position: sticky; top: 76px; }
.radio, .toggle { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; cursor: pointer; transition: border-color var(--t), background var(--t); }
.radio:hover, .toggle:hover { border-color: var(--line-2); }
.radio:has(input:checked) { border-color: var(--accent-line); background: var(--accent-tint); }
.radio input { margin-top: 3px; accent-color: var(--accent); }
.radio strong, .toggle strong { display: block; font-weight: 500; font-size: 13.5px; }
.radio small, .toggle small { display: block; color: var(--muted); font-size: 12px; line-height: 1.4; }
.toggle { margin: 4px 0 16px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-ui { flex: 0 0 auto; width: 30px; height: 18px; border-radius: 5px; background: var(--line-2); position: relative; margin-top: 2px; transition: background var(--t); }
.toggle-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 4px; background: #fff; transition: transform var(--t); box-shadow: 0 1px 1px rgba(0,0,0,.15); }
.toggle input:checked + .toggle-ui { background: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(12px); }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.side-stages { margin: 4px 0 16px; }
.mini-steps { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-wrap: wrap; gap: 4px; }
.mini-steps li { counter-increment: s; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.mini-steps li::before { content: counter(s, decimal-leading-zero) " "; font-family: var(--mono); color: var(--faint); font-size: 11px; }
.form-side .btn + .btn { margin-top: 8px; }

.drop { display: flex; align-items: center; gap: 10px; border: 1px dashed var(--line-2); border-radius: var(--r); padding: 8px; background: var(--surface-2); cursor: pointer; min-width: 0; transition: border-color var(--t), background var(--t); }
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-tint); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-btn { flex: 0 0 auto; height: 28px; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--surface); font-weight: 500; font-size: 12.5px; }
.drop-names { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.drop.has-files .drop-names { color: var(--ink); }

/* auth */
.is-auth .main { display: flex; justify-content: center; padding-top: 12vh; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px; box-shadow: var(--shadow); }
.auth-title { font-family: var(--serif); font-size: 24px; margin-bottom: 6px; }
.auth-card form { margin-top: 20px; }
.setup-list { margin: 16px 0; }
.setup-list div { display: grid; grid-template-columns: 170px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.setup-list dt { font-weight: 500; }
.setup-list dd { margin: 0; color: var(--ink-2); }

/* matters list */
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters input { max-width: 320px; }
.filters select { max-width: 200px; }
.mtable { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) 120px 170px 120px 90px 80px; gap: 16px; align-items: center; padding: 13px 18px; border-top: 1px solid var(--line); color: var(--ink); transition: background var(--t); }
a.mrow:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.mrow.mhead { border-top: 0; padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.m-title { min-width: 0; }
.m-title .t { display: block; font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-title .v { display: block; color: var(--muted); font-size: 12.5px; }
.m-mode, .m-upd { color: var(--ink-2); font-size: 13px; }
.m-stage { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.segbar { display: flex; gap: 3px; }
.segbar i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); max-width: 22px; }
.segbar i.on { background: var(--accent); }
.empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r); padding: 48px 24px; text-align: center; }
.empty .row-gap { justify-content: center; margin-top: 14px; }
.empty-title { font-family: var(--serif); font-size: 20px; margin-bottom: 6px; }
.empty-note { color: var(--muted); padding: 14px 0; margin: 0; }

/* matter page */
.mhead-wrap { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 16px; }
.mhead-l { min-width: 0; }
.matter-title { font-family: var(--serif); font-size: 28px; line-height: 1.2; font-weight: 600; overflow-wrap: anywhere; }
.mhead-r { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.cost-total { color: var(--ink-2); font-size: 14px; }
.actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0 18px; border-top: 1px solid var(--line); }
.runline { color: var(--ink-2); font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; margin-left: 6px; }
.done-line { margin-left: 0; margin-right: 8px; color: var(--ok); font-weight: 500; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--accent-line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }

.stepper { list-style: none; margin: 0 0 22px; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.step-a { position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink); overflow: hidden; height: 100%; transition: border-color var(--t), background var(--t), box-shadow var(--t); }
.step-a:hover { text-decoration: none; border-color: var(--line-2); color: var(--ink); }
.step.is-sel .step-a { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.step-n { color: var(--faint); font-size: 11.5px; padding-top: 1px; }
.step-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.step-name { font-weight: 600; font-size: 13.5px; }
.step-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); white-space: nowrap; }
.step-cost { font-size: 11px; color: var(--faint); }
.step-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.step.st-done .step-bar { background: var(--ok); }
.step.st-done .step-st { color: var(--ok); }
.step.st-failed .step-bar { background: var(--high); }
.step.st-failed .step-st { color: var(--high); }
.step.st-needs_input .step-bar, .step.st-stale .step-bar { background: var(--med); }
.step.st-needs_input .step-st, .step.st-stale .step-st { color: #7a5c0c; }
.step.st-skipped .step-a { background: var(--surface-2); }
.step.st-skipped .step-name { color: var(--muted); }
.step.st-queued .step-st, .step.st-running .step-st { color: var(--accent); }
.step.st-queued .step-bar { background: var(--accent-line); }
.step.st-running .step-bar, .shimmer {
  background: linear-gradient(90deg, var(--accent-line) 0%, var(--accent) 35%, var(--accent-line) 70%);
  background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
.step.st-running .step-a { background: linear-gradient(180deg, var(--surface) 0%, #f4f8f7 100%); }

.mgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.mmain { min-width: 0; }
.mside { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.out-panel { padding: 22px 24px 24px; }
.out-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.out-title { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.out-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 0; color: var(--muted); font-size: 12.5px; }
.sub-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.working { padding: 8px 0 4px; }
.working .shimmer { height: 4px; border-radius: 2px; margin-bottom: 12px; }

.confirm-wrap { position: relative; flex: 0 0 auto; }
.confirm-box { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 280px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 12px 14px; box-shadow: 0 6px 20px rgba(22, 24, 27, 0.08); font-size: 13px; }
.mside .confirm-box { position: static; width: auto; margin-top: 8px; box-shadow: none; }

.panel-ask { padding: 20px 22px; margin-bottom: 16px; border-color: var(--med-line); background: #fffdf7; }
.panel-head { margin-bottom: 14px; }
.panel-h { font-family: var(--serif); font-size: 19px; margin-bottom: 4px; }
.q-label { display: flex; gap: 10px; font-weight: 500; }
.q-n { color: var(--med); font-size: 12px; padding-top: 1px; }

.side-panel { padding: 14px 16px; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.log { margin: 0; max-height: 300px; min-height: 80px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; font: 11.5px/1.65 var(--mono); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.usage { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.usage th { text-align: left;
}
.usage th.ta-r { text-align: right; }
.usage th { font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 0 0 6px; }
.usage td { padding: 5px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.usage .mono { font-size: 11.5px; }
.vers { list-style: none; margin: 0; padding: 0; }
.vers a { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; padding: 6px 6px; margin: 0 -6px; border-radius: var(--r-s); color: var(--ink-2); font-size: 12.5px; }
.vers a:hover { background: var(--sunk); text-decoration: none; color: var(--ink); }
.vers li.is-on a { background: var(--accent-tint); color: var(--accent-ink); }
.vers-o { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vers-t { color: var(--faint); }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink-2); text-align: right; }
.side-links { margin: 10px 0 4px; font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; padding: 8px 8px 8px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13.5px; }

/* outputs */
.details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 500; list-style: none; }
.details summary::-webkit-details-marker { display: none; }
.details summary::before { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); margin-right: 9px; vertical-align: 2px; transition: transform var(--t); }
.details[open] summary::before { transform: rotate(45deg); vertical-align: 3px; }
.details > *:not(summary) { margin-top: 12px; }
.raw { margin-top: 24px; }
.pre { margin: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px 14px; font: 12px/1.6 var(--mono); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow: auto; }
.pre-tall { max-height: 70vh; }

.prose { font-size: 14.5px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { font-family: var(--serif); margin: 1.1em 0 0.4em; }
.prose h1 { font-size: 22px; } .prose h2 { font-size: 19px; } .prose h3 { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--sunk); padding: 1px 4px; border-radius: 3px; }

.cols-2-1 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; }
.box { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface-2); margin-bottom: 12px; }
.box-note { background: #fffdf7; border-color: var(--med-line); }
.box-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.feat { list-style: none; margin: 0; padding: 0; }
.feat li { display: grid; grid-template-columns: 34px 1fr; gap: 6px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.feat li:first-child { border-top: 0; }
.plain { margin: 0; padding-left: 1.1em; font-size: 13.5px; }
.plain li + li { margin-top: 3px; }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 6px 0 18px; }
.stat { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; background: var(--surface-2); }
.stat-n { display: block; font-size: 22px; font-weight: 500; color: var(--ink); }
.stat-l { color: var(--muted); font-size: 12px; }

.rtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rtable th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.rtable td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rtable td:first-child, .rtable th:first-child { padding-left: 0; }
.r-doc { min-width: 0; }
.r-num { font-weight: 500; }
.r-title { font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.r-teach { color: var(--ink-2); margin-top: 4px; }
.threat { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.label-inline { color: var(--muted); margin-right: 6px; }

.verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; border: 1px solid; border-radius: var(--r); padding: 14px 18px; margin-bottom: 16px; }
.verdict-l { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; opacity: 0.8; }
.verdict-v { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.verdict-x { font-size: 12.5px; margin-left: auto; }
.v-ok { color: var(--ok); background: var(--ok-tint); border-color: var(--ok-line); }
.v-med { color: #6e540e; background: var(--med-tint); border-color: var(--med-line); }
.v-high { color: var(--high); background: var(--high-tint); border-color: var(--high-line); }
.v-low { color: var(--low); background: var(--low-tint); border-color: var(--low-line); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 4px; }
.card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface); }
.card-h { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.card-h .tag { margin: 0; }
.card-t { flex: 1; min-width: 0; font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-s { border-top: 1px solid var(--line); padding-top: 9px; margin-top: 9px; font-size: 13.5px; }
.card-sh { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin-bottom: 5px; font-weight: 600; }
.kvs { margin: 0; }
.kv { margin-bottom: 6px; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.vlist { margin: 0; padding-left: 1.1em; }
.vstack { display: grid; gap: 8px; }
.vcard { border-left: 2px solid var(--line); padding-left: 10px; }

.audit-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; margin-bottom: 8px; align-items: stretch; }
.audit-top .verdict { margin: 0; flex-direction: column; gap: 4px; justify-content: center; }
.audit-top .verdict-x { margin-left: 0; }
.scores { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: grid; gap: 7px; }
.score { display: grid; grid-template-columns: 52px 1fr 40px; gap: 10px; align-items: center; }
.score-k { color: var(--ink-2); font-size: 12px; }
.score-v { text-align: right; font-size: 12px; color: var(--ink-2); }
.score-bar { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.score-bar i { display: block; height: 100%; border-radius: 3px; transition: width 300ms ease; }
.sb-ok { background: var(--accent); }
.sb-med { background: #b38c22; }
.sb-low { background: var(--high); }
.fgroup { margin-top: 18px; }
.fgroup-h { display: flex; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 8px; }
.findings { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.findings li { padding: 10px 14px; border-top: 1px solid var(--line); }
.findings li:first-child { border-top: 0; }
.findings p { margin: 3px 0 0; font-size: 13.5px; color: var(--ink-2); }
.f-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.f-check { font-weight: 500; }
.f-loc { color: var(--muted); font-size: 11.5px; text-align: right; }

/* draft document preview */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; overflow-x: auto; }
.subtab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; margin-bottom: -1px; font: 500 13.5px var(--sans); color: var(--muted); cursor: pointer; white-space: nowrap; transition: color var(--t), border-color var(--t); }
.subtab:hover:not(:disabled) { color: var(--ink); }
.subtab.is-on { color: var(--ink); border-bottom-color: var(--ink); }
.subtab:disabled { opacity: 0.45; cursor: default; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.paper { background: #fffefc; border: 1px solid var(--line); border-radius: var(--r-s); padding: 44px 56px; max-height: 78vh; overflow-y: auto; box-shadow: inset 0 1px 0 #fff; }
.doc { font-family: var(--serif); font-size: 15px; line-height: 1.7; color: #1b1c1e; max-width: 720px; margin: 0 auto; }
.doc-title { font-family: var(--serif); font-size: 16px; text-align: center; font-weight: 600; letter-spacing: 0.02em; line-height: 1.45; margin: 0 0 26px; }
.doc-head { font-family: var(--serif); font-size: 14.5px; text-align: center; font-weight: 600; letter-spacing: 0.04em; margin: 26px 0 12px; }
.doc-break { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.doc-sub { font-family: var(--serif); font-size: 15px; font-weight: 600; margin: 18px 0 8px; }
.doc-lead { margin: 0 0 12px; }
.para { margin: 0 0 12px; text-align: left; }
.pnum { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-right: 10px; }
.claim { display: grid; grid-template-columns: 30px 1fr; gap: 4px; margin: 0 0 14px; }
.claim.dep { margin-left: 22px; }
.cnum { font-weight: 600; }
.cbody p { margin: 0 0 4px; }
.ccont { padding-left: 24px; }
.abstract { text-indent: 0; }
.numerals { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 18px; font-size: 13px; }
.numerals div { display: flex; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.numerals .mono { color: var(--accent); min-width: 34px; }
.note-input { flex: 1; min-width: 200px; }

.fig-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.pdf-frame { border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; display: flex; flex-direction: column; background: var(--sunk); min-height: 520px; }
.pdf-frame iframe { flex: 1; width: 100%; min-height: 520px; border: 0; background: #fff; }
.pdf-tall, .pdf-tall iframe { min-height: 720px; }
.pdf-bar { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pdf-empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }

.pkg { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; }
.pkg-list .btn-block { margin-bottom: 12px; }
.files { list-style: none; margin: 0 0 14px; padding: 0; }
.files li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.files li:first-child { border-top: 0; }
.files-pkg li { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 7px 8px; margin: 0 -8px; border-radius: var(--r-s); border-top: 0; }
.files-pkg li.is-on { background: var(--accent-tint); }
.files-pkg .linklike, .files li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ftype { font-size: 10px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 0; text-align: center; background: var(--surface); }
.intake { margin: 0; }
.intake > div { padding: 12px 0; border-top: 1px solid var(--line); }
.intake > div:first-child { border-top: 0; padding-top: 0; }
.intake dt { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.intake dd { margin: 0; overflow-wrap: anywhere; }

/* versions */
.vgrid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.vgrid .side-title { margin-bottom: 8px; }
.diff { margin: 0; font: 12px/1.6 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 0; max-height: 75vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff span { display: block; padding: 0 14px; }
.d-add { background: var(--ok-tint); color: #24563d; }
.d-del { background: var(--high-tint); color: var(--high); }
.d-hunk { color: var(--accent); background: var(--accent-tint); margin-top: 6px; }
.d-ctx { color: var(--muted); }

/* responsive */
@media (max-width: 1080px) {
  .mgrid { grid-template-columns: minmax(0, 1fr); }
  .mside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mrow { grid-template-columns: minmax(0, 1fr) 150px 110px 80px 70px; }
  .mrow .m-mode, .mhead > div:nth-child(2) { display: none; }
}
@media (max-width: 860px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .stepper { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-2-1, .fig-grid, .pkg, .audit-top, .vgrid { grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 28px 26px; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 16px; }
  .main { padding-top: 20px; }
  .brand-name { font-size: 16.5px; }
  .nav { gap: 2px; }
  .nav-link { padding: 6px 8px; }
  .nav > .nav-link:first-child { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn, .page-head form .btn { width: 100%; }
  .page-title { font-size: 26px; }
  .matter-title { font-size: 23px; }
  .mhead-wrap { flex-direction: column; align-items: flex-start; gap: 10px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .filters { flex-wrap: wrap; }
  .filters input { max-width: none; flex: 1 1 100%; }
  .filters select { max-width: none; flex: 1 1 auto; width: auto; }
  .mrow.mhead { display: none; }
  .mrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title status" "stage cost"; gap: 8px 12px; padding: 14px 16px; }
  .m-title { grid-area: title; }
  .m-status { grid-area: status; justify-self: end; }
  .m-stage { grid-area: stage; flex-direction: row; align-items: center; gap: 10px; }
  .m-stage .segbar { flex: 0 0 84px; }
  .m-cost { grid-area: cost; align-self: center; }
  .m-upd { display: none; }
  .stepper { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .step-a { align-items: center; padding: 9px 12px 11px; }
  .step-body { flex-direction: row; justify-content: space-between; align-items: baseline; flex: 1; gap: 8px; }
  .mside { display: flex; }
  .actionbar .btn, .actionbar form { flex: 1 1 auto; }
  .actionbar form .btn { width: 100%; }
  .runline { margin-left: 0; width: 100%; }
  .out-panel { padding: 16px; }
  .out-head { flex-direction: column; }
  .confirm-box { position: static; width: auto; margin-top: 8px; box-shadow: none; }
  .fsec { padding: 18px 16px 4px; }
  .paper { padding: 20px 16px; max-height: none; }
  .doc { font-size: 14.5px; }
  .claim.dep { margin-left: 10px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; }
  .rtable td { border: 0; padding: 3px 0; display: flex; gap: 10px; }
  .rtable td::before { content: attr(data-label); flex: 0 0 72px; color: var(--muted); font-size: 12px; font-family: var(--sans); text-transform: none; letter-spacing: 0; }
  .rtable td.r-doc { display: block; }
  .rtable td.r-doc::before { display: block; margin-bottom: 2px; }
  .pdf-frame, .pdf-frame iframe, .pdf-tall, .pdf-tall iframe { min-height: 420px; }
  .auth-card { padding: 24px 20px; }
  .is-auth .main { padding-top: 6vh; }
  .setup-list div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .code-area { font-size: 12px; }
  .toast { left: 16px; right: 16px; transform: none; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
