/* TAC5 — era theme variables are set from JS (eras.js theme). */
:root {
  --paper: #efe4c8;
  --ink: #2b2418;
  --accent: #8a2b1d;
  --sea: #9db4b8;
  --font: "Courier New", Courier, monospace;
  --line: color-mix(in srgb, var(--ink) 25%, transparent);
  --panel: color-mix(in srgb, var(--paper) 88%, var(--ink));
  --ok: #2e7d32;
  --warn: #b26a00;
  --bad: #b3261e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  min-height: 100vh;
}
h2 { font-size: 1.1rem; margin: 0.2rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 0.9rem 0 0.4rem; }
p { margin: 0.4rem 0; }
.muted { opacity: 0.72; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

button, .button-like {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  min-height: 2rem;
  display: inline-flex;
  align-items: center;
}
button:hover:not(:disabled), .button-like:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.small { padding: 0.15rem 0.45rem; min-height: 1.6rem; font-size: 0.85rem; }
button:focus-visible, .button-like:focus-within, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea, input, select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 4px; padding: 0.35rem;
}
textarea { width: 100%; resize: vertical; }
select { max-width: 100%; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem; border-bottom: 2px solid var(--accent);
}
.brand strong { color: var(--accent); font-size: 1.2rem; letter-spacing: 0.08em; }
.status-line { flex: 1 1 260px; }
.top-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; border: 1px solid var(--line); font-size: 0.8rem; }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.warn { border-color: var(--warn); color: var(--warn); }
.badge.off { opacity: 0.75; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; padding: 0.75rem 1rem 2rem; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0.5rem; }
  .topbar { padding: 0.5rem; }
}
.map-pane { min-width: 0; }
.map-tools { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.4rem; }
.mode[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.map-hint { font-size: 0.85rem; }
.map-viewport { width: 100%; max-height: 540px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
#map-focus { margin: 0.4rem 0; }
.map-viewport:focus-visible { outline: 2px solid var(--accent); }
canvas#map { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: var(--sea); cursor: crosshair; touch-action: manipulation; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.8rem; margin: 0.4rem 0; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border: 1px solid var(--line); vertical-align: -0.1rem; margin-right: 0.25rem; background: var(--swatch, #888); }

.card { border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem 0.75rem; background: var(--panel); }
.selection:empty { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.5rem 0; }
.row.end { justify-content: flex-end; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.8rem; margin: 0.3rem 0; }
.kv dt { opacity: 0.72; }
.kv dd { margin: 0; }

.side { min-width: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.6rem; }
.tabs [role="tab"][aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-panel { border-top: 1px solid var(--line); padding-top: 0.5rem; }

.log { padding-left: 1.4rem; margin: 0.3rem 0; font-size: 0.88rem; max-height: 22rem; overflow: auto; }
.log li { margin-bottom: 0.3rem; }
.results { list-style: none; padding: 0; margin: 0.4rem 0; }
.results li { border-left: 4px solid var(--line); padding: 0.25rem 0.5rem; margin-bottom: 0.3rem; background: var(--panel); }
.status-ok { border-left-color: var(--ok) !important; }
.status-partial { border-left-color: var(--warn) !important; }
.status-rejected { border-left-color: var(--bad) !important; }
.tag { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: bold; margin-right: 0.35rem; }
.tag.ok { color: var(--ok); }
.tag.partial { color: var(--warn); }
.tag.rejected { color: var(--bad); }

.news { list-style: none; padding: 0; margin: 0; }
.news li { border-bottom: 1px dashed var(--line); padding: 0.45rem 0; }
.news .headline { font-weight: bold; }
.news .meta { font-size: 0.75rem; opacity: 0.7; }
.src-ai { color: var(--accent); font-weight: bold; }
.ai-status:empty { display: none; }
.ai-status { margin: 0.4rem 0; padding: 0.4rem 0.6rem; border-radius: 4px; border: 1px solid var(--line); font-size: 0.9rem; }
.ai-status.error { border-color: var(--bad); }

.diplo-row { border-bottom: 1px dashed var(--line); padding: 0.45rem 0; }
.diplo-row .name { font-weight: bold; }
.rel-war { color: var(--bad); font-weight: bold; }
.rel-alliance { color: var(--ok); font-weight: bold; }

.check { display: flex; gap: 0.4rem; align-items: center; margin: 0.6rem 0; }

dialog { border: 2px solid var(--accent); border-radius: 8px; background: var(--paper); color: var(--ink); max-width: min(560px, calc(100vw - 2rem)); width: 100%; }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
fieldset { border: 1px solid var(--line); border-radius: 4px; }
.era-options { display: grid; gap: 0.4rem; }
.era-options label { display: block; padding: 0.35rem; border-radius: 4px; cursor: pointer; }
.era-options label:has(input:checked) { background: var(--panel); outline: 1px solid var(--accent); }
#seed-input { flex: 1 1 10rem; text-transform: uppercase; }

.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; border-radius: 6px; max-width: calc(100vw - 2rem); z-index: 10;
}
.over { font-size: 1.05rem; color: var(--accent); font-weight: bold; }
