:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #677085;
  --border: #dde1e8;
  --accent: #3b6fd8;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #a86b00;
  --danger: #c23b3b;
  --mine: #eaf1ff;
  --code: #eef0f4;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c;
    --surface: #1b202a;
    --text: #e4e7ee;
    --muted: #8d96aa;
    --border: #2c3341;
    --accent: #6d97ef;
    --accent-text: #0d1320;
    --ok: #4cc27f;
    --warn: #e0a843;
    --danger: #ec6d6d;
    --mine: #1f2a40;
    --code: #232a36;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12151c;
  --surface: #1b202a;
  --text: #e4e7ee;
  --muted: #8d96aa;
  --border: #2c3341;
  --accent: #6d97ef;
  --accent-text: #0d1320;
  --ok: #4cc27f;
  --warn: #e0a843;
  --danger: #ec6d6d;
  --mine: #1f2a40;
  --code: #232a36;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
code { background: var(--code); padding: 0.1em 0.35em; border-radius: 4px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.who { color: var(--muted); }
.lang { text-decoration: none; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }
.hero { padding: 2rem 0; max-width: 700px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + section { margin-top: 1rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .span-2 { grid-column: auto; } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; }
.row + .row { margin-top: 0.75rem; }
.grow { flex: 1 1 200px; }
.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--text); }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}
input[type="checkbox"] { width: 1rem; height: 1rem; }

button, .button {
  font: inherit;
  display: inline-block;
  cursor: pointer;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  text-decoration: none;
}
button.ghost, .button.ghost { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 0.05rem 0.45rem; font-size: 0.8rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface); }
.flash.error { border-color: var(--danger); color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
tr.mine td { background: var(--mine); }
tr.archived td { color: var(--muted); }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; vertical-align: middle; border: 1px solid currentColor; }
.badge.running { color: var(--ok); }
.badge.stopped { color: var(--muted); }
.badge.archived { color: var(--warn); }

.progress { display: inline-block; width: 80px; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 0.4rem; }
.progress > span { display: block; height: 100%; background: var(--ok); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; font-size: 0.9rem; }
.feed li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.3rem; }
.feed li.hint { color: var(--warn); }
.feed li.goal { color: var(--ok); font-weight: 600; }

.items, .hints { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.items li, .hints li { padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.items li.flags-1 strong, .items li.flags-3 strong { color: var(--accent); }
.items li.flags-4 strong { color: var(--danger); }
.hints li.found { color: var(--muted); }

.console {
  background: #0d1017;
  color: #cfd6e4;
  border-radius: 8px;
  padding: 0.75rem;
  height: 360px;
  overflow: auto;
  font: 0.82rem/1.45 ui-monospace, "JetBrains Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.75rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  align-items: center;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--mine); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone-title { font-weight: 600; }
.dropzone-hint { color: var(--muted); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 0 0 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.session-bar dt { font-size: 0.8rem; color: var(--muted); }
.session-bar dd { margin: 0; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.slot-sections { display: flex; flex-direction: column; gap: 1rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head h3 { margin: 0.5rem 0; }
.table-wrap.scroll { max-height: 420px; overflow-y: auto; }
.table-wrap.scroll thead th { position: sticky; top: 0; background: var(--surface); }

.kind { font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.kind-progression { color: var(--accent); }
.kind-useful { color: var(--ok); }
.kind-trap { color: var(--danger); }
.kind-filler, .kind-start { color: var(--muted); }
tr.item-progression strong { color: var(--accent); }
tr.item-trap strong { color: var(--danger); }
tr.item-filler td { color: var(--muted); }
table.hide-kind-progression tr.item-progression { display: none; }
table.hide-kind-useful tr.item-useful { display: none; }
table.hide-kind-trap tr.item-trap { display: none; }
table.hide-kind-filler tr.item-filler { display: none; }
table.hide-kind-start tr.item-start { display: none; }
table.hide-found tr.hint-found { display: none; }
tr.hint-found td { color: var(--muted); }

.dropdown { position: relative; }
.dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.9rem;
  user-select: none;
}
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::after { content: " ▾"; color: var(--muted); }
.dropdown[open] > summary { border-color: var(--accent); }
.dropdown-menu {
  position: absolute;
  right: 0;
  z-index: 10;
  margin-top: 0.3rem;
  min-width: 12rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.commands { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.9rem 0.9rem; }
.commands h3 { margin-top: 0.4rem; }
.command-log {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 6px;
  font: 0.85rem/1.45 ui-monospace, "JetBrains Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.command-log time { color: var(--muted); margin-right: 0.3rem; }
.command-log .msg-sent { color: var(--accent); }
.command-log .msg-hint { color: var(--warn); }
.command-log .msg-chat, .command-log .msg-serverchat { color: var(--muted); }
.quick-commands { margin-top: 0.5rem; gap: 0.4rem; }
.command-error { color: var(--danger); margin: 0.5rem 0 0; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
}
.tab.active { color: var(--text); border-color: var(--border); background: var(--surface); margin-bottom: -1px; }
.small-note { font-size: 0.85rem; margin: 0.4rem 0; }
.hint-form { margin-bottom: 0.2rem; }

.conn {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.05rem 0.45rem;
  margin-right: 0.25rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.conn-game { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.conn-bot { color: var(--warn); }
.conn-tracker, .conn-hint { color: var(--accent); }
.conn-text { color: var(--muted); }
