.diplomacy-dialog, .scene > #drawer.atlas-panel-page {
  --diplomacy-gap: clamp(9px, 2.1vmin, 25px);
  --diplomacy-green: #325a49;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(var(--diplomacy-gap), var(--game-inset-top, env(safe-area-inset-top, 0px)))
    max(var(--diplomacy-gap), var(--game-inset-right, env(safe-area-inset-right, 0px)))
    max(var(--diplomacy-gap), var(--game-inset-bottom, env(safe-area-inset-bottom, 0px)))
    max(var(--diplomacy-gap), var(--game-inset-left, env(safe-area-inset-left, 0px)));
  overflow: hidden;
  border: 0;
  color: var(--atlas-ink);
  color-scheme: light;
}
.scene > #drawer.atlas-panel-page {
  --ink: var(--atlas-ink);
  --muted: var(--atlas-muted);
  --gold: #8a4b38;
  --bright-gold: #7c362a;
  --panel: #f8edd2;
  --surface: #faefd4b3;
  --line: var(--atlas-rule);
  --trim: #a98d64;
  --fire-risk-ink: #8a382c;
  --fire-risk-border: #b87a5e;
  --fire-risk-surface: #f7e1cb;
  position: absolute;
  z-index: 5;
  display: block;
  border-radius: 0;
  box-shadow: none;
}
.app:has(> .scene > #drawer.atlas-panel-page:not([hidden])) > :is(.topbar, .bottombar),
.scene:not(.world-mode):has(> #drawer.atlas-panel-page:not([hidden])) > :not(#drawer, .scene-notices) {
  visibility: hidden;
  pointer-events: none;
}
.scene:has(> #drawer.atlas-panel-page:not([hidden])) > .scene-notices {
  top: calc(max(var(--diplomacy-gap, 16px), var(--game-inset-top, env(safe-area-inset-top, 0px))) + 78px);
}
.diplomacy-heading :is(h1, h2) { margin-block-start: 4px; }
.diplomacy-heading .atlas-return svg { transform: rotate(180deg); }
.diplomacy-sheet :is(input, textarea, button, select):focus-visible { outline: 2px solid var(--atlas-red); outline-offset: -2px; }
.diplomacy-frame { display: grid; min-height: 0; }
.diplomacy-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border: 1px solid #8d7658;
  background: #f8edd2;
}
.diplomacy-content {
  display: grid;
  grid-template-columns: clamp(230px, 31%, 374px) minmax(0, 1fr);
  min-height: 0;
}
.diplomacy-content-ledger, .diplomacy-content-messages { grid-template-columns: minmax(0, 1fr); }
.diplomacy-directory {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-inline-end: 3px double var(--atlas-rule);
  background: #eee0be;
}
.diplomacy-directory-head { padding: clamp(10px, 1.5vw, 20px); border-bottom: 1px solid var(--atlas-rule); }
.diplomacy-directory h2, .diplomacy-record h2, .diplomacy-blank h2, .diplomacy-messages h2 {
  margin: 0;
  font: 650 clamp(20px, 2vw, 31px)/1.1 var(--serif);
  letter-spacing: -.025em;
}
.diplomacy-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-block-start: 12px; }
.diplomacy-search input, .diplomacy-offer textarea, .diplomacy-button, .diplomacy-support-form select, .diplomacy-message-compose textarea {
  min-height: 42px;
  padding: 5px 9px;
  border: 1px solid #a98d64;
  border-radius: 0;
  background: #fcf3db;
  color: var(--atlas-ink);
  font: 550 13px/1.2 var(--ui);
}
.diplomacy-search input { width: 100%; min-width: 0; }
.diplomacy-search input::placeholder { color: #6c5b45; opacity: 1; }
.diplomacy-button { padding-inline: 12px; background: #f9eed2; color: #6e382c; font-weight: 700; white-space: nowrap; }
.diplomacy-button:enabled:hover { background: #ecd6af; color: #6d2d23; }
.diplomacy-primary { border-color: #394b3e; background: var(--diplomacy-green); color: #fff0d0; }
.diplomacy-primary:enabled:hover { background: #254437; color: #fff0d0; }
.diplomacy-button[data-message-player] { display: inline-flex; align-items: center; gap: 7px; }
.diplomacy-button[data-message-player] svg { width: 16px; height: 16px; }
.diplomacy-sections {
  display: flex;
  align-items: stretch;
  overflow: auto;
  border-bottom: 3px double var(--atlas-rule);
  background: linear-gradient(#f8ecd1,#edddba);
}
.diplomacy-sections button {
  display: inline-flex;
  min-height: 45px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1px clamp(10px, 2vw, 28px) 0;
  border: 0;
  box-shadow: inset -1px 0 var(--atlas-rule);
  background: none;
  color: var(--atlas-muted);
  font: 700 13px/1.2 var(--ui);
  white-space: nowrap;
}
.diplomacy-sections button:hover { color: #7c362a; background: #f7ebcd; }
.diplomacy-sections button[aria-pressed=true] {
  color: #7c362a;
  background: #f8edd2;
  box-shadow: inset -1px 0 var(--atlas-rule), inset 0 -2px var(--atlas-red);
}
.diplomacy-sections small {
  min-width: 17px;
  padding: 1px 4px;
  border-radius: 9px;
  background: #8b3c30;
  color: #fff1d8;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.diplomacy-roster, .diplomacy-register { min-height: 0; overflow: auto; scrollbar-color: #aa906a #efdfbb; }
.diplomacy-roster ul { margin: 0; padding: 0; list-style: none; }
.diplomacy-roster li + li { border-top: 1px solid var(--atlas-rule); }
.diplomacy-roster-empty { margin: 0; padding: 18px; color: var(--atlas-muted); }
.diplomacy-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(7px, 1vw, 13px);
  width: 100%;
  min-height: 66px;
  padding: 8px clamp(8px, 1.5vw, 19px);
  border: 0;
  border-inline-start: 3px solid transparent;
  background: none;
  color: var(--atlas-ink);
  text-align: start;
}
.diplomacy-player:is([aria-pressed=true], :hover) { background: #e8d2a6; }
.diplomacy-player[aria-pressed=true] { border-inline-start-color: var(--atlas-red); }
.diplomacy-identity { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.diplomacy-identity strong { font: 700 16px/1.18 var(--serif); }
.diplomacy-identity small { color: var(--atlas-muted); font: 600 12px/1.2 var(--ui); }
.diplomacy-portrait {
  display: grid;
  place-items: center;
  width: 39px;
  aspect-ratio: 1;
  padding: 2px;
  border: 1px solid #a98a5b;
  border-radius: 50%;
  background: #e7d0a7;
  color: #835146;
}
.diplomacy-portrait svg { width: 54%; }
.diplomacy-player-mark { width: 8px; height: 8px; border-radius: 50%; background: #8c7858; }
.diplomacy-player-mark[data-status=incoming] { background: var(--atlas-red); }
.diplomacy-player-mark[data-status=active] { background: var(--diplomacy-green); }
.diplomacy-register {
  min-width: 0;
  background: radial-gradient(ellipse at 55% 37%, #fcf2d9 10%, #f3e4c1 88%);
}
.diplomacy-parties {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(40px, 17vw, 220px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(4px, 2vw, 25px);
  padding: clamp(17px, 3.8vh, 43px) clamp(8px, 3.6vw, 51px);
  border-bottom: 3px double var(--atlas-rule);
  background:
    repeating-linear-gradient(0deg, #82664610 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, #82664610 0 1px, transparent 1px 24px),
    radial-gradient(ellipse at 50% 0%, #fcf1d6e6, #ecdbb78c);
}
.diplomacy-party { display: grid; justify-items: center; gap: 8px; min-width: 0; text-align: center; }
.diplomacy-party .diplomacy-portrait {
  width: clamp(46px, 7.5vw, 96px);
  padding: clamp(2px, .48vw, 6px);
  outline: 1px solid #aa8f63;
  outline-offset: 2px;
}
.diplomacy-counterpart .diplomacy-portrait { border-color: #985a48; outline-color: #985a48; }
.diplomacy-party strong { font-size: clamp(15px, 2.2vw, 29px); }
.diplomacy-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: clamp(46px, 7.5vw, 96px);
  color: var(--atlas-red);
}
.diplomacy-handshake { display: block; flex: none; width: clamp(37px, 5vw, 72px); height: auto; }
.diplomacy-link::before, .diplomacy-link::after { content: ""; width: 50%; height: 4px; border-block: 1px solid var(--atlas-rule); }
.diplomacy-record { width: min(100%, 1040px); margin-inline: auto; padding: clamp(12px, 2.1vw, 28px); }
.diplomacy-record > header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 5px 10px;
  padding-bottom: 10px;
}
.diplomacy-record > header span { color: var(--atlas-muted); font: 600 11px/1.2 var(--ui); font-variant-numeric: tabular-nums; }
.diplomacy-pacts { display: grid; gap: 8px; }
.diplomacy-pact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px clamp(8px, 1.3vw, 19px);
  padding: clamp(8px, 1.15vw, 15px);
  border: 1px solid var(--atlas-rule);
  background: #faefd47a;
}
.diplomacy-pact-icon {
  display: grid;
  place-items: center;
  width: clamp(30px, 3.2vw, 44px);
  aspect-ratio: 1;
  border: 1px solid #b8a07b;
  background: #eddbb7;
  color: #814336;
}
.diplomacy-pact-icon svg { width: 55%; }
.diplomacy-pact-summary h3 { margin: 0; font: 700 clamp(15px, 1.45vw, 22px)/1.14 var(--serif); }
.diplomacy-pact-summary p { margin: 4px 0 0; color: var(--atlas-muted); font: 550 13px/1.3 var(--ui); }
.diplomacy-pact-controls { display: grid; justify-items: end; gap: 6px; }
.diplomacy-status { color: var(--atlas-muted); font: 650 12px/1.2 var(--ui); text-align: end; }
.diplomacy-status[data-status=incoming] { color: #8a382c; }
.diplomacy-status[data-status=active] { color: var(--diplomacy-green); }
.diplomacy-pact-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 5px; }
.diplomacy-note {
  margin: 8px 0 0;
  padding: 7px 10px;
  border-inline-start: 2px solid var(--atlas-rule);
  background: #f6e6c3;
  color: var(--atlas-muted);
  font: 600 14px/1.4 var(--serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.diplomacy-offer {
  display: grid;
  gap: 6px;
  grid-column: 2 / -1;
  padding-top: 8px;
  border-top: 1px solid var(--atlas-rule);
}
.diplomacy-offer label { font-weight: 700; }
.diplomacy-offer label span, .diplomacy-offer small { color: var(--atlas-muted); font-size: 12px; font-weight: 500; }
.diplomacy-offer textarea { width: 100%; resize: vertical; }
.diplomacy-offer-footer { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.diplomacy-offer-footer > small { white-space: nowrap; }
.diplomacy-ledger { padding-top: clamp(14px, 3vw, 36px); }
.diplomacy-ledger-card, .diplomacy-history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px clamp(8px, 1.6vw, 21px);
  padding: clamp(10px, 1.4vw, 18px);
  border: 1px solid var(--atlas-rule);
  background: #faefd47a;
}
.diplomacy-ledger-card { border-inline-start: 3px solid #a58b66; }
.diplomacy-ledger-card[data-status=incoming] { border-inline-start-color: var(--atlas-red); }
.diplomacy-ledger-card[data-status=active] { border-inline-start-color: var(--diplomacy-green); }
.diplomacy-ledger-card .diplomacy-portrait { width: clamp(36px, 4.2vw, 54px); }
.diplomacy-ledger-content h3 { margin: 0; font: 700 clamp(16px, 1.6vw, 23px)/1.2 var(--serif); }
.diplomacy-ledger-content p { margin: 5px 0 0; color: var(--atlas-muted); }
.diplomacy-ledger-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 11px;
  color: var(--atlas-muted);
  font-size: 12px;
}
.diplomacy-ledger-meta time { white-space: nowrap; }
.diplomacy-peer-link {
  max-width: 100%;
  min-height: 25px;
  padding: 0 2px 2px;
  border: 0;
  background: none;
  color: #7c362a;
  font-size: 13px;
  font-weight: 700;
  text-align: start;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.diplomacy-peer-link:hover { color: #47291b; }
.diplomacy-history { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.diplomacy-history-item + .diplomacy-history-item { border-top: 0; }
.diplomacy-history-item[data-status=active] .diplomacy-pact-icon { color: var(--diplomacy-green); }
.diplomacy-history-date { display: grid; justify-items: end; gap: 3px; color: var(--atlas-muted); font-size: 12px; }
.diplomacy-history-date time { font-weight: 700; text-align: end; }
.diplomacy-support > header { margin-bottom: 12px; border-bottom: 3px double var(--atlas-rule); }
.diplomacy-support > h3, .diplomacy-support-heading h3 {
  margin: 0;
  font: 700 clamp(15px, 1.6vw, 22px)/1.2 var(--serif);
}
.diplomacy-support-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.diplomacy-support-heading .diplomacy-button { min-height: 35px; }
.diplomacy-support-list { display: grid; gap: 8px; margin: 8px 0 23px; padding: 0; list-style: none; }
.diplomacy-support-target {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(8px, 1.6vw, 21px);
  padding: clamp(10px, 1.4vw, 18px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid var(--atlas-red);
  background: #faefd47a;
}
.diplomacy-support-threat { display: block; color: var(--atlas-red); font-size: 12px; font-weight: 700; }
.diplomacy-support-target h3 { margin-top: 2px; }
.diplomacy-support-times { display: flex; flex-wrap: wrap; gap: 4px 15px; margin-top: 6px; color: var(--atlas-muted); font-size: 12px; }
.diplomacy-support-times time { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.diplomacy-support-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-top: 9px; }
.diplomacy-support-form label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; }
.diplomacy-support-form label, .diplomacy-support-form select { min-width: 0; max-width: 100%; }
.diplomacy-support-form small { align-self: end; margin-block-end: 13px; color: var(--atlas-muted); font-size: 12px; }
.diplomacy-support-target .diplomacy-support-issue { color: #7c362a; }
.diplomacy-support-target .diplomacy-support-sent, .diplomacy-support-mission-status { color: var(--diplomacy-green); font-weight: 700; }
.diplomacy-support-mission-status { align-self: center; font-size: 12px; }
.diplomacy-support > .diplomacy-history { margin-top: 8px; }
.diplomacy-support-empty { margin: 8px 0 23px; padding: 10px 12px; border: 1px dashed var(--atlas-rule); color: var(--atlas-muted); }
.diplomacy-blank { display: grid; min-height: 100%; place-content: center; justify-items: center; gap: 8px; padding: 22px; text-align: center; }
.diplomacy-blank svg { width: 40px; color: #9b583f; }
.diplomacy-blank p { margin: 0; max-width: 33ch; color: var(--atlas-muted); }
.diplomacy-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3px 12px;
  min-height: 33px;
  padding-block: 8px;
  font-size: 12px;
  color: var(--atlas-muted);
}
.diplomacy-footer i { display: inline-block; width: 7px; height: 7px; margin-inline-end: 4px; border-radius: 50%; background: var(--atlas-red); }
.diplomacy-footer [data-feedback] { color: var(--diplomacy-green); font-weight: 700; }
.diplomacy-footer [data-error] { color: #8a382c; }

.diplomacy-messages {
  --message-padding: clamp(12px, 2vw, 28px);
  --letter-dark: #22362e;
  --letter-gold: #e7c991;
  --letter-rule: #b494637b;
  --letter-width: 880px;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: clamp(235px, 29%, 350px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}
.diplomacy-sheet:has(.diplomacy-content-messages) .diplomacy-footer { display: none; }
.diplomacy-message-list, .diplomacy-message-thread {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}
.diplomacy-message-list {
  border-inline-end: 3px double #a98f63;
  background: radial-gradient(ellipse at 40% 0%, #3b5140, var(--letter-dark) 54%, #192820);
  color: #fff0d5;
}
.diplomacy-message-list::before, .diplomacy-message-thread::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: var(--atlas-grain);
  opacity: .23;
  mix-blend-mode: multiply;
  pointer-events: none;
  content: "";
}
.diplomacy-message-list > :is(h2, header, .diplomacy-letter-masthead), .diplomacy-message-thread > header {
  flex: none;
  padding: var(--message-padding);
  border-bottom: 1px solid var(--letter-rule);
}
.diplomacy-letter-masthead {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.3vw, 16px);
  min-width: 0;
}
.diplomacy-letter-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: clamp(39px, 3.5vw, 52px);
  aspect-ratio: 1;
  border: 1px solid #c3a36b;
  border-radius: 2px;
  color: var(--letter-gold);
  background: #22342c;
  box-shadow: 0 2px 5px #101a1480, inset 0 0 0 3px #384b3e, inset 0 0 0 4px #b094603b;
  transform: rotate(-4deg);
}
.diplomacy-letter-mark svg { width: 52%; height: auto; }
.diplomacy-message-list h2 {
  font-size: clamp(23px, 2.25vw, 34px);
  overflow-wrap: anywhere;
}
.diplomacy-mail-search {
  display: grid;
  flex: none;
  gap: 5px;
  padding: 12px max(10px, calc(var(--message-padding) * .65)) 0;
}
.diplomacy-mail-search label {
  color: #fff0d5;
  font: 650 12px/1.2 var(--ui);
}
.diplomacy-mail-search > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}
.diplomacy-mail-search input,
.diplomacy-mail-report select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 5px 8px;
  border: 1px solid #a98d64;
  border-radius: 0;
  background: #fff8e6;
  color: var(--atlas-ink);
  font: 550 13px/1.25 var(--ui);
}
.diplomacy-mail-search .diplomacy-button, .diplomacy-mail-more { min-height: 36px; }
.diplomacy-mailbox-folders, .diplomacy-message-log {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #aa906a #efdfbb;
  margin: 0;
  padding: 0;
  list-style: none;
}
.diplomacy-mailbox-folders {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 17px;
  padding: 12px max(10px, calc(var(--message-padding) * .65));
  scrollbar-color: #b49c6e var(--letter-dark);
}
.diplomacy-mailbox-folders ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.diplomacy-player-mail > .diplomacy-message-status {
  margin: 0 0 8px;
  color: #ecd4a9;
}
.diplomacy-player-mail > .diplomacy-message-status:empty { display: none; }
.diplomacy-player-mail > .diplomacy-message-status[data-error] { color: #ffbbab; }
.diplomacy-mail-more {
  display: block;
  margin: 10px auto 0;
  border-color: #c3a36b;
  background: #f0d39d;
  color: #2f3527;
}
.diplomacy-mail-more[aria-disabled=true], .diplomacy-letter-block[aria-disabled=true] { opacity: .6; }
.diplomacy-quest-mail h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 9px;
  padding: 1px 1px 6px;
  border-bottom: 1px solid var(--letter-rule);
  color: var(--letter-gold);
  font: 750 11px/1.2 var(--ui);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.diplomacy-quest-mail h3 svg {
  width: 15px;
  height: 15px;
}
.diplomacy-message-list > [data-new-message] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: none;
  margin: 0 var(--message-padding) var(--message-padding);
  border-color: #c3a36b;
  background: #f0d39d;
  color: #2f3527;
  box-shadow: 0 3px 5px #151e185c;
}
.diplomacy-message-list > [data-new-message]:enabled:hover { background: #ffe0a5; color: #283526; }
.diplomacy-message-list > [data-new-message] svg { width: 17px; height: 17px; }
.diplomacy-message-peer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  min-height: 64px;
  padding: 10px;
  border: 1px solid #a78d60;
  border-inline-start: 3px solid #ad9061;
  border-radius: 2px;
  background: linear-gradient(145deg, #fff0d0, #ead4a7);
  color: var(--atlas-ink);
  text-align: start;
  box-shadow: 0 2px 5px #1420198c, inset 0 0 0 2px #f9eac77a;
}
.diplomacy-message-peer:is(:hover, [aria-pressed=true], [aria-current=true]) {
  background: linear-gradient(145deg, #fff6de, #f4d69b);
}
.diplomacy-message-peer:is([aria-pressed=true], [aria-current=true]) { border-inline-start-color: var(--atlas-red); }
.diplomacy-quest-mail-row { border-inline-start-color: #807c54; }
.diplomacy-message-peer > .diplomacy-portrait {
  width: clamp(34px, 3.25vw, 44px);
}
.diplomacy-letter-preview { display: grid; gap: 4px; min-width: 0; }
.diplomacy-message-peer .diplomacy-identity strong { font-size: clamp(15px, 1.35vw, 18px); }
.diplomacy-message-preview, .diplomacy-message-peer .diplomacy-letter-subject {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diplomacy-message-preview { color: #66513a; font: 500 12px/1.25 var(--ui); }
.diplomacy-message-peer .diplomacy-letter-subject { color: #7c3b2f; font: 700 12px/1.2 var(--ui); }
.diplomacy-message-unread {
  grid-column: 3;
  grid-row: 1;
  min-width: 21px;
  padding: 2px 5px;
  border-radius: 12px;
  background: #943f33;
  color: #fff1d8;
  font: 700 11px/1.2 var(--ui);
  text-align: center;
  box-shadow: inset 0 0 0 1px #ffe0a946;
}
.diplomacy-message-thread {
  --letter-paper: #fffae9;
  background: radial-gradient(ellipse at 52% 42%, #fcf2d9, #f1e0b9 91%);
}
.diplomacy-message-thread > header {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 20px);
  padding-block: clamp(8px, 1.1vh, 14px);
  background: linear-gradient(106deg, #fbedd0b8, #f3dfb78c);
  overflow-wrap: anywhere;
}
.diplomacy-message-thread > header > div { min-width: 0; }
.diplomacy-letter-block {
  flex: none;
  min-height: 34px;
  margin-inline-start: auto;
  padding-inline: 9px;
}
.diplomacy-letter-recipient {
  display: block;
  margin-block-end: 3px;
  color: #77553a;
  font: 750 10px/1.15 var(--ui);
  text-transform: uppercase;
  letter-spacing: .13em;
}
.diplomacy-message-back, .diplomacy-message-reply { display: none; }
.diplomacy-message-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: clamp(9px, 1.35vw, 16px);
  min-width: 0;
  padding: clamp(9px, 1.4vh, 16px) max(var(--message-padding), calc((100% - var(--letter-width)) / 2));
}
.diplomacy-message-log:empty { display: none; }
.diplomacy-message-log > li { flex: none; }
.diplomacy-message-log > li:has(.diplomacy-message-older) { align-self: center; margin-block-end: 3px; }
.diplomacy-message-bubble {
  --letter-fold: #b991566b;
  --letter-edge: #c6ac7e;
  position: relative;
  align-self: start;
  width: min(88%, 720px);
  padding: clamp(9px, 1.05vw, 15px) clamp(12px, 1.75vw, 23px);
  border: 1px solid var(--letter-edge);
  background: linear-gradient(135deg, var(--letter-paper), #fdf0d1);
  box-shadow: 1px 4px 8px #74503525, inset 0 0 0 3px #ffffff43;
}
.diplomacy-message-bubble[data-own=true] {
  --letter-fold: #86907870;
  --letter-edge: #a7aa84;
  align-self: end;
  background: linear-gradient(135deg, #fff9e7, #ecebd2);
}
.diplomacy-letter-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  padding-block-end: 6px;
  border-bottom: 1px solid var(--letter-fold);
  color: #714b35;
  font: 700 12px/1.2 var(--ui);
}
.diplomacy-message-bubble[data-own=true] .diplomacy-letter-meta { color: #415744; }
.diplomacy-message-bubble .diplomacy-letter-subject {
  margin: 8px 0 5px;
  color: #523627;
  font: 680 clamp(18px, 1.7vw, 24px)/1.16 var(--serif);
  overflow-wrap: anywhere;
}
.diplomacy-message-bubble p, .diplomacy-letter-body {
  margin: 0;
  font: 500 clamp(16px, 1.4vw, 19px)/1.45 var(--serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.diplomacy-letter-meta + .diplomacy-letter-body { margin-block-start: 8px; }
.diplomacy-message-bubble:has(.diplomacy-letter-seal) .diplomacy-letter-body { padding-inline-end: 32px; }
.diplomacy-letter-result {
  margin-block-end: 5px;
  color: #47704e;
  font: 750 11px/1.2 var(--ui);
  letter-spacing: .055em;
  text-transform: uppercase;
}
.diplomacy-letter-actions {
  display: flex;
  align-items: center;
  min-height: 25px;
  margin-block-start: 6px;
  padding-inline-end: 28px;
}
.diplomacy-letter-report-button,
.diplomacy-letter-report-label {
  color: #77553a;
  font: 650 12px/1.2 var(--ui);
}
.diplomacy-letter-report-button {
  min-height: 25px;
  padding: 2px 0;
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.diplomacy-letter-report-button:hover { color: #8a382c; }
.diplomacy-message-bubble time {
  display: block;
  color: #635544;
  font: 600 11px/1.25 var(--ui);
  text-align: end;
}
.diplomacy-letter-seal {
  position: absolute;
  inset: auto 12px 10px auto;
  display: grid;
  place-items: center;
  width: 26px;
  aspect-ratio: 1;
  border: 1px solid #75342b;
  border-radius: 45% 52% 48% 53%;
  background: radial-gradient(circle at 33% 30%, #b65c46, #84352d 72%);
  color: #f4cb94;
  box-shadow: 0 1px 2px #69321e60, inset 0 0 0 2px #e68a5c42;
  transform: rotate(-9deg);
}
.diplomacy-letter-seal svg { width: 13px; height: 13px; }
.diplomacy-quest-letter {
  width: min(100%, 700px);
  align-self: center;
  border-block-start: 3px solid #72815f;
}
.diplomacy-quest-objectives {
  margin-block-start: clamp(12px, 2.1vh, 21px);
  padding: clamp(10px, 1.6vw, 17px);
  border: 1px solid #baa379;
  background: linear-gradient(140deg, #eae6ca, #f6edcf);
}
.diplomacy-quest-objectives header,
.diplomacy-quest-objective-value,
.diplomacy-quest-reward {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.diplomacy-quest-objectives h4 {
  margin: 0;
  color: #3c4735;
  font: 700 clamp(15px, 1.65vw, 20px)/1.2 var(--serif);
}
.diplomacy-quest-status {
  padding: 3px 7px;
  border: 1px solid #b9a583;
  border-radius: 2px;
  background: #fff2d5;
  color: #653e2e;
  font: 750 11px/1.25 var(--ui);
}
.diplomacy-quest-status:is([data-status=accepted], [data-status=completed]) {
  border-color: #8f9a7a;
  background: #e0e8d4;
  color: #30463a;
}
.diplomacy-quest-objectives ul {
  display: grid;
  gap: 8px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}
.diplomacy-quest-objective-value {
  align-items: baseline;
  font-size: 12px;
  color: #4e4233;
}
.diplomacy-quest-objective-value b { white-space: nowrap; }
.diplomacy-quest-objectives progress {
  display: block;
  width: 100%;
  height: 7px;
  margin-top: 4px;
  border: 0;
  border-radius: 2px;
  appearance: none;
  background: #d3c5a3;
}
.diplomacy-quest-objectives progress::-webkit-progress-bar {
  border-radius: 2px;
  background: #d3c5a3;
}
.diplomacy-quest-objectives progress::-webkit-progress-value {
  border-radius: 2px;
  background: #7a684b;
}
.diplomacy-quest-objectives progress::-moz-progress-bar { background: #7a684b; }
.diplomacy-quest-objectives [data-complete=true] progress::-webkit-progress-value { background: #4e6a52; }
.diplomacy-quest-objectives [data-complete=true] progress::-moz-progress-bar { background: #4e6a52; }
.diplomacy-quest-reward {
  margin-top: 12px;
  font: 600 12px/1.35 var(--ui);
}
.diplomacy-quest-reward > span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.diplomacy-quest-actions, .diplomacy-quest-destination {
  display: flex;
  align-items: center;
  gap: 6px;
}
.diplomacy-quest-actions { flex-wrap: wrap; }
.diplomacy-quest-destination svg { transform: rotate(180deg); }
.diplomacy-quest-reward strong { color: #694229; }
.diplomacy-quest-reward svg {
  flex: none;
  width: 19px;
  height: 19px;
  color: #835a29;
}
.diplomacy-quest-reward button:is(:disabled, [aria-disabled=true]) {
  opacity: .65;
  cursor: default;
}
.diplomacy-mail-report {
  display: grid;
  flex: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px 9px;
  width: min(calc(100% - 2 * var(--message-padding)), var(--letter-width));
  margin: 0 auto var(--message-padding);
  padding: clamp(9px,1.2vw,15px);
  border: 1px solid #a57961;
  border-top: 2px solid #a04b3e;
  background: var(--letter-paper);
}
.diplomacy-mail-report h3 {
  margin: 0;
  color: #784338;
  font: 700 18px/1.2 var(--serif);
}
.diplomacy-mail-report > :is(div:first-child, label, p) { grid-column: 1 / -1; }
.diplomacy-mail-report > div > p {
  margin: 3px 0;
  overflow-wrap: anywhere;
  color: var(--atlas-muted);
  font: 550 13px/1.25 var(--ui);
}
.diplomacy-mail-report label { font: 700 12px/1.2 var(--ui); }
.diplomacy-mail-report-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.diplomacy-mail-report .diplomacy-button { min-height: 36px; }
.diplomacy-mail-report .diplomacy-message-status { margin: 0; }
.diplomacy-mail-report .diplomacy-message-status:empty { display: none; }
.diplomacy-message-compose {
  position: relative;
  display: grid;
  flex: none;
  width: min(calc(100% - 2 * var(--message-padding)), var(--letter-width));
  min-width: 0;
  margin: 0 auto clamp(8px, 1.6vh, 15px);
  padding: clamp(9px, 1.4vh, 14px) clamp(12px, 1.7vw, 22px);
  gap: 6px;
  border: 1px solid #bda477;
  background: linear-gradient(130deg, var(--letter-paper), #f8ebcb);
  box-shadow: 1px 4px 10px #74503535;
}
.diplomacy-message-compose::before {
  position: absolute;
  inset: -1px -1px auto;
  block-size: 3px;
  background: repeating-linear-gradient(135deg, #934a3a 0 12px, #f6e3b8 12px 19px, #486253 19px 31px, #f6e3b8 31px 38px);
  content: "";
}
.diplomacy-message-compose[data-first-letter=true] {
  width: min(calc(100% - 2 * var(--message-padding)), 680px);
  margin: 14px auto auto;
}
.diplomacy-letter-fields { display: grid; gap: 6px; min-width: 0; }
.diplomacy-message-compose label { color: #61503b; font-size: 12px; font-weight: 750; }
.diplomacy-message-compose label small { color: #695e50; font-size: 11px; font-weight: 550; }
.diplomacy-message-compose :is(input, textarea) {
  width: 100%;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid #bfa77c;
  border-radius: 2px;
  background-color: #fff8e6;
  color: var(--atlas-ink);
}
.diplomacy-message-compose input { font: 650 16px/1.2 var(--serif); }
.diplomacy-message-compose input + label { margin-block-start: 2px; }
.diplomacy-message-compose textarea {
  min-height: 52px;
  max-height: 24dvh;
  font: 500 16px/1.4 var(--serif);
  resize: vertical;
}
@media (min-height: 640px) {
  .diplomacy-message-compose[data-first-letter=true] textarea { min-height: 120px; }
}
@media (min-width: 621px) {
  .diplomacy-message-compose[data-first-letter=false] .diplomacy-letter-fields {
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    gap: 5px 11px;
  }
  .diplomacy-message-compose[data-first-letter=false] label { padding-top: 8px; }
}
.diplomacy-message-compose-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.diplomacy-message-compose-actions button {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-inline-start: auto;
  border-radius: 2px;
  box-shadow: 0 1px 2px #483c2f36;
}
.diplomacy-message-compose-actions svg { width: 17px; height: 17px; }
.diplomacy-message-status { color: var(--atlas-muted); font-size: 12px; }
.diplomacy-message-status[data-error] { color: #8a382c; }
.diplomacy-message-list > .diplomacy-message-status { color: #ecd4a9; }
.diplomacy-message-list > .diplomacy-message-status[data-error] { color: #ffbbab; }
.diplomacy-message-list > .diplomacy-message-status, .diplomacy-message-thread > .diplomacy-message-status { margin: 0; }
.diplomacy-message-list > .diplomacy-message-status:not(:empty),
.diplomacy-message-thread > .diplomacy-message-status:not(:empty) { padding: var(--message-padding); }
.diplomacy-message-log:empty + .diplomacy-message-status {
  display: grid;
  flex: 1;
  place-content: center;
  text-align: center;
}
.diplomacy-message-log:empty + .diplomacy-message-status:has(~ .diplomacy-message-compose[data-first-letter=true]:not([hidden])) {
  flex: none;
  margin: auto auto 0;
  padding: 10px var(--message-padding) 0;
}
.diplomacy-messages:not([data-thread-open=true]) .diplomacy-message-log:empty + .diplomacy-message-status::before {
  width: clamp(64px, 13vmin, 144px);
  aspect-ratio: .9;
  margin: 0 auto 14px;
  background: center / contain no-repeat url("./assets/post-office.webp");
  filter: drop-shadow(0 7px 5px #56391e4a);
  content: "";
}

@media (max-width: 850px) {
  .diplomacy-pact { grid-template-columns: auto minmax(0, 1fr); }
  .diplomacy-pact-controls { grid-column: 2; justify-items: start; }
  .diplomacy-status { text-align: start; }
  .diplomacy-pact-actions { justify-content: start; }
}
@media (max-width: 620px) {
  .diplomacy-heading .atlas-nav { width: auto; justify-content: end; }
  .diplomacy-heading .atlas-return { margin-inline-start: 0; }
  .diplomacy-sections button { flex: 1; padding-inline: 7px; min-height: 42px; font-size: 11px; }
  .diplomacy-content { display: block; overflow: auto; }
  .diplomacy-directory { border-inline-end: 0; border-bottom: 3px double var(--atlas-rule); }
  .diplomacy-roster { max-height: min(23dvh, 180px); }
  .diplomacy-player { min-height: 51px; padding-block: 5px; }
  .diplomacy-player .diplomacy-portrait { width: 32px; }
  .diplomacy-register { overflow: visible; }
  .diplomacy-content-ledger .diplomacy-register { min-height: 100%; }
  .diplomacy-ledger-card, .diplomacy-history-item { grid-template-columns: auto minmax(0, 1fr); }
  .diplomacy-history-date { grid-column: 2; justify-items: start; }
  .diplomacy-history-date time { text-align: start; }
  .diplomacy-support-mission-status { grid-column: 2; }
  .diplomacy-support-form small { width: 100%; margin-block-end: 0; }
  .diplomacy-footer { font-size: 11px; }
}
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .diplomacy-content.diplomacy-content-messages { display: grid; overflow: hidden; }
  .diplomacy-messages { grid-template-columns: minmax(0, 1fr); }
  .diplomacy-message-list { border-inline-end: 0; }
  .diplomacy-messages[data-thread-open=true] > .diplomacy-message-list,
  .diplomacy-messages:not([data-thread-open=true]) > .diplomacy-message-thread { display: none; }
  .diplomacy-message-back { display: inline-flex; align-items: center; }
  .diplomacy-mail-search input, .diplomacy-mail-report select { font-size: 16px; }
  .diplomacy-message-bubble { width: min(94%, 720px); }
  .diplomacy-quest-letter { width: 100%; }
  .diplomacy-messages[data-compose-open=false] .diplomacy-message-compose { display: none; }
  .diplomacy-message-reply {
    display: inline-flex;
    flex: none;
    align-items: center;
    align-self: end;
    gap: 7px;
    margin: 0 var(--message-padding) var(--message-padding);
  }
  .diplomacy-messages[data-compose-open=true] .diplomacy-message-reply { margin-block-end: 6px; }
  .diplomacy-message-reply svg { width: 16px; height: 16px; }
}
@media (max-width: 430px) {
  .diplomacy-letter-block { padding-inline: 6px; }
  .diplomacy-mail-report { grid-template-columns: minmax(0, 1fr); }
  .diplomacy-mail-report-actions { justify-content: end; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .diplomacy-dialog, .scene > #drawer.atlas-panel-page { --diplomacy-gap: 7px; }
  .diplomacy-directory-head { padding: 6px 9px; }
  .diplomacy-search { margin-block-start: 6px; }
  .diplomacy-sections button, #drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) button { min-height: 38px; }
  .diplomacy-parties { padding-block: 12px; }
  .diplomacy-party .diplomacy-portrait { width: min(54px, 7.5vw); }
  .diplomacy-link { height: min(54px, 7.5vw); }
  .diplomacy-footer { min-height: 24px; padding-block: 4px; }
  .diplomacy-messages { --message-padding: 8px; }
  .diplomacy-mail-search { padding-top: 7px; }
  .diplomacy-mailbox-folders { padding-block: 8px; }
  .diplomacy-message-thread > header { padding-block: 5px; }
  .diplomacy-message-thread .diplomacy-letter-recipient { margin-block-end: 1px; }
  .diplomacy-message-compose { grid-template-columns: minmax(0, 1fr) auto; }
  .diplomacy-letter-fields { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .diplomacy-message-compose input + label { margin-block-start: 0; }
  .diplomacy-message-compose :is(input, textarea) { min-height: 32px; padding: 5px 7px; }
  .diplomacy-message-compose-actions { align-self: end; }
}

/* Full-screen Atlas/Diplomacy ledger styling for Economy, Trade, Quests, Research, and Expeditions */
#drawer.atlas-panel-page .drawer-head {
  min-height: 0;
  padding: clamp(12px, 2vh, 25px) 0 clamp(12px, 2vh, 23px);
  border-bottom: 0;
  background: none;
  box-shadow: none;
}
#drawer.atlas-panel-page .drawer-head h2 {
  margin: 4px 0 0;
  color: var(--atlas-ink);
  font: 600 clamp(28px, 5vw, 53px)/1.02 var(--serif);
  letter-spacing: -.045em;
}
#drawer.atlas-panel-page .diplomacy-workspace:not(:has(> .panel-views)) {
  grid-template-rows: minmax(0, 1fr);
}
#drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 0;
  border-bottom: 3px double var(--atlas-rule);
  border-radius: 0;
  background: linear-gradient(#f8ecd1, #edddba);
  scrollbar-width: thin;
  scrollbar-color: #aa906a #efdfbb;
}
#drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) button {
  display: inline-flex;
  flex: 1 0 auto;
  min-height: 45px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 1px clamp(12px, 2vw, 26px) 0;
  border: 0;
  border-radius: 0;
  box-shadow: inset -1px 0 var(--atlas-rule);
  background: none;
  color: var(--atlas-muted);
  font: 700 13px/1.2 var(--ui);
  white-space: nowrap;
}
#drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) button svg {
  width: 15px;
  height: 15px;
  color: currentColor;
}
#drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) button:hover:not(:disabled) {
  color: #7c362a;
  background: #f7ebcd;
}
#drawer.atlas-panel-page :is(.panel-views, .trade-tabs, .export-tabs) button[aria-pressed=true] {
  color: #7c362a;
  background: #f8edd2;
  box-shadow: inset -1px 0 var(--atlas-rule), inset 0 -2px var(--atlas-red);
}
#drawer.atlas-panel-page .export-tabs button span {
  min-width: 17px;
  height: auto;
  padding: 1px 4px;
  border-radius: 9px;
  background: #8b3c30;
  color: #fff1d8;
  font: 700 11px/1.2 var(--ui);
}
#drawer.atlas-panel-page .drawer-body {
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 2.2vw, 28px) max(clamp(14px, 2.4vw, 32px), calc((100% - 1340px) / 2));
  background:
    repeating-linear-gradient(0deg, #8266460b 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, #8266460b 0 1px, transparent 1px 28px),
    radial-gradient(ellipse at 55% 37%, #fcf2d9 10%, #f3e4c1 88%);
  scrollbar-color: #aa906a #efdfbb;
}
#drawer.atlas-panel-page p {
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page :is(input:not([type=checkbox], [type=radio], [type=range]), select, textarea) {
  min-height: 40px;
  padding: 6px 9px;
  border: 1px solid #a98d64;
  border-radius: 2px;
  background: #fcf3db;
  color: var(--atlas-ink);
  font: 550 13px/1.25 var(--ui);
}
#drawer.atlas-panel-page .small-button {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid #a98d64;
  border-radius: 2px;
  background: #f9eed2;
  color: #6e382c;
  font: 700 13px/1.2 var(--ui);
  box-shadow: none;
}
#drawer.atlas-panel-page .small-button svg {
  color: currentColor;
}
#drawer.atlas-panel-page .small-button:enabled:hover {
  border-color: var(--atlas-red);
  background: #ecd6af;
  color: #6d2d23;
  filter: none;
}
#drawer.atlas-panel-page .small-button.accent {
  border-color: #394b3e;
  background: var(--diplomacy-green);
  color: #fff0d0;
}
#drawer.atlas-panel-page .small-button.accent:enabled:hover {
  border-color: #254437;
  background: #254437;
  color: #fff0d0;
}
#drawer.atlas-panel-page .small-button.danger,
#drawer.atlas-panel-page .export-cancel .export-danger {
  border-color: #8f3d30;
  background: var(--atlas-red);
  color: #fff1d8;
}
#drawer.atlas-panel-page .small-button.danger:enabled:hover,
#drawer.atlas-panel-page .export-cancel .export-danger:enabled:hover {
  background: #783024;
  color: #fff1d8;
}
#drawer.atlas-panel-page progress {
  height: 7px;
  border-radius: 2px;
  background: #d3c5a3;
  accent-color: var(--diplomacy-green);
}
#drawer.atlas-panel-page progress::-webkit-progress-bar {
  border-radius: 2px;
  background: #d3c5a3;
}
#drawer.atlas-panel-page progress::-webkit-progress-value {
  border-radius: 2px;
  background: var(--diplomacy-green);
}
#drawer.atlas-panel-page progress::-moz-progress-bar {
  background: var(--diplomacy-green);
}
#drawer.atlas-panel-page .cost .cost-short,
#drawer.atlas-panel-page .economy-flow-short {
  color: var(--atlas-red);
  font-weight: 700;
}
#drawer.atlas-panel-page .village-chain [data-state=working],
#drawer.atlas-panel-page .village-complete,
#drawer.atlas-panel-page .progression-requirements [data-complete=true] strong {
  color: var(--diplomacy-green);
  font-weight: 700;
}
#drawer.atlas-panel-page .village-chain [data-state=blocked] {
  color: var(--atlas-red);
  font-weight: 700;
}
#drawer.atlas-panel-page .economy-status {
  border: 1px solid #b9a583;
  border-radius: 2px;
  font-weight: 700;
}
#drawer.atlas-panel-page .economy-status--good {
  border-color: #7c947d;
  background: #dce6d5;
  color: #2a4938;
}
#drawer.atlas-panel-page .economy-status--warn {
  border-color: #b87a5e;
  background: #f6dfc9;
  color: #7e3629;
}
#drawer.atlas-panel-page .economy-status--neutral {
  border-color: #b9a583;
  background: #f3e4c2;
  color: #544533;
}
#drawer.atlas-panel-page .flow-bar {
  background: #d9c8a5;
}
#drawer.atlas-panel-page .flow-bar i {
  background: #3d6b52;
}
#drawer.atlas-panel-page .flow-demand i {
  background: #b25d3a;
}
#drawer.atlas-panel-page .stock-history-chart i {
  background: #3d6854;
}
#drawer.atlas-panel-page .history-made { --series: #3d6b52; }
#drawer.atlas-panel-page .history-used { --series: #b25d3a; }
#drawer.atlas-panel-page .history-homes { --series: #3d637d; }
#drawer.atlas-panel-page .history-visits { --series: #7b5283; }

/* Economy full-screen ledger */
#drawer.atlas-panel-page[data-panel=economy] .drawer-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  align-items: start;
  gap: clamp(12px, 1.6vw, 20px);
}
#drawer.atlas-panel-page[data-panel=economy] .drawer-body > :is(
  .economy-stats,
  .economy-section:only-of-type,
  .economy-section:has(.economy-flow-table, .coffee-comparison table, .history-chart, .stock-history-chart, .vehicle-targets)
) {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page .economy-stats {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 0;
}
#drawer.atlas-panel-page .economy-stat {
  padding: 12px 14px;
  border: 1px solid var(--atlas-rule);
  border-top: 2px solid var(--atlas-red);
  border-radius: 2px;
  background: #faefd4a6;
}
#drawer.atlas-panel-page .economy-stat dt {
  color: var(--atlas-muted);
  font: 700 12px/1.2 var(--ui);
}
#drawer.atlas-panel-page .economy-stat dd {
  color: var(--atlas-ink);
  font: 700 clamp(21px, 2.2vw, 29px)/1.12 var(--serif);
}
#drawer.atlas-panel-page .economy-section {
  margin: 0;
  padding: clamp(12px, 1.5vw, 18px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #a58b66;
  border-radius: 2px;
  background: #faefd485;
}
#drawer.atlas-panel-page .economy-section h3 {
  margin: 0 0 9px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--atlas-rule);
  color: var(--atlas-ink);
  font: 700 clamp(17px, 1.6vw, 22px)/1.2 var(--serif);
}
#drawer.atlas-panel-page .economy-chain li {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #f5e5c1;
}
#drawer.atlas-panel-page .economy-building-row,
#drawer.atlas-panel-page .warehouse-shipment-link,
#drawer.atlas-panel-page .warehouse-shipment-card {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #fcf3dba6;
}
#drawer.atlas-panel-page :is(.economy-building-row, .warehouse-shipment-link):hover {
  border-color: var(--atlas-red);
  background: #eedab2;
}
#drawer.atlas-panel-page .production-cause {
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #b5653b;
  border-radius: 2px;
  background: #f7e6c4;
}
#drawer.atlas-panel-page .production-cause h4 {
  color: #7c362a;
}

/* Quests full-screen ledger */
#drawer.atlas-panel-page[data-panel=quests] .drawer-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  align-content: start;
  align-items: start;
  gap: clamp(12px, 1.6vw, 20px);
}
#drawer.atlas-panel-page[data-panel=quests] .drawer-body > :is(.quest:has(.village-chain), .economy-section:first-child) {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page[data-panel=quests] .economy-section:first-child {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
}
#drawer.atlas-panel-page[data-panel=quests] .economy-section:first-child > h3 {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page .quest {
  display: grid;
  align-content: start;
  gap: 8px;
  margin: 0;
  padding: clamp(12px, 1.6vw, 18px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #72815f;
  border-radius: 2px;
  background: #faefd48c;
}
#drawer.atlas-panel-page .quest:has([data-npc-quest-letter], .village-chain) {
  border-inline-start-color: var(--atlas-red);
  background: #fcf2d8b8;
}
#drawer.atlas-panel-page .quest h3 {
  color: var(--atlas-ink);
  font: 700 clamp(17px, 1.6vw, 21px)/1.2 var(--serif);
}
#drawer.atlas-panel-page .quest p {
  margin: 0;
}

/* Research full-screen Forge-style horizontal parchment tree */
#drawer.atlas-panel-page[data-panel=research] .drawer-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  background: #cfa774;
}
.research-workspace {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.research-tabs {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 6px 8px 0;
  border-bottom: 2px solid #8a6a42;
  background: linear-gradient(180deg, #563a20 0%, #3d2714 100%);
  overflow-x: auto;
  scrollbar-width: none;
}
.research-tabs::-webkit-scrollbar { display: none; }
.research-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid #8e6c42;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #74512f 0%, #5b3d21 100%);
  color: #f3dfba;
  font: 700 11.5px/1.15 var(--ui);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.research-tab:hover {
  background: linear-gradient(180deg, #8b633c 0%, #6d4929 100%);
  color: #fff6e0;
}
.research-tab.is-active {
  margin-bottom: -2px;
  padding-bottom: 8px;
  border-color: var(--atlas-rule);
  border-bottom: 2px solid #f8ecd1;
  background: linear-gradient(180deg, #fff5dc 0%, #f8ecd1 100%);
  color: var(--atlas-ink);
}
.research-tab-count {
  padding: 1px 5px;
  border-radius: 8px;
  background: #0000002e;
  color: inherit;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.research-tab.is-active .research-tab-count {
  background: #e3cea1;
  color: var(--atlas-muted);
}
.research-tab-badge {
  padding: 1px 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
}
.research-tab-badge.is-ready {
  background: #2f7033;
  color: #fff8e2;
}
.research-tab-badge.is-running {
  background: #c8841a;
  color: #291404;
}
.research-tab-match {
  padding: 1px 5px;
  border-radius: 9px;
  background: #9c3825;
  color: #fff4dd;
  font-size: 10px;
  font-weight: 800;
}
.research-cross-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid #b8986b;
  background: #f3e0b6;
  color: var(--atlas-ink);
  font: 600 12px/1.2 var(--ui);
}
.research-cross-hint[hidden] { display: none; }
.research-dep-chip.is-cross {
  border-style: dashed;
}
.research-dep-chip small {
  color: var(--atlas-muted);
  font-size: 10px;
  font-weight: 700;
}
.research-slots-wrap {
  display: grid;
}
.research-slots-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid #a8875a;
  background: linear-gradient(180deg, #f3e2be 0%, #e7d1a5 100%);
}
.research-slots-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}
.research-slot-item {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid #b7771d;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff4d6 0%, #f5dca0 100%);
  box-shadow: inset 0 1px 0 #ffffffc4, 0 1px 3px #492a0629;
  overflow: hidden;
}
.research-slot-item:hover {
  border-color: var(--atlas-red);
}
.research-slot-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 46px;
  padding: 5px 8px;
  border: 1px solid #96774d;
  border-radius: 3px;
  background: #f9eed4;
  color: var(--atlas-ink);
  text-align: start;
  font: 600 11px/1.15 var(--ui);
}
.research-slot-item .research-slot-card.is-running {
  flex: 1 1 auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 5px 6px 5px 7px;
  cursor: pointer;
}
.research-slot-item .research-slot-card.is-running:hover {
  background: #fff9e866;
}
.research-slot-cancel {
  flex: none;
  width: 22px;
  border: 0;
  border-inline-start: 1px solid #c69a55;
  background: #e5c37a38;
  color: #7c311c;
  font: 700 14px/1 var(--ui);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.research-slot-cancel:hover:enabled {
  background: #9c3825;
  color: #fff6e0;
}
.research-slot-cancel:disabled {
  opacity: .45;
  cursor: default;
}
.research-slot-card.is-empty {
  border-style: dashed;
  border-color: #7d623e;
  background: #f8ecd0b8;
  cursor: pointer;
}
.research-slot-card.is-empty:hover:enabled {
  border-color: var(--diplomacy-green);
  background: #fff6df;
}
.research-slot-card.is-empty:disabled {
  opacity: .65;
  cursor: default;
}
.research-slot-card.is-locked {
  border-color: #a68b64;
  background: #e1cca08c;
  color: #6b5336;
}
.research-slot-thumb {
  width: 34px;
  height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: 1px solid #8a6434;
  border-radius: 3px;
  background: radial-gradient(circle at 35% 30%, #fff7e0, #d8b580);
}
.research-slot-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.research-slot-num {
  width: 30px;
  height: 30px;
  margin-inline: auto;
  display: grid;
  place-items: center;
  border: 1px solid #9b7d53;
  border-radius: 3px;
  background: #efe0bc;
  color: #5c4123;
  font: 700 12px/1 var(--serif);
}
.research-slot-card.is-locked .research-slot-num {
  background: #d7bf90;
  color: #745b3e;
}
.research-slot-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.research-slot-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #241509;
  font: 700 11.5px/1.15 var(--serif);
}
.research-slot-card.is-locked .research-slot-title {
  color: #5d462b;
}
.research-slot-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #694922;
  font: 600 10px/1.15 var(--ui);
  font-variant-numeric: tabular-nums;
}
.research-slot-progress {
  width: 100%;
  height: 5px;
  margin-top: 2px;
  accent-color: #b7771d;
}
.research-speed-box {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 1px;
  padding: 4px 11px;
  border: 1px solid #8a6b42;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff5dc 0%, #ead6ab 100%);
  color: var(--atlas-ink);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.research-speed-box:hover,
.research-speed-box.is-open {
  border-color: var(--atlas-red);
  background: linear-gradient(180deg, #fff9e8 0%, #f2e1bc 100%);
}
.research-speed-kicker {
  color: var(--atlas-muted);
  font: 700 9.5px/1.1 var(--ui);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.research-speed-val {
  color: #295927;
  font: 700 15px/1.1 var(--serif);
  font-variant-numeric: tabular-nums;
}
.research-speed-meta {
  color: #5c4224;
  font: 600 10px/1.1 var(--ui);
  font-variant-numeric: tabular-nums;
}
.research-speed-popover {
  display: grid;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid #a8875a;
  background: #fbf1d8;
  color: var(--atlas-ink);
  font: 500 11.5px/1.35 var(--ui);
}
.research-speed-popover-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.research-speed-popover-label {
  font: 700 11px/1.2 var(--ui);
  color: #573d1f;
  white-space: nowrap;
}
.research-speed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.research-speed-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid #8a9e74;
  border-radius: 2px;
  background: #e4eed4;
  color: #26451e;
  font: 600 11px/1.2 var(--ui);
}
.research-speed-chip strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.research-speed-empty {
  color: var(--atlas-muted);
  font-style: italic;
}
.research-speed-popover-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: #5c4224;
  font-size: 11px;
}
.research-speed-popover-notes strong {
  color: var(--atlas-ink);
}
.research-duration-base {
  color: var(--atlas-muted);
  font-weight: 500;
}
.research-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 14px;
  border-bottom: 2px solid var(--atlas-rule);
  background: linear-gradient(180deg, #f8ecd1, #ebdab4);
}
.research-search-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 190px;
  max-width: 280px;
  min-width: 150px;
}
#researchSearchInput {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px !important;
  padding: 4px 9px;
  border: 1px solid #967a54;
  border-radius: 3px;
  background: #fff9ea;
  color: var(--atlas-ink);
  font: 500 13px/1.2 var(--ui);
}
.research-search-count {
  flex: none;
  color: var(--atlas-red);
  font: 700 11px/1.1 var(--ui);
  white-space: nowrap;
}
.research-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.research-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}
.research-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--atlas-rule);
  border-radius: 3px;
  background: #fff5db;
  color: var(--atlas-ink);
  font: 600 12px/1.1 var(--ui);
  cursor: pointer;
  white-space: nowrap;
}
.research-chip span {
  padding: 1px 5px;
  border-radius: 9px;
  background: #e5d2a7;
  color: var(--atlas-muted);
  font-size: 11px;
  font-weight: 700;
}
.research-chip:hover:enabled {
  border-color: var(--atlas-red);
  background: #faebd0;
}
.research-chip[aria-pressed=true] {
  border-color: var(--atlas-red);
  background: #8f3d2d;
  color: #fff3db;
}
.research-chip[aria-pressed=true] span {
  background: #fff3db33;
  color: #fff3db;
}
.research-chip.is-focus {
  border-color: #2f5133;
  background: var(--diplomacy-green);
  color: #fff3db;
}
.research-chip.is-focus:hover:enabled {
  background: #22462b;
}
.research-chip.is-running {
  border-color: #b7771d;
  background: #ffebc1;
  color: #6b3c07;
}
.research-chip:disabled {
  opacity: .5;
  cursor: default;
}
.research-zoom-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--atlas-rule);
  border-radius: 3px;
  overflow: hidden;
  background: #fff5db;
}
.research-zoom-btn {
  min-width: 30px;
  min-height: 30px;
  padding: 0 7px;
  border: 0;
  border-inline-end: 1px solid var(--atlas-rule);
  background: transparent;
  color: var(--atlas-ink);
  font: 700 13px/1 var(--ui);
  cursor: pointer;
}
.research-zoom-btn:last-child { border-inline-end: 0; }
.research-zoom-btn.is-readout {
  min-width: 46px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.research-zoom-btn.is-fit {
  padding: 0 9px;
  font-size: 11.5px;
  white-space: nowrap;
}
.research-zoom-btn:hover:enabled { background: #efdcb4; }
.research-zoom-btn:disabled { opacity: .45; cursor: default; }

.research-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(290px, 26vw, 356px);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.research-board-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  user-select: none;
  scrollbar-width: thin;
  scrollbar-color: #7c5833 #e8cfa4;
  background:
    repeating-linear-gradient(0deg, #6e4b280d 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, #6e4b280d 0 1px, transparent 1px 28px),
    radial-gradient(ellipse at 45% 32%, #e0ba85 0%, #c89d68 100%);
}
.research-board-scroll.is-dragging {
  cursor: grabbing;
}
.research-zoom-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}
.research-canvas {
  position: relative;
  transform-origin: top left;
  display: flex;
  flex-direction: column;
}
.research-stage {
  position: relative;
  flex: 1 0 auto;
}

/* Orthogonal tree wires */
.research-wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}
.research-wire[data-wire-dim=true] {
  opacity: .22;
}
.research-wire-shadow {
  fill: none;
  stroke: #e2be8a;
  stroke-width: 5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
}
.research-wire-line {
  fill: none;
  stroke: #7a522c99;
  stroke-width: 2.2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .14s ease, stroke-width .14s ease, opacity .14s ease;
}
.research-wire-arrow {
  fill: #7a522c99;
  transition: fill .14s ease;
}
.research-wire.is-unlocked .research-wire-line { stroke: #604320; }
.research-wire.is-unlocked .research-wire-arrow { fill: #604320; }
.research-wire.is-complete .research-wire-line {
  stroke: #3f6d29;
  stroke-width: 2.5px;
}
.research-wire.is-complete .research-wire-arrow { fill: #3f6d29; }
.research-wire[data-wire-active=true] .research-wire-line,
.research-wire[data-wire-hover=true] .research-wire-line {
  stroke: #a43b24;
  stroke-width: 3.2px;
}
.research-wire[data-wire-active=true] .research-wire-arrow,
.research-wire[data-wire-hover=true] .research-wire-arrow {
  fill: #a43b24;
}

/* Technology node cards */
.research-node {
  position: absolute;
  z-index: 3;
  display: flex;
  border: 2px solid #583a1d;
  border-radius: 4px;
  background: linear-gradient(180deg, #d7c7a0 0%, #c0ad7f 100%);
  box-shadow: inset 0 1px 0 #fff7df99, 0 2px 5px #24140844;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.research-node--researched {
  border-color: #4b5d33;
  background: linear-gradient(180deg, #cbc596 0%, #b1a874 100%);
}
.research-node--available {
  border-color: #844522;
  background: linear-gradient(180deg, #fff5dc 0%, #eedbb0 100%);
  box-shadow: inset 0 1px 0 #ffffffd9, 0 3px 8px #5d2b123d;
}
.research-node--researching {
  border-color: #b7771d;
  background: linear-gradient(180deg, #ffefc6 0%, #f1d38e 100%);
  box-shadow: 0 0 0 2px #d89b3255, 0 3px 10px #59350b4d;
}
.research-node--unaffordable {
  border-color: #7c5c39;
  background: linear-gradient(180deg, #efe0be 0%, #dbc59a 100%);
}
.research-node--locked {
  border-color: #674b2f;
  background: linear-gradient(180deg, #cab48c 0%, #b39970 100%);
}
.research-node:hover {
  z-index: 5;
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 #ffffffcc, 0 5px 12px #21120655;
}
.research-node.is-selected {
  z-index: 6;
  outline: 2px solid #9c3825;
  outline-offset: 2px;
  box-shadow: 0 6px 16px #2a14075e;
}
.research-node.is-related {
  z-index: 4;
  outline: 1.5px dashed #8a5321;
  outline-offset: 2px;
}
.research-node[data-match=dim] {
  opacity: .34;
}
.research-node[data-match=dim]:hover,
.research-node[data-match=dim].is-selected {
  opacity: 1;
}
.research-node-select {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  height: 100%;
  padding: 5px 7px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #241509;
  text-align: start;
  cursor: pointer;
}
.research-node-thumb {
  position: relative;
  width: 50px;
  height: 50px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: 1px solid #6b4b2a;
  border-radius: 3px;
  background: radial-gradient(circle at 35% 30%, #f8ebd0, #cfa976);
  box-shadow: inset 0 1px 3px #23140740;
}
.research-node-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px #1e130750);
}
.research-node--locked .research-node-thumb img {
  filter: saturate(.55) contrast(.92) drop-shadow(0 2px 2px #1e130738);
}
.research-node-content {
  display: grid;
  gap: 4px;
  min-width: 0;
  align-content: center;
}
.research-node-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #211207;
  font: 700 12px/1.15 var(--serif);
}
.research-node-meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.research-node-bar {
  display: block;
  height: 6px;
  border: 1px solid #593d1f;
  border-radius: 99px;
  background: #80633e;
  overflow: hidden;
}
.research-node-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #5ba43f, #98cc4b);
}
.research-node-meter small {
  color: #462f18;
  font: 700 10.5px/1.1 var(--ui);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.research-node-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}
.research-node-unlock-pill {
  padding: 1px 5px;
  border: 1px solid #75563270;
  border-radius: 2px;
  background: #ffffff52;
  color: #3d2814;
  font: 600 10px/1.25 var(--ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.research-node-cost-hint {
  color: #5a3c1f;
  font: 700 10px/1.1 var(--ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.research-node-cost-hint.is-done { color: #2b5c26; }
.research-node-cost-hint.is-short { color: #8c271b; }
.research-node--available .research-node-select {
  padding-bottom: 10px;
}
.research-node--available .research-node-foot {
  padding-right: 64px;
}
.research-node-go {
  position: absolute;
  right: 7px;
  bottom: 5px;
  z-index: 2;
  padding: 2px 9px;
  min-height: 22px;
  border: 1px solid #294c2c;
  border-radius: 2px;
  background: linear-gradient(180deg, #4b8248, #305d30);
  color: #fff5dc;
  font: 700 11px/1.1 var(--ui);
  cursor: pointer;
  box-shadow: 0 1px 3px #00000033;
}
.research-node-go:hover:enabled {
  background: linear-gradient(180deg, #579653, #3a6e39);
}
.research-node-go:disabled {
  opacity: .55;
  cursor: default;
}
.research-node .research-progress {
  margin-top: 2px;
  gap: 5px;
}
.research-node .research-progress progress {
  height: 7px;
}
.research-node .research-progress small {
  color: #6b3b09;
  font: 700 10.5px/1.1 var(--ui);
  white-space: nowrap;
}

/* Docked technology dossier / inspector */
.research-inspector {
  display: grid;
  align-content: start;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(12px, 1.5vw, 18px);
  border-inline-start: 3px double var(--atlas-rule);
  background:
    repeating-linear-gradient(0deg, #8266460b 0 1px, transparent 1px 28px),
    linear-gradient(180deg, #fbf0d6 0%, #f1e0b9 100%);
  scrollbar-width: thin;
  scrollbar-color: #aa906a #efdfbb;
}
.research-inspector-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-bottom: 1px solid #8c735044;
  background: linear-gradient(180deg, #f3e2bb, #e8d2a2);
  color: var(--atlas-ink);
  font: 700 13px/1.2 var(--serif);
  cursor: pointer;
}
.research-inspector-toggle small {
  color: var(--atlas-red);
  font: 700 11px/1.1 var(--ui);
}
.research-inspector-body {
  display: grid;
  align-content: start;
  gap: 12px;
}
.research-inspector-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--atlas-rule);
  text-align: center;
}
.research-inspector-head {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 2px solid #8c735044;
}
.research-inspector-art {
  width: 68px;
  height: 68px;
  max-width: 68px;
  max-height: 68px;
  padding: 6px;
  object-fit: contain;
  border: 1px solid var(--atlas-rule);
  border-radius: 3px;
  background: radial-gradient(circle at 35% 30%, #fff7e2, #dfca9a);
}
.research-inspector-kicker {
  display: block;
  color: var(--atlas-muted);
  font: 700 10.5px/1.2 var(--ui);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.research-inspector-head h3 {
  margin: 2px 0 5px;
  color: var(--atlas-ink);
  font: 700 20px/1.12 var(--serif);
}
.research-inspector-detail {
  margin: 0;
  color: var(--atlas-ink) !important;
  font-size: 13px;
  line-height: 1.5;
}
.research-inspector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 7px 10px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #f5e6c3;
  color: var(--atlas-muted);
  font-size: 12px;
}
.research-inspector-meta strong { color: var(--atlas-ink); }
.research-inspector-block {
  display: grid;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid #8c735038;
}
.research-inspector-block h4 {
  margin: 0;
  color: var(--atlas-muted);
  font: 700 11px/1.2 var(--ui);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.research-dep-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.research-dep-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #fff6df;
  color: var(--atlas-ink);
  font: 600 11.5px/1.2 var(--ui);
  cursor: pointer;
}
.research-dep-chip:hover {
  border-color: var(--atlas-red);
  background: #faebc7;
}
.research-dep-chip.is-done {
  border-color: #4f724588;
  background: #dde6cf;
  color: #274421;
}
.research-unlock-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.research-unlock-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #fff8e6;
  color: var(--atlas-ink);
  font: 600 11.5px/1.25 var(--ui);
}
.research-unlock-item img {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  flex: none;
  object-fit: contain;
}
.research-unlock-item > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.research-unlock-item strong {
  color: var(--atlas-ink);
  font-size: 12px;
}
.research-unlock-item small {
  color: var(--atlas-muted);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.25;
}
.research-bonus-pill {
  padding: 6px 9px;
  border: 1px solid #6b8459;
  border-radius: 2px;
  background: #e1ead2;
  color: #26451e;
  font: 700 12px/1.25 var(--ui);
}
.research-bonus-pill.is-specialist {
  border-color: #a1711a;
  background: #f9e6b3;
  color: #5e3807;
}
.research-cost-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.research-cost-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #fff6df;
  font-size: 12px;
  color: var(--atlas-ink);
}
.research-cost-row > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.research-cost-row strong { font-variant-numeric: tabular-nums; }
.research-cost-row strong small {
  font-weight: 500;
  color: var(--atlas-muted);
}
.research-cost-row.is-short {
  border-color: #963e3188;
  background: #f5dfca;
  color: #792f23;
}
.research-cost-row.is-short strong { color: var(--atlas-red); }
.research-inspector-cta {
  padding-top: 8px;
  border-top: 2px solid #8c735044;
  display: grid;
  gap: 8px;
}
.research-inspector-note {
  margin: 0;
  color: #7c362a !important;
  font: 600 12px/1.35 var(--ui);
}
.research-inspector-done {
  padding: 9px 10px;
  border: 1px solid #486b3f88;
  border-radius: 2px;
  background: #dce5cd;
  color: #24421d;
  font: 700 12.5px/1.25 var(--ui);
  text-align: center;
}
.research-inspector-cta .research-action {
  width: 100%;
  min-height: 40px;
  justify-content: center;
  border-color: #2f5133;
  background: var(--diplomacy-green);
  color: #fff3db;
  font-weight: 700;
}
.research-inspector-cta .research-action:hover:enabled {
  background: #23462c;
}
.research-inspector-cta .research-action:disabled {
  border-color: var(--atlas-rule);
  background: #e9d9b8;
  color: var(--atlas-muted);
}
.research-inspector-cta .research-inspector-cancel {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  border-color: #9c3825;
  background: #f6e1cc;
  color: #7d291a;
  font-weight: 700;
}
.research-inspector-cta .research-inspector-cancel:hover:enabled {
  background: #9c3825;
  color: #fff4df;
}

@media (max-width: 980px) {
  .research-slots-bar {
    grid-template-columns: minmax(0, 1fr);
    padding: 6px 8px;
    gap: 5px;
  }
  .research-slots-list {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .research-slots-list::-webkit-scrollbar { display: none; }
  .research-slot-card,
  .research-slot-item {
    flex: 0 0 176px;
  }
  .research-slot-item .research-slot-card {
    flex: 1 1 auto;
  }
  .research-speed-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 8px;
  }
  .research-speed-popover {
    padding: 6px 9px;
    gap: 4px;
    font-size: 11px;
  }
  .research-toolbar {
    padding: 6px 10px;
    gap: 6px 8px;
  }
  .research-search-wrap {
    max-width: none;
  }
  .research-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(130px, 1.25fr) minmax(110px, 0.85fr);
  }
  .research-shell[data-inspector-open=false] {
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .research-inspector {
    padding: 0;
    border-inline-start: 0;
    border-top: 3px double var(--atlas-rule);
  }
  .research-inspector-toggle {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .research-inspector-body {
    padding: 12px 14px;
  }
  .research-shell[data-inspector-open=false] .research-inspector {
    overflow: hidden;
  }
  .research-shell[data-inspector-open=false] .research-inspector-toggle {
    border-bottom: 0;
  }
  .research-shell[data-inspector-open=false] .research-inspector-body {
    display: none;
  }
}

/* Trade & Export Contracts full-screen ledger */
#drawer.atlas-panel-page:is([data-panel=trade], [data-panel=exportContracts]) .drawer-body {
  padding: 0;
}
#drawer.atlas-panel-page :is(.trade-panel, .export-contract-panel) {
  --export-gold: #7c362a;
  --export-surface: #faefd48c;
  --export-green: #325a49;
  --export-amber: #b26b29;
  --export-alert: #963e31;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.6vw, 18px);
  padding-bottom: clamp(16px, 2.4vw, 28px);
}
#drawer.atlas-panel-page :is(.trade-tabs, .export-tabs) {
  order: -2;
  position: sticky;
  top: 0;
  z-index: 3;
}
#drawer.atlas-panel-page :is(.trade-panel, .export-contract-panel) > :not(.trade-tabs, .export-tabs) {
  width: min(calc(100% - 2 * clamp(14px, 2.4vw, 32px)), 1280px);
  margin-inline: auto;
}
#drawer.atlas-panel-page .trade-fleet,
#drawer.atlas-panel-page .naval-fleet {
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #8a4b38;
  border-radius: 2px;
  background: #faefd499;
}
#drawer.atlas-panel-page .naval-fleet {
  border-inline-start-color: var(--diplomacy-green);
}
#drawer.atlas-panel-page .trade-fleet-icon,
#drawer.atlas-panel-page .naval-fleet-icon {
  border-color: #b8a07b;
  border-radius: 2px;
  background: #eddbb7;
  color: #814336;
}
#drawer.atlas-panel-page .naval-fleet-icon {
  border-color: #829b8e;
  background: #dce5dc;
  color: #2b4e40;
}
#drawer.atlas-panel-page .naval-fleet small,
#drawer.atlas-panel-page .naval-fleet-register small,
#drawer.atlas-panel-page .naval-ship-spec {
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page .naval-fleet-register summary,
#drawer.atlas-panel-page .naval-ship-picker legend,
#drawer.atlas-panel-page .naval-ship-choice strong,
#drawer.atlas-panel-page .naval-home-name,
#drawer.atlas-panel-page .naval-order-head > strong,
#drawer.atlas-panel-page .naval-route-fleet summary,
#drawer.atlas-panel-page .naval-arrival strong {
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .naval-vessel-card {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #f8ebd0;
}
#drawer.atlas-panel-page button.naval-vessel-card:hover {
  border-color: var(--atlas-red);
  background: #eedab2;
}
#drawer.atlas-panel-page .naval-ship-picker {
  border-color: var(--atlas-rule);
  border-radius: 2px;
  background: #f6e7c680;
}
#drawer.atlas-panel-page .naval-form .naval-ship-picker label.naval-ship-choice {
  border-radius: 2px;
  background: #fcf3db;
}
#drawer.atlas-panel-page .naval-ship-choice small {
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page .naval-ship-choice:has(input:checked) {
  border-color: var(--diplomacy-green);
  background: #e2eadb;
}
#drawer.atlas-panel-page .naval-stop,
#drawer.atlas-panel-page .naval-route-fleet > li {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #f6e7c6;
}
#drawer.atlas-panel-page .naval-stop:not(:first-child) {
  border-inline-start: 2px solid var(--diplomacy-green);
}
#drawer.atlas-panel-page .naval-stop-number {
  border-color: #7b9689;
  background: #dce5dc;
  color: #264638;
}
#drawer.atlas-panel-page .naval-order {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #fcf3db;
}
#drawer.atlas-panel-page .naval-itinerary li {
  border-color: var(--atlas-rule);
  background: #f2e2be;
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .naval-itinerary [aria-current] {
  border-color: var(--diplomacy-green);
  background: var(--diplomacy-green);
  color: #fff0d0;
}
#drawer.atlas-panel-page .naval-dock {
  border: 1px solid #869e90;
  border-radius: 2px;
  background: #e3ece0;
  color: #254033;
}
#drawer.atlas-panel-page .naval-dock small,
#drawer.atlas-panel-page .naval-dock-heading > span {
  color: #435c4e;
}
#drawer.atlas-panel-page .trade-export-entry {
  border: 1px solid #a98d64;
  border-inline-start: 3px solid var(--atlas-red);
  border-radius: 2px;
  background: #f9eed2;
  color: #6e382c;
}
#drawer.atlas-panel-page .trade-export-entry:hover {
  background: #ecd6af;
}
#drawer.atlas-panel-page .trade-panel .trade-message,
#drawer.atlas-panel-page .export-feedback {
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid var(--diplomacy-green);
  border-radius: 2px;
  background: #f4e6c3;
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .trade-panel .trade-message[data-state=error],
#drawer.atlas-panel-page .export-feedback[data-error=true] {
  border-inline-start-color: var(--atlas-red);
  background: #f7dfd0;
  color: #7c2f23;
}
#drawer.atlas-panel-page .trade-form,
#drawer.atlas-panel-page .trade-route-builder {
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #faefd485;
}
#drawer.atlas-panel-page .trade-customs[data-discounted] {
  border-inline-start: 2px solid var(--diplomacy-green);
  background: #dce6d5;
  color: #264636;
}
#drawer.atlas-panel-page .trade-route-summary {
  border-left: 2px solid var(--atlas-rule);
  background: #f4e4c1;
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .trade-route-summary[data-state=ready] {
  border-left-color: var(--diplomacy-green);
  color: #264636;
}
#drawer.atlas-panel-page .trade-route-summary:is([data-state=error], [data-state=unavailable]) {
  border-left-color: var(--atlas-red);
  color: #7e3125;
}
#drawer.atlas-panel-page .trade-list,
#drawer.atlas-panel-page .naval-panel .naval-route-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 12px;
}
#drawer.atlas-panel-page .trade-card,
#drawer.atlas-panel-page .export-card,
#drawer.atlas-panel-page .export-empty {
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #a58b66;
  border-radius: 2px;
  background: #faefd48c;
}
#drawer.atlas-panel-page .export-card.export-active {
  border-inline-start-color: var(--diplomacy-green);
}
#drawer.atlas-panel-page .export-contract-panel .export-empty {
  border-style: dashed;
  background: #f4e5c366;
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page :is(.trade-badge, .export-badge) {
  border: 1px solid #b9a583;
  border-radius: 2px;
  background: #f3e4c2;
  color: #544533;
}
#drawer.atlas-panel-page :is(.trade-badge, .export-badge):is([data-state=buy], [data-state=completed], [data-state=delivered], [data-state=sailing], [data-state=loading], [data-state=handling]) {
  border-color: #7c947d;
  background: #dce6d5;
  color: #2a4938;
}
#drawer.atlas-panel-page :is(.trade-badge, .export-badge):is([data-state=sell], [data-state=outbound], [data-state=returning], [data-state=active], [data-state=inTransit]) {
  border-color: #b89762;
  background: #f4e2bc;
  color: #684227;
}
#drawer.atlas-panel-page :is(.trade-badge, .export-badge):is([data-state=unloading], [data-state=storageFull], [data-state=portUnavailable], [data-state=waitingCargo], [data-state=dockQueue], [data-state=expired], [data-state=cancelled]) {
  border-color: #b87a5e;
  background: #f6dfc9;
  color: #7e3629;
}
#drawer.atlas-panel-page .export-body {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
  gap: 14px;
  align-items: start;
}
#drawer.atlas-panel-page .export-body > :is(.export-active, .export-empty) {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page .export-goods li {
  border-color: var(--atlas-rule);
  border-radius: 2px;
  background: #f5e6c4;
}
#drawer.atlas-panel-page .export-deadline {
  border-color: var(--atlas-rule);
  border-radius: 2px;
  background: #f3e3be;
}
#drawer.atlas-panel-page .export-progress-label strong {
  color: var(--diplomacy-green);
}
#drawer.atlas-panel-page .export-progress {
  border-radius: 2px;
  background: #d3c5a3;
}
#drawer.atlas-panel-page .export-cargo thead {
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page .export-dispatch fieldset {
  border-color: var(--atlas-rule);
  border-radius: 2px;
  background: #f6e7c580;
}
#drawer.atlas-panel-page .export-shipments > ul > li {
  border-color: var(--atlas-rule);
  border-radius: 2px;
  background: #f6e7c5;
}

/* Expeditions full-screen ledger */
#drawer.atlas-panel-page[data-panel=expeditions] .expedition-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(14px, 1.8vw, 22px);
}
#drawer.atlas-panel-page[data-panel=expeditions] .expedition-panel > :is(.expedition-error, .expedition-priority, [data-expedition-empty], [data-expedition-no-specialists]) {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page[data-panel=expeditions] .expedition-section {
  padding: clamp(12px, 1.6vw, 20px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid #a58b66;
  border-radius: 2px;
  background: #faefd485;
}
#drawer.atlas-panel-page[data-panel=expeditions] .expedition-priority {
  border-inline-start-color: var(--atlas-red);
}
#drawer.atlas-panel-page[data-panel=expeditions] .expedition-current {
  border-inline-start-color: var(--diplomacy-green);
}
#drawer.atlas-panel-page[data-panel=expeditions][data-expedition-view=all] [data-expedition-no-specialists],
#drawer.atlas-panel-page[data-panel=expeditions][data-expedition-view=active] :is(.expedition-preparation, [data-expedition-inventory-section], .expedition-past, [data-expedition-no-specialists]),
#drawer.atlas-panel-page[data-panel=expeditions][data-expedition-view=prepare] :is(.expedition-priority, .expedition-current, [data-expedition-empty], [data-expedition-inventory-section], .expedition-past, [data-expedition-no-specialists]),
#drawer.atlas-panel-page[data-panel=expeditions][data-expedition-view=specialists] :is(.expedition-priority, .expedition-current, [data-expedition-empty], .expedition-preparation) {
  display: none !important;
}
#drawer.atlas-panel-page[data-panel=expeditions]:not([data-expedition-view=all]) .expedition-panel {
  grid-template-columns: minmax(0, 1fr);
}

/* City planners full-screen workspace + preview */
#drawer.atlas-panel-page .city-land-quote i {
  border-color: var(--atlas-red);
  background: #b8862e38;
}
#drawer.atlas-panel-page .city-land-quote strong {
  color: var(--atlas-ink);
  font-variant-numeric: tabular-nums;
}
#drawer.atlas-panel-page .coop-row small,
#drawer.atlas-panel-page .fire-risk-list small,
#drawer.atlas-panel-page .fire-risk-factors {
  color: var(--atlas-muted);
}
#drawer.atlas-panel-page .economy-section:has(.fire-risk-list) h4 {
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .fire-risk-heading button[aria-pressed=true] {
  border-color: var(--atlas-red);
  background: #963e311f;
  color: var(--atlas-red);
}
#drawer.atlas-panel-page .progression {
  padding: clamp(14px, 1.8vw, 22px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid var(--atlas-red);
  border-radius: 2px;
  background: #faefd485;
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .progression h3 {
  color: var(--atlas-ink);
}
#drawer.atlas-panel-page .progression-goal strong {
  color: var(--atlas-red);
}
#drawer.atlas-panel-page .progression-requirements li {
  border-bottom-color: #8a735244;
  padding-block: 6px;
}

.city-planners-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 1.04fr) minmax(320px, 0.96fr);
  align-items: start;
  gap: clamp(14px, 2vw, 24px);
}
.city-planners-ledger {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.city-planners-ledger .city-planner[data-selected-planner=true] {
  border-inline-start: 3px solid var(--atlas-red);
  background: #fff4d9;
}
.city-planner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.city-planner-head h3 {
  margin: 0;
}
.city-planner-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #ead8b3;
  color: var(--atlas-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.city-planners-preview {
  position: sticky;
  top: 0;
  min-width: 0;
}
.city-planners-preview-card,
.city-planners-preview-empty {
  display: grid;
  gap: 12px;
  padding: clamp(14px, 1.8vw, 22px);
  border: 1px solid var(--atlas-rule);
  border-inline-start: 3px solid var(--diplomacy-green);
  border-radius: 2px;
  background: #faefd4cc;
  color: var(--atlas-ink);
}
.city-planners-preview-empty {
  border-inline-start-color: #a58b66;
  background: #faefd485;
}
.city-planners-preview-card h3,
.city-planners-preview-empty h3 {
  margin: 4px 0 0;
  font: 700 20px/1.15 var(--serif);
  color: var(--atlas-ink);
}
.city-planner-kicker {
  display: block;
  color: var(--atlas-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.city-planners-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.city-planners-areas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.city-planners-areas button[aria-pressed=true] {
  border-color: var(--atlas-red);
  background: var(--atlas-red);
  color: #fff3d9;
}
.city-planners-preview-diagnosis,
.city-planners-preview-note {
  margin: 0;
  color: var(--atlas-muted);
  font-size: 13px;
  line-height: 1.5;
}
.city-planners-canvas-wrap {
  position: relative;
  height: clamp(250px, 36vh, 410px);
  border: 1px solid #8a7352;
  border-radius: 2px;
  background: #1d2a30;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px #00000028;
}
.city-planners-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.city-planners-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 8px 10px;
  border: 1px solid var(--atlas-rule);
  border-radius: 2px;
  background: #f6e7c5;
  font-size: 12px;
  color: var(--atlas-ink);
}
.city-planners-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1px solid #4e3b25;
  border-radius: 2px;
}
.legend-swatch.is-build { background: #5a9c69; }
.legend-swatch.is-road { background: #a88f65; }
.legend-swatch.is-parcel { background: #d6aa46; }
.city-planners-summary-count {
  margin-inline-start: auto;
  color: var(--atlas-red);
  font-size: 12px;
}
.city-planners-preview-cost :is(.cost, .city-land-quote) {
  margin: 0;
}
.city-planners-preview-actions {
  margin-top: 2px;
}

/* Coop, Profile, Town Status, Workforce full-screen ledgers */
#drawer.atlas-panel-page:is([data-panel=coop], [data-panel=townStatus], [data-panel=workforce]) .drawer-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(14px, 1.8vw, 22px);
}
#drawer.atlas-panel-page[data-panel=coop] .drawer-body > [role=status],
#drawer.atlas-panel-page[data-panel=townStatus] .drawer-body > :is([role=status], .economy-section:first-child),
#drawer.atlas-panel-page[data-panel=workforce] .drawer-body > :first-child {
  grid-column: 1 / -1;
}
#drawer.atlas-panel-page[data-panel=profile] .drawer-body {
  display: grid;
  align-content: start;
  gap: 14px;
  max-width: 860px;
  width: 100%;
  margin-inline: auto;
}
#drawer.atlas-panel-page[data-panel=profile] .drawer-body > #openPlanningDesk {
  justify-self: start;
  width: auto;
  min-width: 220px;
}

@media (max-width: 960px) {
  .city-planners-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .city-planners-preview {
    position: static;
  }
}

@media (max-width: 820px) {
  #drawer.atlas-panel-page[data-panel=economy] .drawer-body,
  #drawer.atlas-panel-page[data-panel=expeditions] .expedition-panel,
  #drawer.atlas-panel-page:is([data-panel=coop], [data-panel=townStatus], [data-panel=workforce]) .drawer-body {
    grid-template-columns: minmax(0, 1fr);
  }
}
