/* Drift Inspector site design layer: the autumnfleet look (flat sections on the #EEE4D3 ground, 2px ink rules,
   rust pill buttons, line icons with one rust stroke).
   Ported from prototype/src/style.css (v4, commit 1a80e82), minus the prototype-only rules (.fake, .proto-banner,
   .admin-only). The prototype stays the visual reference: when the two differ, the prototype is the intent. */
:root {
  --ink: #1E1B18;
  --stone: #EEE4D3;      /* AF ground, as rendered by autumnfleet.com/next/ */
  --rust: #C2562F;
  --ochre: #E3A22A;
  --oxblood: #5B2318;
  --moss: #56603A;
  --paper: #F6EFE3;      /* fields and popovers: one step lighter than the ground */
  --line: #D5C9B5;       /* hairlines on the ground */
  --muted: #6B6259;      /* secondary text on stone */
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --text: 'Newsreader', Georgia, serif;
  --gutter: clamp(16px, 4vw, 56px);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--text); font-size: 1.0625rem; line-height: 1.5; color: var(--ink); background: var(--stone); overflow-x: hidden; }
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--rust); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
img, svg { max-width: 100%; }
code, .mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: .86em; }
p + p { margin-top: .7em; }


/* ---------- header ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px var(--gutter); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .mark { height: 34px; width: auto; display: block; }
.brand span { font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1; letter-spacing: .005em; }
.bar nav { display: flex; align-items: center; gap: clamp(12px, 2.4vw, 30px); font-size: 1rem; flex-wrap: wrap; justify-content: flex-end; }
.bar nav a { text-decoration: none; }
.bar nav a:hover { text-decoration: underline; }
.bar nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--rust); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.bar .who { display: inline-flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--moss); color: var(--stone); display: inline-grid; place-items: center; font-family: var(--text); font-weight: 600; font-size: .95rem; line-height: 1; }
@media (max-width: 720px) {
  .bar { flex-wrap: wrap; }
  .bar nav { width: 100%; justify-content: flex-start; gap: 6px 18px; }
  .bar .who .email { display: none; }
}

/* ---------- layout ---------- */
main { padding: clamp(28px, 5vw, 56px) var(--gutter) clamp(56px, 8vw, 96px); }
.wrap { max-width: 1180px; margin: 0 auto; }
.narrow { max-width: 520px; margin: 0 auto; }
/* Type (P3): the display face is kept for short, large attention elements only (h1 and hero/page titles, the
   wordmark, .stat .v numerals, .btn pills). Section headings, table heads, labels and every small or dense text
   use the body face, Newsreader, at 600 with normal tracking. */
h1 { font-family: var(--display); line-height: .95; letter-spacing: -.005em; font-weight: 900; font-size: clamp(2.4rem, 5.4vw, 4rem); }
h2, h3, h4 { font-family: var(--text); font-weight: 600; letter-spacing: 0; line-height: 1.2; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.95rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
.lede { font-size: clamp(1.1rem, 1.6vw, 1.3rem); max-width: 46ch; margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: .92rem; }
.crumbs { font-size: .95rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: clamp(24px, 4vw, 40px); }
.page-head > div { min-width: 0; }
.stack > * + * { margin-top: clamp(28px, 4vw, 44px); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 40px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .grid-2, .grid-side { grid-template-columns: minmax(0, 1fr); } }

.card { background: transparent; border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding: 18px 0 0; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 14px; }
.section-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 14px; }
.rule { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--rust); color: #fff; border: 0; cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1; padding: 11px 22px 12px; text-decoration: none; border-radius: 999px; }
.btn:hover { background: var(--oxblood); color: #fff; }
.btn.big { font-size: 1.5rem; padding: 12px 28px 14px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--stone); }
.btn.danger { background: var(--oxblood); }
.btn.danger:hover { background: var(--ink); }
.btn.sm { font-size: 1rem; padding: 7px 15px 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkbtn:hover { color: var(--rust); }
.actions { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin-top: 22px; }

/* ---------- forms ---------- */
label, .label { display: block; font-family: var(--text); font-weight: 600; font-size: 1rem; line-height: 1.3; margin-bottom: 6px; }
.field { margin-bottom: 18px; min-width: 0; }
.field .hint { font-size: .9rem; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: #F7F1E7; border: 1.5px solid #B5A992; border-radius: 6px; padding: 9px 11px; }
textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(194, 86, 47, .25); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-family: var(--text); font-weight: 400; font-size: 1rem; margin: 0; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--rust); width: 16px; height: 16px; flex: none; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.choice label { display: block; border: 1.5px solid #B5A992; border-radius: 8px; padding: 12px 14px; cursor: pointer; font-family: var(--text); font-weight: 400; font-size: .98rem; margin: 0; background: #F7F1E7; }
.choice label strong { font-family: var(--text); font-weight: 600; font-size: 1.05rem; line-height: 1.25; display: block; margin-bottom: 2px; }
.choice input { accent-color: var(--rust); margin-right: 6px; }
.choice label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--paper); }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-family: var(--text); font-weight: 400; font-size: 1rem; margin: 0; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: #B5A992; position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--moss); }
.switch input:checked::after { left: 23px; }

/* ---------- notes / callouts ---------- */
.note { border-left: 4px solid var(--ink); background: var(--paper); padding: 12px 16px; border-radius: 0; font-size: .98rem; }
.note.warn { border-color: var(--rust); background: #F6E6DC; }
.note.ok { border-color: var(--moss); background: #E7E8DA; }
.note.halt { border-color: var(--oxblood); background: #EFDCD6; }
.note strong { font-family: var(--text); font-weight: 600; }
.note + .note, * + .note { margin-top: 14px; }

/* ---------- tabs ---------- */
.tabs [role=tablist] { display: flex; gap: 4px; border-bottom: 2px solid var(--ink); overflow-x: auto; scrollbar-width: thin; }
.tabs [role=tab] { appearance: none; background: none; border: 0; cursor: pointer; font-family: var(--text); font-weight: 600; font-size: 1.05rem; line-height: 1.25; padding: 9px 16px 8px; color: var(--muted); border-radius: 8px 8px 0 0; white-space: nowrap; }
.tabs [role=tab]:hover { color: var(--ink); }
.tabs [role=tab][aria-selected=true] { background: var(--ink); color: var(--stone); }
.tabs [role=tabpanel] { padding-top: 22px; }
.tabs [role=tabpanel][hidden] { display: none; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: none; font-family: var(--text); font-weight: 600; font-size: .98rem; line-height: 1.25; padding: 6px 14px; cursor: pointer; color: var(--ink); }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--stone); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 0; border-radius: 0; background: transparent; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .97rem; }
th { font-family: var(--text); font-weight: 600; font-size: .92rem; line-height: 1.25; text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--ink); white-space: nowrap; background: transparent; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.title { min-width: 260px; }
td.nowrap { white-space: nowrap; }
tbody tr:hover { background: #E6DCC9; }
.table-wrap.wide table { min-width: 760px; }

/* status chips */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; line-height: 1.25; vertical-align: baseline; white-space: nowrap; }
.st::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.st.ok::before { background: var(--moss); }
.st.warn::before { background: var(--ochre); }
.st.bad::before { background: var(--oxblood); }
.st.run::before { background: var(--rust); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.vis { display: inline-block; font-family: var(--text); font-weight: 600; font-size: .85rem; line-height: 1.35; border: 1.5px solid currentColor; border-radius: 99px; padding: 0 8px; }
.vis.public { color: var(--moss); }
.vis.shared { color: var(--rust); }
.vis.private { color: var(--muted); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat { background: transparent; border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding: 10px 0 0; min-width: 0; }
.stat .v { font-family: var(--display); font-weight: 800; font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .9rem; color: var(--muted); margin-top: 4px; }

/* ---------- progress ---------- */
.progress { height: 14px; background: #DCD0BB; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--rust); border-radius: 99px; transition: width .4s ease; }
.progress.paused > div { background: repeating-linear-gradient(45deg, var(--oxblood) 0 10px, #7A3A2C 10px 20px); }
.progress.done > div { background: var(--moss); }
.stages { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 18px 0; counter-reset: st; }
.stages li { counter-increment: st; border-top: 4px solid #CFC7B8; padding-top: 8px; font-family: var(--text); font-weight: 600; font-size: 1rem; line-height: 1.25; color: var(--muted); }
.stages li small { display: block; font-family: var(--text); font-weight: 400; font-size: .82rem; color: var(--muted); }
.stages li.done { border-color: var(--moss); color: var(--ink); }
.stages li.now { border-color: var(--rust); color: var(--ink); }
.stages li.halt { border-color: var(--oxblood); color: var(--oxblood); }
@media (max-width: 720px) { .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.log { background: var(--ink); color: #DDD6C9; border-radius: 8px; padding: 14px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; line-height: 1.55; height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .e { color: #F0A58A; }
.log .w { color: var(--ochre); }

/* ---------- dropzone ---------- */
.drop { border: 2px dashed #A8997F; border-radius: 10px; padding: 32px 18px; text-align: center; background: #F7F1E7; transition: background .15s, border-color .15s; }
.drop.over { border-color: var(--rust); background: #F6E6DC; }
.drop svg { width: 56px; height: 56px; display: block; margin: 0 auto 10px; }

/* ---------- clusters ---------- */
.clist { list-style: none; padding: 0; }
.clist li { display: grid; grid-template-columns: minmax(0, 1fr) 96px 64px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.clist li:last-child { border-bottom: 0; }
.clist .name { font-weight: 500; }
.clist .meta { font-size: .85rem; color: var(--muted); }
.clist svg { width: 96px; height: 30px; display: block; }
.clist .d { font-family: var(--text); font-weight: 600; font-size: 1.05rem; text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--moss); }
.down { color: var(--oxblood); }

/* ---------- comments ---------- */
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { border-left: 3px solid var(--line); padding-left: 12px; }
.comment .who { font-size: .88rem; color: var(--muted); }
.comment .anchor { display: inline-block; font-size: .82rem; background: #E3D8C4; border-radius: 4px; padding: 0 6px; margin: 2px 0 4px; }
.comment p { font-size: .97rem; }

/* ---------- viewer page: full viewport (layout "viewer") ---------- */
body.viewer-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.vhead { flex: none; display: flex; align-items: center; gap: 12px 16px; padding: 0 16px; min-height: 60px; border-bottom: 2px solid var(--ink); background: var(--stone); position: relative; z-index: 5; }
.vbrand { flex: none; display: block; }
.vbrand .mark { height: 30px; width: auto; display: block; }
.vtitle { flex: 0 1 460px; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; padding: 6px 0; }
.vtitle strong { font-family: var(--display); font-weight: 800; font-size: 1.3rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcrumb { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vcrumb a { color: var(--muted); }
.vsub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vtools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.vlook button { font-size: .92rem; padding: 5px 10px 4px; }
.vicon { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: none; box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); cursor: pointer; padding: 0; flex: none; }
.vicon svg { width: 18px; height: 18px; }
.vicon:hover, .vicon[aria-pressed=true] { background: var(--ink); color: var(--stone); }
.vcomments svg { width: 15px; height: 15px; }
.vcount { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--ochre); color: var(--ink); font-size: .8rem; font-weight: 800; }
.vcomments[aria-expanded=true] { background: var(--oxblood); }
.vmain { flex: 1; min-height: 0; display: flex; position: relative; overflow: hidden; }
.vframe { flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--stone); }
.orig-nav [data-view-btn], .orig-nav #v-theme { opacity: .4; pointer-events: none; }

/* view rail (desktop) / bottom bar (phone) */
.rail { flex: none; width: 168px; display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; border-right: 1px solid var(--line); background: var(--stone); transition: width .18s ease; overflow: hidden; }
.rail button { appearance: none; border: 0; background: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-family: var(--text); font-weight: 600; font-size: 1.02rem; line-height: 1.2; text-align: left; white-space: nowrap; }
.rail button svg { width: 22px; height: 22px; flex: none; }
.rail button:hover { color: var(--ink); background: #E3D8C4; }
.rail button[aria-current=page] { background: var(--ink); color: var(--stone); }
.rail .rail-toggle { margin-top: auto; font-size: .95rem; }
.rail .rail-toggle svg { transition: transform .18s; }
.rail.collapsed { width: 62px; }
.rail.collapsed .lbl { display: none; }
.rail.collapsed .rail-toggle svg { transform: rotate(180deg); }

/* comments drawer (slide-over) */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(400px, 100%); background: var(--stone); border-left: 2px solid var(--ink); transform: translateX(104%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; display: flex; flex-direction: column; z-index: 10; }
.drawer.open { transform: none; visibility: visible; box-shadow: -18px 0 40px rgba(30, 27, 24, .18); transition: transform .22s ease; }
.drawer-head { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.cmt-chip { display: inline-block; font-family: var(--text); font-weight: 600; font-size: .88rem; line-height: 1.35; padding: 0 9px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px #B5A992; color: var(--ink); white-space: nowrap; }
#i-picked.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--ochre); } 100% { box-shadow: 0 0 0 0 rgba(227, 162, 42, 0); } }

@media (max-width: 1020px) { .vcrumb { display: none; } .vshare { display: none; } .vlook button { padding: 5px 8px 4px; } }
@media (max-width: 860px) {
  .vhead { padding: 6px 12px; gap: 10px; min-height: 52px; }
  .vbrand .mark { height: 26px; }
  .vtitle { flex: 1 1 0; padding: 0; }
  .vtitle strong { font-size: 1.15rem; }
  .vtools { gap: 8px; }
  .vtools .vlook, .vtools .vshare { display: none; }
  .vcomments .lbl { display: none; }
  .vcomments { padding: 7px 10px 8px; }
  .vsub .dt, .vsummary { display: none; }
  .vmain.has-rail { flex-direction: column-reverse; }
  .rail, .rail.collapsed { width: 100%; flex-direction: row; gap: 2px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 2px solid var(--ink); }
  .rail button { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: .78rem; text-align: center; justify-content: center; }
  .rail.collapsed .lbl { display: inline; }
  .rail .rail-toggle { display: none; }
  .drawer { width: 100%; }
}

/* ---------- admin ---------- */
.admin-stack { display: flex; flex-direction: column; gap: clamp(28px, 4vw, 44px); }
.admin-stack > aside { order: -1; }
.admin-stack > aside.stack > * + * { margin-top: 0; }
.admin-stack .table-wrap.wide table { min-width: 860px; }
.bar nav a.admin-link { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- clustering versions ---------- */
.versions { list-style: none; padding: 0; }
.versions .ver { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.versions .ver:last-child { border-bottom: 0; }
.versions .ver.on { background: #E6DCC9; box-shadow: inset 3px 0 0 var(--ink); }
.versions .ver .check { font-size: .95rem; }
.versions .ver .st { flex: none; margin-top: 3px; }

/* ---------- spend notice ---------- */
.stat.over { border-color: var(--rust); background: #F6E6DC; }
details.mail { margin-top: 14px; }
details.mail summary { cursor: pointer; }
.mail-body { margin-top: 10px; background: #F7F1E7; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; font-size: .97rem; }
.mail-body p + p { margin-top: .6em; }

/* ---------- modal ---------- */
dialog { border: 0; border-top: 6px solid var(--ink); padding: 0; border-radius: 0; background: var(--stone); color: var(--ink); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 80px rgba(30, 27, 24, .35); }
dialog::backdrop { background: rgba(30, 27, 24, .55); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px 12px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 22px 22px; }
.x { background: none; border: 0; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--ink); padding: 0 4px; }
.people { list-style: none; padding: 0; margin-top: 10px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people li .em { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.people select { width: auto; padding: 5px 8px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(140%); background: var(--ink); color: var(--stone); padding: 10px 18px; border-radius: 999px; font-size: .95rem; transition: transform .25s ease; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: clamp(28px, 6vw, 80px) 0 clamp(40px, 7vw, 100px); }
.hero h1 { font-size: clamp(3rem, 7.4vw, 6.6rem); line-height: .86; max-width: 11ch; }
.hero .drift-art { width: 100%; max-width: 560px; height: auto; justify-self: center; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 32px; padding: clamp(40px, 6vw, 80px) 0; border-top: 2px solid var(--ink); }
.steps .spot { width: 72px; height: 72px; display: block; margin-bottom: 14px; }
.steps h3 { margin-bottom: 8px; }
.steps p { font-size: 1rem; max-width: 30ch; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr; } }
.credit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; padding: clamp(40px, 6vw, 80px) 0; border-top: 2px solid var(--ink); }
@media (max-width: 900px) { .credit { grid-template-columns: 1fr; } }
.linklist { list-style: none; padding: 0; }
.linklist li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.linklist a { font-family: var(--text); font-weight: 600; font-size: 1.15rem; }

/* ---------- auth ---------- */
.auth { max-width: 460px; margin: clamp(8px, 4vw, 40px) auto 0; }
.auth h1 { font-size: clamp(2.4rem, 6vw, 3.4rem); margin-bottom: 10px; }
.auth form { margin-top: 26px; }
.auth .alt { margin-top: 22px; font-size: .98rem; }
.envelope { width: 110px; height: 110px; display: block; margin-bottom: 18px; }

footer.site { border-top: 1px solid var(--line); padding: 24px var(--gutter) 36px; font-size: .92rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer.site a { color: var(--muted); }

.keyline { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }
.keyline:last-child { border-bottom: 0; }
.keyline .what { flex: 1 1 200px; min-width: 0; }
.keyline .what strong { font-family: var(--text); font-weight: 600; font-size: 1.05rem; }
.keyline code { background: #E3D8C4; padding: 2px 7px; border-radius: 4px; }
.estimate dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; }
.estimate dt { color: var(--muted); }
.estimate dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.estimate .total { font-family: var(--display); font-weight: 800; font-size: 2.4rem; line-height: 1; }
.map-list { columns: 2 280px; padding-left: 1.2em; }
.map-list li { margin-bottom: 6px; break-inside: avoid; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 600px) { td.title { min-width: 190px; } .table-wrap.wide table { min-width: 620px; } }
.choice label { position: relative; padding-left: 40px; }
.choice input { position: absolute; left: 14px; top: 17px; margin: 0; }
@media (max-width: 600px) { .clist li { grid-template-columns: minmax(0, 1fr) 60px 46px; gap: 8px; } .clist svg { width: 60px; } }

/* ---------- Django-side additions (not in the prototype) ---------- */
.bar form.inline { display: inline; margin: 0; }
.bar .linklike { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
.bar .linklike:hover { color: var(--rust); text-decoration: underline; text-underline-offset: 3px; }
.messages { list-style: none; padding: 16px var(--gutter) 0; margin: 0; }
.messages .note { margin-top: 0; }
.messages .note + .note { margin-top: 8px; }
.credit .lead-in { margin-top: 16px; max-width: 46ch; }
.credit .small.muted { max-width: 46ch; }

/* ---------- accounts (Django-side: server-rendered form errors, tab links, one-time invite box) ---------- */
.field .errors { list-style: none; padding: 0; margin: 6px 0 0; color: var(--oxblood); font-size: .92rem; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--oxblood); box-shadow: 0 0 0 2px #EFDCD6; }
.field.has-error .errors { background: #EFDCD6; border-left: 3px solid var(--oxblood); padding: 6px 10px; border-radius: 2px; }
.auth .note + form, .auth .note + .field { margin-top: 18px; }
.auth .small { margin-top: 10px; }
.tabs .tablist { display: flex; gap: 4px; border-bottom: 2px solid var(--ink); overflow-x: auto; scrollbar-width: thin; margin-bottom: clamp(24px, 4vw, 36px); }
.tabs .tablist a { font-family: var(--text); font-weight: 600; font-size: 1.05rem; line-height: 1.25; padding: 9px 16px 8px; color: var(--muted); border-radius: 8px 8px 0 0; white-space: nowrap; text-decoration: none; }
.tabs .tablist a:hover { color: var(--ink); }
.tabs .tablist a[aria-current="page"] { background: var(--ink); color: var(--stone); }
input.invite-link { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.inline-form { display: inline; margin: 0; }
.intro { max-width: 62ch; margin-top: 10px; }
.card .note + form { margin-top: 18px; }
.table-wrap + p { margin-top: 10px; }
.once-row { margin-top: 10px; }
.after-stats { margin-top: clamp(28px, 4vw, 44px); }
.admin-stack { margin-top: clamp(28px, 4vw, 44px); }
.page-head .card { min-width: 0; }

/* ---------- keys (Django-side) ---------- */
.keys .hint-after { margin-top: 16px; max-width: 62ch; }
.keys .keys-url { overflow-wrap: anywhere; }
.keys .keyline .what { overflow-wrap: anywhere; }
.keys .confirm { max-width: 62ch; }
.keys .confirm h1 { overflow-wrap: anywhere; }

/* Django-side additions: corpus builder */
.corpus-grid { display: grid; gap: 28px; min-width: 0; }
.corpus-section { min-width: 0; margin-block: 24px; }
.counts { display: flex; flex-wrap: wrap; gap: 18px; list-style: none; padding: 0; }
.counts b { display: block; font-size: 1.5rem; }
.corpus-table { width: 100%; }
.corpus-table td { overflow-wrap: anywhere; }
.corpus-table details { max-width: 45ch; white-space: normal; }
.corpus-grid form textarea, .corpus-grid form input, .corpus-grid form select { max-width: 100%; }
.corpus-grid form textarea { width: 100%; }

/* Task 15a: run pages and the prototype v4 rail, with M1 controls. */
.run-page h1 { overflow-wrap: anywhere; margin-bottom: 18px; }
.run-page h2 { margin: 24px 0 12px; }
.run-page p, .run-page code, .run-page td { overflow-wrap: anywhere; }
.run-page fieldset { border: 0; border-top: 2px solid var(--ink); padding: 18px 0; }
.run-page .preset { margin: 12px 0; }
.run-page .preset label { display: inline; }
.run-page .preset small { display: block; }
.run-page .warn { border-left: 4px solid var(--ochre); padding: 8px 12px; }
.run-page .table-wrap { overflow-x: auto; max-width: 100%; }
.run-table { width: 100%; border-collapse: collapse; }
.run-table th, .run-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.run-page form { margin: 14px 0; }
.run-inspector main { padding: 0; flex: 1; display: flex; min-height: 0; }
.run-inspector .vmain { width: 100%; }
.run-inspector .rail { width: 230px; overflow-y: auto; }
.rail-views { display: flex; flex-direction: column; gap: 4px; }
.rail-details { font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.rail-details > * { margin-top: 14px; }
.rail-details details summary { cursor: pointer; }
.rail-details .versions a, .rail-details .versions strong { display: block; }
.rail-details .citation h3 { margin: 10px 0; }
.rail-details .citation p { font-size: .85rem; }
.empty-inspector { padding: 32px; min-width: 0; }
.details-hidden .rail-details > :not(.rail-toggle) { display: none; }
.run-inspector[data-theme=dark] { --ink:#E9E4DA; --stone:#1E1B18; --paper:#2A2622; --line:#3A342E; --muted:#ABA192; }
@media (max-width: 860px) {
  .run-inspector .rail { width: 100%; flex-direction: column; max-height: 34dvh; padding: 4px 10px; }
  .rail-views { flex-direction: row; flex: none; }
  .rail-details { display: flex; gap: 8px 16px; flex-wrap: wrap; overflow-y: auto; }
  .rail-details > * { margin-top: 4px; }
  .rail-details .rail-citation, .rail-details details[open] { flex: 1 0 100%; }
  .rail-details .note { margin: 4px 0; }
  .run-inspector .rail .rail-toggle { display: flex; }
  .vbrand { max-width: 100px; font-family: var(--display); line-height: 1; }
}

.demo-link { padding: 18px var(--gutter) 0; }

/* Django-side additions: stored key settings */
.key-settings { margin: 12px 0 24px; min-width: 0; }
.key-settings summary { cursor: pointer; font-weight: 600; }
.key-settings form { margin-top: 16px; }
.key-settings .hint { overflow-wrap: anywhere; }

/* PDF uploads (Django-side additions). */
.pdf-drop { margin: 16px 0; padding: 16px; border: 2px dashed var(--line); border-radius: 8px; }
.pdf-drop.dragging { border-color: var(--ink); }
.pdf-drop input { display: block; max-width: 100%; margin-top: 8px; }
#pdf-progress { padding-left: 20px; overflow-wrap: anywhere; }
#pdf-progress progress { max-width: 100%; vertical-align: middle; }
#pdf-upload label { display: block; }
#uploads-status td { overflow-wrap: anywhere; }

/* Django-side additions: cost estimates and usage comparisons. */
.estimate, .usage { margin: 20px 0; }
.estimate-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.estimate-table th, .estimate-table td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.estimate-table th { font-weight: 500; }
.estimate-table small { display: block; color: var(--muted); }
.estimate-total { font-weight: 600; }
.estimate-note { color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
@media (max-width: 600px) { .estimate-table th, .estimate-table td { padding: 8px 4px; font-size: 12px; } }

.run-page .params-table { table-layout: fixed; }
.run-page .params-table th { white-space: normal; overflow-wrap: anywhere; }

/* Django-side additions: sharing page (Task M2-01) */
.share-page .share-add { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.share-page .people form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.share-page .linklike { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--rust); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.share-page .share-url-label { display: block; margin-top: 16px; }
.share-page .share-url { width: 100%; max-width: 100%; font-family: var(--mono, monospace); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.role-badge { display: inline-block; font-size: .82rem; padding: 0 8px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px #B5A992; }

/* Django-side additions: compare analyses (Task M2-11) */
.page-head .actions { margin-top: 0; }
.compare .compare-rows { display: grid; gap: 4px 16px; grid-template-columns: minmax(0, 1fr); }
.compare .compare-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
@media (min-width: 760px) { .compare .compare-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.compare fieldset label { display: block; }
.compare-picked li .small { overflow-wrap: anywhere; min-width: 0; }
.compare .note, .compare-sources .note { overflow-wrap: anywhere; }
.compare-sources ul.plain { list-style: none; padding: 0; margin: 4px 0; }
.compare-sources li { overflow-wrap: anywhere; margin-bottom: 4px; }

/* Django-side additions: search (Task M2-04) */
.search-form .seg-radios { display: flex; flex-wrap: wrap; gap: 6px 16px; border: 0; padding: 0; margin: 0 0 8px; }
.search-form .seg-option { display: inline-flex; gap: 6px; align-items: center; }
.search-form .search-row { display: grid; gap: 4px 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .search-form .search-row { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; } }
.search-results .keyline strong { overflow-wrap: anywhere; }

/* Django-side additions: comments drawer on the analysis page (Task M2-02) */
#comments-drawer .comment.removed p { font-style: italic; }
#comments-drawer .thread { display: flex; flex-direction: column; gap: 10px; }
#comments-drawer .reply { margin-left: 16px; }
#comments-drawer .comment p { overflow-wrap: anywhere; margin: 2px 0; }
#comments-drawer .comment .anchor { max-width: 100%; overflow-wrap: anywhere; }
#comments-drawer .comment-actions { display: flex; gap: 12px; align-items: baseline; }
#comments-drawer form.inline { display: inline; margin: 0; }
#comments-drawer .linklike { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--rust); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#comments-drawer #comment-form { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
#comments-drawer #comment-form .field { margin-bottom: 12px; }
#comments-drawer #comment-form .note { margin: 0 0 12px; overflow-wrap: anywhere; }
#comments-drawer select, #comments-drawer textarea { width: 100%; max-width: 100%; }
#comments-drawer textarea { min-height: 90px; font-family: var(--text); font-size: 1rem; }
#comments-drawer .comments-help { margin-top: 14px; }

/* Django-side additions: rename and merge clusters (Task M2-05) */
.clusters-edit .inline-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.clusters-edit .inline-edit input[type=text] { width: auto; min-width: 0; flex: 1 1 120px; }
.clusters-edit .inline-edit select { width: auto; max-width: 100%; min-width: 0; padding: 5px 8px; }
.clusters-edit .clusters-table td { vertical-align: top; overflow-wrap: anywhere; }
/* the visually-hidden labels are position:absolute: without a positioned scroller they escape it and widen the page */
.clusters-edit .table-wrap { position: relative; }
.clusters-edit .people form.inline { display: inline; margin: 0; }
.clusters-edit .linklike { appearance: none; background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--rust); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.clusters-edit .card { margin-top: 22px; }

/* Django-side additions: full-text mode (Task M2-06) */
.mode-form { margin-top: 8px; }
.mode-form fieldset { border: 0; padding: 0; margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.mode-form legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.mode-form .note { margin: 6px 0; }

/* Django-side additions: Langfuse key on the API keys page (Task M2-07) */
.kind-field[hidden] { display: none; }
.langfuse-consent .note { margin: 0 0 8px; }
.langfuse-consent .note strong { font-size: inherit; overflow-wrap: anywhere; }
.langfuse-consent .consent-label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: .95rem; }
.langfuse-consent .consent-label input { margin-top: 4px; flex: none; }
.trace-link { margin: 8px 0 0; }

/* Django-side additions: run progress bars (P2) */
.stage-bar { margin: 10px 0; }
.stage-bar label { display: block; font-family: var(--text); margin-bottom: 4px; }
.stage-bar progress { display: block; width: 100%; max-width: 480px; height: 12px; appearance: none; -webkit-appearance: none; border: 1px solid var(--ink); border-radius: 6px; background: var(--paper); overflow: hidden; }
.stage-bar progress::-webkit-progress-bar { background: var(--paper); }
.stage-bar progress::-webkit-progress-value { background: var(--rust); }
.stage-bar progress::-moz-progress-bar { background: var(--rust); }

/* Django-side additions: native controls in the design (P3). Selects get the field look plus a rust chevron;
   checkboxes and radios take rust everywhere; file pickers, summaries and number fields lose the Chrome look. */
select { appearance: none; -webkit-appearance: none; background-color: #F7F1E7; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5' fill='none' stroke='%23C2562F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; padding-right: 36px; line-height: 1.3; cursor: pointer; text-overflow: ellipsis; }
select[multiple], select[size]:not([size="1"]) { background-image: none; padding-right: 11px; cursor: default; }
select option { color: var(--ink); background: #F7F1E7; }
.people select, .clusters-edit .inline-edit select { padding-right: 30px; background-position: right 9px center; }
select:disabled, input:disabled:not([type=checkbox]):not([type=radio]), textarea:disabled { opacity: .55; cursor: not-allowed; }
/* text-like inputs rendered without a type (corpus name, delete confirmation) or with date/tel types */
input:not([type]), input[type=date], input[type=tel], input[type=datetime-local] {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: #F7F1E7; border: 1.5px solid #B5A992; border-radius: 6px; padding: 9px 11px; }
input:not([type]):focus, input[type=date]:focus, input[type=tel]:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(194, 86, 47, .25); }
input[readonly] { background: transparent; }
label > input:not([type]) { margin-top: 6px; }
/* datalist inputs: hide Chrome's grey picker arrow; the list still opens on focus/typing */
input[list]::-webkit-calendar-picker-indicator { opacity: 0; }
/* number fields: no spinners (arrow keys still step) */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* checkboxes and radios: rust everywhere (zero specificity, so .switch / .choice / .check keep their own rules) */
:where(input[type=checkbox], input[type=radio]) { accent-color: var(--rust); width: 16px; height: 16px; margin: 0 8px 0 0; vertical-align: -2px; cursor: pointer; }
label:has(> input[type=checkbox]), label:has(> input[type=radio]) { font-weight: 400; }
/* a Django BooleanField renders label then checkbox: put the box first, on the label's line */
.field:has(> input[type=checkbox]) { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: start; }
.field:has(> input[type=checkbox]) > input[type=checkbox] { grid-row: 1; grid-column: 1; margin: 4px 0 0; }
.field:has(> input[type=checkbox]) > label { grid-row: 1; grid-column: 2; font-weight: 400; margin: 0; }
.field:has(> input[type=checkbox]) > :not(input):not(label) { grid-column: 2; }
/* Django RadioSelect: options are plain text beside the radio */
.field > div > div > label:has(> input[type=radio]) { margin-bottom: 4px; }
/* file pickers: the button is a small ghost pill (body face: it is a small control, not a .btn) */
input[type=file] { font: inherit; font-size: .95rem; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font-family: var(--text); font-weight: 600; font-size: .95rem; line-height: 1.2; color: var(--ink); background: transparent; border: 0; box-shadow: inset 0 0 0 2px var(--ink); border-radius: 999px; padding: 7px 15px 8px; margin-right: 12px; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--ink); color: var(--stone); }
/* details: a rust chevron instead of the black triangle */
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 2px solid var(--rust); border-bottom: 2px solid var(--rust); transform: rotate(-45deg); margin: 0 9px 2px 1px; transition: transform .15s; }
details[open] > summary::before { transform: rotate(45deg); margin-bottom: 4px; }
progress { accent-color: var(--rust); }
/* clusters table at phone width: the name column kept wrapping one syllable per line; it scrolls sideways instead */
.clusters-edit .clusters-table td:nth-child(2) { min-width: 170px; }

/* Django-side additions: credit of an imported original analysis (Task P6) */
.import-credit h3 { margin: 10px 0; }
.import-credit p { overflow-wrap: anywhere; }
.rail-details .import-credit p { font-size: .85rem; }
.import-credit .cite { font-style: italic; }

/* Django-side additions: time-axis reports and import previews. Contain positioned hidden labels. */
.table-wrap { position: relative; }
