:root {
  color-scheme: light dark;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1b1b1e;
  --muted: #6b6b73;
  --line: #e2e0d9;
  --accent: #2b4a6f;
  --accent-ink: #fff;
  --danger: #a8342a;
  --ok: #2c6e49;
  --warn: #9a6b12;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131317; --panel: #1c1c22; --ink: #e9e8e4; --muted: #9a99a2;
    --line: #2e2e37; --accent: #6f9bd1; --accent-ink: #10131a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top nav */
#topnav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.4rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
#topnav .brand { font-weight: 700; cursor: pointer; letter-spacing: -.01em; }
#topnav nav { display: flex; align-items: center; gap: 1rem; }
#topnav nav .spacer { flex: 1; }
.who { color: var(--muted); font-size: .85rem; }

main { max-width: 1000px; margin: 0 auto; padding: 1.8rem 1.4rem 5rem; }
.loading { color: var(--muted); padding: 3rem 0; text-align: center; }

/* Auth */
.auth-wrap { max-width: 380px; margin: 8vh auto; }
.auth-wrap h1 { font-size: 1.4rem; text-align: center; }
.auth-wrap .sub { text-align: center; color: var(--muted); margin-top: -.4rem; margin-bottom: 1.6rem; }

/* Panels & cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; margin-bottom: 1.2rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: .7rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.card .meta { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.card h3 { margin: 0; font-size: 1.02rem; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 1.6rem 0 .6rem; }
.section-head h2 { font-size: 1.15rem; margin: 0; }

/* Forms */
label { display: block; font-weight: 600; font-size: .82rem; margin: .9rem 0 .3rem; }
label .hint { font-weight: 400; color: var(--muted); }
input, textarea, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; font-weight: 600; cursor: pointer; border: none; border-radius: 8px;
  padding: .55rem 1rem; background: var(--accent); color: var(--accent-ink);
}
button:hover { filter: brightness(1.06); }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.small { padding: .3rem .6rem; font-size: .8rem; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.row > * { margin: 0; }
.grow { flex: 1; }

/* Repeatable subforms */
.item {
  border: 1px solid var(--line); border-radius: 8px; padding: .8rem; margin-bottom: .6rem;
  background: var(--bg);
}
.item .item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.item .item-head strong { font-size: .85rem; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* Status pills */
.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.pill.queued { background: #dfe3e8; color: #444; }
.pill.gathering, .pill.classifying, .pill.analyzing, .pill.reviewing { background: #e7eefb; color: #2b4a6f; }
.pill.done { background: #d9efe1; color: var(--ok); }
.pill.error { background: #f6ddd9; color: var(--danger); }
@media (prefers-color-scheme: dark) {
  .pill.queued { background: #33333c; color: #cfcfd6; }
  .pill.gathering, .pill.classifying, .pill.analyzing, .pill.reviewing { background: #223250; color: #a8c4ea; }
  .pill.done { background: #1f3a2c; color: #7fd0a0; }
  .pill.error { background: #46231f; color: #e79a90; }
}

/* Log console */
.console {
  background: #0e0e12; color: #cfe3d0; border-radius: 8px; padding: .8rem 1rem;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 340px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
}
.console .l-error { color: #ff9d90; }
.console .l-warn { color: #ffd479; }
.console .ts { color: #6b7a6c; }

/* Editorial preview frame */
.editorial-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .6rem 1.1rem; border-radius: 8px; font-size: .85rem;
  z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,.25);
}
.err-text { color: var(--danger); font-size: .85rem; margin: .4rem 0; }
.empty { color: var(--muted); text-align: center; padding: 2rem; }
.muted { color: var(--muted); }
.stat { display: inline-block; margin-right: 1.4rem; }
.stat b { font-size: 1.3rem; display: block; }
.stat span { color: var(--muted); font-size: .78rem; }
