/* subcms editor. Colours and type come from the site theme (/api/sites/<id>/theme.css):
   --primary/--on-primary (sidebar), --paper/--ink (the page), --tertiary/--on-tertiary (focus, selection,
   the main action), --font, --display-weight, --menu-weight. Defaults below are for the login screen. */
:root {
  --primary: #1d1d1b; --on-primary: #fff; --secondary: #fff;
  --tertiary: #2f5cf0; --on-tertiary: #fff;
  --paper: #fff; --ink: #1d1d1b;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display-weight: 750; --display-tracking: -0.015em; --menu-weight: 650; --subtitle-style: normal;

  --muted: color-mix(in oklab, var(--ink) 52%, var(--paper));
  --faint: color-mix(in oklab, var(--ink) 30%, var(--paper));
  --line: color-mix(in oklab, var(--ink) 13%, var(--paper));
  --wash: color-mix(in oklab, var(--ink) 4%, var(--paper));
  --wash-2: color-mix(in oklab, var(--ink) 8%, var(--paper));
  --side-muted: color-mix(in oklab, var(--on-primary) 55%, var(--primary));
  --side-line: color-mix(in oklab, var(--on-primary) 16%, var(--primary));
  --danger: #b3261e;
  --r: 4px;
  --col: 720px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: var(--tertiary); color: var(--on-tertiary); }
:focus-visible { outline: 2px solid var(--tertiary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: var(--r); padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 14px; line-height: 1.3; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.solid:hover { background: color-mix(in oklab, var(--ink) 85%, var(--paper)); }
.btn.go { background: var(--tertiary); border-color: var(--tertiary); color: var(--on-tertiary); }
.btn.go:hover { filter: brightness(1.06); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--wash-2); border-color: transparent; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.icon { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: var(--r); cursor: pointer; color: var(--muted); font-size: 15px; }
.icon:hover { background: var(--wash-2); color: var(--ink); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 320px minmax(0, 1fr); height: 100vh; }
.shell.wide { grid-template-columns: 248px minmax(0, 1fr); }

.side { background: var(--primary); color: var(--on-primary); display: flex; flex-direction: column; min-height: 0; }
.mark { display: block; padding: 22px 22px 6px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 46px; line-height: 1; text-decoration: none; color: var(--on-primary); }
.site-name { padding: 0 22px 18px; color: var(--side-muted); font-size: 13px; }
.site-switch { margin: 0 22px 18px; width: calc(100% - 44px); background: transparent; color: var(--on-primary); border: 1px solid var(--side-line); border-radius: var(--r); padding: 5px 8px; }
.site-switch option { color: #000; }
.nav { flex: 1; overflow: auto; padding: 4px 0 16px; border-top: 1px solid var(--side-line); }
.nav h3 { margin: 18px 22px 4px; font-size: 12px; font-weight: 500; color: var(--side-muted); }
.nav a { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 22px; font-weight: var(--menu-weight); font-size: 17px; line-height: 1.35; color: var(--on-primary); text-decoration: none; }
.nav a:hover .lbl { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.nav a.on .lbl { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; text-decoration-color: var(--tertiary); }
.nav .count { font-size: 12px; font-weight: 400; color: var(--side-muted); }
.side-foot { padding: 14px 22px 18px; border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 10px; }
.side-foot .btn.go { justify-content: center; padding: 10px 12px; font-size: 15px; }
.pubstate { font-size: 12px; color: var(--side-muted); cursor: pointer; }
.pubstate.failed { color: #ff9b91; }
.who { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--side-muted); }
.who button { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 0; text-decoration: underline; }
.who a { color: var(--side-muted); }

/* ---------- document list ---------- */
.list { background: var(--wash); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.list-head .row1 { display: flex; align-items: center; justify-content: space-between; }
.list-head h2 { margin: 0; font-size: 22px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }
.search { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 7px 10px; }
.search:focus { outline: none; border-color: var(--ink); }
.items-scroll { overflow: auto; flex: 1; padding: 6px 0 24px; }
.doc { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 16px 7px 13px; border-left: 3px solid transparent; text-decoration: none; color: var(--ink); }
.doc.noimg { grid-template-columns: minmax(0, 1fr); }
.doc:hover { background: var(--wash-2); }
.doc.on { background: var(--paper); border-left-color: var(--tertiary); }
.doc .th { width: 48px; height: 48px; border-radius: 3px; background: var(--wash-2) center/cover no-repeat; }
.doc .tt { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.doc .ss { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--wash-2); color: var(--muted); vertical-align: 2px; margin-left: 6px; }

/* ---------- page ---------- */
.page { overflow: auto; min-width: 0; position: relative; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 28px; background: color-mix(in oklab, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); min-height: 56px; }
.bar .crumb { color: var(--muted); font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .crumb a { text-decoration: none; }
.bar .crumb a:hover { text-decoration: underline; }
.state { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.state.dirty::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--tertiary); box-shadow: 0 0 0 1px color-mix(in oklab, var(--ink) 25%, transparent); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { transform: translateX(14px); }

.sheet { max-width: calc(var(--col) + 56px); padding: 34px 28px 160px; }
.title-in { width: 100%; border: 0; padding: 0; margin: 0; background: transparent; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 40px; line-height: 1.12; resize: none; overflow: hidden; display: block; }
.title-in:focus { outline: none; }
.title-in::placeholder { color: var(--faint); }
.slugline { display: flex; align-items: center; gap: 0; margin: 10px 0 0; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.slugline input { border: 0; border-bottom: 1px dashed var(--faint); background: transparent; padding: 0 2px; min-width: 60px; color: var(--ink); font-weight: 600; }
.slugline input:focus { outline: none; border-bottom: 1px solid var(--ink); }
.titlewrap { padding-bottom: 26px; margin-bottom: 26px; border-bottom: 1px solid var(--line); }

.field { margin: 0 0 28px; }
.field > .lab { display: block; font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.field > .lab .req { color: var(--muted); font-weight: 400; margin-left: 4px; }
.in { width: 100%; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; background: var(--paper); }
.in:hover { border-color: var(--faint); }
.in:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--tertiary) 45%, transparent); }
textarea.in { resize: vertical; min-height: 96px; line-height: 1.55; }
.in.short { width: 180px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* rich text */
.rt { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.rt:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklab, var(--tertiary) 45%, transparent); }
.rt-bar { display: flex; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); position: sticky; top: 56px; background: var(--paper); z-index: 2; border-radius: var(--r) var(--r) 0 0; flex-wrap: wrap; }
.rt-bar .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rt-bar .icon.on { background: var(--ink); color: var(--paper); }
.rt-bar select { border: 0; background: transparent; font-weight: 600; font-size: 13px; padding: 4px; border-radius: var(--r); cursor: pointer; }
.rt-bar select:hover { background: var(--wash-2); }
.rt-bar .grow { flex: 1; }
.rt-bar .mode { font-size: 12px; color: var(--muted); }
.wys { min-height: 140px; padding: 4px 16px 10px; font-size: 16px; line-height: 1.6; outline: none; }
.wys p { margin: .7em 0; }
.wys h2 { font-size: 24px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.2; margin: .9em 0 .4em; }
.wys h3 { font-size: 19px; font-weight: 700; font-style: var(--subtitle-style); margin: .9em 0 .4em; }
.wys h1 { font-size: 28px; font-weight: var(--display-weight); margin: .8em 0 .4em; }
.wys blockquote { margin: .8em 0; padding-left: 14px; border-left: 3px solid var(--tertiary); color: var(--muted); }
.wys a { text-decoration: underline; text-decoration-color: var(--tertiary); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.wys ul, .wys ol { padding-left: 26px; }
.wys:empty::before { content: attr(data-ph); color: var(--faint); }
.raw { width: 100%; border: 0; min-height: 180px; padding: 12px 16px; font: 13.5px/1.6 ui-monospace, Menlo, monospace; resize: vertical; background: var(--wash); border-radius: 0 0 var(--r) var(--r); }
.raw:focus { outline: none; }
.linkpop { position: absolute; z-index: 20; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--r); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: 10px; display: flex; gap: 6px; align-items: center; width: 460px; }
.linkpop input { flex: 1; }

/* colour */
.colour { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; position: relative; background: var(--c, transparent); }
.swatch.none { background: repeating-linear-gradient(45deg, var(--paper) 0 5px, var(--wash-2) 5px 10px); }
.swatch.sel { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.swatch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.colour .hexin { width: 110px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.colour .from { font-size: 12px; color: var(--muted); }

/* media */
.drop-one { display: flex; align-items: flex-start; gap: 16px; }
.media-frame { position: relative; width: 240px; border-radius: var(--r); overflow: hidden; background: var(--wash-2); }
.media-frame img { display: block; width: 100%; max-height: 240px; object-fit: contain; }
.media-empty { width: 240px; height: 150px; border: 1.5px dashed var(--faint); border-radius: var(--r); display: grid; place-items: center; color: var(--muted); cursor: pointer; text-align: center; padding: 10px; background: var(--wash); }
.media-empty:hover, .over { border-color: var(--ink) !important; color: var(--ink); background: color-mix(in oklab, var(--tertiary) 14%, var(--paper)) !important; }
.media-actions { display: flex; flex-direction: column; gap: 6px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.mcell { position: relative; aspect-ratio: 1; border-radius: var(--r); background: var(--wash-2) center/cover no-repeat; cursor: grab; }
.mcell.dragging { opacity: .35; }
.mcell .x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); display: none; cursor: pointer; font-size: 13px; }
.mcell:hover .x, .mcell:focus-within .x { display: grid; place-items: center; }
.madd { aspect-ratio: 1; border: 1.5px dashed var(--faint); border-radius: var(--r); display: grid; place-items: center; color: var(--muted); cursor: pointer; background: var(--wash); text-align: center; font-size: 13px; padding: 8px; }
.madd:hover { border-color: var(--ink); color: var(--ink); }

/* links + references */
.card { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.card.noimg { grid-template-columns: minmax(0, 1fr) auto; }
.card .th { width: 56px; height: 56px; border-radius: 3px; background: var(--wash-2) center/cover no-repeat; display: grid; place-items: center; font-weight: var(--display-weight); font-size: 20px; color: var(--muted); }
.card .tt { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .ss { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .acts { display: flex; gap: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); padding: 2px; background: var(--wash); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 3px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.pick-target { width: 100%; padding: 14px; border: 1.5px dashed var(--faint); border-radius: var(--r); background: var(--wash); color: var(--muted); cursor: pointer; font-weight: 600; text-align: left; }
.pick-target:hover { border-color: var(--ink); color: var(--ink); }

/* lists */
.stack { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.item.dragging { opacity: .35; }
.item.drop-before { box-shadow: 0 -3px 0 var(--tertiary); }
.handle { width: 24px; height: 36px; border: 0; background: transparent; cursor: grab; color: var(--faint); font-size: 14px; letter-spacing: -2px; padding: 0; }
.handle:hover { color: var(--ink); }
.adder { margin-top: 10px; }
.group { border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
.group > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-weight: 650; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary .chev { transition: transform .15s; color: var(--muted); }
.group[open] > summary .chev { transform: rotate(90deg); }
.group > summary .sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group > summary .sw { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); }
.group > .gbody { padding: 6px 14px 4px; border-top: 1px solid var(--line); }
.group .field { margin-bottom: 20px; }

/* ---------- modal, drawer, toast ---------- */
.scrim { position: fixed; inset: 0; background: color-mix(in oklab, var(--primary) 55%, transparent); display: grid; place-items: center; z-index: 30; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--paper); border-radius: 8px; width: min(1040px, 94vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.modal.narrow { width: min(460px, 94vw); }
.m-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.m-head h3 { margin: 0; flex: 1; font-size: 22px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }
.m-tools { display: flex; gap: 8px; padding: 0 20px 12px; align-items: center; border-bottom: 1px solid var(--line); }
.m-tools .search { max-width: 300px; }
.m-body { padding: 16px 20px; overflow: auto; }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); align-items: center; }
.m-foot .note { flex: 1; color: var(--muted); font-size: 13px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pcell { cursor: pointer; border-radius: var(--r); }
.pcell .ph { aspect-ratio: 1; border-radius: var(--r); background: var(--wash-2) center/cover no-repeat; display: grid; place-items: center; font-size: 34px; font-weight: var(--display-weight); color: var(--faint); position: relative; }
.pcell.sel .ph { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--tertiary); }
.pcell.sel .ph::after { content: "✓"; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--tertiary); color: var(--on-tertiary); font-size: 14px; display: grid; place-items: center; font-weight: 700; }
.pcell .cap { font-size: 13px; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcell .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow { display: flex; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.prow:hover { background: var(--wash); }
.prow.sel { font-weight: 700; }
.prow.sel::after { content: "✓"; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 96vw); background: var(--paper); border-left: 1px solid var(--line); box-shadow: -20px 0 60px rgba(0, 0, 0, .15); z-index: 25; display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer .d-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer .d-head h3 { margin: 0; flex: 1; font-size: 18px; font-weight: var(--display-weight); }
.drawer .d-body { padding: 18px; overflow: auto; flex: 1; }
.drawer img { width: 100%; border-radius: var(--r); background: var(--wash-2); display: block; margin-bottom: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 14px 10px 16px; border-radius: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); z-index: 40; display: flex; gap: 12px; align-items: center; max-width: min(720px, 92vw); font-size: 14px; animation: rise .16s ease-out; }
.toast.err { border-left: 4px solid var(--tertiary); white-space: pre-wrap; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; font-size: 16px; }
@keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } }

.log { position: fixed; left: 264px; bottom: 16px; width: min(640px, 70vw); max-height: 48vh; display: flex; flex-direction: column; background: var(--primary); color: var(--on-primary); border-radius: 8px; box-shadow: 0 16px 50px rgba(0, 0, 0, .4); z-index: 26; border: 1px solid var(--side-line); }
.log-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--side-line); font-weight: 700; }
.log-head .grow { flex: 1; }
.log-head a { color: var(--tertiary); font-weight: 600; }
.log-head button { background: none; border: 0; color: var(--side-muted); cursor: pointer; font-size: 16px; }
.log pre { margin: 0; padding: 10px 14px; overflow: auto; font: 12px/1.55 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: color-mix(in oklab, var(--on-primary) 80%, var(--primary)); }

/* ---------- media library page ---------- */
.lib { padding: 30px 28px 120px; }
.lib h1 { margin: 0 0 18px; font-size: 40px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.1; }
.lib-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.lib-tools .search { max-width: 340px; }
.lib-tools .count { color: var(--muted); font-size: 13px; flex: 1; }
.dropzone { border: 1.5px dashed var(--faint); border-radius: 8px; padding: 22px; text-align: center; color: var(--muted); margin-bottom: 18px; background: var(--wash); }
.dropzone a { color: var(--ink); font-weight: 600; }
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

.empty { display: grid; place-items: center; height: calc(100vh - 56px); color: var(--muted); text-align: center; padding: 40px; }
.empty h2 { color: var(--ink); font-size: 26px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); margin: 0 0 6px; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; background: var(--primary); }
.login-card { background: var(--paper); padding: 30px; border-radius: 8px; width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0 0 4px; font-size: 30px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.login-card input { border: 1px solid var(--line); border-radius: var(--r); padding: 9px 10px; font-weight: 400; }
.login-card input:focus { outline: none; border-color: var(--ink); }
.login-card .err { color: var(--danger); margin: 0; font-size: 13px; }
.login-card button { margin-top: 4px; justify-content: center; padding: 10px; }

@media (max-width: 1000px) {
  .shell, .shell.wide { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; min-height: 100vh; }
  .side { position: static; }
  .nav { max-height: 34vh; }
  .list { max-height: 40vh; }
  .log { left: 16px; }
}

/* history menu */
.menu { position: fixed; z-index: 35; min-width: 260px; max-height: 60vh; overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, .18); padding: 6px; animation: fade .1s ease-out; }
.menu-h { font-size: 12px; color: var(--muted); padding: 6px 10px 4px; }
.menu button { display: flex; justify-content: space-between; gap: 12px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 4px; cursor: pointer; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--wash-2); }
.menu .by { color: var(--muted); font-size: 12.5px; }
/* compact links */
.link-edit { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--wash); }
.link-edit .top { display: flex; gap: 8px; align-items: center; }
.link-edit .top .in { flex: 1; }
.row-end { display: flex; justify-content: flex-end; }
.card .ext { font-weight: var(--display-weight); }

/* chips (references without images: people, categories) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-weight: 600; font-size: 14px; cursor: grab; }
.chip:hover { border-color: var(--faint); }
.chip.dragging { opacity: .35; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; }
.chip button:hover { background: var(--wash-2); color: var(--ink); }
.chip.add { cursor: pointer; border-style: dashed; color: var(--muted); padding-right: 12px; }
.chip.add:hover { color: var(--ink); border-color: var(--ink); }

/* =====================================================================
   The site's own look. Everything below is driven by the site theme:
   its two colours, its fonts, its item style (uppercase, ☞) and its
   menu rule (pietersteyaert.net: 4px dashed white). No extra colours.
   ===================================================================== */
:root {
  --r: 0px;
  --danger: var(--ink);
  --line: color-mix(in oklab, var(--ink) 26%, var(--paper));
  --rule: 1px dashed color-mix(in oklab, var(--ink) 55%, var(--paper));
  --rule-heavy: 2px dashed var(--ink);
}
:focus-visible { outline: 2px dashed var(--ink); outline-offset: 3px; }

.btn { text-transform: var(--item-transform); font-weight: var(--item-weight); letter-spacing: .03em; font-size: 13px; }
.btn.small { font-size: 12px; }
.btn.go, .btn.solid { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.go:hover, .btn.solid:hover { background: var(--paper); color: var(--ink); filter: none; }
.btn.danger:hover { text-decoration: underline; }
.btn.quiet:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }

/* sidebar: the site's menu box */
.side { border-right: var(--rule); }
.mark { font-size: 64px; padding: 24px 22px 4px; }
.site-name { padding-bottom: 22px; }
.nav { flex: 0 1 auto; margin: 0 22px; padding: 12px 0 14px; border-top: var(--rule-heavy); border-bottom: var(--rule-heavy); }
.nav h3 { margin: 16px 0 6px; }
.nav h3:first-child { margin-top: 4px; }
.nav a { padding: 3px 0; font-size: 21px; line-height: 1.2; align-items: center; justify-content: flex-start; gap: 10px; }
.nav a .lbl { flex: 1; }
.nav a .ico { color: var(--side-muted); display: inline-flex; }
.nav a.on .ico, .nav a:hover .ico { color: var(--on-primary); }
.nav a.on .lbl { text-decoration-color: var(--on-primary); text-decoration-thickness: 2px; }
.side-foot { margin-top: auto; border-top: 0; }
.side-foot .btn.go { font-size: 16px; padding: 11px 12px; }

.ico { display: inline-flex; flex: none; }
.ico svg { display: block; }

/* list */
.list { border-right: var(--rule); background: var(--paper); }
.list-head { border-bottom: var(--rule); }
.list-head h2 { display: flex; align-items: center; gap: 10px; }
.doc { border-left-width: 2px; }
.doc.on { background: var(--wash-2); border-left-color: var(--ink); }
.badge { background: none; border: 1px dashed var(--muted); border-radius: 0; text-transform: var(--item-transform); font-size: 10px; letter-spacing: .05em; }

/* page */
.bar { border-bottom: var(--rule); background: color-mix(in oklab, var(--paper) 94%, transparent); }
.bar .crumb { display: flex; align-items: center; gap: 8px; }
.titlewrap { border-bottom: var(--rule); }
.switch input { border-radius: 0; }
.switch input::after { border-radius: 0; }
.in:focus, .rt:focus-within { box-shadow: none; border-color: var(--ink); }
.wys { font-size: var(--text-size); line-height: 1.6; }
.wys a { text-decoration-color: currentColor; text-decoration-thickness: 1px; }
.wys blockquote { border-left: 2px dashed var(--ink); }
.rt-bar { border-bottom: var(--rule); }
.rt-bar .icon.on { background: var(--ink); color: var(--paper); }
.raw { background: var(--wash); }
.linkpop { border: var(--rule-heavy); box-shadow: none; }
.link-edit { border: var(--rule); background: var(--paper); }
.card { border-color: var(--line); }
.pick-target, .media-empty, .madd, .dropzone { border: 1px dashed color-mix(in oklab, var(--ink) 55%, var(--paper)); background: transparent; }
.media-empty:hover, .over, .madd:hover, .pick-target:hover { border-color: var(--ink) !important; background: var(--wash-2) !important; color: var(--ink); }
.chip { border-radius: 0; }
.chip.add { border-style: dashed; }
.seg, .seg button { border-radius: 0; }
.seg button.on { background: var(--ink); color: var(--paper); box-shadow: none; }
.group > summary .sw { border-radius: 0; }
.mcell .x { border-radius: 0; background: var(--ink); color: var(--paper); }
.pcell.sel .ph { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.pcell.sel .ph::after { border-radius: 0; background: var(--ink); color: var(--paper); }
.state.dirty::before { border-radius: 0; background: var(--ink); box-shadow: none; }

/* dialogs carry the site's menu rule */
.scrim { background: color-mix(in oklab, var(--paper) 78%, transparent); }
.modal { border: var(--rule-heavy); border-radius: 0; box-shadow: none; }
.m-head h3::before, .drawer .d-head h3::before { content: "/ "; }
.m-tools { border-bottom: var(--rule); }
.m-foot { border-top: var(--rule); }
.drawer { border-left: var(--rule-heavy); box-shadow: none; }
.drawer .d-head { border-bottom: var(--rule); }
.menu { border: var(--rule-heavy); border-radius: 0; box-shadow: none; }
.menu button { border-radius: 0; }
.log { border: var(--rule-heavy); border-radius: 0; box-shadow: none; background: var(--paper); color: var(--ink); }
.log-head { border-bottom: var(--rule); }
.log-head a { color: var(--ink); text-decoration: underline; }
.log pre { color: var(--muted); }
.toast { border-radius: 0; background: var(--ink); color: var(--paper); box-shadow: none; }
.toast.err { border-left: 0; outline: 2px dashed var(--ink); outline-offset: 3px; }

.lib h1, .empty h2 { display: flex; align-items: center; gap: 14px; justify-content: inherit; }
.empty .ico { color: var(--muted); margin-bottom: 12px; justify-content: center; width: 100%; }
.nav a { font-size: 19px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- theme page ---------- */
.theme { display: grid; grid-template-columns: minmax(420px, 620px) minmax(0, 1fr); gap: 36px; padding: 34px 28px 140px; align-items: start; }
.tcol .titlewrap { margin-bottom: 8px; }
.tsec { padding: 22px 0 18px; border-bottom: var(--rule); }
.tsec h2 { margin: 0 0 14px; font-size: 22px; font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }
.trow { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; align-items: center; margin: 0 0 10px; }
.trow .tl { font-size: 14px; font-weight: 600; }
.subl { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.in.tlen { width: 120px; }
.in.tnum { width: 84px; }
.scale { display: grid; gap: 6px; overflow-x: auto; }
.scale-h, .scale-r { display: grid; grid-template-columns: 130px 78px 78px 78px 86px 116px 100px; gap: 6px; align-items: center; }
.scale-h span { font-size: 12px; color: var(--muted); }
.scale-r .rl { font-weight: 600; font-size: 13.5px; }
.scale-r .in { width: 100%; padding: 6px 7px; font-size: 13px; }
.fonts { display: grid; gap: 8px; }
.font { display: grid; grid-template-columns: auto 56px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); cursor: pointer; }
.font.on { border-color: var(--ink); }
.font input { accent-color: var(--ink); }
.font .aa { font-size: 34px; font-weight: 700; line-height: 1; }
.tprev { position: sticky; top: 76px; }
.pv-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.pv-frame { border: var(--rule); overflow: hidden; max-height: calc(100vh - 120px); }
.pv-site { zoom: .5; padding: 30px 40px 60px; min-height: 100%; }
.pv-mark { text-align: center; }
.pv-cols { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 80px; margin-top: 20px; }
.pv-menu { padding: 10px 0; align-self: start; }
@media (max-width: 1250px) { .theme { grid-template-columns: 1fr; } .tprev { position: static; } }
.theme { grid-template-columns: minmax(420px, 700px) minmax(0, 1fr); }
.scale-h, .scale-r { grid-template-columns: 116px 70px 66px 66px 84px 104px 92px; }

/* ---------- inbox ---------- */
.inbox-tabs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.inbox-list { display: grid; border-top: var(--rule); }
.inbox-row { all: unset; display: grid; grid-template-columns: 110px minmax(0, 1fr) 120px; gap: 16px; align-items: baseline; padding: 12px 6px; border-bottom: var(--rule); cursor: pointer; }
.inbox-row:hover { background: var(--wash-2); }
.inbox-row:focus-visible { outline: 2px dashed var(--ink); }
.inbox-row.unread .ir-who { font-weight: 800; }
.inbox-row.unread .ir-when::before { content: "● "; }
.ir-when { font-size: 13px; color: var(--muted); }
.ir-main { display: flex; flex-direction: column; min-width: 0; }
.ir-who { font-weight: 600; }
.ir-lead { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-form { font-size: 12px; text-transform: var(--item-transform); letter-spacing: .04em; color: var(--muted); text-align: right; }
.kvs { display: grid; gap: 10px; margin: 14px 0 18px; }
.kv .k { font-size: 12.5px; color: var(--muted); }
.kv .v { white-space: pre-wrap; overflow-wrap: anywhere; }
.plist { margin: 0; padding: 0; list-style: none; border-top: var(--rule); }
.plist li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: var(--rule); }
.nav .count.new { color: var(--on-primary); font-weight: 700; }
.mark.long { font-size: 30px; line-height: 1.05; overflow-wrap: anywhere; }
