/* ---- fonts (SIL Open Font License, see /fonts/LICENSE.txt) ---- */
@font-face { font-family: 'Plex Sans'; src: url('/fonts/plex-sans-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Sans'; src: url('/fonts/plex-sans-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Sans'; src: url('/fonts/plex-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/fonts/newsreader-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/fonts/newsreader-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('/fonts/newsreader-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Courier Prime'; src: url('/fonts/courier-prime-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Courier Prime'; src: url('/fonts/courier-prime-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --ink: #16171a;
  --ink-2: #3b3d42;
  --muted: #74767c;
  --faint: #a4a5a9;
  --line: #e4e1db;
  --line-2: #efece7;
  --hover: #faf9f6;
  --night: #121315;
  --night-2: #1c1d20;
  --night-line: #2a2b2f;
  --tungsten: #e0a43c;
  --tungsten-ink: #8f5f12;
  --tungsten-wash: #fbf1df;
  --red: #b4372b;
  --red-wash: #fbeceb;
  --green: #3c7a4a;
  --green-wash: #e9f3eb;
  --blue-wash: #edf0f6;
  --sans: 'Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --mono: 'Courier Prime', 'Courier New', monospace;
  --radius: 4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
h3 { font-size: 15px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--line-2); padding: 1px 5px; border-radius: 3px; }
small { font-size: 12px; color: var(--muted); }
[hidden] { display: none !important; }
svg.i, nav svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.nowrap { white-space: nowrap; }
.loading { color: var(--muted); padding: 60px 0; font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.empty { color: var(--muted); padding: 22px 0; margin: 0; font-size: 13.5px; }
.card.flush .empty, .panel .empty { padding: 18px 20px; }
.eyebrow { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }

/* ---- layout ---- */
#app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--night); color: #c9c8c4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid #000; }
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 22px 28px; color: #fff; text-decoration: none; }
.brand .mark { width: 30px; height: 30px; color: var(--tungsten); flex: none; }
.wordmark { font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1; letter-spacing: .01em; display: flex; flex-direction: column; gap: 5px; }
.wordmark small { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: #8b8a86; }
.sidebar nav { display: flex; flex-direction: column; padding: 0 12px; gap: 1px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; color: #a9a8a4; padding: 9px 12px; border-radius: var(--radius); text-decoration: none; font-size: 13.5px; position: relative; }
.sidebar nav a:hover { color: #fff; background: var(--night-2); }
.sidebar nav a.active { color: #fff; background: var(--night-2); }
.sidebar nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; background: var(--tungsten); border-radius: 0 2px 2px 0; }
.sidebar nav a.active svg { color: var(--tungsten); }
.nav-sep { height: 1px; background: var(--night-line); margin: 12px; }
.user-box { margin-top: auto; padding: 16px 22px; border-top: 1px solid var(--night-line); display: flex; gap: 12px; align-items: center; font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--night-2); border: 1px solid var(--night-line); color: var(--tungsten); display: grid; place-items: center; font-family: var(--mono); font-size: 12px; font-weight: 700; flex: none; }
.who { display: flex; flex-direction: column; color: #e9e8e4; min-width: 0; }
.who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .link { color: #8b8a86; padding: 0; font-size: 12px; text-align: left; }
.who .link:hover { color: #fff; }

#main { padding: 40px 48px 80px; max-width: 1480px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 32px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--serif); font-size: 36px; font-weight: 400; line-height: 1.1; letter-spacing: -.012em; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-head .sub { margin: 8px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 40px 0 14px; display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.section-title .more { font-family: var(--sans); text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h3 { margin-bottom: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.split.wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
.split > .card { margin-bottom: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 170px; }

/* ---- buttons ---- */
button, .button { font: inherit; font-size: 13.5px; font-weight: 500; border: 1px solid transparent; border-radius: var(--radius); padding: 8px 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; line-height: 1.25; text-decoration: none; white-space: nowrap; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.primary:hover:not(:disabled) { background: #000; }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover:not(:disabled) { border-color: var(--faint); }
.ghost { background: none; color: var(--ink-2); border-color: transparent; padding-left: 0; }
.ghost:hover { color: var(--ink); }
.danger { background: var(--red); color: #fff; }
.danger-outline { background: var(--surface); color: var(--red); border-color: #ecc9c5; }
.danger-outline:hover:not(:disabled) { background: var(--red-wash); }
button.small, .button.small { padding: 4px 10px; font-size: 12.5px; }
button.icon { background: none; border: 0; padding: 6px; color: var(--muted); }
button.icon:hover { color: var(--ink); }
button.link { background: none; border: 0; cursor: pointer; }
.icon-only { padding: 8px 10px; }

details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(20, 20, 20, .12); min-width: 200px; padding: 6px; z-index: 20; display: flex; flex-direction: column; }
.menu-list button { background: none; border: 0; text-align: left; padding: 8px 10px; font-weight: 400; color: var(--ink); }
.menu-list button:hover { background: var(--hover); }
.menu-list .danger-text { color: var(--red); }

/* ---- forms ---- */
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); width: 100%; transition: border-color .12s; }
input:hover, select:hover, textarea:hover { border-color: #d6d2ca; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(224, 164, 60, .22); }
input[type=checkbox] { width: auto; accent-color: var(--ink); }
select { appearance: none; padding-right: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2374767c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center; }
input[disabled] { background: var(--line-2); color: var(--muted); }
.search { position: relative; display: flex; align-items: center; min-width: 320px; }
.search svg { position: absolute; left: 11px; color: var(--muted); }
.search input { padding-left: 34px; }
fieldset { border: 0; padding: 0; margin: 0 0 28px; }
legend { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; padding: 0 0 8px; width: 100%; border-bottom: 1px solid var(--line-2); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field.full { grid-column: 1 / -1; }
.field > a.small { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--ink-2); font-size: 13px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.kv-row { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 8px; margin-bottom: 8px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding: 12px 16px; background: var(--surface); }
.table td { border-bottom: 1px solid var(--line-2); padding: 13px 16px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 9px 16px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--hover); }
.table td a { text-decoration: none; font-weight: 500; }
.table td.mono a { font-weight: 700; }
.table .title-link { font-family: var(--serif); font-size: 17px; font-weight: 400; }
.table del { color: var(--red); }
.table ins { color: var(--green); text-decoration: none; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }

/* ---- status, badges, alerts ---- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); white-space: nowrap; font-family: var(--sans); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.status-sent i { background: var(--tungsten); box-shadow: 0 0 0 3px var(--tungsten-wash); }
.status-signed i { background: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.status-terminated i, .status-cancelled i { background: var(--red); }
.status-terminated, .status-cancelled { color: var(--muted); }
.badge { display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; padding: 2px 8px; border-radius: 3px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; font-weight: 400; }
h1 .badge { font-size: 12px; }
.badge.ok { background: var(--green-wash); color: var(--green); }
.badge.warn { background: var(--tungsten-wash); color: var(--tungsten-ink); }
.count { font-family: var(--mono); color: var(--muted); font-size: 12px; }

.alert { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--faint); font-size: 13.5px; }
.alert.error { border-left-color: var(--red); background: var(--red-wash); border-color: #f0d3cf; color: #7d2219; }
.alert.warn { border-left-color: var(--tungsten); background: var(--tungsten-wash); border-color: #f0dfbf; color: #5d3e0a; }
.alert.ok { border-left-color: var(--green); background: var(--green-wash); border-color: #cfe3d3; color: #24502e; }
.alert.info { border-left-color: var(--ink); background: var(--blue-wash); border-color: #dde2ec; color: var(--ink); }
.alert .table { margin: 10px 0; background: rgba(255, 255, 255, .7); }
.alert .table th, .alert .table td { padding: 7px 10px; background: none; }
.alert code { background: rgba(255, 255, 255, .6); }
.error { color: var(--red); }

/* ---- overview ---- */
.figures { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.figures a { padding: 18px 20px; text-decoration: none; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line-2); }
.figures a:first-child { padding-left: 0; }
.figures a:last-child { border-right: 0; }
.figures b { font-family: var(--serif); font-weight: 400; font-size: 38px; letter-spacing: -.01em; line-height: 1; }
.figures span { font-size: 12.5px; color: var(--muted); }
.figures a:hover b { color: var(--tungsten-ink); }

.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.prod-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; transition: border-color .15s; }
.prod-card:hover { border-color: var(--ink); }
.prod-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-bottom: 6px; }
.prod-top .eyebrow { margin: 0; color: var(--ink); }
.prod-card h3 { font-family: var(--serif); font-size: 24px; font-weight: 400; line-height: 1.1; }
.prod-card p { margin: 0 0 10px; font-size: 13px; }
.rec { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; box-shadow: 0 0 0 3px var(--red-wash); }
.progress { height: 3px; background: var(--line-2); border-radius: 2px; overflow: hidden; margin-top: auto; }
.progress span { display: block; height: 100%; background: var(--tungsten); }
.prod-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 8px; }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line-2); }
.rows a { display: grid; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center; padding: 12px 20px; text-decoration: none; }
.rows a:hover { background: var(--hover); }
.rows .num { font-weight: 700; font-size: 13px; }
.rows .who { display: flex; flex-direction: column; min-width: 0; color: var(--ink); }
.rows .who b { font-weight: 500; }
.rows .who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .meta { font-size: 12.5px; color: var(--muted); font-family: var(--mono); }

/* ---- slate (contract header) ---- */
.slate { background: var(--night); color: #e9e8e4; border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.slate-stripes { height: 14px; background: repeating-linear-gradient(-55deg, #f2f0eb 0 18px, var(--night) 18px 36px); }
.slate-grid { display: grid; grid-template-columns: 2fr 2fr 1fr; margin: 0; }
.slate-grid > div { padding: 14px 20px; border-right: 1px solid var(--night-line); border-bottom: 1px solid var(--night-line); min-width: 0; }
.slate-grid > div:nth-child(3n) { border-right: 0; }
.slate-grid > div:nth-last-child(-n+3) { border-bottom: 0; }
.slate-grid dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #8b8a86; margin-bottom: 4px; }
.slate-grid dd { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.slate-grid dd a { color: #fff; text-decoration-color: #555; }
.slate-grid dd small { color: #8b8a86; }
.slate .status { color: #e9e8e4; }
.slate .status-sent i { box-shadow: 0 0 0 3px rgba(224, 164, 60, .2); }
.slate .status-signed i { box-shadow: 0 0 0 3px rgba(60, 122, 74, .3); }

/* ---- templates ---- */
.script-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.script { aspect-ratio: 8.5 / 11; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; padding: 26px 22px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; text-decoration: none; font-family: var(--mono); box-shadow: 0 1px 0 var(--line), 0 6px 18px -12px rgba(0, 0, 0, .25); transition: transform .15s, box-shadow .15s; }
.script:hover { transform: translateY(-2px); box-shadow: 0 1px 0 var(--line), 0 14px 28px -16px rgba(0, 0, 0, .35); }
.script-type { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.script-title { margin-top: auto; font-size: 17px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.35; }
.script-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.5; }
.script-foot { margin-top: auto; width: 100%; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 10px; }

.editor-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor-grid > .card { margin-bottom: 20px; padding: 20px; }
.vars { max-height: 78vh; overflow: auto; position: sticky; top: 16px; }
.vars h3 { margin-bottom: 4px; }
.var-group h4 { margin: 16px 0 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 400; text-transform: uppercase; color: var(--muted); letter-spacing: .14em; }
.var-btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 3px 6px; font-family: var(--mono); font-size: 12.5px; font-weight: 400; color: var(--ink-2); border-radius: 3px; }
.var-btn:hover { background: var(--tungsten-wash); color: var(--ink); }
.editor .row, .preview-pane .row { margin-bottom: 12px; }
.editor textarea { font-family: var(--mono); font-size: 13px; line-height: 1.6; min-height: 70vh; resize: vertical; background: #fdfcfa; }
.preview-pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.preview-pane > h3 { margin-bottom: 12px; }
.preview-controls { display: flex; gap: 6px; }
.preview-controls select { width: auto; max-width: 180px; font-size: 12.5px; padding: 5px 28px 5px 8px; background-position: right 8px center; }
.save-bar { display: flex; gap: 10px; position: sticky; bottom: 16px; z-index: 5; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .2); padding: 14px 16px; }
.help summary { cursor: pointer; color: var(--ink-2); font-size: 12.5px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.help ul { margin: 10px 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.help li { margin-bottom: 5px; }
pre.code { background: #fdfcfa; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; max-height: 70vh; overflow: auto; }

/* ---- contract document ---- */
.paper { background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 0 var(--line), 0 18px 40px -28px rgba(0, 0, 0, .3); padding: 56px 64px; font-family: Charter, 'Iowan Old Style', Georgia, serif; font-size: 14.5px; line-height: 1.65; max-width: 820px; color: #1b1b1b; }
.paper h1 { font-family: var(--serif); font-weight: 500; font-size: 25px; text-align: center; line-height: 1.15; margin-bottom: 22px; }
.paper h2 { font-size: 15px; font-weight: 700; margin: 26px 0 6px; }
.paper h3 { font-size: 14.5px; font-weight: 700; margin: 20px 0 4px; }
.paper p { margin: 0 0 11px; }
.small-paper { padding: 28px 30px; font-size: 13px; }
.small-paper h1 { font-size: 21px; }
.var { background: #f4efe4; border-radius: 2px; box-shadow: 0 0 0 1px #f4efe4; }
.var.missing { background: var(--red-wash); box-shadow: 0 0 0 1px #f0cfcb; color: var(--red); font-family: var(--mono); font-size: .85em; padding: 0 3px; }
.page-break { border-top: 1px dashed var(--faint); margin: 24px 0; }

.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs a { padding: 10px 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; font-size: 13.5px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tabs a:hover { color: var(--ink); }

pre.diff { white-space: pre-wrap; font-family: Charter, Georgia, serif; font-size: 14px; line-height: 1.65; background: #fdfcfa; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; max-height: 60vh; overflow: auto; }
pre.diff ins { background: var(--green-wash); color: #1f4d29; text-decoration: none; box-shadow: 0 0 0 1px #cfe3d3; }
pre.diff del { background: var(--red-wash); color: var(--red); }
pre.diff .gap { display: block; color: var(--faint); text-align: center; margin: 8px 0; letter-spacing: 6px; }

/* ---- modal & toasts ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18, 19, 21, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 6px; width: 100%; max-width: 560px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 400; }
.modal-body { padding: 22px 24px 26px; }
.modal-body h3 { font-family: var(--mono); font-weight: 400; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 6px 0 10px; }
.modal-body .paper { box-shadow: none; max-width: none; padding: 36px 40px; }
#toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--night); color: #f1f0ec; padding: 11px 16px; border-radius: var(--radius); border-left: 3px solid var(--tungsten); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 420px; font-size: 13.5px; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---- auth ---- */
#auth { min-height: 100vh; }
.auth-split { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-visual { background: var(--night); color: #e9e8e4; position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.auth-visual::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .09; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.auth-visual .slate-stripes { height: 26px; }
.auth-copy { padding: 0 64px; max-width: 620px; }
.auth-copy .eyebrow { color: var(--tungsten); }
.auth-copy h1 { font-family: var(--serif); font-weight: 400; font-size: 48px; line-height: 1.08; letter-spacing: -.015em; margin: 10px 0 22px; }
.auth-copy h1 em { color: var(--tungsten); }
.auth-copy p { color: #a9a8a4; font-size: 15px; max-width: 420px; }
.auth-slate { display: grid; grid-template-columns: 2fr 1fr 1fr; margin: 0; border-top: 1px solid var(--night-line); }
.auth-slate div { padding: 18px 24px; border-right: 1px solid var(--night-line); }
.auth-slate div:last-child { border-right: 0; }
.auth-slate dt { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: #8b8a86; }
.auth-slate dd { margin: 4px 0 0; font-family: var(--mono); font-size: 18px; color: #fff; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form-wrap { position: relative; }
.auth-card { width: 100%; max-width: 360px; }
.lang-switch { position: absolute; top: 28px; right: 32px; display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lang-switch button { background: none; border: 0; border-radius: 0; padding: 5px 10px; font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: .08em; }
.lang-switch button + button { border-left: 1px solid var(--line); }
.lang-switch button.active { background: var(--ink); color: #fff; }
.auth-card h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.1; }
.auth-card > p { margin: 6px 0 28px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card button { justify-content: center; padding: 11px; margin-top: 4px; }

@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .vars { grid-column: 1 / -1; position: static; max-height: 240px; }
  .figures { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav-sep { display: none; }
  #main { padding: 24px 18px; }
  .page-head h1 { font-size: 30px; }
  .split, .split.wide-right, .editor-grid, .panels, .auth-split { grid-template-columns: 1fr; }
  .slate-grid { grid-template-columns: 1fr 1fr; }
  .preview-pane { position: static; max-height: none; }
  .person-split > .side-stack { order: -1; }
  .auth-visual { min-height: 320px; }
  .auth-copy h1 { font-size: 34px; }
  .paper { padding: 28px 22px; }
}

/* ---- workspace switcher, onboarding, misc ---- */
.workspace { padding: 0 22px 18px; }
.ws-label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #6f6e6a; margin-bottom: 6px; }
.workspace select { background-color: var(--night-2); border-color: var(--night-line); color: #e9e8e4; font-size: 13px; padding: 7px 30px 7px 10px; }
.workspace select:focus { border-color: var(--tungsten); box-shadow: none; }
.side-stack { display: flex; flex-direction: column; gap: 20px; }
.side-stack > .card { margin-bottom: 0; }
.onb-status { margin: 0 0 14px; }
.copy-row { display: flex; gap: 8px; margin-bottom: 16px; }
.copy-row input { font-family: var(--mono); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.auth-switch { margin-top: 22px; color: var(--muted); font-size: 13.5px; }

/* ---- public onboarding page ---- */
.onboarding-page { min-height: 100vh; display: flex; flex-direction: column; }
.onb-head { background: var(--night); color: #fff; }
.onb-head-inner { max-width: 860px; margin: 0 auto; padding: 34px 24px 36px; }
.onb-head .eyebrow { color: var(--tungsten); }
.onb-head h1 { font-family: var(--serif); font-weight: 400; font-size: 36px; line-height: 1.1; }
.onb-main { max-width: 860px; width: 100%; margin: 0 auto; padding: 32px 24px 60px; flex: 1; }
.onb-lead { font-size: 15px; color: var(--ink-2); margin: 0 0 24px; max-width: 640px; }
.onb-done h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin-bottom: 8px; }
.onb-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px; border-top: 1px solid var(--line); }
