:root {
  --paper: #f6f5f2; --surface: #ffffff; --raised: #fbfaf8; --ink: #1c1c1e; --body: #48484a; --quiet: #8a8a8e;
  --line: rgba(60, 60, 67, .12); --accent: #2f6fe4; --accent-ink: #ffffff; --accent-soft: rgba(47, 111, 228, .1);
  --danger: #d14343; --danger-soft: rgba(209, 67, 67, .1); --ok: #2f9e62; --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
  --radius: 16px; --font: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151514; --surface: #1f1f1e; --raised: #262625; --ink: #f2f2f0; --body: #c8c8c4; --quiet: #8d8d88;
    --line: rgba(255, 255, 255, .1); --accent: #6d9cff; --accent-ink: #0d1424; --accent-soft: rgba(109, 156, 255, .14);
    --danger: #ff7b72; --danger-soft: rgba(255, 123, 114, .14); --ok: #5cd08f; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151514; --surface: #1f1f1e; --raised: #262625; --ink: #f2f2f0; --body: #c8c8c4; --quiet: #8d8d88;
  --line: rgba(255, 255, 255, .1); --accent: #6d9cff; --accent-ink: #0d1424; --accent-soft: rgba(109, 156, 255, .14);
  --danger: #ff7b72; --danger-soft: rgba(255, 123, 114, .14); --ok: #5cd08f; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }

.login { min-height: 80vh; display: grid; place-items: center; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.login .card { width: min(400px, 100%); display: grid; gap: 16px; }
.brand { font-size: 24px; font-weight: 600; letter-spacing: -.01em; }
.quiet { color: var(--quiet); font-size: 13px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--body); }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px var(--accent-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.error { color: var(--danger); font-size: 13px; min-height: 1.5em; }

header.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
header.top .brand { margin-right: auto; }
nav.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); overflow-x: auto; }
nav.tabs button { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; color: var(--body); white-space: nowrap; }
nav.tabs button[aria-selected=true] { background: var(--accent); color: var(--accent-ink); }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.row h2 { margin: 0 auto 0 0; font-size: 20px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile .value { font-size: 32px; font-weight: 600; letter-spacing: -.02em; }
.tile .label { color: var(--quiet); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--quiet); font-size: 12px; padding: 6px 8px; }
td { padding: 8px; border-top: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td code { font-size: 12px; color: var(--body); word-break: break-all; }
.bar { height: 6px; border-radius: 3px; background: var(--accent); opacity: .85; }
.chart svg { width: 100%; height: 160px; display: block; }
.chart .axis { fill: var(--quiet); font-size: 11px; }
.empty { color: var(--quiet); padding: 24px 0; text-align: center; }

.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.item { padding: 0; overflow: hidden; display: grid; }
.item .pic { aspect-ratio: 1; background: #fff; display: grid; place-items: center; }
.item .pic img { width: 100%; height: 100%; object-fit: contain; }
.item .meta { padding: 12px 16px; display: grid; gap: 4px; }
.item .name { font-weight: 600; }
.item .actions { display: flex; gap: 8px; padding: 0 16px 16px; flex-wrap: wrap; }
.item.removed .pic, .item.removed .meta { opacity: .45; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.off { background: var(--danger-soft); color: var(--danger); }

dialog { border: 0; border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { padding: 24px; display: grid; gap: 12px; max-height: 85vh; overflow: auto; }
dialog .langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
dialog .foot { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--quiet); }
.preview { max-height: 160px; max-width: 100%; border-radius: 12px; display: block; margin: 8px auto 0; }
.spaced { margin-bottom: 16px; }
.stack { display: grid; gap: 16px; align-content: start; }
td.barcell { width: 40%; }

/* To-do templates */
[hidden] { display: none !important; }
input[type=time], input[type=number] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); outline: none; }
.filters { gap: 12px; }
.filters input[type=text] { width: auto; flex: 1 1 200px; }
.chips { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); overflow-x: auto; max-width: 100%; }
.chips button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer; color: var(--body); white-space: nowrap; }
.chips button[aria-selected=true] { background: var(--accent); color: var(--accent-ink); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--body); cursor: pointer; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.checks select { width: auto; }
.inline { display: flex; gap: 12px; }
h3.group { margin: 24px 0 4px; font-size: 18px; font-weight: 600; }
.section { margin: 16px 0 8px; color: var(--quiet); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.tpl { display: grid; grid-template-columns: 64px 1fr; gap: 4px 16px; padding: 16px; align-items: start; }
.tpl .pic { width: 64px; height: 64px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 1px var(--line), 0 0 0 4px var(--raised);
  display: grid; place-items: center; overflow: hidden; grid-row: span 2; font-size: 28px; }
.tpl .pic img { width: 84%; height: 84%; object-fit: contain; }
.tpl .meta { display: grid; gap: 4px; min-width: 0; }
.tpl .name { font-weight: 600; overflow-wrap: anywhere; }
.tpl .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl.removed .pic, .tpl.removed .meta { opacity: .45; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge.warn, .warn { background: rgba(214, 140, 20, .14); color: #b06a00; }
.warn { padding: 4px 8px; border-radius: 8px; margin-top: 4px; font-size: 12px; }
label.btn.file { display: inline-flex; color: var(--accent); font-size: 13px; }
label.btn.file input { display: none; }
dialog fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; display: grid; gap: 12px; margin: 0; }
dialog legend { padding: 0 6px; font-size: 13px; color: var(--body); }
.swatches { display: flex; gap: 12px; justify-content: center; margin: 12px 0 4px; }
.swatch { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; }
.swatch.light { background: #ffffff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.swatch.dark { background: #2b2b2e; }
.swatch img { width: 84%; height: 84%; object-fit: contain; }
.history { display: grid; gap: 4px; }
.history .entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.history .entry .quiet { grid-column: 1; }
.history .entry button { grid-row: 1 / span 2; grid-column: 2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn, :root:not([data-theme="light"]) .warn { color: #f0b25a; } }
:root[data-theme="dark"] .badge.warn, :root[data-theme="dark"] .warn { color: #f0b25a; }
@media (max-width: 480px) { .tpls { grid-template-columns: 1fr; } .tpl { grid-template-columns: 56px 1fr; } .tpl .pic { width: 56px; height: 56px; } }

/* Operations, crashes, feedback, accounts */
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); outline: none; resize: vertical; }
.alerts { border: 1px solid var(--danger-soft); }
.alerts .alert { padding: 8px 0; color: var(--danger); }
.alerts .alert + .alert { border-top: 1px solid var(--line); }
.crash { display: grid; gap: 8px; margin-bottom: 12px; }
.crash.regressed { box-shadow: var(--shadow), inset 4px 0 0 var(--danger); }
.crash code { word-break: break-all; }
.feedback { display: grid; gap: 10px; }
.feedback .message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; display: block; }
code.secret { display: inline-block; font-size: 16px; letter-spacing: .12em; padding: 6px 10px; border-radius: 8px; background: var(--raised); user-select: all; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row select { width: auto; }
.tile .value.text { font-size: 20px; line-height: 1.3; padding: 6px 0; }
