:root {
    --bg: #1f1d1a;
    --panel: #f4ecd8;
    --panel-ink: #2a2418;
    --muted: #7a6d55;
    --accent: #8a2a1a;
    --line: #d8ccb0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); font-family: Georgia, 'Times New Roman', serif; }

.shell {
    display: grid;
    grid-template-columns: 1fr 340px;
    grid-template-rows: auto 1fr;
    height: 100vh;
}

.toolbar {
    grid-column: 1 / -1;
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: #2e2a24; color: #efe4c8; font-size: 13px;
    border-bottom: 1px solid #000;
}
.toolbar .brand { font-weight: bold; font-size: 16px; letter-spacing: 0.04em; margin-right: 8px; color: #f6d79c; }
.toolbar label { display: flex; align-items: center; gap: 4px; }
.toolbar input, .toolbar select { background: #f4ecd8; border: 1px solid #000; padding: 3px 5px; font: inherit; color: #222; }
.toolbar input.num { width: 56px; }
.toolbar .spacer { flex: 1; }
/* Figures on the first row, buttons on the row under them */
.toolbar .tb-break { flex-basis: 100%; height: 0; margin: -4px 0; }
.toolbar .modes button.on { background: #f6d79c; color: #222; }

button {
    font: inherit; cursor: pointer;
    background: #5a4a32; color: #f4ecd8; border: 1px solid #000; padding: 4px 10px; border-radius: 3px;
}
button:hover { background: #6e5a3c; }
button:disabled { opacity: 0.6; cursor: wait; }
button.small { padding: 3px 7px; }
button.link { background: none; border: none; color: var(--accent); padding: 0 4px; font-size: 16px; }

.map-wrap { position: relative; overflow: hidden; }
.map-wrap canvas { display: block; cursor: crosshair; }
.map-wrap > .hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.3em; color: #ccc; pointer-events: none; }

.panel { background: var(--panel); color: var(--panel-ink); overflow-y: auto; border-left: 2px solid #000; font-size: 14px; }
.panel section { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel h2 { margin: 0 0 2px; font-size: 20px; }
.panel h3 { margin: 4px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.panel .muted, .muted { color: var(--muted); font-size: 12px; }
.summary div { margin: 1px 0; }

table.stats { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.stats th { text-align: left; font-weight: normal; color: var(--muted); padding: 2px 0; width: 42%; }
table.stats td { padding: 2px 0; }
table.stats tr { border-bottom: 1px dotted var(--line); }

.poi { margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: #e8dcc0; color: var(--panel-ink); border: 1px solid #b9a882; padding: 2px 7px; font-size: 12px; }
.chip:hover { background: #f6d79c; }
.chip.water { background: #c9eef3; border-color: #7fc6d1; }
.rename { display: flex; gap: 4px; }
.rename input { flex: 1; font: inherit; padding: 3px 5px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #ffe; padding: 8px; z-index: 10; }

/* ---- Home ---- */
.home { min-height: 100vh; padding: 24px; color: var(--panel-ink); }
.home-head { color: #efe4c8; margin-bottom: 16px; }
.home-head h1 { margin: 0; color: #f6d79c; letter-spacing: 0.05em; }
.muted-light { color: #b9ab8a; font-size: 13px; margin-left: 6px; }
.forge-link { color: #f6d79c; font-size: 13px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.card { background: var(--panel); border: 2px solid #000; border-radius: 4px; padding: 14px 18px; }
.card h2 { margin: 0 0 10px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.field { display: inline-flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); margin-right: 10px; }
.field input, .field select { font: inherit; font-size: 14px; padding: 4px 6px; border: 1px solid #8a7a5a; background: #fffaf0; color: #222; }
.field input.num, input.num { width: 64px; }
input.num.tiny { width: 48px; padding: 1px 3px; font-size: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; }
.races { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.race { display: flex; flex-direction: column; gap: 3px; text-align: left; background: #efe5cc; color: var(--panel-ink); border: 1px solid #b9a882; padding: 8px; }
.race:hover { background: #f6e7bf; }
.race.on { background: #f6d79c; border: 2px solid var(--accent); }
.race .traits { font-size: 11px; color: var(--accent); }
button.primary { background: var(--accent); font-weight: bold; padding: 6px 16px; margin-top: 12px; }
.toolbar button.primary { margin-top: 0; }
.save { display: flex; flex-direction: column; padding: 8px; border-bottom: 1px dotted var(--line); color: var(--panel-ink); text-decoration: none; }
.save:hover { background: #efe5cc; }

/* ---- Game ---- */
a.brand { text-decoration: none; }
.nation-chip { border-left: 6px solid; padding-left: 6px; }
.tabs { display: flex; flex-wrap: wrap; position: sticky; top: 0; background: #e6dbbf; border-bottom: 1px solid #b9a882; z-index: 1; }
.tabs button { flex: 1 1 auto; white-space: nowrap; background: none; color: var(--panel-ink); border: none; border-radius: 0; padding: 7px 5px; font-size: 12.5px; }
.tabs button.on { background: var(--panel); font-weight: bold; box-shadow: inset 0 -3px 0 var(--accent); }
.banner { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: #fff7d6; border: 2px solid var(--accent); padding: 6px 12px; border-radius: 4px; font-size: 13px; }
.option { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; font-size: 13px; }
.option .btns { display: flex; gap: 2px; }
.option button { flex: none; min-width: 42px; }
.action-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.army { margin: 6px 0; font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; margin-right: 4px; vertical-align: middle; }
.chip.static { cursor: default; }
button.on { background: #f6d79c; color: #222; }
.bar { display: inline-block; width: 140px; height: 9px; background: #d8ccb0; border: 1px solid #8a7a5a; vertical-align: middle; }
.bar div { height: 100%; background: var(--accent); }
td.neg { color: #8a2a1a; }
td.pos { color: #2a6b2a; }
tr.total th, tr.total td { font-weight: bold; border-top: 1px solid #8a7a5a; }
tr.me th, tr.me td { font-weight: bold; }
.field-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 4px; font-size: 13px; }
.report { font-size: 13px; margin: 4px 0; }
.report .cat { display: inline-block; min-width: 74px; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.warn { color: #8a2a1a; font-weight: bold; margin-top: 6px; }
button.link.small-text, .small-text { font-size: 12px; }

/* ---- Court ---- */
.hero-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.hero .crown { color: #b8860b; }
.bar.xp { width: 100%; height: 6px; margin: 4px 0; }
.bar.xp div { background: #2e86c1; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin: 4px 0; }
.hero-stats .main { color: var(--accent); }
.chip.skill { background: #dbe8f4; border-color: #8fb3d6; }
.relic { display: inline-block; margin-right: 6px; color: #6b4f2a; }
.report.system { color: #1f4f8a; }
.panel select { font: inherit; font-size: 13px; padding: 2px 4px; max-width: 220px; }
.cargo { margin: 2px 0 2px 16px; font-size: 12px; color: var(--muted); }

/* ---- Map hover tooltip ---- */
.map-tip { position: absolute; display: none; pointer-events: none; z-index: 5; max-width: 280px;
    background: rgba(244, 236, 216, 0.97); color: var(--panel-ink); border: 1px solid #000; border-radius: 3px;
    padding: 6px 9px; font-size: 12px; line-height: 1.4; box-shadow: 2px 3px 8px rgba(0,0,0,0.45); }
.map-tip b { font-size: 13px; }
.map-tip .mt-muted { color: var(--muted); }
.map-tip .mt-sw { display: inline-block; width: 9px; height: 9px; border: 1px solid #000; margin-right: 4px; vertical-align: middle; }
.map-tip .mt-poi { color: #4a2a7a; }
.map-tip .mt-quest { margin-top: 3px; max-width: 280px; }
.map-tip .mt-qg { display: inline-block; width: 15px; height: 15px; line-height: 15px; border-radius: 50%; color: #fff; text-align: center; font-size: 9px; font-weight: bold; margin-right: 4px; vertical-align: -2px; }
.stronghold { font-size: 12px; color: #5a4a32; margin-top: 2px; }

/* ---- Research tree ---- */
.tech-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tech { font-size: 12px; padding: 3px 7px; border-radius: 3px; border: 1px solid #8a7a5a; background: #efe5cc; color: var(--panel-ink); }
.tech.known { background: #cfe8c4; border-color: #6a9a5a; color: #2a4a22; }
.tech.current { background: #f6d79c; border: 2px solid var(--accent); font-weight: bold; }
.tech.aimed { outline: 2px dashed var(--accent); outline-offset: 1px; opacity: 1; }
.tech.open:hover { background: #f6e7bf; }
.tech.locked { opacity: 0.45; cursor: default; }
.tech.branch-arcane, .branch-arcane { border-left: 4px solid #7a3fb0; }
.tech.branch-industrial, .branch-industrial { border-left: 4px solid #6b5a45; }
.tech.branch-magitech, .branch-magitech { border-left: 4px solid #148f8f; }
.tech.branch-naval, .branch-naval { border-left: 4px solid #2e86c1; }
.tech.branch-civic, .branch-civic { border-left: 4px solid #b8860b; }
span.branch-arcane, span.branch-industrial, span.branch-magitech, span.branch-naval, span.branch-civic { padding-left: 4px; }
.tension { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 6px 0 2px; }
.tension-bar { position: relative; flex: 1; height: 10px; border: 1px solid #8a7a5a; border-radius: 5px;
    background: linear-gradient(90deg, #8a7a6a 0%, #e8dcc0 40%, #cfe8e4 50%, #e8dcc0 60%, #9b6bc8 100%); }
.tension-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #000; }
.tension-mark { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; background: var(--accent); border: 1px solid #000; }

/* ---- Society ---- */
.district { font-size: 11px; color: #5a4a32; background: #e6dbbf; padding: 0 4px; border-radius: 2px; }
.option.no-room { opacity: 0.6; }
.estates-mini { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin: 2px 0 6px; color: var(--muted); }
.estate { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 3px 0; }
.estate-name { width: 120px; }
.bar.mood { width: 110px; }

/* ---- Events ---- */
.decisions-box { background: #fff3d6; }
.event { margin-bottom: 10px; }
.event .choice { display: block; width: 100%; text-align: left; margin: 3px 0; background: #efe5cc; color: var(--panel-ink); border: 1px solid #b9a882; font-size: 12px; }
.event .choice.on { background: #f6d79c; border: 2px solid var(--accent); }
.event .choice:disabled { opacity: 0.45; }
.toolbar .decisions { background: #b8860b; color: #fff; font-weight: bold; }
.report.event-report { color: #5a3a0a; }

/* ---- Diplomacy ---- */
.diplo { border-top: 1px dotted var(--line); padding: 6px 0; font-size: 13px; }
.chip.war { background: #f2c4c4; border-color: #a33; color: #6a1010; font-weight: bold; }
button.danger { background: #8a1a1a; }

/* ---- Setup ---- */
.builder { border: 1px dashed #b9a882; padding: 8px; margin: 8px 0; background: #f8f0dc; }
.field.wide { display: flex; width: 100%; }
.field.wide input { width: 100%; }
.chip.trait.on { background: #cfe8c4; border-color: #6a9a5a; }
.chip.trait.flaw { border-style: dashed; }
.chip.on { background: #f6d79c; border-color: var(--accent); }
.startup .option { margin: 2px 0; }
.victory-banner { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); background: #fff3d6; border: 3px solid #b8860b; padding: 16px 24px; text-align: center; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
.victory-banner b { font-size: 26px; color: #8a2a1a; display: block; }

/* ---- GM console, content editor, seats ---- */
.head-links { display: flex; gap: 14px; flex-wrap: wrap; }
.gm-link { color: #f6d79c; font-size: 12px; border: 1px solid #6a5a40; padding: 1px 6px; text-decoration: none; }
.gm .table-wrap, .table-wrap { overflow-x: auto; }
.gm-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.gm-table th, .gm-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.gm-table tr.dead { opacity: 0.45; }
input.narrow { width: 7em; }
.seat-row { border-left: 3px solid var(--line); padding-left: 8px; margin: 4px 0; }
.editor-grid { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(200px, 1.4fr) minmax(0, 3fr); gap: 12px; align-items: start; }
.editor-grid .files .chip { display: block; width: 100%; text-align: left; margin: 2px 0; }
.editor-grid .entries { max-height: 78vh; overflow-y: auto; }
.editor-grid .entry { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line); padding: 4px 2px; color: var(--panel-ink); font-size: 13px; }
.editor-grid .entry.on, .editor-grid .entry:hover { background: #f6d79c; }
.editor-grid .filter { width: 100%; margin-bottom: 6px; }
.editor-grid textarea { width: 100%; min-height: 62vh; font-family: Consolas, monospace; font-size: 12.5px; box-sizing: border-box; }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } .editor-grid textarea { min-height: 40vh; } }
.pre-line { white-space: pre-line; }
.check-report .row { align-items: baseline; gap: 10px; }
.check-report h4 { margin: 10px 0 4px; }
.check-report ul.problems { margin: 0; padding-left: 18px; max-height: 46vh; overflow-y: auto; font-size: 13px; }
.check-report li { margin: 2px 0; }
.check-report li button.link { font-size: 12px; font-family: Consolas, monospace; padding: 0 6px 0 0; }
h4.sev-error, li.sev-error::marker { color: #9a1c1c; }
h4.sev-warning, li.sev-warning::marker { color: #9a6a0c; }
h4.sev-info, li.sev-info::marker { color: #4a6a8a; }
.used-by { margin-top: 6px; }
.used-by .chip { margin: 2px 3px 2px 0; }

/* ---- Companies, armoury, designs (1l) ---- */
table.companies { width: 100%; border-collapse: collapse; margin: 4px 0 2px 12px; font-size: 12.5px; }
table.companies td { padding: 3px 4px; border-bottom: 1px dotted var(--line); vertical-align: top; }
table.companies .kit { color: #5a4a30; font-size: 12px; }
.company-name { cursor: text; }
.company-actions select { max-width: 9.5em; font-size: 12px; margin: 1px 0; display: block; }
.design-btn { margin-left: 4px; font-size: 11px; }
.design-editor { border: 1px solid var(--line); padding: 6px 8px; margin-top: 6px; background: #efe4c8; }
.design-editor .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.artifact { color: #8a2a1a; font-weight: bold; }

/* ---- Battles (1m) ---- */
.battle-orders { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 3px 0 2px 12px; }
.battle-orders select { font-size: 12px; max-width: 10em; }
details.battle { border-left: 3px solid var(--line); padding: 2px 6px; margin: 4px 0; font-size: 13px; }
details.battle.won { border-left-color: #4a8a3a; }
details.battle.lost { border-left-color: var(--accent); }
details.battle summary { cursor: pointer; }
.battle-line { font-size: 12px; padding: 1px 0 1px 8px; color: #4a3d28; }
.chip.skill.maneuver { background: #dfeedd; } .chip.skill.command { background: #f3e2c2; }
.chip.skill.tactics { background: #f1d6d0; } .chip.skill.logistics { background: #e2e2ef; }

/* ---- Deposits and stocks (2a) ---- */
.deposit { margin: 4px 0; font-size: 13px; }
.stars { color: #b8860b; letter-spacing: -1px; }
table.stocks td, table.stocks th { padding: 2px 4px; font-size: 12.5px; width: auto; }

/* ---- Unit builder (2b) ---- */
.blueprint { border-left: 3px solid var(--line); padding: 2px 6px; margin: 5px 0; font-size: 13px; }
.chip.quirk.good { background: #d8ecd0; border-color: #6a9a5a; }
.chip.quirk.bad { background: #f2d2cc; border-color: #a33; }

/* ---- Regions (2g) ---- */
.region { border-left: 3px solid var(--line); padding: 3px 6px; margin: 6px 0; font-size: 13px; }
.region .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.region-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.region-line .small-text { flex-basis: 100%; }
.hint { background: #f6e7bf; border: 1px solid #d8b86a; padding: 4px 8px; font-size: 13px; }

/* ---- Supply (1n) ---- */
.supply-line { font-size: 12px; margin: 1px 0 2px 12px; }
.supply-line.low { color: #9a6a10; }

/* ---- Accounts and server browser (M2a) ---- */
.account-bar { display: inline-flex; gap: 10px; align-items: center; font-size: 13px; color: #f6e7bf; }
.account-bar a { color: #f6d79c; }
.account-card { max-width: 420px; margin: 20px auto; }
.account-card .field { display: block; margin: 6px 0; }
.account-card input { width: 100%; box-sizing: border-box; }
.lobby .needs-orders td { background: #f6e7bf; }
.lobby-game { margin: 6px 0; padding: 4px 6px; border-left: 3px solid var(--line); }

/* Server browser and account pages: same warm brown look as the game screen. */
.lobby, .account-page { background: radial-gradient(ellipse at top, #4a3c2a 0%, #2e2a24 55%, #1f1d1a 100%); background-attachment: fixed; }
.lobby .home-head { background: #2e2a24; border: 1px solid #000; border-bottom: 3px solid #5a4a32; border-radius: 4px; padding: 10px 16px; }
.lobby .home-head .head-links { display: inline-flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 6px; }
.lobby .card, .account-page .card { border: 1px solid #000; border-top: 4px solid #5a4a32; box-shadow: 0 2px 8px rgba(0,0,0,0.45); margin-bottom: 14px; }
.lobby .card h2, .account-page .card h2 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.12em; color: #5a4a32; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.lobby .gm-table th { background: #5a4a32; color: #f4ecd8; font-weight: normal; letter-spacing: 0.04em; }
.lobby .gm-table tr:hover td { background: #ece1c6; }
.lobby .needs-orders td { background: #f1dfb0; }
.lobby .needs-orders td:first-child { border-left: 3px solid var(--accent); }
.lobby a.small { display: inline-block; background: #5a4a32; color: #f4ecd8; border: 1px solid #000; padding: 2px 9px; border-radius: 3px; text-decoration: none; }
.lobby a.small:hover { background: #7a6444; }
.lobby-game { background: #ece1c6; border-left: 3px solid #5a4a32; border-radius: 2px; padding: 6px 8px; }
.lobby .card a:not(.small) { color: var(--accent); }
.lobby a.small, .lobby button.small, .lobby .card button { font-size: 13px; }

/* Inbox (M2b) */
.account-bar .inbox-link.unread { background: var(--accent); color: #f6e7bf; padding: 0 6px; border-radius: 8px; text-decoration: none; }
.lobby a.badge { background: var(--accent); color: #f6e7bf; padding: 1px 7px; border-radius: 8px; font-size: 12px; text-decoration: none; }
details.notice { background: #f8f1df; border: 1px solid var(--line); border-left: 4px solid #b9a882; border-radius: 2px; margin: 5px 0; padding: 5px 9px; }
details.notice.unread { border-left-color: var(--accent); background: #fbf3dc; }
details.notice.unread summary b::after { content: " •"; color: var(--accent); }
details.notice summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
details.notice .notice-kind { font-size: 12px; color: #5a4a32; min-width: 86px; }
details.notice .notice-body { white-space: pre-line; font-size: 13px; margin: 6px 0; color: var(--panel-ink); }
details.notice.kind-deadline { border-left-color: #b8701a; }

/* Diplomacy tab (M2c) */
.diplo-picker .chip.on { background: #5a4a32; color: #f4ecd8; }
.diplo-picker .chip.war { border-color: var(--accent); }
.letters { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; padding-right: 4px; }
.letter { max-width: 88%; padding: 5px 8px; border-radius: 6px; font-size: 13px; border: 1px solid var(--line); }
.letter.mine { align-self: flex-end; background: #efe3c2; }
.letter.theirs { align-self: flex-start; background: #fbf6e8; border-left: 3px solid #8a7a5a; }
.letter-head { font-size: 11px; color: #5a4a32; margin-bottom: 2px; }
.letter-text { white-space: pre-line; }
.letter-box { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; background: #fffaf0; border: 1px solid #8a7a5a; padding: 4px 6px; }
.offer { border: 1px solid var(--line); border-left: 4px solid #b9a882; padding: 5px 8px; margin: 5px 0; font-size: 13px; background: #fbf6e8; }
.offer.pending { border-left-color: #b8701a; }
.offer.accepted { border-left-color: #4a8a3a; }
.offer.declined, .offer.expired, .offer.failed, .offer.withdrawn { opacity: 0.7; }
.offer-builder { margin-top: 8px; }
.offer-builder summary { cursor: pointer; font-weight: bold; color: #5a4a32; }
.bundle-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #5a4a32; margin-top: 6px; border-bottom: 1px solid var(--line); }
.bundle .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin: 4px 0; }
.bundle select { max-width: 150px; }
.tabs button { padding-left: 6px; padding-right: 6px; }
.panel .option { flex-wrap: wrap; }
.panel .action-row { display: flex; flex-wrap: wrap; gap: 4px; }
details.notice summary b { font-size: 14px; }

/* Real-time clock (M2d) */
.turn-clock { display: inline-flex; gap: 3px; align-items: center; background: #3a332a; border: 1px solid #000; border-radius: 3px; padding: 1px 5px; }
.turn-clock .clock-face { font-variant-numeric: tabular-nums; min-width: 64px; color: #f6d79c; }
.turn-clock.paused .clock-face { color: #c9b98f; font-style: italic; }
.turn-clock button.small { padding: 1px 5px; font-size: 11px; }
.turn-clock button.on { background: #f6d79c; color: #222; }

/* Server settings and Discord (M2e) */
.discord-button { display: inline-block; background: #5865f2; color: #fff !important; padding: 6px 14px; border-radius: 4px; text-decoration: none; font-weight: bold; margin: 6px 0; border: 1px solid #000; }
.discord-button:hover { background: #4752c4; }
.steam-button { display: inline-block; background: #1b2838; color: #fff !important; padding: 6px 14px; border-radius: 4px; text-decoration: none; font-weight: bold; margin: 6px 0; border: 1px solid #000; }
.steam-button:hover { background: #2a475e; }
.hint-box { background: #fbf3dc; border: 1px solid var(--line); border-left: 4px solid #b8701a; padding: 6px 10px; margin: 6px 0; font-size: 13px; }
.hint-box ol { margin: 4px 0 2px 18px; padding: 0; }
.lobby code { background: #ece1c6; padding: 0 3px; font-size: 12px; }

/* Unrest (3a) */
.unrest-box { margin: 6px 0; font-size: 13px; }
.bar.unrest { width: 100px; }
.bar.unrest div { background: linear-gradient(90deg, #6a9a4a, #c8a030 50%, #a01010); }

/* Getting started */
.getting-started { background: #fbf3dc; border: 1px solid var(--line); border-left: 4px solid #b8701a; padding: 6px 10px; margin-bottom: 8px; }
.getting-started h3 { margin: 0 0 4px; }
.gs-step { font-size: 13px; margin: 3px 0; }
.gs-step.done { color: #6a7a5a; text-decoration: line-through; }

/* Loyalty (3b) */
.loyalty-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; margin: 3px 0; }

/* Management screens: full window over the map */
.shell { position: relative; }
.manage { grid-row: 2; grid-column: 1 / -1; z-index: 20; background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-top: 3px solid #5a4a32; color: var(--panel-ink); }
.manage-tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 10px; background: #2e2a24; border-bottom: 1px solid #000; }
.manage-tabs button { background: #5a4a32; color: #f4ecd8; border: 1px solid #000; padding: 4px 12px; border-radius: 3px; }
.manage-tabs button.on { background: #f6d79c; color: #222; }
.manage-tabs .spacer { flex: 1; }
.manage-body { flex: 1; overflow: auto; padding: 12px 18px; }
.manage-body.columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 14px 22px; align-items: start; }
.manage-body.columns > * { min-width: 0; background: #fbf6e8; border: 1px solid var(--line); border-top: 4px solid #5a4a32; padding: 6px 12px; }
.overview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.ov-card { background: #fbf6e8; border: 1px solid var(--line); border-top: 4px solid #5a4a32; padding: 8px 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.ov-card h3 { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.1em; font-size: 13px; color: #5a4a32; }
.ov-big { font-size: 20px; margin-bottom: 4px; }
.ov-alert { font-size: 13px; margin: 3px 0; }
.prov-table td, .prov-table th { white-space: normal; }
.prov-table tr.row-alert td { background: #f6d9c8; }
.manage-btn.on { background: #f6d79c; color: #222; }
.shell > .map-wrap { grid-row: 2; grid-column: 1; }
.shell > aside.panel { grid-row: 2; grid-column: 2; }
.prov-table button.link { font-size: 13px; }
.prov-table th button.link { font-size: 12px; color: #f4ecd8; }
.manage-tabs button { font-size: 13px; }

/* The side panel's look, inside the management screens */
.manage section { padding: 6px 4px; }
.manage h2 { margin: 0 0 2px; font-size: 20px; }
.manage h3 { margin: 4px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.manage select { font: inherit; font-size: 13px; padding: 2px 4px; max-width: 260px; }
.manage .option { flex-wrap: wrap; }
.manage .action-row { display: flex; flex-wrap: wrap; gap: 4px; }
.manage-body button { font-size: 13px; }
.manage-body button.small { font-size: 12px; }

/* GM hub */
.hub-table td { white-space: normal; vertical-align: top; }
.hub-table tr.paused td { background: #ece4d0; color: #7a6d55; }
.hub-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* Battle forecast on the province panel */
.forecast { border: 1px solid var(--line, #8a7350); border-left-width: 4px; border-radius: 4px; padding: 6px 8px; margin: 6px 0; background: rgba(0,0,0,0.04); }
.forecast.bad { border-left-color: #a33; }
.forecast.even { border-left-color: #b8860b; }
.forecast.good { border-left-color: #3a7; }


/* Turn gazette and decisions windows */
.modal-back { position: fixed; inset: 0; background: rgba(20, 12, 4, 0.45); z-index: 90; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 91; width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
         overflow: auto; background: #fbf3df; color: #2b1d0e; border: 3px double #8a6a3a; box-shadow: 0 10px 40px rgba(0,0,0,0.5); padding: 14px 18px; border-radius: 4px; }
.modal-head { display: flex; align-items: baseline; gap: 8px; font-size: 18px; margin-bottom: 8px; }
.modal-head .close { margin-left: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; border-top: 1px solid #c9b48a; padding-top: 8px; flex-wrap: wrap; }
.modal-foot .muted { margin-right: auto; }
.decisions-modal { width: min(720px, calc(100vw - 32px)); }
.gazette { font-family: Georgia, "Times New Roman", serif; }
.gz-mast { text-align: center; border-bottom: 3px double #2b1d0e; padding-bottom: 6px; }
.gz-title { font-size: 34px; font-weight: bold; letter-spacing: 1px; font-variant: small-caps; }
.gz-date { font-size: 13px; font-style: italic; }
.gz-lead { font-size: 22px; font-weight: bold; text-align: center; margin: 10px 0; line-height: 1.25; }
.gz-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.gz-col { border-left: 1px solid #c9b48a; padding-left: 10px; font-size: 13px; }
.gz-col:first-child { border-left: none; padding-left: 0; }
.gz-col h4 { margin: 8px 0 4px; font-variant: small-caps; font-size: 15px; border-bottom: 1px solid #c9b48a; }
.gz-item { margin: 3px 0; }
.gz-item.good b { color: #2e6b2e; }
.gz-item.bad b { color: #8a2a1a; }
@media (max-width: 760px) { .gz-cols { grid-template-columns: 1fr; } .gz-col { border-left: none; padding-left: 0; } }

/* Toolbar stats: icon, word and value */
.toolbar .stat { white-space: nowrap; }
.toolbar .stat .muted { font-size: 0.9em; }

/* Map legend */
.map-legend { position: absolute; top: 8px; left: 8px; z-index: 20; width: min(420px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto;
              background: #fbf3df; border: 2px solid #8a6a3a; border-radius: 4px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.map-legend > div { margin: 5px 0; }
.map-legend .lg-head { display: flex; justify-content: space-between; align-items: center; margin-top: 0; }
.lg-flag, .lg-ship, .lg-shield, .lg-badge, .lg-poi { display: inline-block; min-width: 20px; text-align: center; color: #fff; font-weight: bold; font-family: Georgia, serif; font-size: 11px; padding: 1px 3px; margin-right: 3px; }
.lg-flag { border: 1px solid #fff; clip-path: polygon(0 0, 100% 0, 80% 50%, 100% 100%, 0 100%); padding-right: 8px; }
.lg-ship { background: #7a5a2a; border-radius: 0 0 8px 8px; }
.lg-badge { background: #4a3a20; border-radius: 50%; min-width: 16px; }
.lg-shield { border-radius: 2px 2px 10px 10px; }
.lg-shield.wild { background: #7d7262; } .lg-shield.rebel { background: #a01010; } .lg-shield.rift { background: #6b2a8a; }
.lg-poi { color: #6b2a8a; font-size: 14px; }

/* Order confirmation toast */
.toast { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(640px, calc(100% - 24px));
         background: #2b1d0e; color: #f4ecd8; padding: 8px 14px; border-radius: 6px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,0.4); cursor: pointer; }

/* How-to boxes on the province panel */
.howto { border: 1px dashed #a08a60; border-radius: 4px; padding: 4px 8px; margin: 6px 0; font-size: 12.5px; }
.howto summary { cursor: pointer; }
.howto ol { margin: 4px 0 4px 18px; padding: 0; }


/* Buildings screen */
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px; }
.build-grid select { max-width: 240px; }


/* Army templates */
.template { border: 1px solid #c9b48a; border-radius: 4px; padding: 6px 8px; margin: 6px 0; }
.template .btns { float: right; }
.template.edit { background: rgba(0,0,0,0.03); }


/* Zeal and holy sites */
.zeal-row { margin: 6px 0 2px; }
.zeal-row .bar { display: inline-block; width: 120px; vertical-align: middle; }
.holy { border-left: 4px solid #b8860b; padding: 3px 8px; margin: 6px 0; background: rgba(184,134,11,0.08); }


/* Hand of Fate */
.fate-card { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.fate-face { display: inline-block; min-width: 44px; text-align: center; padding: 8px 4px; border: 2px solid #8a6a3a; border-radius: 6px; background: #fffaf0; font: bold 16px Georgia, serif; }
.fate-face.suit-swords { color: #8a2a1a; } .fate-face.suit-coins { color: #a07800; } .fate-face.suit-stars { color: #2a4a8a; } .fate-face.suit-shadows { color: #4a2a6a; }

.chip.flaw { border-color: #a33; color: #8a2a1a; }


/* The Gazette and decisions windows float over the map without blocking the toolbar, the map's edges or the side panel. */
.modal { top: 96px; left: 12px; transform: none; width: min(900px, calc(100vw - 440px)); max-height: calc(100vh - 120px); }
.decisions-modal { width: min(640px, calc(100vw - 440px)); }
.gazette { position: fixed; }
.gz-close { position: absolute; top: 8px; right: 10px; }
@media (max-width: 900px) { .modal, .decisions-modal { left: 8px; width: calc(100vw - 16px); } }

/* Map legend: sections and drawn sample symbols */
.map-legend .lg-sec { font-variant: small-caps; font-weight: bold; letter-spacing: .04em; border-bottom: 1px solid rgba(90,74,50,.35); margin-top: 10px; }
.map-legend .lg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; }
.map-legend .lg-grid > span { display: flex; align-items: center; gap: 6px; }
.map-legend .lg-ic { width: 30px; height: 20px; flex: none; display: inline-block; }
.map-legend .lg-ic.tall { height: 26px; }

/* Deleting games */
.save-row { display: flex; align-items: center; gap: 6px; }
.save-row .save { flex: 1; }
.save-row .save-del { background: transparent; color: #8a2a1a; border: 1px solid #8a2a1a; white-space: nowrap; flex: none; }
.save-row .save-del:hover { background: #8a1a1a; color: #f4ecd8; }
.save-confirm { white-space: nowrap; font-size: 13px; }
.danger-text { color: #8a2a1a; }
.confirm-row td { background: #f6e3d8; }

/* UI pass: advisor, research speed, build previews, expedition odds */
.advisor { border: 1px solid #c9a35a; background: #fbf3df; border-radius: 4px; padding: 6px 10px; margin-bottom: 10px; }
.advisor h3 { margin: 0 0 4px; }
.research-speed { border-top: 1px dashed rgba(90,74,50,.35); margin-top: 8px; padding-top: 6px; }
.build-preview { display: block; color: #2f5d2a; }
.expedition-outlook { margin: 2px 0 6px; max-width: 520px; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { text-decoration: underline; }

/* Deaths of heroes, governors and rulers: impossible to miss in the Gazette */
.gz-losses { border: 2px solid #2b1d0e; background: #efe6d2; padding: 6px 10px; margin: 8px 0; font-family: Georgia, serif; }
.gz-losses > b { display: block; font-variant: small-caps; letter-spacing: .06em; }

/* Company ranks */
.rank { font-weight: bold; }
.rank-0 { color: #6b8a3a; } .rank-1 { color: #5a4a32; } .rank-2 { color: #2a4a8a; } .rank-3 { color: #8a2a1a; }

/* Guild, goodwill and parties */
.goodwill-line { margin: 4px 0; }
.party-line { margin: 2px 0 4px; color: #4a3a20; }
.party-line select { font-size: 12px; padding: 0 2px; }
.job { border-bottom: 1px dotted rgba(90,74,50,.35); padding: 4px 0 6px; }
.job.ours { background: #f3ead2; }
.goodwill-line button { margin-left: 6px; }
.charter-line { margin: 6px 0; padding: 4px 6px; border-left: 3px solid #b08a3e; background: rgba(176,138,62,0.08); }
.charter-line select { max-width: 100%; margin-top: 3px; }
.petition { margin: 4px 0; padding: 3px 6px; border-left: 3px solid #7a5c9e; background: rgba(122,92,158,0.07); }
.frontier { margin: 4px 0; }
.frontier .action-row { margin-top: 3px; }

/* Description first, its buttons on the right in one column (playtest 11-06). */
.option > .btns { order: 2; margin-left: auto; flex: none; }
.option > span:not(.btns):first-of-type { flex: 1 1 auto; min-width: 0; }
.retired-toggle { margin: 4px 0; }
.option > button:first-child { order: 2; margin-left: auto; }
.jump-nav { position: sticky; top: 0; z-index: 2; background: inherit; padding: 4px 0 6px; }
.jump-nav a { cursor: pointer; }

/* Picture frames (optional, per player) */
.img-slot { display: inline-flex; align-items: flex-start; gap: 2px; vertical-align: top; margin-right: 6px; }
.img-frame { display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid rgba(90,74,50,.55); border-radius: 4px; background: rgba(90,74,50,.08); box-shadow: inset 0 0 6px rgba(0,0,0,.12); flex: none; }
.img-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; color: rgba(90,74,50,.6); line-height: 1.1; }
.img-ph .ph-icon { font-size: 1.2em; }
.img-ph .ph-size { font-size: 10px; }
.img-tools { display: inline-flex; flex-direction: column; gap: 0; }
.img-tools label, .img-tools button { cursor: pointer; padding: 0 2px; }
.prompt-box { margin: 4px 0 8px; padding: 6px; border: 1px dashed rgba(90,74,50,.5); border-radius: 4px; background: rgba(255,250,235,.6); }
.prompt-box textarea { width: 100%; box-sizing: border-box; margin: 3px 0; font-size: 12px; }
.race-frame .img-frame { margin: 2px 0; }
.district-head { margin: 8px 0 2px; font-variant: small-caps; font-weight: bold; border-bottom: 1px solid rgba(90,74,50,.3); }
.option.grave { color: #a0281e; font-weight: bold; }
.tech.branch-works, .branch-works { border-left: 4px solid #6b8e23; }
.tech.branch-martial, .branch-martial { border-left: 4px solid #a0281e; }
.tech.branch-lore, .branch-lore { border-left: 4px solid #2f6f8f; }
.tech.branch-faith, .branch-faith { border-left: 4px solid #d4af37; }
.tech-chips { margin-left: 4px; font-size: 0.8em; opacity: 0.85; }
.tech-chips span { margin-left: 3px; }
.forecast-card { border-left: 4px solid #999; padding: 2px 6px; margin: 2px 0; }
.forecast-card.verdict-good { border-left-color: #2e7d32; }
.forecast-card.verdict-fair { border-left-color: #b8860b; }
.forecast-card.verdict-poor { border-left-color: #a0281e; }
.bar.life-bar > div { background: #8a6d3b; }

.gm-only { display: block; margin: 8px 0 2px; }
.gm-only input { margin-right: 6px; }

.founding { margin-top: 8px; padding: 8px; border-top: 1px solid var(--line, #c9b98f); }

/* The toolbar's gold line: larger and bold, with income and costs in clear colours. */
.stat.gold-line { font-size: 15px; font-weight: 700; }
.stat.gold-line .inc { color: #9fe08a; }
.stat.gold-line .exp { color: #ff9f8f; }
.stat.gold-line.neg .inc, .stat.gold-line.neg .exp { color: inherit; }

/* Toolbar figures sit on a dark bar: the light-panel greys and dark reds vanish there, so give every figure light, bold colours. */
.toolbar .stat { font-size: 15px; font-weight: 700; color: #f4ecd8; }
.toolbar .stat .muted { color: #e6d9b8; font-size: 0.95em; font-weight: 700; }
.toolbar .stat .neg, .toolbar .stat .exp { color: #ff9f8f; }
.toolbar .stat .pos, .toolbar .stat .inc { color: #9fe08a; }
.toolbar .stat .warn { color: #ffb38a; }
.toolbar .stat.neg { color: #ff9f8f; }
.toolbar .stat.neg .muted { color: #ffc6bb; }

/* The province table's header is a dark bar, so its light sort buttons read clearly. */
.prov-table th { background: #5a4a32; color: #f4ecd8; font-weight: normal; letter-spacing: 0.03em; cursor: help; }
.prov-table th button.link { color: #f4ecd8; font-weight: 700; padding: 0; }
.prov-table tr:hover td { background: #ece1c6; }

/* Popups can be dragged by their title strip (and messages anywhere). */
.modal-head, .gz-mast, .toast { cursor: move; user-select: none; }
.modal-head button, .modal-head a { cursor: pointer; }
.modal-head::before, .gz-mast::before { content: "⠿"; color: #8a7a5a; margin-right: 6px; font-size: 14px; }
.gz-mast::before { position: absolute; left: 14px; top: 12px; }
.dragging { opacity: 0.92; box-shadow: 0 10px 30px rgba(0,0,0,0.45); }

/* Research tree: ages down the side, branches across the top. */
.tech-tree { overflow-x: auto; margin-bottom: 8px; }
.tech-tree table { border-collapse: collapse; min-width: 900px; }
.tech-tree th { font-size: 12px; text-transform: capitalize; padding: 3px 6px; background: #5a4a32; color: #f4ecd8; position: sticky; top: 0; }
.tech-tree th.era-head { position: static; text-align: left; vertical-align: top; min-width: 90px; }
.tech-tree th.era-head .muted { color: #e6d9b8; }
.tech-tree td { vertical-align: top; border: 1px solid var(--line); padding: 3px; min-width: 110px; }
.tech-tree td .tech { display: block; width: 100%; margin-bottom: 3px; text-align: left; }
.manage-body.columns > section:has(.tech-tree), .manage-body > section:has(.tech-tree) { grid-column: 1 / -1; }

/* Trends screen */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.trend-card { border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px; background: rgba(255,255,255,0.35); }
.trend-svg { width: 100%; height: 90px; display: block; }
.trend-line { fill: none; stroke: #7a4a10; stroke-width: 2; vector-effect: non-scaling-stroke; }
.trend-zero { stroke: #a01010; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.trend-era { stroke: #5a4a32; stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.6; vector-effect: non-scaling-stroke; }
.trend-card .inc { color: #2f7a2a; }
.trend-card .exp { color: #a01010; }

/* Help and glossary */
.help-modal { max-width: 720px; }
.help-search { width: 100%; box-sizing: border-box; font: inherit; padding: 5px 8px; margin-bottom: 8px; border: 1px solid #8a7a5a; background: #fffaf0; }
.help-term { padding: 5px 0; border-bottom: 1px solid var(--line); }
.help-link { font-size: 12px; text-decoration: none; padding: 0 2px; }

/* Folding side-panel sections */
aside.panel h3 { cursor: pointer; user-select: none; }
aside.panel h3[data-fold="open"]::before { content: "▾ "; color: var(--muted); font-size: 0.8em; }
aside.panel h3[data-fold="closed"]::before { content: "▸ "; color: var(--muted); font-size: 0.8em; }
aside.panel [data-folded="1"] { display: none !important; }
tr.war-row td { background: rgba(160,16,16,0.08); }
@media (max-width: 760px) {
  .toolbar .stat.gold-line { white-space: normal; font-size: 13px; }
  .trend-grid { grid-template-columns: 1fr; }
  .help-modal { max-width: 96vw; }
}
@media (max-width: 760px) {
  .manage-body { padding: 8px 8px; }
  .manage-body .prov-table { display: block; overflow-x: auto; }
}
.game-options fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.game-options fieldset:disabled { opacity: .7; }
.game-options .preset-desc { max-width: 60ch; }
.game-options-summary table.stats th { text-align: left; font-weight: normal; padding-right: 12px; }
.newsfax { font-family: Georgia, "Times New Roman", serif; border-top: 3px double #8a7a5a; border-bottom: 3px double #8a7a5a; padding: 6px 2px; }
.newsfax .nf-mast { font-size: 22px; font-weight: bold; font-variant: small-caps; letter-spacing: 1px; text-align: center; }
.newsfax .nf-date { font-size: 12px; font-style: italic; text-align: center; color: var(--muted); }
.newsfax .nf-head { font-size: 17px; font-weight: bold; margin: 6px 0; line-height: 1.25; }
.newsfax .nf-lore, .gz-lore { font-style: italic; margin-top: 8px; color: var(--muted); }
.newsfax .nf-foot { font-size: 11px; text-align: center; color: var(--muted); margin-top: 4px; }
.gz-lore { font-family: Georgia, "Times New Roman", serif; text-align: center; padding: 6px 12px; }
.field.wide textarea.short { width: 100%; min-height: 64px; font: inherit; }
.army.flash { outline: 2px solid var(--accent, #c0392b); outline-offset: 2px; animation: armyflash 1.6s ease-out 1; }
@keyframes armyflash { from { background: #f6d79c; } to { background: transparent; } }
.purpose { display: block; font-size: 12px; color: #4a3a1a; }

/* ---- Editor app (EditorMode) ---- */
.editor-nav { display: inline-flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.editor-nav .brand { color: #f6d79c; font-family: Georgia, serif; }
.editor-nav a { color: #f4ecd8; text-decoration: none; padding: 2px 8px; border: 1px solid #7a6a4a; border-radius: 3px; }
.editor-nav a.on, .editor-nav a:hover { background: #5a4a32; }
.saved-worlds h3 { margin: 8px 0 4px; font-size: 14px; }
.saved-worlds .row input { flex: 1; min-width: 120px; }
.saved-world { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; border-bottom: 1px solid var(--line); padding: 3px 0; }

/* ---- Editor forms and grid (step 6 slice C) ---- */
.edit-head { align-items: baseline; gap: 10px; }
.edit-head .tabs button.on { background: #f6d79c; }
.entry-form { display: flex; flex-direction: column; gap: 4px; max-height: 66vh; overflow-y: auto; padding-right: 4px; }
.entry-form .form-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px; align-items: start; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.entry-form .form-row > label { font-family: Consolas, monospace; font-size: 12.5px; padding-top: 4px; overflow-wrap: anywhere; cursor: help; }
.entry-form .help-dot { color: #9a6a0c; font-weight: bold; }
.entry-form input:not([type=checkbox]), .entry-form select { max-width: 100%; }
.entry-form input.num { width: 110px; }
.entry-form textarea.short { width: 100%; min-height: 3.2em; box-sizing: border-box; }
.entry-form textarea.code { font-family: Consolas, monospace; font-size: 12px; min-height: 6em; }
.entry-form .chips { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.entry-form .chips input.add { width: 150px; }
.entry-form .map-rows { display: flex; flex-direction: column; gap: 2px; }
.entry-form .map-row { display: flex; gap: 4px; align-items: center; }
.entry-form .map-row input { width: 170px; }
.entry-form .map-row input.num { width: 90px; }
.entry-form .json-field { display: flex; flex-direction: column; }
.entry-form details.unset > summary { cursor: pointer; color: var(--accent); padding: 4px 0; }
.entry-form .form-row.unknown label { color: #9a6a0c; }
input.bad-ref, .chip.bad-ref { border-color: #a33 !important; background: #f6dcdc !important; }
.grid-card { grid-column: 2 / 4; min-width: 0; }
.table-grid .grid-tools { gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.table-grid .grid-tools .filter { width: 220px; }
.table-grid .columns .column-picks { display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 760px; padding: 6px; font-size: 12px; }
.table-grid .file-pick input[type=file] { max-width: 210px; font-size: 12px; }
.table-grid .grid-scroll { max-height: 64vh; overflow: auto; border: 1px solid var(--line); }
.table-grid table.grid { border-collapse: collapse; font-size: 12.5px; }
.table-grid table.grid th { position: sticky; top: 0; background: #e8dcc0; cursor: pointer; padding: 3px 6px; text-align: left; white-space: nowrap; font-family: Consolas, monospace; }
.table-grid table.grid td { padding: 1px 3px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-grid table.grid td input:not([type=checkbox]) { width: 130px; font-size: 12px; padding: 1px 3px; }
.table-grid table.grid td input.num { width: 70px; }
.table-grid table.grid tr.sel td { background: #f6e7bf; }

/* ---- Tech tree and removal impact (step 6 slice D) ---- */
.tech-tree .tree-tools { gap: 10px; align-items: center; flex-wrap: wrap; }
.tech-tree .tree-tools .filter { width: 200px; }
.tech-tree .legend .swatch { display: inline-block; width: 11px; height: 11px; border: 1px solid #8a7a5a; margin-right: 3px; vertical-align: middle; }
.tech-tree .tree-panel { background: #fbf4e2; border: 1px solid var(--line); padding: 6px 8px; margin: 6px 0; }
.tech-tree .tree-panel .unlock-group { margin-right: 12px; }
.tech-tree .tree-scroll { max-height: 70vh; overflow: auto; border: 1px solid var(--line); background: #fffaf0; }
.tech-tree svg text { font-family: Georgia, serif; font-size: 11.5px; fill: #2e2a24; pointer-events: none; }
.tech-tree svg text.era-head { font-weight: bold; font-size: 13px; }
.tech-tree svg .node { cursor: pointer; }
.tech-tree svg .node rect { stroke: #8a7a5a; stroke-width: 1; }
.tech-tree svg .node:hover rect { stroke: #2e2a24; stroke-width: 2; }
.tech-tree svg .node.sel rect { stroke: #9a1c1c; stroke-width: 3; }
.tech-tree svg .node.anc rect { stroke: #1c4a9a; stroke-width: 2; }
.tech-tree svg .node.desc rect { stroke: #2a7a2a; stroke-width: 2; }
.tech-tree svg .node.dim { opacity: 0.25; }
.tech-tree svg path.edge { fill: none; stroke: #9a8a6a; stroke-width: 1; opacity: 0.55; }
.tech-tree svg path.edge.up { stroke: #1c4a9a; stroke-width: 2; opacity: 1; }
.tech-tree svg path.edge.down { stroke: #2a7a2a; stroke-width: 2; opacity: 1; }
.tech-tree svg path.edge.dim { opacity: 0.08; }
.impact { border: 1px solid #a33; background: #fbecec; padding: 6px 8px; margin-top: 6px; }
.impact > div { margin: 3px 0; }

/* ---- Sim test (step 6 slice E) ---- */
.sim-panel .row { align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sim-progress { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.sim-progress .bar { display: inline-block; width: 260px; height: 9px; border: 1px solid #8a7a5a; background: #f4ecd8; }
.sim-progress .bar span { display: block; height: 100%; background: #8a6a2a; }
.sim-table td, .sim-table th { padding: 1px 8px; text-align: right; }
.sim-table tr.baseline td { color: #5a4a32; font-style: italic; border-top: 1px dashed var(--line); }
.delta.up { color: #2a7a2a; } .delta.down { color: #9a1c1c; }
.sim-unused .chip { margin: 2px 3px 2px 0; }

/* ---- World editor painting (step 6 slice F) ---- */
.paint-box h3 { margin: 0 0 4px; font-size: 14px; }
.paint-box .paint-modes, .paint-box .brushes { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.paint-box button.on { background: #f6d79c; color: #2e2a24; }
.paint-box .brush { font-size: 11.5px; padding: 1px 6px; }

/* ---- Packages (step 6 slice G) ---- */
.packages .pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; }
.packages .pkg-box { border: 1px solid var(--line); padding: 6px 8px; background: #fbf4e2; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.packages .pkg-box h4 { margin: 0; }
.packages .pkg-box textarea { width: 100%; box-sizing: border-box; }
