:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6860;
  --border: #dedbd3;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --danger: #a3261b;
  --warn: #8a5a00;
  --ok: #1d6b3a;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #201f1c;
    --text: #ecebe6;
    --muted: #a3a097;
    --border: #3a3833;
    --accent: #7fb2e5;
    --accent-text: #0e1a26;
    --danger: #f08a7e;
    --warn: #e0b35c;
    --ok: #7fcf98;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: 0.02em; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page { max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.card h2 { margin-top: 0; }
.card.disabled { opacity: 0.6; }

form p, form div { margin-bottom: 0.75rem; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
  width: 100%; max-width: 28rem; padding: 0.5rem 0.6rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
input[readonly] { color: var(--muted); }
button, .button {
  display: inline-block; padding: 0.5rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--accent-text); background: var(--accent); border: 1px solid var(--accent);
  border-radius: 6px; text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 400; }
button.danger, .danger { color: var(--danger); }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start; }
.row input { flex: 1 1 16rem; }
input.copy { max-width: 100%; font-family: ui-monospace, monospace; font-size: 0.85rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message, .notice { padding: 0.6rem 0.9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 0.5rem; }
.message.error { border-color: var(--danger); }
.message.success { border-color: var(--ok); }
.errorlist { color: var(--danger); padding-left: 1rem; margin: 0.25rem 0; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
@media (max-width: 640px) { table { display: block; overflow-x: auto; } }

.badge { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.badge.pending { color: var(--accent); border-color: var(--accent); }
.badge.used { color: var(--ok); border-color: var(--ok); }
.badge.revoked, .badge.expired { color: var(--muted); }

/* --- archive --------------------------------------------------------------- */
.small { font-size: 0.85rem; }
.small-button { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.cards form input[type=file] { margin: 0.25rem 0 0.75rem; max-width: 100%; }
details summary { cursor: pointer; }
.artifact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.artifact-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 0.75rem; align-items: center;
  padding: 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.artifact-row:hover { border-color: var(--accent); }
.artifact-row .thumb { width: 96px; height: 64px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.artifact-row .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.artifact-row .summary { display: flex; flex-direction: column; min-width: 0; }
.artifact-row .title { font-weight: 600; overflow-wrap: anywhere; }
.artifact-title { overflow-wrap: anywhere; }
.source-url { overflow-wrap: anywhere; }
.capture-bar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; padding: 0.6rem 0.8rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; }
#capture-status { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.badge.running, .badge.pending { color: var(--accent); border-color: var(--accent); }
.badge.done { color: var(--ok); border-color: var(--ok); }
.badge.partial { color: var(--warn); border-color: var(--warn); }
.badge.failed { color: var(--danger); border-color: var(--danger); }
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.shots figure { margin: 0; }
.shots img { width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.media-grid img, .media-grid video { width: 100%; border-radius: 6px; border: 1px solid var(--border); background: #000; }
.media-grid video { grid-column: span 2; }
iframe.replay { width: 100%; height: 75vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.extracted-text { white-space: normal; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; max-height: 24rem; overflow: auto; }
.inline-h2 { display: inline; }
.provenance { margin-top: 1.5rem; }
.provenance dt { font-weight: 600; margin-top: 0.5rem; }
.provenance dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
table.files { margin-top: 0.5rem; font-size: 0.85rem; }
code { font-family: ui-monospace, monospace; font-size: 0.85em; }
@media (max-width: 640px) { .media-grid video { grid-column: auto; } .artifact-row { grid-template-columns: 64px 1fr; } .artifact-row .badge { display: none; } }
.capture-notes { flex-basis: 100%; margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--warn); }
.card-title { margin: 0 0 0.5rem; font-size: 1rem; }
.card dl dt { font-weight: 600; margin-top: 0.4rem; }
.card dl dd { margin: 0; }

/* --- organize & search (M4) ------------------------------------------------- */
.topsearch { flex: 1 1 12rem; max-width: 24rem; margin: 0; }
.topsearch input { width: 100%; max-width: none; padding: 0.35rem 0.6rem; }
input[type=search], input[type=date], input[type=number] {
  padding: 0.5rem 0.6rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.search-form input[type=search] { flex: 1 1 16rem; }
.filters { margin: 0.75rem 0 0; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem 1rem; margin-top: 0.75rem; }
.filter-grid > div { margin: 0; }
.filter-grid label { font-size: 0.85rem; }
.filter-grid select, .filter-grid input { width: 100%; }
.pager { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
.snippet { display: block; color: var(--text); overflow-wrap: anywhere; margin-top: 0.2rem; }
mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; padding: 0 0.1em; border-radius: 2px; }

.owner-bar { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; margin: -0.25rem 0 1rem; }
.notice.warn-border { border-color: var(--warn); }
.notice.warn-border form { margin-left: 0.5rem; }
.organize { display: grid; gap: 0.75rem; margin: 1rem 0; }
.org-group { margin: 0; }
.org-heading { font-size: 0.95rem; margin: 0 0 0.35rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.1rem 0.6rem; font-size: 0.85rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text); text-decoration: none;
}
a.chip:hover { border-color: var(--accent); }
.chip a { color: var(--text); text-decoration: none; }
.chip-x { background: none; border: none; padding: 0 0.1rem; color: var(--muted); font-weight: 400; font-size: 1rem; line-height: 1; }
.chip-x:hover { color: var(--danger); }
.tag-add { display: inline-flex; gap: 0.3rem; align-items: center; }
.tag-add input { width: 9rem; padding: 0.15rem 0.5rem; font-size: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 0.4rem; align-items: stretch; margin-top: 0.5rem; }
.stack > * { margin: 0; }
.stack textarea, .stack select, .stack input { max-width: 100%; }
.organize details { margin-top: 0.4rem; }
label.checkbox { display: inline-flex; gap: 0.35rem; align-items: center; font-weight: 400; margin: 0; }

.found-text { margin-top: 0.75rem; }
.found-text .extracted-text { margin-top: 0.5rem; }
.extracted-text p { margin: 0 0 0.6rem; }
.extracted-text p:last-child { margin-bottom: 0; }
.transcript p { margin: 0 0 0.35rem; }
.transcript .seek { font-variant-numeric: tabular-nums; text-decoration: none; margin-right: 0.35rem; }
.file-list { padding-left: 1.1rem; }
.file-list li { margin-bottom: 0.5rem; }

.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.list-row { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; padding: 0.6rem 0.8rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.list-row .title { font-weight: 600; }
.item-note { margin: 0.3rem 0 0 0.5rem; }
.placeholder { padding: 0.6rem 0.8rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.placeholder-body { display: flex; flex-direction: column; }
.placeholder .title { font-weight: 600; color: var(--muted); }
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose pre { overflow-x: auto; background: var(--bg); padding: 0.5rem; border-radius: 6px; }
.prose blockquote { margin: 0.5rem 0; padding-left: 0.75rem; border-left: 3px solid var(--border); color: var(--muted); }
.note { margin-top: 0.75rem; }
.note .note-meta { margin-top: 0.5rem; }
.item-tools { margin: 0.2rem 0 0 0.5rem; }
.item-tools .stack { max-width: 36rem; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.filters-inline a[aria-current] { font-weight: 700; color: var(--text); text-decoration: none; }
@media (max-width: 640px) { .topbar { flex-wrap: wrap; } .topsearch { order: 3; flex-basis: 100%; max-width: none; } }
