:root {
  --bg: #f5f5f3; --surface: #fff; --text: #1d1d1b; --muted: #6b6b66; --line: #e2e1dc;
  --accent: #1f4e5f; --accent-text: #fff; --won: #2e7d4f; --lost: #a8473d; --warn: #b26a00;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --surface: #21211f; --text: #ecebe6; --muted: #9a9993; --line: #34332f;
    --accent: #5fa3b8; --accent-text: #0f1a1e; --won: #5fbf86; --lost: #e0857b; --warn: #e0a24a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, sans-serif; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 17px; margin: 0; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px;
  cursor: pointer; font: inherit; }
nav button.on { background: var(--accent); color: var(--accent-text); }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.login { max-width: 340px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }
h2 { font-size: 18px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.bar .grow { flex: 1; }
button, select, input, textarea { font: inherit; color: inherit; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--lost); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
.bar input, .bar select { width: auto; min-width: 160px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col { flex: 0 0 270px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 140px; }
.col.over { outline: 2px dashed var(--accent); }
.col header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 600; }
.col header small { color: var(--muted); font-weight: 400; display: block; }
.col.won header { color: var(--won); } .col.lost header { color: var(--lost); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; }
.card:hover { border-color: var(--accent); }
.card .t { font-weight: 600; word-break: break-word; }
.card .s { color: var(--muted); font-size: 13px; }
.card .v { font-size: 13px; margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--bg); }
.tablewrap { overflow-x: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; } .stat span { color: var(--muted); font-size: 13px; }
.late { color: var(--lost); font-weight: 600; } .muted { color: var(--muted); }
.srow { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.srow input[type=number] { width: 80px; } .srow select { width: 150px; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { padding: 18px; display: grid; gap: 10px; max-height: 88vh; overflow: auto; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label.chk { display: flex; gap: 8px; align-items: center; } dialog label.chk input { width: auto; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.chat { display: grid; grid-template-columns: 300px 1fr; gap: 12px; align-items: start; }
.convlist { display: grid; gap: 6px; max-height: 70vh; overflow: auto; }
.conv { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; }
.conv.on { border-color: var(--accent); }
.conv .t { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.conv .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.thread { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; max-height: 70vh; overflow: auto; }
.threadhead { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.msg { max-width: 75%; padding: 7px 10px; border-radius: 12px; background: var(--bg); white-space: pre-wrap; word-break: break-word; }
.msg.out { margin-left: auto; background: var(--accent); color: var(--accent-text); }
@media (max-width: 760px) { .chat { grid-template-columns: 1fr; } }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }
@media (max-width: 640px) { main { padding: 12px; } .col { flex-basis: 85vw; } }
.login.wide { max-width: 480px; }
.login label.chk { display: flex; gap: 8px; align-items: center; color: var(--text); }
.login label.chk input { width: auto; }
ol.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 16px; letter-spacing: .08em; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; user-select: all; word-break: break-all; }
