:root {
  --bg: #f6f5f0; --fg: #1f211d; --muted: #6b6e66; --line: #d3d4cb; --soft: #ecebe4; --surface: #ffffff;
  --accent: #f0452b; --accent-ink: #c8331c; --review: #b7791f; --done: #3f7a4f; --info: #2f6fb3;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171815; --fg: #e9eae3; --muted: #9a9d93; --line: #34362f; --soft: #23251f; --surface: #1e201b; --accent-ink: #ff7a63; --review: #e0a84a; --done: #7cc08f; --info: #7fb3ea; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent-ink); }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 6px 0 14px; white-space: pre-wrap; word-break: break-all; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--fg); text-decoration: none; }
.grow { flex: 1; }
.live { font-size: 12px; color: var(--muted); padding-left: 14px; position: relative; }
.live::before { content: ""; position: absolute; left: 0; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--muted); }
.live.on::before { background: var(--done); }
.filter { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
select, input, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.btn { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--accent-ink); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; height: calc(100% - 51px); }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 6px 7px; cursor: pointer; white-space: nowrap; }
.tab:hover { background: var(--soft); }
.tab.on { background: var(--fg); color: var(--bg); }
.tab i { font-style: normal; font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--soft); color: var(--muted); display: inline-grid; place-items: center; }
.tab.on i { background: rgb(127 127 127 / .3); color: var(--bg); }
.tab i.hot { background: var(--review); color: #fff; }
.list { overflow-y: auto; padding: 8px; flex: 1; }
.detail { overflow-y: auto; padding: 20px 24px 60px; }
.empty { color: var(--muted); padding: 40px 16px; text-align: center; }

.card { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; margin-bottom: 4px; }
.card:hover { background: var(--soft); }
.card.sel { background: var(--surface); border-color: var(--line); }
.card-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }

.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.chip.open { color: var(--accent-ink); }
.chip.in_progress, .chip.partial { color: var(--info); }
.chip.review { color: var(--review); }
.chip.done { color: var(--done); }
.chip.wontfix, .chip.pending { color: var(--muted); }

.detail h1 { font-size: 20px; margin: 0 0 6px; line-height: 1.3; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 14px; }
.meta a { word-break: break-all; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.banner { border: 1px solid var(--review); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.banner p { margin: 0; flex: 1 1 260px; }
.shot { display: block; max-width: 100%; max-height: 520px; border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in; background: var(--soft); }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 14px 0; white-space: pre-wrap; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 24px 0 8px; }

.mark { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; }
.badge { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.mark-body { min-width: 0; }
.label-text { display: inline-block; border: 1.5px solid var(--accent); color: var(--accent-ink); font-weight: 600; padding: 3px 7px; border-radius: 3px; margin-bottom: 6px; white-space: pre-wrap; }
.comment { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.agent { margin-top: 8px; padding: 6px 10px; border-left: 3px solid var(--info); background: var(--soft); border-radius: 0 8px 8px 0; font-size: 13px; white-space: pre-wrap; }
.agent.user { border-left-color: var(--review); }
.crop { grid-column: 3; grid-row: 1 / span 2; width: 150px; max-height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; background: var(--soft); }
.mark .actions { grid-column: 2 / -1; margin: 8px 0 0; }
details { margin-top: 18px; }
summary { cursor: pointer; color: var(--muted); }
.diag { font-size: 12.5px; padding-left: 18px; overflow-wrap: anywhere; }

.login { max-width: 360px; margin: 12vh auto 0; padding: 24px; text-align: center; display: grid; gap: 10px; }
.login h1 { margin: 0; }
.login p { margin: 0; color: var(--muted); }
.error { color: var(--accent-ink) !important; min-height: 1.5em; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--fg); padding: 0; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
.setup { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.setup-in { padding: 20px 24px; }
.setup h2:first-child { margin-top: 0; }
.setup-head { display: flex; align-items: center; justify-content: space-between; }
.setup-head h1 { font-size: 18px; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.project { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--surface); }
.project b { font-size: 14px; }
.zoom { max-width: 96vw; max-height: 96vh; background: transparent; border: 0; }
.zoom img { max-width: 96vw; max-height: 94vh; display: block; border-radius: 8px; cursor: zoom-out; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 48vh; }
  .detail { padding: 16px; }
  .mark { grid-template-columns: auto 1fr; }
  .crop { grid-column: 2; grid-row: auto; width: 100%; max-height: 160px; }
}
.linkish { background: none; border: 0; color: var(--accent-ink); cursor: pointer; font: inherit; text-decoration: underline; }
.login details { text-align: left; color: var(--muted); }
.login details input { width: 100%; margin-top: 8px; }
.project .row { justify-content: space-between; }

/* ---------- navigation ---------- */
.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--soft); color: var(--fg); }
.nav a.on { background: var(--soft); color: var(--fg); }
.whoami { color: var(--muted); font-size: 13px; margin-left: 10px; white-space: nowrap; }

/* ---------- pages ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 24px; margin: 4px 0; }
.back { color: var(--muted); text-decoration: none; font-size: 13px; }
.muted { color: var(--muted); }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.box h2 { margin: 0 0 12px; }
.form { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: grid; gap: 4px; flex: 1 1 200px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { font-weight: 400; width: 100%; }
.field small { font-weight: 400; color: var(--muted); }
.field input:disabled { opacity: .7; }
.form .btn.primary { justify-self: start; }
.form .row { align-items: flex-start; }
.code { position: relative; margin: 6px 0 12px; }
.code pre { margin: 0; padding-right: 72px; }
.code .btn { position: absolute; top: 6px; right: 6px; }
.notice { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--line); }
.notice p { margin: 6px 0; }
.notice.ok { border-color: var(--done); background: color-mix(in srgb, var(--done) 8%, transparent); }
.notice.warn { border-color: var(--review); background: color-mix(in srgb, var(--review) 10%, transparent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.stat b { font-size: 22px; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.hot { border-color: var(--review); }
.stat.hot b, b.hot { color: var(--review); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.off td { opacity: .6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; min-width: 220px; }
.actions-cell .btn { white-space: nowrap; }
.facts dd.wide { grid-column: 2; margin-bottom: 8px; }
code { background: var(--soft); border-radius: 6px; padding: 2px 6px; word-break: break-all; }
code.secret:not(.shown) { color: transparent; text-shadow: 0 0 6px var(--muted); cursor: pointer; user-select: none; }
a.btn { display: inline-block; text-decoration: none; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .nav { order: 9; width: 100%; margin: 4px 0 0; overflow-x: auto; }
  .whoami { display: none; }
  .page { padding: 16px 12px 60px; }
  .actions-cell { justify-content: flex-start; }
}

.auth-tabs { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 3px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 7px; border-radius: 8px; cursor: pointer; }
.auth-tabs button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.login .fine { font-size: 12px; margin-top: 10px; }
.login input { width: 100%; }
