:root {
  --bg: #efeae1;
  --panel: #fbfaf7;
  --ink: #17150f;
  --muted: #6b6357;
  --rule: #d9d1c3;
  --accent: #6b4f35;
  --danger: #a3372b;
  --ok: #2f7a4b;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 28px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { font-weight: 600; letter-spacing: 0.08em; }
.top .brand span { opacity: 0.6; font-weight: 400; margin-left: 4px; }
.top nav { display: flex; gap: 18px; }
.top nav a { opacity: 0.78; font-size: 14px; letter-spacing: 0.04em; }
.top nav a:hover { opacity: 1; }
.top .site { margin-left: auto; font-size: 13px; opacity: 0.7; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px; }
h1 { font-size: 26px; margin: 0 0 12px; font-weight: 500; }
h2 { font-size: 18px; margin: 32px 0 10px; font-weight: 500; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }
.hint a { text-decoration: underline; }
button, .button { font: inherit; padding: 8px 14px; border: 1px solid var(--ink); background: var(--ink); color: #fff; border-radius: 6px; cursor: pointer; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.primary { padding: 12px 22px; font-size: 16px; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; width: 100%; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input, .inline select { width: auto; min-width: 180px; }
.fields { display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 18px; }
.fields .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.fields button { justify-self: start; }
.checks { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
.checks legend { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.checks label { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.checks input { width: auto; }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.toggle input { width: auto; }
.actions { display: flex; gap: 12px; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 200px)); gap: 12px; margin: 10px 0 18px; }
.stat { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px; color: var(--muted); font-size: 13px; }
.stat span { display: block; font-size: 28px; color: var(--ink); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list li { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; display: flex; align-items: center; }
.list li a { display: flex; align-items: center; gap: 14px; padding: 8px 12px; flex: 1; }
.list img, .list .nohero { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--rule); flex: none; }
.list .name { font-weight: 500; }
.list .meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.grip { cursor: grab; color: var(--muted); padding: 0 6px 0 12px; user-select: none; }
.sortable li.dragging { opacity: 0.4; }
.sortable li.over { outline: 2px dashed var(--accent); }
.media-section { margin-top: 28px; }
.count { color: var(--muted); font-weight: 400; font-size: 14px; }
.grid { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid li { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; cursor: grab; }
.grid li.is-hero { outline: 3px solid var(--accent); }
.grid img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; }
.grid .tools { display: grid; grid-template-columns: auto 1fr; gap: 6px; padding: 8px; align-items: center; }
.grid .tools select { padding: 5px 6px; font-size: 12px; grid-column: 1 / -1; }
.grid .star { background: transparent; color: var(--muted); border-color: var(--rule); padding: 4px 8px; }
.grid li.is-hero .star { color: var(--accent); border-color: var(--accent); }
.grid .remove { background: transparent; color: var(--danger); border-color: transparent; padding: 4px 8px; justify-self: end; }
.grid .replace { cursor: pointer; color: var(--muted); font-size: 16px; justify-self: end; }
.grid .replace input { display: none; }
.pairs { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pairs button { justify-self: start; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table th { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; display: flex; align-items: center; gap: 14px; z-index: 50; }
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); }
/* A change just made can be taken back from its message. */
.toast .undo { flex: none; min-height: 32px; padding: 5px 14px; border: 0; border-radius: 999px; background: #f4efe6; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.toast .undo:hover { background: #fff; }
.toast .undo[disabled] { opacity: 0.5; cursor: default; }

/* The console's own question, in place of the browser's grey box. */
.ask-scrim { position: fixed; inset: 0; background: rgba(20, 16, 10, 0.42); z-index: 60; }
.ask { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 22px 18px; border-radius: 12px; background: var(--panel); box-shadow: 0 18px 50px rgba(20, 16, 10, 0.28); z-index: 61; }
.ask h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.ask p { margin: 0; color: var(--muted); white-space: pre-line; }
.ask-buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.ask-buttons button.ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.ask-buttons button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }

.grid .file { grid-column: 1 / -1; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checks legend small { font-weight: 400; }
.table td.nowrap { white-space: nowrap; }
.cover summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 13px; color: var(--muted); }
.cover summary::-webkit-details-marker { display: none; }
.cover summary img, .cover summary .nohero { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: var(--rule); flex: none; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 8px; max-height: 320px; overflow: auto; padding: 6px; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; min-width: 360px; }
.cover-grid button { padding: 0; border: 2px solid transparent; background: transparent; border-radius: 6px; overflow: hidden; line-height: 0; }
.cover-grid button img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.cover-grid button.is-current { border-color: var(--accent); }
.cover-grid .cover-auto { line-height: 1.4; font-size: 12px; background: var(--panel); border: 2px solid var(--rule); color: var(--ink); aspect-ratio: 4 / 3; }
.cover-grid .cover-auto.is-current { border-color: var(--accent); }
.cover-grid .hint { grid-column: 1 / -1; margin: 0; }
.fields .row > label { align-content: start; }
.table td input[data-key-field] { min-width: 160px; }
.table td select[data-key-field] { min-width: 130px; }
.table td.cover-cell { width: 40%; min-width: 340px; }
.cover-grid { min-width: 0; width: 100%; }
.cover summary { flex-wrap: wrap; }
.cover summary .cover-label { white-space: nowrap; }
.cover summary .cover-note { color: var(--muted); font-size: 12px; }
.cover-borrow { grid-column: 1 / -1; margin-top: 8px; }
.cover-borrow > summary { font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px 0; }
.cover-grid .cover-auto:has(img) { aspect-ratio: auto; display: grid; grid-template-rows: 1fr auto; }
.cover-grid .cover-auto img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.cover-grid .cover-auto span { display: block; padding: 3px 0; font-weight: 600; }

/* --- console controls added for the full control panel --- */
.top .links { margin-left: auto; display: flex; gap: 14px; }
.top .site { margin-left: 0; }
h3 { font-size: 15px; margin: 18px 0 6px; font-weight: 500; }
.stat small { font-size: 14px; color: var(--muted); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 14px; }
.plain a { text-decoration: underline; }
.meta { color: var(--muted); font-size: 13px; }
.tag { font-weight: 500; font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--rule); color: var(--ink); }
.tag.warn { background: #f3dcd2; color: var(--danger); }
.warnings { margin: 0; padding-left: 18px; font-size: 14px; color: var(--danger); display: grid; gap: 4px; }
.warn-line { color: var(--danger); font-size: 13px; margin: 0 0 8px; }
.empty { color: var(--muted); font-size: 14px; padding: 16px; border: 1px dashed var(--rule); border-radius: 10px; text-align: center; margin: 12px 0; }
button.ghost { background: transparent; color: var(--ink); border-color: var(--rule); padding: 3px 8px; font-size: 13px; }
button.ghost.danger { color: var(--danger); }
.rowtools { display: flex; gap: 4px; align-items: center; padding: 0 10px; margin-left: auto; }
.list li .rowtools { margin-left: 0; }
.preview { font-size: 13px; color: var(--accent); text-decoration: underline; white-space: nowrap; }
.actions .preview { margin-right: 6px; }
.grid .tools input[data-key="note"] { grid-column: 1 / -1; padding: 5px 6px; font-size: 12px; }
.grid .tools .moves { display: flex; gap: 4px; }
.grid .tools .filetools { display: flex; gap: 6px; align-items: center; justify-self: end; }
.grid .remove { justify-self: auto; }
.picks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; counter-reset: pick; }
.picks li { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 6px 10px; }
.picks li::before { counter-increment: pick; content: counter(pick); color: var(--muted); font-size: 12px; width: 16px; }
.picks .name { font-weight: 500; }
.picks .rowtools { padding: 0; }
.poster { width: 96px; height: 60px; object-fit: cover; border-radius: 6px; background: var(--rule); display: block; }
code { font-size: 13px; background: var(--panel); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
label small { font-weight: 400; color: var(--muted); }
.table .toggle { font-size: 13px; }

/* films */
.grid.films { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.films video { width: 100%; aspect-ratio: 16 / 10; background: #000; display: block; }
.grid.films .film-placeholder { aspect-ratio: 16 / 10; display: grid; place-items: center; color: var(--muted); font-size: 13px; background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(255, 255, 255, 0.04) 10px 20px); }
.grid.films li[data-status='failed'] .film-placeholder { color: var(--danger); }
.grid.films .film-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.grid.films .tools input { grid-column: 1 / -1; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; margin: 0; }
.login { width: min(100% - 32px, 380px); display: grid; gap: 20px; }
.login .brand { font-size: 22px; }
.login-form { display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 22px; }
.login-form label { display: grid; gap: 6px; font-size: 14px; }
.login-form input { width: 100%; box-sizing: border-box; }
.login-error { margin: 0; color: var(--danger); font-size: 14px; }



/* site status in the header and the Website button on the login page */
.site-status { font-size: 12px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--rule); border-radius: 999px; }
.site-status[data-state='updating'] { color: var(--accent); border-color: var(--accent); }
.site-status[data-state='failed'] { color: var(--danger); border-color: var(--danger); }
.login-site { text-align: center; font-size: 14px; margin: 0; }
.login-site a { text-decoration: underline; }
.grid .tools em { font-style: normal; color: var(--muted); }

/* statistics */
:root { --chart: #a4702f; --grid: #e7e0d3; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.pill { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px; font-size: 14px; background: var(--panel); }
.pill.is-current { border-color: var(--ink); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.kpi { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; display: grid; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 30px; font-weight: 600; line-height: 1.1; }
.chart { margin: 0 0 28px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px 12px; }
.chart figcaption { font-weight: 600; margin-bottom: 12px; }
.chart-body { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.chart-y { position: relative; height: 200px; min-width: 2.5em; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-y span { position: absolute; right: 0; top: calc((1 - var(--f)) * 100%); transform: translateY(-50%); line-height: 1; }
.chart-plot { position: relative; height: 200px; }
.chart-grid { position: absolute; inset: 0; }
.chart-grid span { position: absolute; left: 0; right: 0; top: calc((1 - var(--f)) * 100%); border-top: 1px solid var(--grid); }
.chart-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); list-style: none; margin: 0; padding: 0; }
.chart-bars li { position: relative; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline: none; }
.chart-bars li:hover, .chart-bars li:focus-visible { background: rgba(23, 21, 15, 0.04); }
.chart-bars li:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
.vbar { display: block; width: min(24px, calc(100% - 2px)); height: calc(var(--h) * 100%); background: var(--chart); border-radius: 4px 4px 0 0; }
.chart-bars li:hover .vbar, .chart-bars li:focus-visible .vbar { filter: brightness(1.12); }
.peak { position: absolute; bottom: calc(var(--h) * 100% + 4px); font-size: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.chart-x { display: grid; grid-template-columns: repeat(var(--n), 1fr); margin-left: calc(2.5em + 8px); font-size: 12px; color: var(--muted); padding-top: 6px; }
.chart-x span { white-space: nowrap; overflow: visible; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--ink); color: #fff; border-radius: 6px; padding: 6px 10px; font-size: 13px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, -100%); }
.chart-tip strong { display: block; font-size: 15px; }
.chart-tip .tip-sub { opacity: 0.75; }
.chart-table { margin-top: 12px; font-size: 14px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stats-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px; }
.stats-card h2 { margin: 0 0 10px; font-size: 16px; }
.stats-card h3 { margin: 14px 0 6px; font-size: 14px; font-weight: 500; color: var(--muted); }
.bar-list { width: 100%; border-collapse: collapse; font-size: 14px; }
.bar-list th { text-align: left; font-weight: 400; padding: 5px 8px 5px 0; width: 45%; }
.bar-list .bar-cell { width: 45%; padding: 5px 8px; }
.bar-list .num { text-align: right; font-variant-numeric: tabular-nums; padding: 5px 0; white-space: nowrap; }
.hbar { display: block; height: 10px; width: calc(var(--w) * 100%); min-width: 2px; background: var(--chart); border-radius: 0 4px 4px 0; }
.num { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .kpi-value { font-size: 26px; }
}

/* phones: the header wraps instead of pushing the page sideways, and wide
   tables scroll inside their own box */
.site-status { white-space: nowrap; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; position: static; }
  .top nav { order: 3; width: 100%; flex-wrap: wrap; gap: 6px 16px; }
  .top nav a { padding: 6px 0; }
  .top .links { margin-left: auto; display: flex; gap: 12px; align-items: center; }
  .top .site { margin-left: 0; }
  .page { padding: 18px 16px; }
  .table { display: block; overflow-x: auto; max-width: 100%; }
  form.inline { flex-wrap: wrap; max-width: 100%; }
  form.inline > * { max-width: 100%; }
  form.inline input[type='file'] { width: 100%; }
}

/* help page */
.guide-toc ol { display: flex; flex-wrap: wrap; gap: 6px 10px; list-style: none; padding: 0; margin: 8px 0 24px; }
.guide-toc a { display: inline-flex; min-height: 34px; align-items: center; padding: 0 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--panel); font-size: 14px; }
.guide { max-width: 820px; }
.guide section { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 6px 22px 14px; margin-bottom: 16px; scroll-margin-top: 80px; }
.guide h2 { margin-top: 16px; }
.guide li { margin: 6px 0; }
.guide ul ul { margin-top: 6px; }
.guide a { text-decoration: underline; }
.guide code { font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* --- the upload control (markup and behaviour: admin/public/upload.js) --- */
.upload-form { display: grid; gap: 10px; margin: 0; flex: 1 1 320px; max-width: 460px; }
.uploader { display: grid; gap: 8px; }
/* the chips and the bar are toggled with the hidden attribute; flex would win over it */
.uploader [hidden] { display: none; }
/* the file input stays the source of truth: out of sight, still focusable */
.uploader input[type='file'] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.dropzone { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; background: var(--panel); color: var(--ink); border: 1px dashed var(--rule); border-radius: 10px; cursor: pointer; }
.dropzone:hover, .dropzone:focus-visible, .uploader input[type='file']:focus + .dropzone { border-color: var(--accent); outline: none; }
.uploader.is-over .dropzone { border-color: var(--accent); border-style: solid; background: #fff; }
.dropzone[disabled] { opacity: 0.6; cursor: default; }
.dz-icon { width: 22px; height: 22px; flex: none; color: var(--accent); }
.dz-lines { display: grid; gap: 2px; min-width: 0; }
.dz-text { font-size: 14px; }
.dz-types { font-size: 12px; color: var(--muted); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 3px 5px 3px 10px; background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; font-size: 13px; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.chip-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip button { width: 26px; height: 26px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; line-height: 1; }
.chip button:hover { background: var(--rule); color: var(--ink); }
.chip-clear { padding: 3px 5px; }
.chip-clear button { width: auto; height: 26px; padding: 0 12px; font-size: 12px; }
.upload-progress { display: flex; align-items: center; gap: 10px; }
.upload-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s linear; }
.upload-pct { font-size: 12px; color: var(--muted); min-width: 72px; text-align: right; }
.upload-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.upload-actions select { flex: 1 1 160px; min-width: 0; width: auto; }
.upload-actions button { flex: none; }
.upload-actions button[disabled] { opacity: 0.45; cursor: default; }
.checks .meta { font-size: 12px; }
@media (max-width: 760px) {
  .upload-form { width: 100%; max-width: none; }
  .chip-name { max-width: 55vw; }
}

/* --- the start page: the two ways in, shown right after logging in --- */
.start-welcome { color: var(--muted); font-size: 16px; margin: 6px 0 20px; }
.start-boxes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.start-box { display: flex; flex-direction: column; gap: 12px; min-height: 240px; padding: 28px 26px; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; color: var(--ink); }
.start-box h2 { margin: 0; font-size: 22px; font-weight: 500; }
.start-box p { margin: 0; color: var(--muted); font-size: 15px; max-width: 34ch; }
.start-box .start-arrow { margin-top: auto; font-size: 24px; line-height: 1; color: var(--accent); }
.start-box:hover, .start-box:focus-visible { border-color: var(--accent); background: #fff; outline: none; }
.start-box:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 760px) {
  .start-boxes { grid-template-columns: 1fr; gap: 14px; }
  .start-box { min-height: 170px; padding: 22px 20px; }
}

/* --- the dashboard tabs and the Edit the website link in the header --- */
.top nav.tabs { gap: 20px; }
.top nav.tabs a { display: inline-flex; align-items: center; min-height: 32px; padding: 2px 0; border-bottom: 2px solid transparent; }
.top nav.tabs a[aria-current='page'] { opacity: 1; font-weight: 600; border-bottom-color: #fff; }
.top .links { flex-wrap: wrap; align-items: center; }
.top .edit-site { opacity: 1; padding: 5px 12px; min-height: 32px; display: inline-flex; align-items: center; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 999px; }
.top .edit-site:hover { background: rgba(255, 255, 255, 0.12); }

/* --- the website card on the Overview --- */
.website-card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; margin: 4px 0 24px; }
.website-card[data-state='failed'] { border-left: 3px solid var(--danger); }
.website-card h2 { margin: 0 0 8px; font-size: 18px; }
.website-card p { margin: 0 0 6px; font-size: 14px; }
.website-card a { text-decoration: underline; }
.website-card .website-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 14px 0 0; }

/* --- the Logs page (markup: admin/logs.mjs) --- */
.warn-banner { margin: 0 0 14px; padding: 10px 14px; font-size: 14px; background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--chart); border-radius: 8px; }
/* on the Logs page the three groups sit under each other; wrapping a column
   container would stretch the form to the height of the whole block */
.filters:has(.filter-form) { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill.on { border-color: var(--ink); background: #fff; font-weight: 600; }
.pill .badge { margin-left: 8px; padding: 0 6px; min-width: 20px; text-align: center; font-size: 12px; font-weight: 400; color: var(--muted); background: var(--bg); border-radius: 999px; }
.pill.on .badge { color: var(--ink); background: var(--rule); }
.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; }
.filter-form label { flex: 1 1 200px; min-width: 0; gap: 4px; }
.filter-form input, .filter-form select { width: 100%; min-height: 36px; }
.filter-form button { flex: none; min-height: 36px; }
.filter-form .clear { display: inline-flex; align-items: center; min-height: 36px; padding: 0 6px; font-size: 13px; color: var(--muted); text-decoration: underline; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 20px 0 8px; }
.log-head .count { margin: 0; font-size: 14px; color: var(--muted); }
.log-tools { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.log-tools a { font-size: 13px; text-decoration: underline; }
button.linkish { padding: 0; min-height: 32px; border: 0; background: transparent; color: var(--danger); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.log-list { display: grid; gap: 4px; margin-bottom: 8px; }
.log-row { background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--rule); border-radius: 8px; }
.log-row[data-level='error'] { border-left-color: var(--danger); }
.log-row[data-level='warn'] { border-left-color: var(--chart); }
.log-row[data-level='audit'] { border-left-color: var(--accent); }
.log-row[data-level='info'], .log-row[data-level='access'] { border-left-color: var(--muted); }
.log-row > summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 36px; padding: 7px 12px; font-size: 14px; cursor: pointer; list-style: none; }
.log-row > summary::-webkit-details-marker { display: none; }
.log-row > summary:hover { background: #fff; }
.log-row[open] > summary { border-bottom: 1px solid var(--rule); }
.log-row .when { flex: none; width: 19ch; font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.log-row .level { flex: none; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 12px; white-space: nowrap; }
.log-row[data-level='error'] .level { background: #f3dcd2; color: var(--danger); }
.log-row[data-level='warn'] .level { color: var(--chart); }
.log-row[data-level='audit'] .level { color: var(--accent); }
.log-row .source { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.log-row .msg { flex: 1 1 180px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .facts { flex: 0 1 auto; min-width: 0; max-inline-size: 100%; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-body { padding: 10px 12px 12px; }
.log-body dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 13px; }
.log-body dt { color: var(--muted); }
.log-body dd { margin: 0; overflow-wrap: anywhere; }
pre.log-detail { margin: 10px 0 0; padding: 10px 12px; max-height: 340px; overflow: auto; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.log-detail.stack { color: var(--danger); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 24px; font-size: 14px; }
.pager a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; }
.pager > span { color: var(--muted); }
@media (max-width: 700px) {
  .log-row .facts { display: none; }
  .log-row .msg { flex: 1 1 100%; white-space: normal; overflow: visible; }
  .log-row .when { width: auto; }
}

/* Cards on the dashboard: what the next update puts on the site, in pictures. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 10px 0 22px; }
.card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; text-decoration: none; color: inherit; position: relative; }
.card:hover { border-color: var(--accent); }
.card img, .card .card-blank { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--rule); }
.card-name { padding: 8px 10px 0; font-size: 14px; font-weight: 500; }
.card-meta { padding: 2px 10px 10px; font-size: 12px; color: var(--muted); }
.card-flag { position: absolute; inset-block-start: 8px; inset-inline-start: 8px; background: #f3dcd2; color: var(--danger); font-size: 11px; padding: 2px 7px; border-radius: 4px; }
h3 .count { margin-inline-start: 6px; }

/* Replacing one of the two films that open the home page. */
.home-films { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin: 10px 0 14px; }
.panel-box { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 14px; }
.panel-box h3 { margin: 0 0 10px; font-size: 14px; }
.poster.wide { width: 100%; height: 140px; object-fit: contain; background: var(--bg); border-radius: 6px; margin-block-end: 10px; }

/* Table rows: the buttons end the row, away from the fields. */
.table td.actions-cell { text-align: right; }
.table td.actions-cell > * { vertical-align: middle; }

/* One style, with the photographs of every project that carries it. */
.style-project { margin: 6px 0 18px; }
.style-project h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 15px; }
.style-project h3 a { font-size: 13px; font-weight: 400; }
.style-project .card { cursor: default; }
.style-project .card:hover { border-color: var(--rule); }

/* A wide table scrolls inside its own box; the page itself never does. */
.table-wrap { max-inline-size: 100%; overflow-x: auto; }
.table-wrap .table { min-inline-size: 640px; }
.log-row, .log-body, .log-body dl, .log-body dd { min-inline-size: 0; }
.log-body dd { overflow-wrap: anywhere; }

/* On a touch screen every control is big enough for a thumb. */
@media (pointer: coarse) {
  .ghost, .star, .remove, .rowtools button, .mini { min-inline-size: 36px; min-block-size: 36px; }
  .replace { min-inline-size: 36px; min-block-size: 36px; display: inline-flex; align-items: center; justify-content: center; }
  .checks input[type='checkbox'], .toggle input[type='checkbox'], .check input[type='checkbox'] { inline-size: 20px; block-size: 20px; }
  .top .links a, .top .brand, .guide a, .log-tools a, .log-tools button { min-block-size: 32px; display: inline-flex; align-items: center; }
  .filters .pill, .pill { min-block-size: 36px; display: inline-flex; align-items: center; }
  .checks label, .check, .toggle { min-block-size: 32px; display: inline-flex; align-items: center; gap: 8px; }
}

/* A row shrinks to its box: the name gives way, the buttons keep their size. */
.list li a { min-inline-size: 0; }
.list li .name, .list li .meta { min-inline-size: 0; overflow-wrap: anywhere; }
@media (pointer: coarse) { .list li { flex-wrap: wrap; } }
