/* Shared UI contract. Loaded last; business layouts and game coordinates stay in their modules. */
:root,
html[data-theme] {
  --ui-radius: 0px;
  --ui-line: 1px;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-control-height: 44px;
  --ui-control-compact: 36px;
  --ui-page-title: clamp(36px, 2.4vw, 46px);
  --ui-section-title: clamp(24px, 1.7vw, 30px);
  --ui-body-size: 16px;
  --ui-label-size: 14px;
  --ui-meta-size: 13px;
  --ui-panel-space: 20px;
  --ui-page-start: 20px;
  --radius: var(--ui-radius);
  --content-width: 1920px;
  --page-gutter: clamp(20px, 2vw, 40px);
  --topbar-height: 68px;
  --header-offset: var(--topbar-height);
  --sidebar-width: 0px;
  --mobile-nav-height: 64px;
}

/* Every panel follows the selected theme. The default dark palette also applies
   to catalogue details and simulator results that previously used paper surfaces. */
html[data-theme='dark'] {
  --marathon-paper: #0d100c;
  --marathon-paper-ink: #f2f3eb;
  --marathon-paper-muted: #a4aa9f;
  --marathon-paper-border: #363b32;
}
html[data-theme='light'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --surface: var(--marathon-paper);
  --surface-raised: #e5e7df;
  --surface-hover: #dce2d2;
  --surface-input: #fafbf5;
  --ink: var(--marathon-paper-ink);
  --muted: var(--marathon-paper-muted);
  --faint: var(--marathon-paper-muted);
  --border: var(--marathon-paper-border);
  --border-strong: #92998a;
  --soft: #e5e7df;
  --accent: #466600;
  --accent-dark: #354e00;
  --accent-ink: #ffffff;
  --accent-border: #6d872e;
  --tint: #e1eccb;
  --focus: #466600;
  color: var(--ink);
}

body { min-width: 0; font-size: var(--ui-body-size); line-height: 1.55; }
html[data-theme='dark'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --surface: #0d100c;
  --surface-raised: #151a12;
  --surface-hover: #1b2116;
  --surface-input: #090c08;
  --ink: #f2f3eb;
  --muted: #a4aa9f;
  --faint: #858d7f;
  --border: #363b32;
  --border-strong: #626b58;
  --soft: #10140d;
  --accent: #c0fe04;
  --accent-dark: #c0fe04;
  --accent-ink: #080b03;
  --accent-border: #8eb905;
  --tint: #202a0c;
  --focus: #c0fe04;
  background: var(--surface);
  color: var(--ink);
}
button, input, select, textarea { font-family: var(--font-sans); }
[hidden] { display: none !important; }
:is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button:disabled { cursor: default; }

/* Daily codes share the site's type, square grid and theme colours. */
html[data-theme] .guide-daily {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--page);
}
.guide-daily .portal-section-header {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.guide-daily .portal-section-header > div {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.guide-daily .portal-section-header p { margin: 0; font-size: var(--ui-label-size); }
.guide-daily .guide-date { display: block; font-size: var(--ui-label-size); }
.guide-daily .daily-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}
html[data-theme] .guide-daily .daily-cell:nth-child(n) {
  align-items: stretch;
  gap: 4px;
  padding: 14px 20px 16px;
  border: 0;
  border-radius: 0;
  background: var(--page);
  text-align: left;
}
.guide-daily .daily-cell > span { color: var(--ink); font-size: var(--ui-body-size); font-weight: 650; }
.guide-daily .guide-password,
.guide-daily .guide-password-record {
  display: flex;
  align-items: center;
  min-height: 60px;
  width: 100%;
  max-width: none;
  padding: 4px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: inherit;
}
.guide-daily .guide-password { transition: background-color 120ms ease, box-shadow 120ms ease; }
.guide-daily .guide-password:hover,
.guide-daily .guide-password:active {
  background: var(--tint);
  box-shadow: inset 0 -2px var(--accent);
}
.guide-daily .guide-password:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.guide-daily .guide-password-digits {
  display: block;
  width: 100%;
  max-width: none;
  color: var(--accent);
  font: 700 clamp(40px, 4.4cqw, 60px)/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
  white-space: nowrap;
  overflow-wrap: normal;
  text-shadow: none;
}
.guide-daily .daily-cell.is-pending .guide-password-digits { color: var(--muted); }
@container daily-passwords (max-width: 1000px) {
  .guide-daily .daily-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container daily-passwords (max-width: 510px) {
  .guide-daily .portal-section-header { padding: 12px; gap: 8px 12px; }
  .guide-daily .portal-section-header > div { display: block; }
  .guide-daily .portal-section-header p { margin-top: 3px; }
  .guide-daily .daily-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-theme] .guide-daily .daily-cell:nth-child(n) { padding: 12px; }
  .guide-daily .guide-password,
  .guide-daily .guide-password-record { min-height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  .guide-daily .guide-password { transition: none; }
}

/* One shell, six primary sections, visible secondary navigation. */
.portal-topbar {
  left: 0;
  gap: clamp(12px, 1.5vw, 28px);
  height: var(--topbar-height);
  padding-inline: var(--page-gutter);
  background: var(--page);
  border-bottom: var(--ui-line) solid var(--border);
}
#app-sidebar, #menu-toggle, #nav-scrim { display: none; }
#desktop-navigation.ui-primary-nav {
  display: flex;
  flex: 1;
  align-items: stretch;
  gap: clamp(2px, .7vw, 14px);
  min-width: 0;
}
#desktop-navigation.ui-primary-nav > button {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--ui-body-size);
  font-weight: 700;
  white-space: nowrap;
}
#desktop-navigation.ui-primary-nav > button:is(.active, [aria-current='page']) {
  border-bottom-color: var(--accent);
  color: var(--accent);
}
#desktop-navigation.ui-primary-nav > button:hover { color: var(--ink); }
.theme-toggle { min-height: 44px; }
.theme-menu { border-radius: 0; }
.theme-menu button { min-height: 44px; font-size: var(--ui-body-size); }
#main-content.app-main {
  width: 100%;
  margin: 0;
  padding: calc(var(--topbar-height) + var(--ui-page-start)) var(--page-gutter) 32px;
}
#main-content > :is(.hero, #workspace, #portal-view, #section-navigation, .marathon-footer) {
  width: 100%;
  max-width: var(--content-width);
  min-width: 0;
  margin-inline: auto;
}
#section-navigation.ui-section-nav,
#portal-view .guide-codex-tabs.ui-section-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0 8px;
  margin-top: calc(-1 * var(--ui-page-start));
  margin-bottom: 24px;
  padding: 0;
  overflow: visible;
  border-bottom: 1px solid var(--border);
}
#section-navigation.ui-section-nav > button,
#portal-view .guide-codex-tabs.ui-section-nav > button {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 11px 14px 9px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: 650 var(--ui-body-size)/1.4 var(--font-sans);
  white-space: nowrap;
}
#section-navigation.ui-section-nav > button:is(.active, [aria-current='page']),
#portal-view .guide-codex-tabs.ui-section-nav > button:is(.active, [aria-current='page']) {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
#section-navigation.ui-section-nav > button:hover,
#portal-view .guide-codex-tabs.ui-section-nav > button:hover { color: var(--ink); background: var(--surface-hover); }

/* A single page-title scale; catalogue pages provide their own title/search row. */
body[data-page='fishing'] #main-content > .hero { display: none; }
#main-content > .hero,
#portal-view .ui-page-heading { min-height: 0; margin-top: 0; margin-bottom: 24px; }
#main-content > .hero h1,
#portal-view .ui-page-heading h1,
#portal-view .en-fishing-header h1,
#portal-view :is(.gc-gallery, .en-collections) .gc-section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: var(--ui-page-title);
  font-weight: 900;
  letter-spacing: -.035em;
  line-height: 1.18;
}
#main-content > .hero p,
#portal-view .ui-page-heading p { margin: 8px 0 0; color: var(--muted); font-size: var(--ui-body-size); line-height: 1.65; }
#portal-view :is(.gc-gallery, .en-collections) .gc-section-head { padding-bottom: 20px; }
#portal-view :is(.gc-gallery, .en-collections) .gc-count { font-size: var(--ui-body-size); font-weight: 600; }
html[data-theme] :is(.at-heading h2, .mr-heading h2, .ta-heading h2, .nt-panel-title,
  .portal-section-header h2, .table-heading h2, .panel-heading h2, .panel-heading h3,
  .chart-heading h3, .sim-panel h2, .mh-section-head h2) {
  color: var(--ink);
  font-size: var(--ui-section-title);
  font-weight: 800;
  letter-spacing: -.025em;
  line-height: 1.35;
}
#portal-view .gc-section:not(.gc-gallery):not(.en-collections) > .gc-section-head h2 {
  font-size: var(--ui-section-title);
  font-weight: 800;
  line-height: 1.35;
}
html[data-theme] :is(.at-heading p, .mr-heading p, .ta-heading p, .gc-section-head p,
  .panel-heading p, .chart-heading span, .table-heading > span, .nt-notice p) {
  color: var(--muted);
  font-size: var(--ui-label-size);
  line-height: 1.65;
}
.at-view-toolbar { align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.at-view-toolbar p { flex: 1 1 230px; margin: 0; }

/* Shared surfaces. Do not include map markers, graph geometry or inventory cells. */
html[data-theme] :is(.portal-panel, .white-panel, .filter-panel, .table-panel,
  .compare-card, .condition-preset, .at-panel, .at-mode-card, .at-plan, .at-build,
  .at-plan-items > li, .at-plan-difference, .at-table-wrap, .at-carry-card, .at-carry-best,
  .at-event-items > div, .at-reward-items > span, .at-status, .at-tags > span, .at-default,
  .mr-station, .mr-item, .mr-catalog, .gc-section, .gc-card, .gc-mini-card,
  .gc-media, .gc-grade, .gc-count, .en-skill, .en-operator-tab, .en-portrait,
  .en-role, .en-fish-prices > div, .en-task-level, .ta-navigator, .ta-detail,
  .ta-search-results, .ta-task-choices > button, .ta-node, .ta-requirements,
  .ta-rewards > li, .nt-notice, .nt-data-card, .nt-chart, .nt-record, .nt-track,
  .nt-empty-symbol, .guide-summary-card, .guide-weapon-card, .guide-load-error,
  .sim-panel, .sim-foldout, .om-tool, .om-sidebar, .om-detail, .om-editor,
  .tray-inner, .selection-chip, .gc-ingredient-quantity, .mobile-sort-button) { border-radius: var(--ui-radius); }
html[data-theme] :is(.at-panel, .filter-panel) { padding: var(--ui-panel-space); }
#portal-view :is(.at-workspace, .nt-workspace, .gc-guide, .ta-atlas, .sim-workspace) {
  min-width: 0;
  font-size: var(--ui-body-size);
}

/* Buttons and filters use the same dimensions, weight and selection treatment. */
html[data-theme] :is(.primary-button, .secondary-button, .outline-button,
  .at-button, .ta-button, .gc-reset, .nt-file-button, .gc-production-footer button,
  .mr-catalog-link) {
  min-height: var(--ui-control-height);
  padding: 9px 14px;
  border-radius: 0;
  font: 650 var(--ui-body-size)/1.4 var(--font-sans);
}
html[data-theme] :is(.at-mini-button, .at-icon-button) {
  min-height: var(--ui-control-compact);
  border-radius: 0;
  font: 600 var(--ui-label-size)/1.4 var(--font-sans);
}
/* Preserve contrast when touch leaves a primary action in the global hover state. */
html[data-theme] .at-primary { color: var(--accent-ink); }
html[data-theme] :is(.at-text-button, .text-button) { font-size: var(--ui-label-size); }
html[data-theme] :is(.at-tabs button, .at-chips button, .ta-tab, .ta-view-tabs button,
  .mr-segments button, .gc-type-chips button, .en-fishing-tab, .gc-jump-links button) {
  min-height: var(--ui-control-height);
  padding: 8px 13px;
  border-radius: 0;
  font: 600 var(--ui-body-size)/1.4 var(--font-sans);
}
html[data-theme] :is(.at-tabs, .ta-tabs, .gc-jump-links) { gap: 6px; }
html[data-theme] :is(.at-tabs button.active, .at-chips button.active, .ta-tab[aria-selected='true'],
  .ta-view-tabs button[aria-selected='true'], .mr-segments button.active) {
  border-color: var(--accent);
  background: var(--tint);
  color: var(--accent);
}
.at-section-tabs { margin-bottom: 20px; }
.at-section-tabs > .at-tabs { margin: 0; }
html[data-theme] .mr-segments { padding: 0; border-radius: 0; gap: 0; }
html[data-theme] .mr-segments button { border: 1px solid var(--border); }
html[data-theme] .mr-segments button + button { margin-left: -1px; }

html[data-theme] :is(.at-field, .nt-field, .nt-form label, .filter-field > span,
  .gc-select-label, .mr-control-group, .mr-search, .guide-tool-picker,
  .at-field > span, .at-draft-row label > span) { font-size: var(--ui-label-size); }
html[data-theme] :is(.at-field input, .at-field select, .at-field textarea,
  .at-search input, .at-draft-row input, .nt-form input, .nt-form select,
  .nt-form textarea, .nt-field input, .nt-field select, .nt-result-filter input,
  .ta-search-bar input, .ta-search-bar select, .mr-search input,
  .filter-field select, .table-tools select, .analysis-side select,
  .gc-select-label select, .guide-tool-picker select, .hit-sequence-slot select) {
  min-width: 0;
  max-width: 100%;
  min-height: var(--ui-control-height);
  height: auto;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background-color: var(--surface-input);
  color: var(--ink);
  font: 400 var(--ui-body-size)/1.45 var(--font-sans);
}
html[data-theme] :is(.gc-search, .search-field, .sim-search) {
  min-height: var(--ui-control-height);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--surface-input);
}
html[data-theme] :is(.gc-search input, .search-field input, .sim-search input) {
  min-width: 0;
  min-height: 42px;
  border-radius: 0;
  color: var(--ink);
  font-size: var(--ui-body-size);
  line-height: 1.45;
}
html[data-theme] :is(.at-search, .mr-search, .ta-search-bar > label:first-child) { max-width: 520px; }
html[data-theme] :is(input, textarea)::placeholder { color: var(--muted); opacity: .85; }

/* Table header language is shared; responsive row/card structures remain intact. */
html[data-theme] :is(.ranking-table, .analysis-table, .facts-table, .at-table,
  .nt-table, .guide-summary-table, .gc-ammo-table, .hit-trace-table, .sim-comparison) {
  font-size: var(--ui-body-size);
  font-variant-numeric: tabular-nums;
}
html[data-theme] :is(.ranking-table, .analysis-table, .facts-table, .at-table,
  .nt-table, .guide-summary-table, .gc-ammo-table, .hit-trace-table, .sim-comparison) thead th {
  background: var(--surface-raised);
  color: var(--muted);
  border-color: var(--border);
  font-size: var(--ui-label-size);
  font-weight: 650;
  line-height: 1.5;
}
html[data-theme] :is(.ranking-table, .analysis-table, .facts-table, .at-table,
  .nt-table, .guide-summary-table, .gc-ammo-table, .hit-trace-table, .sim-comparison) tbody td { border-color: var(--border); }
#portal-view .at-table [data-ui-numeric] { text-align: right; font-variant-numeric: tabular-nums; }
html[data-theme] :is(.at-item strong, .at-plan-copy > strong, .at-carry-item strong,
  .at-build h3, .mr-product > div > strong, .ta-task-choices > button strong,
  .gc-mini-title > strong, .en-skill h4, .en-bt-skill-list h4) {
  font-size: var(--ui-body-size);
  line-height: 1.45;
}
html[data-theme] :is(.at-caption, .at-count, .at-source, .at-item small,
  .at-table td > small, .at-plan-copy > small, .at-plan-price small,
  .at-plan-item-difference > small, .at-readiness-date, .at-plan-title > span,
  .at-metrics span, .at-material-list, .at-build-meta, .at-build-note,
  .ta-task-choices > button small, .ta-eyebrow, .ta-detail-index,
  .gc-mini-type, .gc-mini-facts, .gc-footnote, .gc-scroll-hint,
  .en-muted, .en-field dt, .en-field dd small, .en-skill-facts,
  .en-skill header small, .en-rule-list p, .en-bt-skill-list small,
  .en-bt-skill-list .en-skill-note, .nt-muted, .nt-feedback) {
  font-size: var(--ui-label-size);
  line-height: 1.6;
}
html[data-theme] :is(.en-skill > p, .en-operator-bio p, .en-field dd,
  .en-rule-list strong, .en-water-list, .en-bait-list li,
  .gc-detail-facts dt, .gc-detail-facts dd, .gc-detail-description,
  .ta-detail li, .nt-data-text, .nt-record-note) { font-size: var(--ui-body-size); line-height: 1.75; }
html[data-theme] :is(.gc-detail-source, .ta-source, .guide-source, .sim-note,
  .hit-mode-note, .hit-probability-note p, .hit-exclusion-note,
  .hit-sequence-counts, .hit-trace-note, .hit-compare-counts) { font-size: var(--ui-label-size); line-height: 1.7; }

/* Explicit legacy text sizes must use the same roles as their parent surfaces. */
html[data-theme] :is(.weapon-name, .bullet-name, .at-build-title > strong,
  .at-event-grid h3, .at-event-items > div > strong, .at-reward-items > span,
  .gc-card-title-line h3, .gc-card-field dd, .gc-ingredient-copy strong,
  .gc-production-detail h3, .gc-effects li, .sim-gear strong,
  .sim-reward-row > span:not(.gc-media), .sim-best > span, .sim-best strong,
  .sim-pull-detail strong, .sim-history strong, .sim-history b,
  .sim-comparison tbody button, .sim-result-lines dt,
  .nt-data-fields dd, .nt-data-title, .dialog-body p, .dialog-body li) {
  font-size: var(--ui-body-size);
  line-height: 1.55;
}
html[data-theme] :is(.sort-button, .mobile-sort-button, .weapon-sub, .bullet-level,
  .ms-label, .ttk-value small, .compare-config, .comparison-note, .at-build-stats,
  .at-plan-price, .at-plan-difference > span, .at-recipe-detail,
  .at-recipe-detail p, .at-status, .mr-count, .mr-values dt, .mr-source-note,
  .mr-catalog > summary, .mr-catalog > summary > span,
  .gc-card-field dt, .gc-card-title-line .gc-cell-stack small,
  .gc-ingredient-copy small, .gc-production-meta,
  .gc-production-footer button span, .gc-production-detail h3 span,
  .gc-detail-strip, .gc-gallery-rarity, .en-collection-rarity,
  .sim-reward-heading, .sim-comparison-heading > span,
  .sim-pull-detail span:not(.gc-media, .gc-media-empty, .gc-sprite-image),
  .sim-pull-detail small, .sim-history small, .sim-foldout summary > small,
  .sim-metrics dt, .sim-total small, .sim-odds > div, .sim-notice,
  .ta-total, .ta-search-bar > span, .ta-level > span, .ta-detail-status,
  .nt-result-meta, .nt-data-fields dt) {
  font-size: var(--ui-label-size);
  line-height: 1.6;
}
html[data-theme] :is(.at-tags > span, .at-default, .mr-best-label,
  .ta-task-group > h3 small, .gc-type-chips button b, .gc-ingredient-quantity,
  .gc-footprint, .gc-footprint > span:last-child small) {
  font-size: var(--ui-meta-size);
  line-height: 1.5;
}
html[data-theme] .sort-button { font-weight: 650; }
html[data-theme] .mobile-sort-button { min-height: 44px; }
#portal-view .gc-production-card .gc-card-title-line h3 { font-size: var(--ui-body-size); }
#portal-view .gc-production-card .gc-field-metric dd,
#portal-view .gc-production-detail .gc-field-metric dd { font-size: calc(var(--ui-body-size) + 3px); }
#portal-view :is(.gc-production-card, .gc-production-detail) .gc-field-metric .gc-cell-stack > span { white-space: normal; overflow-wrap: anywhere; }
#portal-view .gc-production-footer { flex-wrap: wrap; }
#portal-view .at-reward-items > span { gap: 10px; padding: 12px; }
#portal-view .at-reward-items > span > span:last-child { min-width: 0; overflow-wrap: anywhere; }
#portal-view .at-event-items > div { flex-wrap: wrap; padding: 12px; }
#portal-view .sim-comparison-heading h3 { font-size: calc(var(--ui-body-size) + 2px); }
#portal-view .gc-gallery-filter-label {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: var(--ui-control-height);
  margin-right: 6px;
  color: var(--muted);
  font-size: var(--ui-label-size);
  font-weight: 600;
}

/* Carry choices: readable filters, one clear item price, and a secondary per-slot comparison. */
#portal-view .at-carry-filters { gap: 12px; margin-bottom: 16px; }
#portal-view .at-carry-filter { grid-template-columns: 3em minmax(0, 1fr); gap: 12px; align-items: start; }
#portal-view .at-carry-filter > span { padding-top: 12px; font-size: var(--ui-label-size); line-height: 1.5; }
#portal-view .at-chips { gap: 6px; }
#portal-view .at-carry-toolbar { gap: 12px; margin-bottom: 16px; }
#portal-view .at-carry-toolbar .at-search { max-width: 520px; }
#portal-view .at-carry-toolbar .at-text-button { min-height: 44px; }
#portal-view .at-carry-viewbar { gap: 10px 16px; padding-top: 16px; margin-bottom: 16px; }
#portal-view .at-carry-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; }
#portal-view .at-carry-best { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
#portal-view .at-carry-size { flex-wrap: wrap; gap: 4px 10px; margin: 0; }
#portal-view .at-carry-size > span:last-child { margin: 0; color: var(--muted); font-size: var(--ui-meta-size); line-height: 1.5; }
#portal-view .at-carry-size .gc-footprint { font-size: var(--ui-label-size); }
#portal-view .at-carry-item { gap: 12px; }
#portal-view .at-carry-item .at-image { width: 64px; height: 64px; flex-basis: 64px; }
#portal-view .at-carry-item strong { font-size: calc(var(--ui-body-size) + 1px); line-height: 1.45; }
#portal-view .at-carry-item small { font-size: var(--ui-label-size); line-height: 1.5; }
#portal-view .at-carry-price {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
#portal-view .at-carry-price > span { color: var(--muted); font-size: var(--ui-label-size); }
#portal-view .at-carry-price > strong {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  color: var(--accent);
  font: 750 clamp(20px, 1.35vw, 26px)/1.3 var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#portal-view .at-carry-price small { color: var(--muted); font: 400 var(--ui-meta-size)/1.4 var(--font-sans); }
#portal-view .at-carry-value { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 0; border: 0; }
#portal-view .at-carry-value > span { display: block; min-width: 0; margin: 0; color: var(--muted); font-size: var(--ui-meta-size); line-height: 1.55; white-space: normal; overflow-wrap: anywhere; }
#portal-view .at-carry-value strong { color: var(--ink); font: 600 var(--ui-label-size)/1.55 var(--font-mono); font-variant-numeric: tabular-nums; }
#portal-view .at-carry-viewbar .at-caption { font-size: var(--ui-label-size); }
#portal-view .at-carry-table .gc-footprint { font-size: var(--ui-label-size); }

/* Fishing uses the same readable type scale and square tabs as the other codex pages. */
#portal-view .en-fishing-tabs > [role='tablist'] > button {
  min-height: var(--ui-control-height);
  border-radius: 0;
  font: 650 var(--ui-body-size)/1.4 var(--font-sans);
}
#portal-view .en-fishing-tabs > [role='tablist'] > button b { font-size: var(--ui-label-size); }
#portal-view .en-fishing-tabs .en-location-card strong { font-size: calc(var(--ui-body-size) + 1px); }
#portal-view .en-fishing-tabs .en-fish-places,
#portal-view .en-fishing-tabs .gc-mini-bottom > small,
#portal-view .en-fishing-tabs .en-location-card small {
  font-size: var(--ui-label-size);
  line-height: 1.6;
}
#portal-view .en-fishing-tabs .en-fish-places { white-space: normal; }
#portal-view .en-fishing-tabs .gc-footprint,
#portal-view .en-fishing-tabs .gc-footprint > span:last-child small { font-size: var(--ui-meta-size); }

/* Readiness, income and manufacturing keep their own useful content shape. */
#portal-view .at-workspace[data-action-tool='readiness'] { --at-gold: var(--accent); }
#portal-view .at-mode-tabs { gap: 12px; }
#portal-view .at-mode-card { min-height: 104px; }
#portal-view .at-mode-card > span { font-size: var(--ui-body-size); }
#portal-view .at-plan { padding: 18px; }
#portal-view .at-plan h3 { font-size: 20px; font-weight: 800; }
#portal-view .at-plan-totals dt { font-size: var(--ui-label-size); }
#portal-view .at-plan-totals dd { font-size: clamp(22px, 1.8vw, 30px); }
#portal-view .at-plan-actions .at-button { min-height: 44px; font-size: var(--ui-body-size); }
#portal-view .at-build { padding: 16px; }
#portal-view .at-build .at-code { font: var(--ui-label-size)/1.7 var(--font-mono); overflow-wrap: anywhere; }
#portal-view .at-build.is-private .at-code { font-size: var(--ui-label-size); }
#portal-view .mr-station > header h3 { font-size: 17px; font-weight: 750; }
#portal-view .mr-product > div > strong { font-size: var(--ui-body-size); }
#portal-view .mr-product > div > small { font-size: var(--ui-label-size); }
#portal-view .mr-values { font-size: var(--ui-label-size); }
#portal-view .mr-values dd { font-size: var(--ui-body-size); }
#portal-view .mr-values .mr-value-active dd { font-size: 17px; }

/* Item catalogues and fishing share a three-column grid and a themed detail panel. */
#portal-view :is(.gc-gallery-workspace, .en-collection-workspace) {
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 1fr);
  gap: 16px;
}
#portal-view :is(.gc-gallery-grid, .en-mini-collections) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
}
#portal-view :is(.gc-gallery, .en-collections) .gc-type-chips {
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  overflow: visible;
}
#portal-view :is(.gc-gallery, .en-collections) .gc-type-chips button {
  min-height: var(--ui-control-height);
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: var(--ui-body-size);
}
#portal-view :is(.gc-gallery, .en-collections) .gc-type-chips button[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
#portal-view :is(.gc-gallery, .en-collections) .gc-mini-title > strong { font-size: 16px; }
#portal-view :is(.gc-gallery, .en-collections) .gc-mini-bottom > :is(b, .gc-cell-stack) { font-size: 19px; }
#portal-view :is(.gc-gallery-detail, .en-collection-detail) { padding: 24px; }
#portal-view :is(.gc-gallery-detail-content, .en-collection-detail-content) .gc-detail-title h2 {
  font-size: clamp(26px, 2.2vw, 34px);
  line-height: 1.2;
}
#portal-view :is(.gc-gallery.is-empty, .en-collections.is-empty) > :is(.gc-gallery-workspace, .en-collection-workspace) { grid-template-columns: minmax(0, 1fr); }

/* Guide content and task controls, without changing the task graph's coordinates. */
#portal-view .en-operator-tab { border-radius: 0; }
#portal-view .en-operator-tab strong { font-size: var(--ui-label-size); }
#portal-view .en-operator-tab small { font-size: var(--ui-meta-size); }
#portal-view .ta-task-group > h3 { font-size: var(--ui-body-size); }
#portal-view .ta-detail h4 { font-size: var(--ui-label-size); }
#portal-view .ta-task-choices > button { min-height: 64px; }
#portal-view .ta-detail-nav .ta-button strong { font-size: var(--ui-body-size); }
#portal-view .ta-detail-nav .ta-button span { font-size: var(--ui-label-size); }
#portal-view .ta-rewards :is(span, b) { font-size: var(--ui-label-size); }
#portal-view .ta-graph-toolbar .ta-button { min-width: 36px; padding-inline: 8px; }

/* Simulators and the map share chrome only; their boards, imagery and events are untouched. */
#portal-view .sim-panel h2 { font-size: var(--ui-section-title); }
#portal-view :is(.sim-choices button, .sim-settings-panel .sim-choices button,
  .sim-presets button) { font-size: var(--ui-body-size); }
#portal-view :is(.sim-audio, .sim-control-group > span, .sim-board-meta,
  .sim-selected-gear dt, .sim-gear small) { font-size: var(--ui-label-size); }
#portal-view .om-header h2 { font-size: 22px; font-weight: 800; }
#portal-view :is(.om-button, .om-map-tab) { border-radius: 0; font-size: var(--ui-label-size); }
#portal-view :is(.om-sidebar, .om-detail, .om-editor, .om-stage) { border-radius: 0; }
#portal-view .om-field :is(input, select, textarea) { border-radius: 0; }

/* Dialogs and empty states have the same visual and focus treatment as full pages. */
html[data-theme] dialog,
#portal-view dialog.gc-detail-dialog { border: 1px solid var(--border-strong); border-radius: 0; }
html[data-theme] :is(.dialog-header h2, .gc-detail-title h2) { font-size: 24px; font-weight: 800; line-height: 1.35; }
.dialog-header { border-bottom: 1px solid var(--border); }
html[data-theme] :is(.gc-detail-close, .dialog-header .icon-button) { min-height: 44px; border-radius: 0; }
html[data-theme] :is(.at-empty, .gc-empty, .nt-empty p, .empty-state p,
  .ta-list-empty, .sim-empty) { color: var(--muted); font-size: var(--ui-body-size); line-height: 1.75; }
html[data-theme] :is(.at-empty, .gc-empty, .nt-empty, .empty-state) { padding: 28px 20px; }
html[data-theme] :is(.empty-state h2, .nt-empty h2) { font-size: 20px; line-height: 1.45; }

/* An empty compare tray is not navigation. Selected configurations still stay available. */
.comparison-tray:has(#selected-tray > .tray-empty) { display: none; }
body[data-page='weapons']:has(#selected-tray > .selection-chip) #main-content { padding-bottom: 116px; }
.comparison-tray .tray-inner { max-width: var(--content-width); border-radius: 0; }
.comparison-tray .selected-tray { gap: 8px; }
.marathon-footer { font-size: var(--ui-label-size); }

@media (min-width: 761px) {
  html[data-theme] :is(.at-table, .nt-table, .analysis-table, .facts-table,
    .gc-ammo-table, .hit-trace-table, .sim-comparison) :is(th, td) { padding: 12px 14px; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  #desktop-navigation.ui-primary-nav { gap: 0; }
  #desktop-navigation.ui-primary-nav > button { padding-inline: 9px; font-size: var(--ui-body-size); }
  .header-brand span { font-size: 21px; }
  .theme-caption { font-size: var(--ui-meta-size); }
  .theme-swatches { gap: 6px; }
}
@media (max-width: 1100px) {
  #portal-view .gc-gallery-filters { flex-wrap: wrap; }
  #portal-view .gc-gallery-filters .gc-type-chips { flex-basis: 100%; }
  #portal-view .en-collection-filters { grid-template-columns: minmax(0, 1fr) 108px; }
  #portal-view .en-collection-filters .gc-type-chips { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  #portal-view :is(.gc-gallery-workspace, .en-collection-workspace) { grid-template-columns: minmax(0, 1fr); }
  #portal-view :is(.gc-gallery-detail, .en-collection-detail) { display: none; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-section-head { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-card-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }
}

@media (max-width: 900px) {
  :root,
  html[data-theme] {
    --page-gutter: 16px;
    --topbar-height: 64px;
    --ui-page-start: 16px;
    --ui-page-title: 30px;
    --ui-body-size: 15px;
    --ui-label-size: 13px;
    --ui-meta-size: 12px;
    --ui-section-title: 24px;
    --ui-panel-space: 16px;
  }
  .portal-topbar { padding-inline: var(--page-gutter); gap: 12px; }
  #desktop-navigation.ui-primary-nav { display: none; }
  .header-brand { flex: 1; gap: 8px; }
  .header-brand span { font-size: 23px; }
  .theme-toggle { min-width: 44px; padding: 6px; border-left: 0; }
  #main-content.app-main {
    padding-top: calc(var(--topbar-height) + var(--ui-page-start));
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 24px);
  }
  #section-navigation.ui-section-nav,
  #portal-view .guide-codex-tabs.ui-section-nav { gap: 0; margin-bottom: 20px; }
  #section-navigation.ui-section-nav > button { flex: 1 1 0; padding-inline: 9px; font-size: var(--ui-body-size); }
  #portal-view .guide-codex-tabs.ui-section-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }
  #portal-view .guide-codex-tabs.ui-section-nav > button { padding: 10px 3px 8px; min-height: 44px; font-size: var(--ui-label-size); }
  #main-content > .hero { margin-bottom: 20px; }
  #main-content > .hero p { font-size: var(--ui-label-size); margin-top: 7px; }
  #portal-view .at-mode-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    scroll-snap-type: none;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0;
  }
  #portal-view .at-mode-card { min-height: 90px; padding: 12px 6px; gap: 6px; }
  #portal-view .at-mode-card strong { font-size: 30px; }
  #portal-view .at-mode-card strong small { font-size: 19px; }
  #portal-view .at-mode-card > span { font-size: var(--ui-label-size); }
  .mobile-nav.ui-mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-strong);
    background: var(--page);
  }
  .mobile-nav.ui-mobile-nav > button {
    min-width: 0;
    min-height: 44px;
    padding: 5px 1px;
    gap: 4px;
    border: 0;
    border-radius: 0;
    font-size: var(--ui-meta-size);
    line-height: 1.3;
  }
  .mobile-nav.ui-mobile-nav > button svg { width: 20px; height: 20px; }
  .mobile-nav.ui-mobile-nav > button span { white-space: nowrap; }
  .mobile-nav.ui-mobile-nav > button:is(.active, [aria-current='page']) {
    background: var(--tint);
    color: var(--accent);
    box-shadow: inset 0 2px var(--accent);
  }
  .comparison-tray { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); padding: 0 var(--page-gutter) 8px; }
  .comparison-tray .tray-inner { padding: 8px; min-height: 0; }
  .comparison-tray .tray-inner > p { display: none; }
  .comparison-tray .selected-tray { width: 100%; gap: 6px; }
  .comparison-tray .selected-tray > span:first-child:not(.selection-chip) { display: none; }
  .comparison-tray .selection-chip { flex: 1 1 78px; min-width: 0; max-width: none; padding: 2px 5px; font-size: var(--ui-meta-size); }
  .comparison-tray .selection-chip button { min-width: 32px; min-height: 40px; }
  .comparison-tray .selected-tray > .primary-button { flex: 1 0 100%; min-height: 44px; }
  body[data-page='weapons']:has(#selected-tray > .selection-chip) #main-content {
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 132px);
  }
  #toast { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px); }
  body[data-page='weapons']:has(#selected-tray > .selection-chip) #toast { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 124px); }
  html[data-theme] :is(.at-field input, .at-field select, .at-field textarea,
    .at-search input, .at-draft-row input, .nt-form input, .nt-form select,
    .nt-form textarea, .nt-field input, .nt-field select, .nt-result-filter input,
    .ta-search-bar input, .ta-search-bar select, .mr-search input,
    .filter-field select, .table-tools select, .analysis-side select,
    .gc-select-label select, .guide-tool-picker select, .hit-sequence-slot select,
    .gc-search input, .search-field input, .sim-search input) { font-size: 16px; }
  html[data-theme] :is(.at-mini-button, .at-icon-button, .at-tabs button, .at-chips button,
    .ta-tab, .ta-view-tabs button, .mr-segments button, .gc-type-chips button,
    .en-fishing-tab, .gc-jump-links button) { min-height: 44px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-search input { font-size: 16px; }
}

@media (max-width: 720px) {
  #portal-view .gc-dense .gc-filters:has(.gc-select-label:nth-of-type(3)) .gc-search { margin-right: 71px; }
  #portal-view .gc-dense .gc-filters:has(.gc-select-label:nth-of-type(3)) .gc-reset {
    width: 64px;
    padding-inline: 10px;
    white-space: nowrap;
  }
  #portal-view :is(.gc-gallery-grid, .en-mini-collections) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  #portal-view .en-fishing-gallery .en-mini-locations { grid-template-columns: minmax(0, 1fr); }
  #portal-view .en-fishing-gallery .en-fishing-filter-options > .gc-type-chips {
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 3px 2px 5px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-padding-inline: 3px;
    scrollbar-width: thin;
  }
  #portal-view .en-fishing-gallery .en-fishing-filter-options > .gc-type-chips button { flex: 0 0 auto; white-space: nowrap; }
  #portal-view .en-fishing-gallery [data-en-filter-group='method'] .gc-type-chips { gap: 4px; }
  #portal-view .en-fishing-gallery [data-en-filter-group='method'] .gc-type-chips button { padding-inline: 5px; }
  #portal-view .en-fishing-gallery .en-fishing-filter-actions > .gc-reset { min-width: 80px; min-height: 44px; padding: 8px 10px; font-size: var(--ui-label-size); }
  #portal-view :is(.gc-gallery, .en-collections) .gc-section-head { padding-bottom: 16px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-mini-title > strong { font-size: var(--ui-body-size); }
  #portal-view :is(.gc-gallery, .en-collections) .gc-mini-bottom > :is(b, .gc-cell-stack) { font-size: 17px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-mini-bottom { flex-wrap: wrap; gap: 6px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-mini-type { font-size: var(--ui-label-size); }
  #portal-view :is(.gc-gallery, .en-collections) .gc-mini-facts { gap: 4px 6px; font-size: var(--ui-meta-size); }
  #portal-view :is(.gc-gallery-filters, .en-collection-filters) { margin-bottom: 16px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-type-chips button { min-height: 44px; padding-inline: 10px; font-size: var(--ui-label-size); }
  #portal-view :is(.gc-gallery, .en-collections) .gc-select-label { max-width: none; flex: 1 1 160px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-reset { flex: 0 0 96px; }
  #portal-view :is(.gc-gallery, .en-collections) .gc-gallery-heading,
  #portal-view .en-collections-heading { gap: 14px; }
  #portal-view .at-search { max-width: none; }
  #portal-view .gc-gallery-filter-label { flex-basis: 100%; min-height: 0; margin: 0 0 2px; }
  #portal-view .at-carry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #portal-view .at-carry-best { padding: 10px; gap: 10px; }
  #portal-view .at-carry-filter { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  #portal-view .at-carry-filter > span { padding: 0; }
  #portal-view .at-chips button { padding-inline: 9px; font-size: var(--ui-label-size); }
  #portal-view .at-carry-item { display: block; }
  #portal-view .at-carry-item .at-image { display: flex; width: 100%; height: 96px; margin: 0 0 8px; }
  #portal-view .at-carry-price { padding-top: 10px; }
  #portal-view .at-carry-price > strong { font-size: 20px; }
  #portal-view .at-carry-value { gap: 4px; }
  #portal-view .ta-graph-toolbar .ta-button { min-width: 44px; min-height: 44px; }
  #portal-view .sim-control-group { flex-wrap: wrap; }
  #portal-view .sim-control-group > .sim-choices { min-width: 0; }
  #portal-view .sim-board-controls .sim-choices button { font-size: var(--ui-label-size); }
  #portal-view .sim-settings-panel .sim-choices button { padding-inline: 4px; font-size: var(--ui-label-size); }
  #portal-view .sim-presets button { padding-inline: 3px; font-size: var(--ui-label-size); }
  html[data-theme] dialog,
  #portal-view dialog.gc-detail-dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 32px - env(safe-area-inset-bottom)); }
  #portal-view dialog.gc-detail-dialog { padding: 18px; }
  .hit-editor-heading { flex-wrap: wrap; }
  .hit-editor-actions { margin-left: auto; }
}
@media (max-width: 600px) {
  #section-navigation.ui-section-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #portal-view .at-mode-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #portal-view .at-mode-card { min-height: 84px; }
  #portal-view .at-plan { padding: 14px; }
  #portal-view .at-plan h3 { font-size: 20px; }
  #portal-view .at-plan-totals dd { font-size: 24px; }
  #portal-view .at-plan-copy > strong { font-size: var(--ui-body-size); }
  #portal-view .at-plan-copy > small { font-size: var(--ui-meta-size); }
  #portal-view .at-build { padding: 14px; }
  #portal-view .at-table tbody tr { border-radius: 0; }
  #portal-view .at-table td::before { font-size: var(--ui-label-size); line-height: 1.5; }
  #portal-view .at-table .at-item strong { font-size: var(--ui-body-size); }
  #portal-view .at-table .at-item small { font-size: var(--ui-label-size); }
  #portal-view .at-table .at-mini-button { min-height: 44px; }
  #portal-view .at-table td[data-ui-numeric] { align-items: flex-end; text-align: right; }
  #portal-view .at-section-tabs .at-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #portal-view .at-section-tabs .at-tabs button { padding-inline: 5px; font-size: var(--ui-label-size); }
  #portal-view .mr-product > div > strong { font-size: var(--ui-body-size); }
  #portal-view .mr-product > div > small { font-size: var(--ui-meta-size); }
  #portal-view .mr-values .mr-value-active dd { font-size: 16px; }
  #portal-view .mr-values > div { flex-wrap: wrap; gap: 3px 6px; }
  #portal-view .mr-values dd { margin-left: auto; }
  #portal-view .mr-station-header { flex-wrap: wrap; }
  #portal-view .en-operator-roster {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    padding-inline: 14px;
    overflow: visible;
  }
  #portal-view .en-operator-tab { min-width: 0; padding-inline: 3px; }
  #portal-view .en-operator-tab strong { font-size: var(--ui-label-size); }
  #portal-view .en-operator-tab small { font-size: var(--ui-meta-size); }
  #section-navigation.ui-section-nav > button { padding-inline: 4px; font-size: var(--ui-label-size); }
}
@media (max-width: 360px) {
  :root, html[data-theme] { --page-gutter: 12px; --ui-page-title: 28px; --ui-panel-space: 12px; }
  #portal-view .guide-codex-tabs.ui-section-nav > button { font-size: var(--ui-label-size); }
  .mobile-nav.ui-mobile-nav > button { font-size: var(--ui-meta-size); }
  #portal-view .at-plan-items > li { gap: 6px; padding: 8px; }
  #portal-view .at-plan-item-difference b { font-size: 15px; }
  #portal-view .ta-tab { padding-inline: 4px; font-size: var(--ui-label-size); }
  #portal-view .at-plan-totals dd { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  :is(button, input, select, textarea, a) { transition: none; }
}

/* Home: one leader from each manufacturing station, using the full ranking's defaults. */
.mh-production {
  min-width: 0;
  padding: 16px 20px 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.mh-production .mh-section-head { align-items: flex-start; gap: 12px; }
.mh-production .mh-section-head > div { min-width: 0; }
.mh-production .mh-section-head > button { min-height: 36px; color: var(--accent); }
.mh-production-note { margin: 6px 0 0; color: var(--muted); font-size: var(--ui-label-size); line-height: 1.6; }
.mh-production-list { list-style: none; margin: 0; padding: 0; }
.mh-production-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.mh-production-row:last-child { border-bottom: 0; }
.mh-production-row.is-empty { min-height: 106px; grid-template-columns: minmax(0, 1fr); }
.mh-production-row.is-empty p { margin: 5px 0 0; color: var(--muted); font-size: var(--ui-body-size); }
.gc-media.mh-production-image { width: 60px; height: 60px; flex-basis: 60px; }
.mh-production-copy { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.mh-production-station { color: var(--muted); font-size: var(--ui-label-size); line-height: 1.4; }
.mh-production-copy strong { color: var(--ink); font-size: 16px; font-weight: 750; line-height: 1.45; overflow-wrap: anywhere; }
.mh-production-copy small { color: var(--muted); font-size: var(--ui-label-size); line-height: 1.4; }
.mh-production-values { display: grid; gap: 6px; margin: 0; text-align: right; white-space: nowrap; }
.mh-production-values dt { color: var(--muted); font-size: var(--ui-label-size); line-height: 1.4; }
.mh-production-values dd { margin: 0; color: var(--ink); font: 600 var(--ui-body-size)/1.4 var(--font-mono); font-variant-numeric: tabular-nums; }
.mh-production-values > div:first-child dd { color: var(--accent); font-size: 21px; font-weight: 750; }
.mh-production-values.is-loss dd,
.mh-production-values.is-loss > div:first-child dd { color: var(--danger, #e99078); }
.mh-ammo-reference .mh-item { gap: 8px; }
.mh-ammo-reference .mh-item-image { width: 34px; height: 32px; flex-basis: 34px; }
.mh-ammo-reference .mh-data-table td { padding-block: 9px; }
@media (max-width: 600px) {
  .mh-production { padding: 14px 12px 2px; }
  .mh-production-row { grid-template-columns: 52px minmax(0, 1fr) auto; gap: 9px; padding-block: 14px; }
  .gc-media.mh-production-image { width: 52px; height: 60px; flex-basis: 52px; }
  .mh-production-copy strong { font-size: 15px; }
  .mh-production-values > div:first-child dd { font-size: 18px; }
}

/* Readable scales also cover the analysis labels and map controls with old fixed type. */
html[data-theme='dark'] .en-collections {
  --en-paper: var(--surface);
  --en-paper-ink: var(--ink);
  --en-paper-muted: var(--muted);
  --en-paper-border: var(--border);
}
html[data-theme='dark'] .gc-gallery-detail .gc-effect-positive { color: var(--accent); }
html[data-theme='dark'] .gc-gallery-detail .gc-effect-negative { color: var(--coral, #e99078); }
html[data-theme] :is(.hit-probability-parts > span, .hit-average-parts,
  .hit-result-caption, .analysis-kpis > div > span, .analysis-side > label,
  .analysis-side .hint, .stat-lines, .analysis-type, .condition-preset span,
  .condition-summary, .preset-tag, .chart-legend, .chart-note, .mini-distance,
  .distribution-footer, .hit-sequence-slot label > span, .hit-sequence-slot > button,
  .hit-editor-heading span, .hit-editor-actions button) {
  font-size: var(--ui-label-size);
  line-height: 1.65;
}
html[data-theme] .analysis-kpis .tiny { font-size: var(--ui-meta-size); line-height: 1.6; }
html[data-theme] .condition-preset strong { font-size: var(--ui-body-size); }
html[data-theme] .distribution-row {
  grid-template-columns: 3em minmax(0, 1fr) 4.5em 5.3em;
  font-size: var(--ui-label-size);
}
html[data-theme] .distribution-row > span { white-space: nowrap; }
html[data-theme] .ttk-chart text { font-size: 14px; }
html[data-theme] .mh-data-table { font-size: var(--ui-body-size); }
html[data-theme] .mh-data-table th { font-size: var(--ui-label-size); }
html[data-theme] .mh-data-table td:last-child { font-size: calc(var(--ui-body-size) + 1px); }
html[data-theme] .mh-item > span { font-size: var(--ui-body-size); }
.mh-production-copy strong { font-size: calc(var(--ui-body-size) + 1px); }
.mh-production .mh-section-head > button { flex-shrink: 0; }
#portal-view :is(.gc-gallery, .en-collections) .gc-mini-title > strong { font-size: calc(var(--ui-body-size) + 1px); }
#portal-view :is(.om-button, .om-map-tab, .om-list-button strong) { font-size: var(--ui-body-size); }
#portal-view :is(.om-field > span, .om-options label, .om-count,
  .om-category-card span, .om-list-button span, .om-pagination > span,
  .om-reset-filters, .om-badge, .om-map-context, .om-category-groups button,
  .om-list-copy > small) { font-size: var(--ui-label-size); }
#portal-view .om-category-card small { font-size: var(--ui-meta-size); }
#portal-view .om-header h2 { font-size: var(--ui-section-title); }
#portal-view .om-field :is(input, select, textarea) { font-size: var(--ui-body-size); min-height: 44px; }
#portal-view .om-sidebar-heading { font-size: var(--ui-body-size); }
#portal-view .om-category-card { min-height: 70px; padding: 8px 4px; }

@media (min-width: 1800px) {
  :root, html[data-theme] {
    --ui-body-size: 18px;
    --ui-label-size: 15px;
    --ui-meta-size: 14px;
    --topbar-height: 76px;
    --ui-control-height: 48px;
  }
  #portal-view :is(.at-item-art, .at-item-image) { width: 56px; height: 56px; flex-basis: 56px; }
  .mh-production-values > div:first-child dd { font-size: 25px; }
  .mh-production-row { padding-block: 20px; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  #desktop-navigation.ui-primary-nav > button { padding-inline: 7px; font-size: 15px; }
}
@media (max-width: 900px) {
  #portal-view .om-field :is(input, select, textarea) { font-size: 16px; }
  #portal-view .guide-codex-tabs.ui-section-nav > button { font-size: 14px; }
  #portal-view .ui-page-heading { margin-bottom: 20px; }
  #portal-view .ui-page-heading p { margin-top: 7px; }
}
@media (max-width: 600px) {
  html[data-theme] .distribution-row { grid-template-columns: 3em minmax(0, 1fr) 4.2em 4.8em; gap: 5px; }
  .chart-container { min-width: 0; max-width: 100%; overflow-x: auto; }
  .ttk-chart { min-width: 640px; }
  .mh-production-copy strong { font-size: var(--ui-body-size); }
  #portal-view .om-category-card { min-height: 66px; }
}

/* Home keeps daily actions compact and gives manufacturing and the current market equal space. */
.mh-hero.mh-hero-compact { grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 18px; align-items: center; }
.mh-hero-compact .mh-hero-copy h1 { font-size: clamp(48px, 4.5vw, 72px); line-height: 1.08; }
.mh-hero-compact .mh-hero-copy > p { margin: 8px 0 12px; font-size: calc(var(--ui-body-size) + 2px); }
.mh-hero-compact .mh-hero-actions { gap: 12px; }
.mh-hero-compact .mh-hero-actions button,
.mh-hero-compact .mh-hero-actions .mh-primary {
  min-width: 148px;
  min-height: 44px;
  padding: 8px 18px;
  font-size: var(--ui-body-size);
}
.mh-hero-compact .mh-hero-map { height: clamp(160px, 12vw, 192px); }
.mh-hero-compact .mh-map-caption strong { font-size: calc(var(--ui-body-size) + 3px); }
.mh-hero-compact .mh-map-caption button { min-height: 44px; font-size: var(--ui-label-size); }
.mh-tools.mh-tools-strip {
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  margin-bottom: 20px;
  background: var(--surface);
}
.mh-tools-strip > h2 { display: flex; align-items: center; justify-content: center; padding: 12px; font-size: 24px; white-space: nowrap; }
.mh-tools-strip nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); min-width: 0; }
.mh-tools-strip nav button {
  justify-content: center;
  min-width: 0;
  min-height: 64px;
  padding: 12px;
  gap: 10px;
  border: 0;
  border-left: 1px solid var(--border);
  font-size: var(--ui-body-size);
  line-height: 1.4;
}
.mh-tools-strip nav svg { width: 24px; height: 24px; flex-basis: 24px; }
.mh-tools-strip nav button > span { min-width: 0; }
.mh-overview-grid.mh-overview-dual { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 20px; }
#home-exchange-block { min-width: 0; }
.mh-exchange { min-width: 0; padding: 16px 20px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
.mh-exchange-header { align-items: flex-start; gap: 14px; }
.mh-exchange-header > div { min-width: 0; }
.mh-exchange-date { margin: 6px 0 0; color: var(--muted); font-size: var(--ui-label-size); line-height: 1.6; }
.mh-exchange-header > .mh-exchange-status {
  display: inline-flex;
  flex-shrink: 0;
  margin-top: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: var(--ui-label-size);
  font-weight: 650;
  line-height: 1.4;
}
.mh-exchange[data-home-exchange-state='live'] .mh-exchange-status { color: var(--accent); border-color: var(--accent-border); background: var(--tint); }
.mh-exchange-section { margin-top: 16px; }
.mh-exchange-section > h3 { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin: 0 0 10px; font-size: var(--ui-body-size); font-weight: 650; }
.mh-exchange-section > h3 > span { color: var(--muted); font-size: var(--ui-label-size); font-weight: 400; }
.mh-exchange-rewards,
.mh-exchange-materials { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.mh-exchange-reward { display: flex; align-items: center; min-width: 0; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); background: var(--page); }
.mh-exchange-reward > strong { min-width: 0; color: var(--ink); font-size: var(--ui-body-size); font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; }
.gc-media.mh-exchange-image { width: 48px; height: 48px; flex: 0 0 48px; }
.mh-exchange-material-section { padding-top: 14px; border-top: 1px solid var(--border); }
.mh-exchange-material { display: flex; align-items: center; min-width: 0; gap: 10px; padding: 9px 10px; background: var(--page); }
.mh-exchange-material .mh-exchange-image { width: 42px; height: 48px; flex-basis: 42px; }
.mh-exchange-material-copy { display: grid; min-width: 0; gap: 5px; }
.mh-exchange-material-copy > strong { font-size: var(--ui-body-size); line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
.mh-exchange-material-price { color: var(--muted); font: 500 var(--ui-label-size)/1.4 var(--font-mono); font-variant-numeric: tabular-nums; }
.mh-exchange-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 12px; }
.mh-exchange-note { margin: 0; color: var(--muted); font-size: var(--ui-label-size); line-height: 1.6; }
.mh-exchange-footer > button { min-height: 44px; flex-shrink: 0; padding: 6px 0; color: var(--accent); font-size: var(--ui-label-size); }
.mh-exchange-empty { margin: 0; padding: 32px 0; color: var(--muted); font-size: var(--ui-body-size); line-height: 1.7; }

@media (min-width: 1800px) {
  .mh-exchange-reward { min-height: 74px; padding-block: 9px; }
  .gc-media.mh-exchange-image { width: 54px; height: 54px; flex-basis: 54px; }
}
@media (max-width: 1200px) {
  .mh-tools.mh-tools-strip { grid-template-columns: 120px minmax(0, 1fr); }
  .mh-tools-strip nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mh-tools-strip nav button { min-height: 54px; }
  .mh-tools-strip nav button:nth-child(n+4) { border-top: 1px solid var(--border); }
  .mh-tools-strip > h2 { font-size: 22px; }
  .mh-exchange { padding-inline: 16px; }
  .mh-exchange-reward { gap: 8px; padding: 9px; }
}
@media (max-width: 900px) {
  .mh-overview-grid.mh-overview-dual { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .mh-overview-dual > #home-exchange-block { order: -1; }
  .mh-hero.mh-hero-compact { gap: 16px; }
  .mh-hero-compact .mh-hero-copy h1 { font-size: clamp(42px, 6vw, 54px); }
  .mh-hero-compact .mh-hero-actions button,
  .mh-hero-compact .mh-hero-actions .mh-primary { flex: 1; min-width: 0; padding-inline: 10px; }
  .mh-hero-compact .mh-map-caption { inset: auto 10px 10px; }
}
@media (max-width: 600px) {
  .mh-hero.mh-hero-compact { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
  .mh-hero-compact .mh-hero-copy h1 { font-size: clamp(40px, 12vw, 48px); }
  .mh-hero-compact .mh-hero-copy > p { margin: 6px 0 10px; font-size: var(--ui-body-size); }
  .mh-hero-compact .mh-hero-actions { gap: 10px; }
  .mh-hero-compact .mh-hero-map { height: 88px; }
  .mh-hero-compact .mh-map-caption strong { font-size: 18px; }
  .mh-tools.mh-tools-strip { display: block; margin-bottom: 18px; }
  .mh-tools-strip > h2 { justify-content: flex-start; padding: 9px 12px; font-size: 22px; }
  .mh-tools-strip nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mh-tools-strip nav button { justify-content: flex-start; min-height: 56px; padding: 10px 12px; border: 0; }
  .mh-tools-strip nav button:nth-child(odd) { border-right: 1px solid var(--border); }
  .mh-tools-strip nav button:nth-child(n+3) { border-top: 1px solid var(--border); }
  .mh-exchange { padding: 14px 12px 10px; }
  .mh-exchange-header { gap: 8px; }
  .mh-exchange-header > .mh-exchange-status { padding: 4px 6px; font-size: var(--ui-meta-size); }
  .mh-exchange-section { margin-top: 14px; }
  .mh-exchange-section > h3 { margin-bottom: 8px; }
  .mh-exchange-reward { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; }
  .mh-exchange-reward > .gc-media.mh-exchange-image { width: 100%; height: 64px; flex-basis: 64px; background: var(--surface-raised); }
  .mh-exchange-reward > strong { font-size: var(--ui-body-size); }
  .mh-exchange-materials { grid-template-columns: minmax(0, 1fr); }
  .mh-exchange-material { gap: 12px; }
  .mh-exchange-material-copy { flex: 1; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  .mh-exchange-material-price { text-align: right; }
  .mh-exchange-material .mh-exchange-image { width: 40px; height: 44px; flex-basis: 40px; }
  .mh-exchange-footer { margin-top: 10px; gap: 4px; }
  .mh-exchange-footer > button { margin-left: auto; }
}

/* Published appearance settings select reviewed tokens, never arbitrary CSS. */
html[data-theme='dark'][data-site-accent='cyan'],
html[data-theme='dark'][data-site-accent='cyan'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --accent: #61e8ee; --accent-dark: #61e8ee; --accent-ink: #061113;
  --accent-border: #359fa5; --tint: #0d292b; --focus: #61e8ee;
}
html[data-theme='dark'][data-site-accent='amber'],
html[data-theme='dark'][data-site-accent='amber'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --accent: #f6c65c; --accent-dark: #f6c65c; --accent-ink: #171105;
  --accent-border: #ad8549; --tint: #30250f; --focus: #f6c65c;
}
html[data-theme='light'][data-site-accent='cyan'],
html[data-theme='light'][data-site-accent='cyan'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --accent: #096b73; --accent-dark: #07535a; --accent-ink: #fff;
  --accent-border: #408a90; --tint: #d7edef; --focus: #096b73;
}
html[data-theme='light'][data-site-accent='amber'],
html[data-theme='light'][data-site-accent='amber'] :is(.gc-gallery-detail, .en-collection-detail, .sim-paper, .mh-ammo) {
  --accent: #835500; --accent-dark: #624000; --accent-ink: #fff;
  --accent-border: #a17f44; --tint: #f0e4c9; --focus: #835500;
}
html[data-theme][data-site-density='large'] {
  --ui-body-size: 18px; --ui-label-size: 16px; --ui-meta-size: 14px;
  --ui-control-height: 48px; --ui-panel-space: 24px;
}
.site-announcement { margin: 0 0 20px; padding: 12px 16px; border: 1px solid var(--accent-border); background: var(--tint); color: var(--ink); font-size: var(--ui-body-size); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  html[data-theme][data-site-density='large'] { --ui-body-size: 17px; --ui-label-size: 15px; --ui-meta-size: 13px; --ui-panel-space: 18px; }
}
