: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); }
/* green for actions that add or confirm (install, upload, save, start), red for removing or stopping */
button.ok, .button.ok { background: var(--ok); border-color: var(--ok); color: var(--accent-text); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }
button.ghost.ok, .button.ghost.ok { background: transparent; color: var(--ok); }
button.ghost.danger, .button.ghost.danger { background: transparent; color: var(--danger); }
button.small, .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); }
.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;
}
/* nothing to show yet: a low box with a note instead of a large empty one */
.console.empty { height: auto; min-height: 0; }
.console.empty:empty::before { content: attr(data-empty); color: #8a93a6; font-family: inherit; }

.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;
  align-items: center;
  justify-content: space-between;
  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 dl { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; }
.session-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.session-actions form { margin: 0; }
.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);
}

.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; }

.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); }

.info { position: relative; display: inline-flex; vertical-align: middle; }
.info-button {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border-radius: 50%;
  font: italic 700 0.75rem/1 Georgia, serif;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  cursor: help;
}
.info-text {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  right: -0.5rem;
  width: min(24rem, 80vw);
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-line;
  text-align: left;
}
.info:hover .info-text, .info:focus-within .info-text { display: block; }
.option-row { display: flex; align-items: flex-end; gap: 0.5rem; }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0.75rem 1.5rem; align-items: end; }
.option-row > label { flex: 1; }
.option-row > .info { margin-bottom: 0.45rem; }
.option-row > label.check + .info { margin-bottom: 0.1rem; }
h1 .info, h2 .info, h3 .info { margin-left: 0.4rem; }
.info-left .info-text { right: auto; left: -0.5rem; }
/* placed by base.html in the window (not cut off by tables that scroll) */
.info-text.placed { position: fixed; right: auto; }
.copies { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.copies-list summary { cursor: pointer; }
.copies-list ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }

tr.search-miss { display: none; }
th.sort-header { cursor: pointer; user-select: none; white-space: nowrap; }
th.sort-header:hover { color: var(--text); }
th.sort-header::after { content: " ↕"; opacity: 0.35; font-size: 0.8em; }
th[aria-sort="ascending"]::after { content: " ▲"; opacity: 1; }
th[aria-sort="descending"]::after { content: " ▼"; opacity: 1; }
.table-tools { margin: 0.4rem 0; align-items: center; }
input.table-search { min-width: 12rem; }

tr.col-miss { display: none; }
table.hide-done tr.row-done { display: none; }
tr.row-done td { color: var(--muted); }
.table-wrap.scroll.tall { max-height: 75vh; }
.badge.state-open { color: var(--muted); }
.badge.state-hinted { color: var(--warn); }
.badge.state-checked { color: var(--ok); }

/* one height for everything in a tools row */
.table-tools { align-items: center; }
.table-tools input:not([type="checkbox"]), .table-tools select, .table-tools .dropdown > summary { height: 2.3rem; padding-top: 0; padding-bottom: 0; }
.table-tools .dropdown > summary { display: flex; align-items: center; gap: 0.3rem; }
label.inline-field { flex-direction: row; align-items: center; gap: 0.4rem; color: var(--muted); white-space: nowrap; }
.explain { max-width: 60rem; font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }
button.release-location.confirm { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }

table.hide-unplayed tr:not(.played) { display: none; }
table.hide-uninstalled tbody tr:not(.installed) { display: none; }
#games tr.played td { background: var(--mine); }
#games td.notes { font-size: 0.85rem; max-width: 26rem; }
.stability { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.stability-stable { color: var(--ok); }
.stability-unstable { color: var(--warn); }
.stability-broken-on-main { color: var(--danger); }
.mapping-form input[name="sheet_name"] { min-width: 18rem; }
.badge.mapping-missing { color: var(--danger); }
.badge.mapping-manual { color: var(--accent); }
.badge.mapping-auto { color: var(--ok); }
.stability-unlisted { color: var(--muted); }
button.confirm, button.ghost.confirm { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }
ul.columns { columns: 16rem; margin: 0.6rem 0 0; padding-left: 1.1rem; }
.core-games { margin-top: 1rem; }
.core-games summary, details > summary { cursor: pointer; }
.card.highlight { border-color: var(--accent); }
td.creator-yamls { min-width: 10rem; font-size: 0.85rem; }
td.creator-yamls details { margin-top: 0.3rem; }
td.creator-yamls input[type=file] { max-width: 14rem; font-size: 0.8rem; }

.busy { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; margin-left: 0.6rem; }
.busy::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.actions-stack { display: flex; flex-direction: column; align-items: stretch; gap: 0.3rem; }
.actions-stack form, .actions-stack .button, .actions-stack button { width: 100%; text-align: center; }
.badge.registration, .badge.generating { color: var(--accent); }
.warning { color: var(--warn, var(--danger)); margin: 0.4rem 0; }
.generate-error { white-space: pre-wrap; background: transparent; padding: 0; }
#generate-log { max-height: 22rem; }
a.badge { text-decoration: none; }
.dropzone.compact { padding: 0.45rem 0.8rem; border-width: 1px; border-radius: 6px; flex-direction: row; text-align: left; }
.dropzone.compact .dropzone-hint { font-size: 0.9rem; }
td.creator-yamls .dropzone.compact { padding: 0.3rem 0.5rem; }
td.creator-yamls .dropzone.compact .dropzone-hint { font-size: 0.8rem; }

/* <details class="card collapsible"><summary><h2>…</h2></summary>…</details> */
details.collapsible > summary { list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before { content: "▸"; color: var(--muted); width: 1rem; transition: transform 0.15s; }
details.collapsible[open] > summary::before { transform: rotate(90deg); }
details.collapsible > summary h2 { margin: 0; }
details.collapsible[open] > summary { margin-bottom: 0.75rem; }

/* YAML configurator */
.configure .option-row { flex-wrap: wrap; }
.configure .field-error { flex-basis: 100%; margin: 0; }
.configure .has-error input, .configure .has-error textarea, .configure .has-error select { border-color: var(--danger); }
.range-field { display: flex; gap: 0.4rem; }
.range-field input { flex: 1; min-width: 6rem; }
.range-field select { flex: 1; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; width: 100%; }
.configure-actions { position: sticky; bottom: 0; padding: 0.75rem 0; background: var(--bg); }
.info-text.long { width: min(32rem, 85vw); max-height: 60vh; overflow-y: auto; }

/* configurator: input on the left, explanation on the right */
.option-table { display: flex; flex-direction: column; }
.option-line { display: grid; grid-template-columns: minmax(16rem, 2fr) 3fr; gap: 0.5rem 1.5rem; padding: 0.7rem 0; border-top: 1px solid var(--border); }
.option-line:first-child { border-top: 0; }
.option-input { display: flex; flex-direction: column; gap: 0.3rem; }
.option-input > label { display: flex; flex-direction: column; gap: 0.3rem; }
.option-input > label.check { flex-direction: row; align-items: center; }
.option-doc { font-size: 0.88rem; color: var(--muted); line-height: 1.45; }
.option-doc-text { white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.option-doc-text.expanded { display: block; -webkit-line-clamp: unset; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
@media (max-width: 720px) { .option-line { grid-template-columns: 1fr; } }
.rom-status { margin-top: 0.4rem; }
.rom-status details { margin-top: 0.3rem; }
.rom-status form { margin-top: 0.3rem; max-width: 22rem; }
.chain-requests { border: 1px solid var(--accent); border-radius: 8px; padding: 0.6rem 0.9rem; margin: 0.5rem 0 1rem; }
.chain-requests h3 { margin-top: 0; }
.chain-request + .chain-request { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.5rem; }
.chain-request p { margin: 0 0 0.4rem; }
.pre-line { white-space: pre-line; }

/* Autopilot */
.autopilot-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.autopilot-form .interval input { width: 5rem; }
fieldset.plain { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; min-width: 0; }
fieldset.plain:disabled input, fieldset.plain:disabled select { opacity: 0.7; cursor: not-allowed; }
.autopilot-table td { vertical-align: top; }
.badge.pilot-active, .badge.pilot-done { color: var(--ok); }
.badge.pilot-waiting, .badge.pilot-starting, .badge.pilot-generated, .badge.pilot-connected { color: var(--accent); }
.badge.pilot-error { color: var(--danger); }
.pilot-detail { display: block; margin-top: 0.2rem; }

/* translated option descriptions */
.option-doc-text.original { display: none; }
.show-original .option-doc-text.original { display: -webkit-box; }
.show-original .option-doc-text.original.expanded { display: block; }
.show-original .option-doc-text.translated { display: none; }
.translation-bar { justify-content: space-between; align-items: center; margin: 0 0 0.5rem; }
.translation-state { color: var(--muted); font-size: 0.9rem; }
.translation-bar.working { padding: 0.8rem 1rem; border: 1px solid var(--accent); border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.translation-bar.working .translation-state { display: inline-flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
  color: var(--text); font-size: 1rem; font-weight: 600; }
.translation-bar.working .translation-state::before { content: ""; flex: none; width: 1.2rem; height: 1.2rem;
  border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.translation-progress { font-weight: 400; font-size: 0.9rem; }
/* fixed values or weights in the YAML configurator */
.mode-switch { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.6rem; }
.mode-option { display: flex; flex-direction: row; gap: 0.6rem; align-items: flex-start; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.mode-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mode-option > span { display: flex; flex-direction: column; gap: 0.15rem; }
.mode-option input { margin-top: 0.25rem; }
.weights-explain { margin-top: 0.9rem; }
.weights-example { border-left: 3px solid var(--accent); padding: 0.2rem 0 0.2rem 0.8rem; margin: 0.6rem 0; }
.weights-example .weights-table td { padding-right: 1.2rem; }
.weights-table .chance { min-width: 3.5rem; }
.range-slider { width: 100%; margin: 0.3rem 0 0.2rem; accent-color: var(--accent); }
.weights-title { display: block; margin-bottom: 0.2rem; }
.weights-table { width: auto; }
.weights-table th, .weights-table td { padding: 0.15rem 0.5rem 0.15rem 0; }
.weights-table input { width: 11rem; }
.weights-table input.weight-input { width: 5.5rem; }
/* choices with a few values as buttons side by side, true/false as a switch */
.segment-field { display: flex; flex-direction: column; gap: 0.3rem; }
.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { display: block; margin: 0; cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--border); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label > span { display: block; padding: 0.35rem 0.9rem; text-align: center; line-height: 1.25; }
.segmented .raw-hint { display: block; font-size: 0.75rem; opacity: 0.75; margin-left: 0; }
.segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.segmented input:disabled + span { opacity: 0.5; cursor: default; }
.switch input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { flex: none; width: 2.4rem; height: 1.35rem; border-radius: 1rem; background: var(--border); position: relative;
  cursor: pointer; transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1.05rem; height: 1.05rem;
  border-radius: 50%; background: #fff; transition: left 0.15s; box-shadow: 0 1px 2px rgb(0 0 0 / 30%); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { left: 1.2rem; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

/* the identifier next to a value's readable label */
.raw-hint { color: inherit; opacity: 0.65; font-size: 0.8em; margin-left: 0.35em; }
.raw-hint[hidden], .show-original .raw-hint { display: none; }
/* PopTracker on the setup card */
.poptracker-help { margin: 0.6rem 0 0.8rem; }
.factorio-setup { margin-top: 1.2rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }
.factorio-setup h3 { margin: 0 0 0.6rem; }
.factorio-setup .steps { margin: 0.8rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.35rem; }
.badge.factorio-running { color: var(--ok); }
.badge.factorio-preparing, .badge.factorio-starting { color: var(--warn); }
.badge.factorio-error { color: var(--danger); }
.badge.factorio-stopped { color: var(--muted); }
.factorio-setup .error-text { color: var(--danger); overflow-wrap: anywhere; }
.poptracker-help .steps { margin: 0.5rem 0 0; padding-left: 1.4rem; display: grid; gap: 0.35rem; }
.poptracker-cell { min-width: 14rem; }
.poptracker-cell .button { margin-right: 0.4rem; }
.poptracker-edit { margin-top: 0.3rem; }
.poptracker-edit summary { cursor: pointer; }
.poptracker-edit form { margin-top: 0.3rem; flex-wrap: nowrap; }
.poptracker-edit input[type=url] { min-width: 12rem; }
/* login: the Gamemaster's chibi next to the form, above it on small screens */
.login-card { max-width: 46rem; margin: 2rem auto; display: grid; grid-template-columns: minmax(10rem, 17rem) 1fr;
  gap: 2rem; align-items: center; }
.login-art img { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.18)); }
.login-form h1 { margin-top: 0; }
@media (max-width: 40rem) {
  .login-card { grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; }
  .login-art { justify-self: center; width: min(11rem, 50vw); }
}
/* small screens: tables with class stack-mobile become one card per row, each cell with its column
   name above it (data-label); hide-mobile columns are left out */
@media (max-width: 720px) {
  .hide-mobile { display: none; }
  table.stack-mobile, table.stack-mobile tbody, table.stack-mobile tr, table.stack-mobile td { display: block; width: 100%; }
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; margin-bottom: 0.6rem; }
  table.stack-mobile td { border: 0; padding: 0.25rem 0; }
  table.stack-mobile td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem;
    font-weight: 600; color: var(--muted); }
  table.stack-mobile td:empty { display: none; }
  table.stack-mobile .poptracker-cell { min-width: 0; }
  table.stack-mobile td.hide-mobile { display: none; }
  #tracker .progress { display: none; }  /* "5/25" is enough on a phone */
}
/* help pages */
.help { display: grid; gap: 1rem; }
.help > .card { margin: 0; }
.help-toc ol { margin: 0.5rem 0 0; padding-left: 1.4rem; columns: 2 16rem; column-gap: 2rem; }
.help-toc li { margin: 0; padding: 0.15rem 0; break-inside: avoid; }
.help-section h2 { margin-top: 0; }
.help-section { scroll-margin-top: 1rem; line-height: 1.55; }
.help-section .steps > li { margin-bottom: 0.4rem; }
.help-section ul ul { margin-top: 0.3rem; }
.faq dt { font-weight: 600; margin-top: 0.8rem; }
.faq dd { margin: 0.2rem 0 0; color: var(--muted); }
/* feedback of the copy buttons */
button.copied { color: var(--ok, #1f8a4c); border-color: var(--ok, #1f8a4c); }
button.copy-failed { color: var(--danger); border-color: var(--danger); }
