:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2554c7;
  --ok: #1f7a3d;
  --warn: #9a6200;
  --error: #b42318;
  --attention: #7a3cc7;
  --code: #f0f2f5;
  color-scheme: light dark;
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --panel: #1c1f26;
    --text: #e6e8ec;
    --muted: #9aa1ad;
    --line: #2c313b;
    --accent: #7ea2ff;
    --ok: #5cc98a;
    --warn: #e0b04f;
    --error: #ff7b72;
    --attention: #c29bff;
    --code: #242832;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 24px 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code, pre { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { background: var(--code); padding: 8px 10px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
pre.plain { background: none; padding: 0; font-family: inherit; font-size: inherit; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--error); }
input[type=text], input[type=password], input:not([type]), select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%;
}
.muted { color: var(--muted); }
.error { color: var(--error); }
.spacer { flex: 1; }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: min(420px, 100%); display: grid; gap: 10px; }
.check { display: flex; gap: 6px; align-items: center; }
.language { display: flex; gap: 6px; align-items: center; justify-self: end; color: var(--muted); }
.language select, .topbar select { width: auto; }

.app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sidebar { border-right: 1px solid var(--line); padding: 0 12px 16px; background: var(--panel); }
.content { padding: 0 20px 40px; min-width: 0; max-width: 1100px; }

.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.count { background: var(--attention); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.count:empty { display: none; }

.nodes { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nodes button { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; }
.nodes button.selected { border-color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); }
.nodes .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.cards { display: grid; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--attention); border-radius: 8px; padding: 12px 14px; }
.card.stale { opacity: .6; border-left-color: var(--muted); }
.card.reminded { box-shadow: 0 0 0 2px var(--attention); }
.card.done { border-left-color: var(--muted); }
.card-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.card-head .headline { font-weight: 600; }
.card-head .meta { color: var(--muted); font-size: 12.5px; }
.card .when { font-size: 12.5px; color: var(--muted); }
.card .when.urgent { color: var(--error); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.actions input { width: auto; flex: 1; min-width: 160px; }
.result { margin: 8px 0 0; font-size: 13px; }
.result.ok { color: var(--ok); }
.result.warn { color: var(--warn); }
.result.error { color: var(--error); }
details summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 6px; }

fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 10px 0 0; padding: 8px 10px; }
legend { font-weight: 600; padding: 0 4px; }
.option { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.option .desc { color: var(--muted); font-size: 12.5px; }
.other { margin-top: 6px; }

.new-task { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.new-task label { display: grid; gap: 4px; }
.new-task .wide, .new-task .result { grid-column: 1 / -1; }
.new-task button { justify-self: start; }

.table-wrap { overflow-x: auto; }
.sessions { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.sessions th, .sessions td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.sessions th { font-size: 12px; color: var(--muted); font-weight: 600; }
.sessions td.cwd { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions td.row-actions { white-space: nowrap; }
.sessions td.row-actions button { margin-left: 4px; }
.state-parked { color: var(--attention); font-weight: 600; }
.state-working, .state-starting { color: var(--accent); }
.state-settled { color: var(--ok); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed li { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.feed .line { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.feed .at, .feed .where { color: var(--muted); font-size: 12px; }
.feed .title { font-weight: 500; }
.feed .body { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; max-height: 18em; overflow: auto; }
.feed li.tone-ok .title { color: var(--ok); }
.feed li.tone-warn .title { color: var(--warn); }
.feed li.tone-error .title { color: var(--error); }
.feed li.tone-attention .title { color: var(--attention); }
.feed li.draft { border-style: dashed; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .nodes { grid-auto-flow: column; overflow-x: auto; }
  .new-task { grid-template-columns: 1fr; }
}
