:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --ink: #1f1d1a;
  --muted: #6f6a63;
  --line: #e6e1da;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --high: #d9480f;
  --medium: #e8a10c;
  --low: #2f9e44;
  --danger: #c92a2a;
  --ok: #2f9e44;
  --warn: #e8a10c;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --surface: #201f1d; --ink: #f1eee9; --muted: #a39d94; --line: #34312d;
    --accent: #748ffc; --accent-ink: #0d0d0d; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, .button, input, select, textarea { font: inherit; color: inherit; }
button, .button {
  border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px;
  cursor: pointer; text-decoration: none; display: inline-block; min-height: 40px;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); }
button.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input[type=text], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 10px; min-height: 40px;
}
textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-weight: 700; font-size: 18px; }
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.logo { color: var(--accent); letter-spacing: -4px; margin-right: 6px; }
.status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--danger); border-color: var(--danger); }

.banner { padding: 10px 16px; background: #fff3bf; color: #5c4400; border-bottom: 1px solid #f0d97a; font-size: 14px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1200px; margin: 0 auto; }
.layout.with-diag { grid-template-columns: minmax(0, 1fr) 380px; }
@media (max-width: 860px) { .layout.with-diag { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { margin-top: 0; }
.field { display: grid; gap: 6px; margin: 14px 0; font-weight: 600; }
.field input { font-weight: 400; max-width: 320px; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.row input[type=text] { flex: 1; min-width: 180px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hint { background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }

.list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h1 { margin: 0; font-size: 26px; }
.add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.add input { flex: 1; min-width: 200px; }

.todos { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.todo {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--medium);
  border-radius: var(--radius); padding: 10px 12px;
}
.todo.p-high { border-left-color: var(--high); }
.todo.p-low { border-left-color: var(--low); }
.todo.done .text { text-decoration: line-through; color: var(--muted); }
.todo.pending { opacity: .6; }
.todo input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.todo .text { word-break: break-word; cursor: text; }
.todo .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.todo .controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.todo .controls select { min-height: 32px; padding: 2px 6px; font-size: 13px; }
.todo .controls button { min-height: 32px; padding: 2px 8px; }
.todo .edit-input { width: 100%; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); } to { background: var(--surface); } }
@media (max-width: 560px) {
  .todo { grid-template-columns: auto minmax(0, 1fr); }
  .todo .controls { grid-column: 1 / -1; justify-content: flex-start; }
}

.col-diag { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; align-self: start; font-size: 13px; }
.col-diag h3 { margin: 0 0 8px; }
.col-diag h4 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; font-family: ui-monospace, monospace; font-size: 11.5px; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); word-break: break-all; }
.log .t { color: var(--muted); margin-right: 6px; }
.log .err { color: var(--danger); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); max-width: min(560px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: rgb(0 0 0 / .35); }
