:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #1c1b1a;
  --muted: #6f6b66;
  --border: #e7e3de;
  --accent: #3b5bdb;
  --accent-soft: #edf1ff;
  --loop: #c2410c;
  --loop-soft: #fff1e8;
  --ok: #2f7d4f;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1f1e1c;
    --text: #ece9e4;
    --muted: #9c978f;
    --border: #2f2d2a;
    --accent: #8ea4ff;
    --accent-soft: #232a45;
    --loop: #fb923c;
    --loop-soft: #3a2416;
    --ok: #6fcf97;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--accent-soft); padding: 8px 10px; border-radius: 8px; }
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 650; letter-spacing: -0.01em; }
nav { display: flex; gap: 4px; flex: 1; }
nav button, .segmented button { background: none; border: 0; padding: 6px 10px; border-radius: 8px; color: var(--muted); font: inherit; cursor: pointer; }
nav button.active, .segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.upload { cursor: pointer; color: var(--accent); font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h2 { font-size: 17px; margin: 28px 0 6px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 140px; }
input[type=text], input:not([type]), input[type=password] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
button { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
form > button, .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.group-label { margin: 18px 0 6px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.item { display: flex; gap: 12px; padding: 10px; border-radius: var(--radius); cursor: pointer; align-items: flex-start; }
.item:hover { background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--accent-soft); flex: none; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.item .body { min-width: 0; flex: 1; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.chip.loop { background: var(--loop-soft); color: var(--loop); }
.chip.done { background: transparent; color: var(--ok); border: 1px solid currentColor; }
.chip.warn { background: transparent; color: var(--loop); border: 1px solid currentColor; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips label { display: inline-flex; gap: 4px; align-items: center; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; cursor: pointer; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.card label { font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.headline { font-size: 18px; font-weight: 600; margin: 8px 0 4px; }
.segmented { display: inline-flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; }
dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
#detail-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
#detail-body img.original { max-width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); align-self: flex-start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.history { font-size: 13px; color: var(--muted); border-left: 2px solid var(--border); padding-left: 10px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.agent { display: flex; flex-direction: column; gap: 6px; }
.agent header { display: flex; justify-content: space-between; align-items: baseline; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
.consent h3 { margin: 0; }
.consent p { margin: 0; }
