:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1b1f24; --muted: #5d6673; --line: #dde1e6; --accent: #2f6fde; --accent-text: #ffffff;
  --sel: #e8f0fd; --warn-bg: #fff4d6; --warn: #8a5a00; --bad-bg: #fde8e8; --bad: #a32020; --good-bg: #e5f6ea; --good: #1d6b35;
  --in: #ffffff; --out: #eef3fb; --note: #fffbe6; --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --panel: #1d2126; --text: #e6e9ed; --muted: #9aa3ae; --line: #343a42; --accent: #6ea0ff; --accent-text: #0b1220;
    --sel: #243247; --warn-bg: #3a2f12; --warn: #f2c766; --bad-bg: #3d1c1c; --bad: #ff8e8e; --good-bg: #183223; --good: #7fd69b;
    --in: #1d2126; --out: #1f2a3a; --note: #2f2b17;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, li:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.on { background: var(--sel); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; min-height: 110px; resize: vertical; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 16px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px; }
.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; }
#nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#nav button { border: none; background: none; padding: 6px 10px; }
#nav button.on { background: var(--sel); }
.who { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.screen { padding: 12px 16px; max-width: 1400px; margin: 0 auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button { padding: 4px 10px; }
.count { display: inline-block; min-width: 1.6em; padding: 0 5px; margin-left: 4px; border-radius: 10px; background: var(--line); font-size: 12px; text-align: center; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters input[type=search] { min-width: 220px; flex: 1; max-width: 360px; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 12px; align-items: start; }
.split > * { min-width: 0; }
.pane, .box { overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: calc(100vh - 190px); overflow: auto; }
.list li { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li.sel { background: var(--sel); }
.list .row1 { display: flex; justify-content: space-between; gap: 8px; }
.list .addr { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .subj, .list .prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 300px; }
.pane .head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: var(--line); margin-right: 4px; }
.badge.flag, .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.good { background: var(--good-bg); color: var(--good); }
.msg { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; background: var(--in); }
.msg.out { background: var(--out); margin-left: 24px; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.en { border-left: 3px solid var(--accent); padding-left: 8px; }
.decision { font-size: 13px; background: var(--bg); border-radius: 6px; padding: 6px 8px; margin-top: 6px; }
.decision ul { margin: 4px 0; padding-left: 18px; }
.note { background: var(--note); border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.summary { background: var(--sel); border-radius: 6px; padding: 8px 10px; margin: 8px 0; white-space: pre-wrap; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; overflow-x: auto; }
.shadow-item { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.review { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.review input { flex: 1; min-width: 160px; }
.big { font-size: 20px; font-weight: 700; }
.stopped { color: var(--bad); }
.running { color: var(--good); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
.toast.show { opacity: 1; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); max-width: 520px; width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.signin { max-width: 420px; margin: 48px auto; }
.signin form { display: flex; flex-direction: column; gap: 8px; }
.keys { font-size: 12px; color: var(--muted); margin-top: 8px; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 12px; }
.back { display: none; }
@media (max-width: 820px) {
  .top { gap: 4px 8px; padding: 6px 8px; }
  #nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  #nav button { white-space: nowrap; padding: 4px 8px; }
  .who { margin-left: auto; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split.has-open .list { display: none; }
  .split:not(.has-open) .pane { display: none; }
  .back { display: inline-block; }
  .list { max-height: none; }
  .shadow-item { grid-template-columns: 1fr; }
  .msg.out { margin-left: 8px; }
  .screen { padding: 8px; }
}
