:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1b1b22; --muted: #6b6b76; --line: #dedcd4; --accent: #e8a400; --accent-ink: #1b1b22;
  --missing: #fff6d9; --outdated: #fff0e0; --outdated-ink: #a85600; --bad: #c62828; --ok: #2e7d32; --focus: #2a63ff; --section: #ecebe5;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151a; --panel: #1e1e25; --ink: #ecebe6; --muted: #9a9aa5; --line: #34343e; --accent: #ffc41c; --accent-ink: #15151a;
    --missing: #3a3320; --outdated: #3d2a18; --outdated-ink: #ffb067; --bad: #ff7a70; --ok: #7bd389; --focus: #7aa2ff; --section: #26262e;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
code { font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

main { padding: 16px; max-width: 1200px; margin: 0 auto; }
main.narrow { max-width: 420px; margin-top: 10vh; }
h1 { font-size: 20px; margin: 0 0 12px; }
.error { color: var(--bad); }
.login { display: grid; gap: 12px; }
.login label, dialog label { display: grid; gap: 4px; font-weight: 600; }
.login input, dialog input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); font-weight: 400; }
.login button, dialog button:not(.secondary) { padding: 8px 14px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 17px; }
.top nav { display: flex; align-items: center; gap: 14px; }
.top form { margin: 0; }
.who { color: var(--muted); }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; }
.flash { margin: 10px 16px 0; padding: 8px 12px; border-radius: 6px; background: var(--missing); }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px 0; }
.bar input[type=search] { flex: 1 1 240px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.bar select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.for, .count { color: var(--muted); }
.count { margin-left: auto; }

.langs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 120px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: left; opacity: .55; }
.chip.on { opacity: 1; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip .name { font-weight: 700; }
.chip .code, th .code { color: var(--muted); font-size: 12px; }
.chip .pct { font-size: 12px; color: var(--muted); }
.chip .warn { color: var(--outdated-ink); }
.meter { display: block; width: 100%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.action { align-self: center; padding: 7px 12px; border: 1px dashed var(--line); border-radius: 8px; background: none; text-decoration: none; }
.action:hover { border-color: var(--accent); }

.tablewrap { overflow: auto; max-height: calc(100vh - 190px); margin: 0 16px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 720px; table-layout: fixed; }
.grid th, .grid td { border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.grid thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); padding: 8px 10px; border-bottom: 2px solid var(--line); }
.grid th.key { width: 220px; position: sticky; left: 0; z-index: 1; background: var(--panel); padding: 8px 10px; font-weight: 400; border-right: 1px solid var(--line); }
.grid thead th.key { z-index: 3; font-weight: 700; }
.grid th.key code { word-break: break-all; }
.colhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tools { display: inline-flex; align-items: center; gap: 4px; }
.icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 6px; background: none; text-decoration: none; font-size: 14px; }
.readonly { font-size: 11px; color: var(--muted); font-weight: 400; }
tr.section th { position: sticky; left: 0; background: var(--section); padding: 6px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.addline { display: block; margin-top: 4px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; }

.cell { padding: 4px; border-left: 1px solid var(--line); }
.cell textarea { display: block; width: 100%; min-height: 32px; padding: 6px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; resize: vertical; field-sizing: content; line-height: 1.35; }
.cell textarea:hover { border-color: var(--line); }
.cell textarea:focus { border-color: var(--focus); background: var(--panel); outline: none; }
.cell textarea[readonly] { color: var(--muted); }
.cell.missing textarea { background: var(--missing); }
.cell.missing textarea::placeholder { color: var(--muted); font-style: italic; opacity: .8; }
.cell.outdated textarea { background: var(--outdated); }
.cell.dirty textarea { border-color: var(--accent); }
.cell.saving textarea { opacity: .6; }
.cell.failed textarea { border-color: var(--bad); }
.notes { display: grid; gap: 2px; padding: 2px 8px 2px; font-size: 12px; }
.note.outdated { color: var(--outdated-ink); }
.note.bad { color: var(--bad); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.status { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); margin: 0; max-width: min(720px, 90vw); padding: 0; border-radius: 8px; }
.status:not(:empty) { padding: 8px 14px; background: var(--ink); color: var(--bg); box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.status.error:not(:empty) { background: var(--bad); color: #fff; }

dialog { width: min(440px, 92vw); padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0 0 12px; font-size: 17px; }
dialog form { display: grid; gap: 12px; }
dialog small { font-weight: 400; color: var(--muted); }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; }
dialog .secondary { padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: none; }

.log { width: 100%; border-collapse: collapse; background: var(--panel); }
.log th, .log td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.log .old { color: var(--muted); text-decoration: line-through; }

@media (max-width: 700px) {
  .grid th.key { width: 140px; }
  .count { margin-left: 0; width: 100%; }
}
