:root {
  --bg: #f4f3ef; --surface: #ffffff; --ink: #1b1f1d; --muted: #5d6662; --line: #d9dbd5;
  --brand: #1d2a24; --accent: #f2b632; --accent-ink: #1b1f1d;
  --ok: #1f7a46; --ok-bg: #e3f3e8; --warn: #8a5a00; --warn-bg: #fff2d6; --bad: #a3271f; --bad-bg: #fbe5e2;
  --info: #1f4f86; --info-bg: #e3edf9; --gray-bg: #eceeea;
  --radius: 10px; --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #1b211e; --ink: #eef0ec; --muted: #a3aca7; --line: #303834;
    --ok: #6fd39a; --ok-bg: #173323; --warn: #f2c66b; --warn-bg: #3a2c0c; --bad: #ff9389; --bad-bg: #3d1a17;
    --info: #8fb9ef; --info-bg: #172a40; --gray-bg: #262d29;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1b211e; --ink: #eef0ec; --muted: #a3aca7; --line: #303834;
  --ok: #6fd39a; --ok-bg: #173323; --warn: #f2c66b; --warn-bg: #3a2c0c; --bad: #ff9389; --bad-bg: #3d1a17;
  --info: #8fb9ef; --info-bg: #172a40; --gray-bg: #262d29;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-size: 16px; line-height: 1.4; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--info); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 16px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 16px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.mark { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 3px 6px; font-size: .8rem; }
#nav { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
#nav a, #nav button { color: #fff; text-decoration: none; background: transparent; border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px; padding: 6px 10px; font-size: .85rem; cursor: pointer; font-family: inherit; }
#nav a.on { background: rgba(255,255,255,.15); }

main { max-width: 960px; margin: 0 auto; padding: 16px; }
.banner { padding: 10px 16px; background: var(--warn-bg); color: var(--warn); font-weight: 600; text-align: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 10px; }
.card.link { display: block; color: inherit; text-decoration: none; }
.card.link:active { transform: scale(.995); }
.card.hold { border-left: 5px solid var(--bad); }
.card.flag { border-left: 5px solid var(--warn); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 760px) { .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } }

.chip { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .78rem; font-weight: 600; background: var(--gray-bg); color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.layers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
@media (max-width: 520px) { .layers { grid-template-columns: 1fr 1fr; } }
.layer { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--surface); }
.layer b { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input, select, textarea { width: 100%; min-height: var(--tap); font-size: 16px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-family: inherit; }
textarea { min-height: 88px; resize: vertical; }
input[type="file"] { padding: 10px; }
button, .btn { min-height: var(--tap); padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 1rem; font-weight: 600; cursor: pointer; font-family: inherit; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.wide, .btn.wide { width: 100%; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; margin: 10px 0; -webkit-overflow-scrolling: touch; }
.tabs button { min-height: 40px; white-space: nowrap; font-size: .85rem; padding: 6px 12px; }
.tabs button[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.status { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-weight: 600; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.status.busy { background: var(--info-bg); color: var(--info); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.files a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-decoration: none; color: inherit; font-size: .75rem; }
.files img { width: 100%; height: 96px; object-fit: cover; display: block; }
.files span { display: block; padding: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upl { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.upl:last-child { border-bottom: 0; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
table.kv { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.kv td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 38%; }
.sticky-submit { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
.draft { white-space: pre-wrap; background: var(--gray-bg); padding: 10px; border-radius: 8px; font-size: .88rem; }
.empty { padding: 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.login { max-width: 420px; margin: 8vh auto; }
@media (max-width: 480px) {
  .brand span:last-child { display: none; }
  .top { padding: 8px 10px; }
  #nav a, #nav button { padding: 6px 8px; }
}
