/*
 * Preflight — AK portal / preserve the existing weapon workspace.
 * Surface      Dark                         Light
 * Page         #191b1f                      #f5f6f4
 * Panel        #22252b                      #ffffff
 * Border       #2d323a                      #e2e7e3
 * Text         #e8ecf0 / #a5aeb9             #172521 / #63736a
 * Accent       #69cba5                      #226451
 * Desktop      208px rail, 64px top bar, content up to 1664px.
 * Mobile       <=900px drawer; 64px bottom navigation + safe area.
 * Invariants   Real weapon imagery keeps its colours; no global inversion.
 * Load order   After styles.css and refinement.css. No data/logic changes.
 */

:root,
html[data-theme='dark'] {
  color-scheme: dark;
  --page: #191b1f;
  --surface: #22252b;
  --surface-raised: #292d34;
  --surface-hover: #2b3037;
  --surface-input: #1e2126;
  --ink: #e8ecf0;
  --muted: #a5aeb9;
  --faint: #7f8a98;
  --border: #2d323a;
  --border-strong: #404a55;
  --accent: #69cba5;
  --accent-dark: #8bdcba;
  --accent-ink: #12241b;
  --accent-border: #426c59;
  --tint: #24362f;
  --soft: #1e2126;
  --amber: #ddba7b;
  --blue: #8eb3d9;
  --purple: #c3a4de;
  --coral: #e69c88;
  --radius: 12px;
  --shadow: 0 3px 16px #00000012;
  --shadow-popover: 0 12px 36px #00000045;
  --scrim: #05080dc2;
  --focus: #69cba575;
  --toast-bg: #dbece4;
  --toast-ink: #163127;
  --series-1: #69cba5;
  --series-2: #ddba7b;
  --series-3: #8eb3d9;
  --sidebar-width: 208px;
  --topbar-height: 64px;
  --header-offset: 64px;
  --page-gutter: clamp(20px, 2.1vw, 36px);
  --content-width: 1664px;
  --mobile-nav-height: 0px;
  background: var(--page);
  color: var(--ink);
}

html[data-theme='light'] {
  color-scheme: light;
  --page: #f5f6f4;
  --surface: #ffffff;
  --surface-raised: #f5f7f5;
  --surface-hover: #eef3ef;
  --surface-input: #fcfdfc;
  --ink: #172521;
  --muted: #63736a;
  --faint: #7c8a81;
  --border: #e2e7e3;
  --border-strong: #c6d1c9;
  --accent: #226451;
  --accent-dark: #174b3d;
  --accent-ink: #ffffff;
  --accent-border: #acc8b8;
  --tint: #edf5ef;
  --soft: #f7f9f7;
  --amber: #956719;
  --blue: #376b9b;
  --purple: #81599d;
  --coral: #a65342;
  --shadow: 0 3px 16px #173c2905;
  --shadow-popover: 0 12px 36px #183c3020;
  --scrim: #101a2466;
  --focus: #22645155;
  --toast-bg: #183c30;
  --toast-ink: #ffffff;
  --series-1: #226451;
  --series-2: #a77a31;
  --series-3: #5a7fa7;
}

html { scroll-padding-top: calc(var(--topbar-height) + 16px); }
body { min-width: 0; background: var(--page); color: var(--ink); }
body, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
input, select, textarea { accent-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
input:focus, select:focus, .search-field:focus-within, .search-bar:focus-within {
  border-color: var(--accent-border);
  outline-color: var(--focus);
}
img { max-width: 100%; }
::selection { background: var(--accent); color: var(--accent-ink); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.skip-link { background: var(--surface); color: var(--accent); z-index: 120; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Fixed desktop rail; explicitly replaces the previous tablet header layout. */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  background: var(--surface);
  border: 0;
  border-right: 1px solid var(--border);
  overflow: auto;
  overscroll-behavior: contain;
  z-index: 50;
  backdrop-filter: none;
}
.sidebar-top {
  display: block;
  flex-shrink: 0;
  height: auto;
  margin: 0 0 14px;
  padding: 0 8px 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
}
.app-sidebar .brand { height: auto; min-height: 44px; gap: 8px; }
#drawer-close { display: none; }
@media (max-width: 900px) {
  #drawer-close { display: inline-flex; position: absolute; top: 16px; right: 8px; width: 44px; height: 44px; }
}
.app-sidebar .brand .brand-mark { display: block; flex: 0 0 32px; width: 32px; height: 36px; color: var(--accent); fill: currentColor; stroke: none; }
.app-sidebar .brand span { font-size: 22px; letter-spacing: 0; color: var(--ink); }
.app-sidebar .game-name {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 15px 0 0;
  font-size: 12px;
  white-space: normal;
}
.app-sidebar .game-name strong { font-size: 12px; font-weight: 600; }
.app-sidebar .game-name .game-mode {
  display: inline-flex;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--soft);
  font-size: 10px;
}
.app-sidebar .main-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  grid-template-columns: none;
  gap: 3px;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
}
.nav-group-title {
  color: var(--faint);
  margin: 20px 10px 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.5;
}
.nav-group-title:first-child { margin-top: 4px; }
.app-sidebar .main-nav button,
.sidebar-utilities button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  min-height: 42px;
  height: auto;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  white-space: normal;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.app-sidebar .main-nav button > span { min-width: 0; }
.app-sidebar .main-nav button svg,
.sidebar-utilities button svg { display: block; flex-shrink: 0; width: 18px; height: 18px; }
.main-nav .nav-icon, .mobile-nav .nav-icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.app-sidebar .main-nav button:hover,
.sidebar-utilities button:hover { background: var(--surface-hover); color: var(--ink); }
.app-sidebar .main-nav button.active,
.app-sidebar .main-nav button[aria-current='page'] {
  color: var(--accent);
  background: var(--tint);
  border-color: transparent;
  font-weight: 650;
}
.app-sidebar .main-nav button.active::before { content: none; }
.app-sidebar .count-badge { margin-left: auto; color: var(--accent-ink); }
.sidebar-utilities {
  position: static;
  inset: auto;
  display: grid;
  gap: 4px;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 20px;
}
.sidebar-utilities button { min-height: 42px; font-size: 12px; }
.sidebar-utilities button span { display: inline; }

/* Header and theme menu. The selected option is a two-choice radio item. */
.portal-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 var(--page-gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-label { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1; color: var(--ink); font-size: 14px; font-weight: 550; }
.topbar-label #section-label { padding-left: 16px; border-left: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 400; }
.topbar-label small { margin-left: 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.topbar-label strong { font-size: inherit; }
#menu-toggle { display: none; }
.theme-picker { position: relative; flex-shrink: 0; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 96px;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.theme-toggle:hover, .theme-toggle[aria-expanded='true'] {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--ink);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 65;
  display: grid;
  gap: 4px;
  width: 184px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
}
.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}
.theme-menu button svg { width: 18px; height: 18px; }
.theme-menu button:hover { background: var(--surface-hover); color: var(--ink); }
.theme-menu button[aria-checked='true'] { background: var(--tint); color: var(--accent); font-weight: 600; }
.theme-check { visibility: hidden; margin-left: auto; font-size: 16px; }
.theme-menu button[aria-checked='true'] .theme-check { visibility: visible; }
#nav-scrim { display: none; }
.mobile-nav { display: none; }

.app-main {
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  margin: 0 0 0 var(--sidebar-width);
  padding: calc(var(--topbar-height) + 28px) var(--page-gutter) 136px;
  min-height: 100vh;
  min-height: 100dvh;
}
body[data-page]:not([data-page='weapons']) .app-main { padding-bottom: 40px; }
.app-main > .hero, .app-main > #workspace,
.app-main > #portal-view, .app-main > .weapon-tabs {
  width: 100%;
  max-width: var(--content-width);
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
}
.hero { min-height: 0; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.hero h1 { font-size: 30px; letter-spacing: -0.7px; line-height: 1.3; margin: 0 0 7px; }
.hero p { max-width: none; font-size: 13px; line-height: 1.7; color: var(--muted); }
.preview-badge { color: var(--muted); border-color: var(--border); }
.weapon-tabs {
  display: flex;
  gap: 4px;
  align-items: stretch;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  margin: 0 0 18px;
  padding: 0 0 7px;
  border-bottom: 1px solid var(--border);
}
.weapon-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.weapon-tabs button:hover { background: var(--surface-hover); color: var(--ink); }
.weapon-tabs button.active, .weapon-tabs button[aria-current='page'] {
  background: var(--tint); color: var(--accent); font-weight: 650;
}
.weapon-tabs button svg { width: 17px; height: 17px; }
.weapon-tabs .count-badge { color: var(--accent-ink); }

/* Portal content: compact groupings and explicit destinations. */
#portal-view { display: grid; gap: 22px; }
.portal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  margin-bottom: 16px;
}
.portal-section-header > div { min-width: 0; }
.portal-section-header h2 { color: var(--ink); font-size: 18px; font-weight: 650; line-height: 1.45; }
.portal-section-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.portal-section-header > a, .portal-section-header > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
  min-height: 36px;
  padding: 5px 0 5px 8px;
  color: var(--accent);
  font-size: 12px;
}
.portal-section-header svg { width: 16px; height: 16px; }
.portal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.portal-grid > *, .portal-grid > * > * { min-width: 0; }
.portal-grid > aside, .portal-aside { display: grid; gap: 20px; }
.portal-panel {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.portal-panel + .portal-panel { margin-top: 0; }
.portal-panel h3 { color: var(--ink); font-size: 14px; font-weight: 650; }
.portal-panel > p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick-tool {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 76px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.quick-tool:hover { background: var(--surface-hover); border-color: var(--accent-border); color: var(--ink); text-decoration: none; }
.tool-icon {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 18px;
}
.tool-icon svg { width: 19px; height: 19px; }
.tool-copy { display: block; flex: 1; min-width: 0; }
.tool-copy strong { display: block; color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.5; }
.tool-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.tool-arrow { display: inline-flex; flex-shrink: 0; margin-left: auto; color: var(--faint); font-size: 16px; }
.tool-arrow svg { width: 15px; height: 15px; }
.daily-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.daily-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 82px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--soft);
  text-align: center;
}
.daily-cell strong { display: block; color: var(--accent); font-size: 23px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.daily-cell span { display: block; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
a.daily-cell { text-decoration: none; }
a.daily-cell strong { color: var(--ink); font-size: 14px; font-weight: 600; letter-spacing: 0; line-height: 1.5; }
a.daily-cell span { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; font-size: 10px; }
a.daily-cell svg { width: 12px; height: 12px; }
a.daily-cell:hover { background: var(--surface-hover); border-color: var(--accent-border); text-decoration: none; }
a.daily-cell:hover strong { color: var(--accent); }
.daily-cell[disabled] { opacity: 1; }
.daily-cell.is-pending strong { color: var(--faint); font-weight: 550; }
.portal-grid > aside .daily-grid, .portal-aside .daily-grid,
.portal-grid > .daily-panel .daily-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  text-decoration: none;
  width: 100%;
}
.link-row:last-child { border-bottom: 0; }
.link-row:hover { color: var(--accent); text-decoration: none; }
.link-row svg { width: 15px; height: 15px; color: var(--faint); }
.link-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.status-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.75;
}
.status-note svg { width: 14px; height: 14px; margin-top: 2px; }
.status-note a { text-decoration: underline; text-underline-offset: 3px; }
.tool-directory { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.tool-category { min-width: 0; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tool-category h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; font-weight: 650; }
.tool-category > h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 9px; font-size: 15px; font-weight: 650; }
.tool-category > h2 .tool-icon { width: 29px; height: 29px; flex-basis: 29px; border: 0; background: transparent; }
.tool-category > h2 .tool-icon svg { width: 18px; height: 18px; }
.category-count { margin-left: auto; color: var(--faint); font-size: 11px; font-weight: 400; }
.tool-category h3 svg { width: 17px; height: 17px; color: var(--accent); }
.tool-category ul, .tool-category ol { list-style: none; padding: 0; margin: 0; }
.tool-category li { margin: 0; padding: 0; min-width: 0; }
.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  font-size: 13px;
}
.tool-category > .tool-row:last-child, .tool-category > div > .tool-row:last-child,
.tool-category li:last-child .tool-row { border-bottom: 0; }
.tool-row:hover { color: var(--accent); text-decoration: none; }
.tool-row > div, .tool-row > span:first-child { min-width: 0; }
.tool-row strong, .tool-row .tool-name { font-weight: 550; overflow-wrap: anywhere; }
.tool-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.65; overflow-wrap: anywhere; }
.tool-row > .tool-meta { flex: 1; margin-top: 0; }
.tool-meta strong { display: block; color: var(--ink); font-size: 13px; }
.tool-meta small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.tool-row:hover .tool-meta strong { color: var(--accent); }
.tool-row > svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--faint); }
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 2px 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 450;
  line-height: 1.5;
  white-space: nowrap;
}
.tag.active, .tag.is-ready, .tag.tag-native { color: var(--accent); border-color: var(--accent-border); background: var(--tint); }
.category-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.category-intro h2 { margin-bottom: 7px; color: var(--ink); font-size: 20px; }
.category-intro p { margin: 0; }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feature-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  min-height: 188px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.feature-card > .tool-icon { margin-bottom: 15px; }
.feature-card h2 { color: var(--ink); font-size: 17px; font-weight: 650; line-height: 1.45; }
.feature-card p { margin: 9px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.feature-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; margin-top: auto; padding-top: 5px; }
.feature-footer a, .feature-footer button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 0; color: var(--accent); font-size: 12px; font-weight: 550; }
.feature-footer svg { width: 15px; height: 15px; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 46px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.search-bar input { min-width: 0; width: 100%; border: 0; outline: 0; padding: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-bar input:focus-visible { outline: 0; }
.search-bar svg { flex-shrink: 0; width: 18px; height: 18px; }
.search-empty { grid-column: 1 / -1; padding: 42px 18px; color: var(--muted); font-size: 13px; text-align: center; }
.search-empty h3 { color: var(--ink); margin: 0 0 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { min-width: 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.stat strong { display: block; color: var(--ink); font-size: 25px; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.home-feature {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  min-width: 0;
  min-height: 210px;
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.home-feature > div { position: relative; z-index: 1; min-width: 0; }
.home-feature .portal-section-header { margin-bottom: 0; }
.home-feature h2 { margin: 0; font-size: 18px; letter-spacing: -0.3px; line-height: 1.45; }
.home-feature p { max-width: 530px; margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.home-feature .primary-button { min-height: 40px; }
.home-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--ink); background: var(--surface); font-size: 12px; font-weight: 550; }
.secondary-button:hover { border-color: var(--accent-border); background: var(--surface-hover); color: var(--accent); }
.home-weapon-image { display: block; flex: 0 1 38%; width: 38%; max-width: 340px; height: 150px; margin-left: auto; object-fit: contain; }
.portal-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-top: 0; padding: 16px 0 0; border-top: 1px solid var(--border); color: var(--faint); font-size: 11px; line-height: 1.75; }
.portal-footer p { margin: 0; }
.portal-footer a { color: var(--muted); }

/* Legacy surfaces: all fixed light colours receive a theme-aware equivalent. */
html[data-theme] .workspace[data-view='ranking'],
html[data-theme] .filter-panel, html[data-theme] .table-panel,
html[data-theme] .white-panel, html[data-theme] .variant-item,
html[data-theme] .condition-preset, html[data-theme] .dialog-header,
html[data-theme] .tray-inner, html[data-theme] dialog {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
html[data-theme] .filter-field { border-color: var(--border); }
html[data-theme] select {
  background-color: var(--surface-input);
  border-color: var(--border-strong);
  color: var(--ink);
  background-image: none;
}
html[data-theme] select option { background: var(--surface); color: var(--ink); }
html[data-theme] .search-field { background: var(--surface-input); border-color: var(--border-strong); color: var(--muted); }
html[data-theme] .search-field input { background: transparent; color: var(--ink); }
html[data-theme] .ranking-table th, html[data-theme] .analysis-table th,
html[data-theme] .facts-table th { background: var(--soft); color: var(--muted); border-color: var(--border); }
html[data-theme] .ranking-table td, html[data-theme] .analysis-table td,
html[data-theme] .facts-table td { border-color: var(--border); }
html[data-theme] .ranking-table thead th { box-shadow: inset 0 -1px var(--border); }
html[data-theme] .weapon-row.is-leading { background: var(--tint); }
html[data-theme] .weapon-row:hover { background: var(--surface-hover); }
html[data-theme] .expanded-row td { background: var(--soft); }
html[data-theme] .sort-button, html[data-theme] .bullet-name,
html[data-theme] .analysis-details summary { color: var(--ink); }
html[data-theme] .filter-field > span,
html[data-theme] .rank-number, html[data-theme] .weapon-sub,
html[data-theme] .ms-label, html[data-theme] .icon-button,
html[data-theme] .table-footer > .text-button,
html[data-theme] .page-footnote, html[data-theme] .page-footnote button,
html[data-theme] .tray-help, html[data-theme] .tray-empty,
html[data-theme] .analysis-kpis .tiny, html[data-theme] .preview-badge,
html[data-theme] .selection-chip button { color: var(--muted); }
html[data-theme] .condition-summary .dot,
html[data-theme] .preset-tag::after, html[data-theme] .info-icon { color: var(--faint); }
html[data-theme] .weapon-row.is-leading .rank-number,
html[data-theme] .weapon-row.is-leading .ttk-value,
html[data-theme] .analysis-kpis > div:first-child strong { color: var(--accent); }
html[data-theme] .outline-button {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent-border);
}
html[data-theme] .outline-button:hover,
html[data-theme] .outline-button.selected,
html[data-theme] .condition-preset.selected { background: var(--tint); color: var(--accent); border-color: var(--accent-border); }
html[data-theme] .icon-button:hover { background: var(--surface-hover); }
html[data-theme] .primary-button { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
html[data-theme] .primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--accent-ink); }
html[data-theme] .selection-chip { border-color: var(--border); background: var(--soft); color: var(--ink); }
html[data-theme] .empty-mark { background: var(--tint); color: var(--accent); }
html[data-theme] .spinner { border-color: var(--border-strong); border-top-color: var(--accent); }
html[data-theme] .distribution-track { background: var(--surface-raised); }
html[data-theme] .distribution-track > span { background: var(--accent-border); }
html[data-theme] .distribution-row.likely .distribution-track > span { background: var(--accent); }
html[data-theme] .detail-grid > div { background: var(--soft); }
html[data-theme] .dialog-notice { background: var(--tint); color: var(--muted); }
html[data-theme] .preset-tag { background: transparent; color: var(--muted); }
html[data-theme] .preset-tag:hover { background: transparent; color: var(--accent); }
html[data-theme] .mobile-sort-button { background: var(--surface); border-color: var(--border); color: var(--accent); }
html[data-theme] .bullet-level { color: var(--purple); }
html[data-theme] .bullet-level::before { background: var(--purple); }
html[data-theme] .bullet-level.level-3 { color: var(--blue); }
html[data-theme] .bullet-level.level-3::before { background: var(--blue); }
html[data-theme] .bullet-level.level-5 { color: var(--amber); }
html[data-theme] .bullet-level.level-5::before { background: var(--amber); }
html[data-theme] .bullet-level.level-6 { color: var(--coral); }
html[data-theme] .bullet-level.level-6::before { background: var(--coral); }

/* SVG presentation attributes and the original inline series colours. */
.ttk-chart text { fill: var(--muted); }
.ttk-chart [stroke='#e8eeea'] { stroke: var(--border); }
.ttk-chart [stroke='#96ad9f'] { stroke: var(--faint); }
.ttk-chart [stroke='white'] { stroke: var(--surface); }
.ttk-chart [stroke='#226451'] { stroke: var(--series-1); }
.ttk-chart [stroke='#bb8839'] { stroke: var(--series-2); }
.ttk-chart [stroke='#5a7fa7'] { stroke: var(--series-3); }
.ttk-chart [fill='#226451'] { fill: var(--series-1); }
.ttk-chart [fill='#bb8839'] { fill: var(--series-2); }
.ttk-chart [fill='#5a7fa7'] { fill: var(--series-3); }
.compare-card .large-ttk[style*='#226451'] { color: var(--series-1) !important; }
.compare-card .large-ttk[style*='#bb8839'] { color: var(--series-2) !important; }
.compare-card .large-ttk[style*='#5a7fa7'] { color: var(--series-3) !important; }
.series-dot[style*='#226451'] { background: var(--series-1) !important; }
.series-dot[style*='#bb8839'] { background: var(--series-2) !important; }
.series-dot[style*='#5a7fa7'] { background: var(--series-3) !important; }
.ranking-table-wrap, .analysis-content, .chart-container { min-width: 0; }
.analysis-table, .facts-table { max-width: 100%; }
.facts-table { table-layout: fixed; }
.facts-table th, .facts-table td { overflow-wrap: anywhere; }
.library-row > div { min-width: 0; }
.library-row strong, .library-row small { overflow-wrap: anywhere; }
.library-actions { flex-wrap: wrap; }
.library-list { overscroll-behavior: contain; background: var(--surface); }

/* Compare tray stays above mobile navigation; native dialogs use the top layer. */
.comparison-tray {
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  padding: 0 var(--page-gutter) 16px;
  background: none;
  z-index: 30;
}
.tray-inner { max-width: var(--content-width); margin: 0 auto; box-shadow: var(--shadow-popover); }
.selected-tray { min-width: 0; flex-wrap: wrap; white-space: normal; }
html[data-theme] dialog {
  width: 760px;
  max-width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  border-radius: 12px;
  box-shadow: var(--shadow-popover);
}
html[data-theme] dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.dialog-body { min-width: 0; overscroll-behavior: contain; }
.dialog-header .icon-button { width: 44px; height: 44px; min-height: 44px; }
.dialog-header h2 { min-width: 0; overflow-wrap: anywhere; }
#toast {
  left: calc(50% + var(--sidebar-width) / 2);
  bottom: 104px;
  width: max-content;
  max-width: min(440px, calc(100vw - var(--sidebar-width) - 32px));
  background: var(--toast-bg);
  color: var(--toast-ink);
  border: 1px solid var(--accent-border);
  box-shadow: var(--shadow-popover);
  z-index: 110;
}

@media (min-width: 901px) {
  .ranking-table thead th { top: var(--topbar-height); }
  .app-main { padding-bottom: 136px; }
  .table-tools { min-width: 0; }
  .comparison-tray .tray-inner > p { white-space: normal; }
}

@media (min-width: 1600px) {
  :root { --sidebar-width: 208px; --page-gutter: 36px; }
  .app-main { padding-top: calc(var(--topbar-height) + 30px); }
  .portal-grid { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1200px) {
  :root { --sidebar-width: 208px; --page-gutter: 20px; --header-offset: 64px; }
  .portal-grid { grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; }
  .portal-panel { padding: 17px; }
  .quick-grid, .category-grid, .tool-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-feature { padding: 20px; gap: 15px; }
  .home-feature h2 { font-size: 23px; }
  .home-weapon-image { flex-basis: 32%; width: 32%; height: 120px; }
  .table-toolbar { flex-wrap: wrap; gap: 12px; }
  .table-tools { flex: 1 1 360px; }
  .table-tools .search-field { flex: 1; width: auto; max-width: none; min-width: 0; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .filter-field { border: 0; padding-right: 0; }
  .more-button { grid-column: 1 / -1; grid-row: auto; justify-self: end; margin: 0; }
  .condition-summary { margin-top: 10px; width: 100%; gap: 7px; }
  .ranking-table-wrap { overflow-x: auto; overscroll-behavior-inline: contain; }
  .ranking-table { min-width: 700px; }
  .analysis-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 16px; }
  .analysis-kpis { gap: 12px; padding: 17px; }
  .analysis-kpis strong { font-size: 25px; }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; --page-gutter: 20px; --header-offset: 64px; --mobile-nav-height: 64px; }
  body.menu-open { overflow: hidden; }
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 256px;
    max-width: calc(100vw - 48px);
    height: 100vh;
    height: 100dvh;
    padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
    display: flex;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 90;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 180ms ease;
  }
  body.menu-open .app-sidebar { transform: translateX(0); visibility: visible; }
  .app-sidebar .main-nav button { min-height: 44px; }
  .sidebar-top { height: auto; display: block; padding: 0 8px 17px; }
  .app-sidebar .game-name { margin: 14px 0 0; }
  .app-sidebar .main-nav button svg { display: block; }
  .sidebar-utilities { position: static; inset: auto; display: grid; padding-top: 20px; margin-top: auto; }
  .sidebar-utilities button { width: 100%; height: auto; min-height: 44px; justify-content: flex-start; padding: 9px 12px; }
  .sidebar-utilities button span { display: inline; }
  #nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 180ms ease, visibility 180ms ease;
  }
  body.menu-open #nav-scrim { opacity: 1; visibility: visible; pointer-events: auto; }
  .portal-topbar { left: 0; padding: 0 16px 0 10px; gap: 9px; }
  #menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height: 44px; padding: 10px; border-radius: 7px; color: var(--ink); }
  #menu-toggle:hover { background: var(--surface-hover); }
  #menu-toggle svg { width: 21px; height: 21px; }
  .topbar-label { font-size: 14px; }
  .topbar-label small { display: none; }
  .topbar-label #section-label { display: none; }
  .theme-toggle { min-height: 44px; min-width: 86px; }
  .app-main { width: 100%; margin: 0; padding: calc(var(--topbar-height) + 22px) var(--page-gutter) calc(230px + env(safe-area-inset-bottom)); }
  body[data-page]:not([data-page='weapons']) .app-main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .hero { min-height: 0; margin-bottom: 18px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 13px; max-width: none; }
  .portal-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .portal-grid > aside, .portal-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .portal-grid > aside .daily-grid, .portal-aside .daily-grid,
  .portal-grid > .daily-panel .daily-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portal-section-header > button, .portal-section-header > a,
  .feature-footer a, .feature-footer button,
  .home-actions > button, .secondary-button { min-height: 44px; }
  .weapon-tabs { gap: 3px; margin-bottom: 16px; }
  .weapon-tabs button { min-height: 44px; padding: 9px 12px; }
  .comparison-tray { left: 0; bottom: calc(64px + env(safe-area-inset-bottom)); padding: 0 12px 10px; }
  .tray-inner { min-height: 58px; padding: 10px 13px; gap: 9px; }
  .tray-inner > p { white-space: normal; }
  .selected-tray .primary-button { min-height: 44px; font-size: 12px; }
  .selection-chip button { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 36px; }
  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 48px;
    padding: 5px 2px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
  }
  .mobile-nav button svg { width: 21px; height: 21px; }
  .mobile-nav button.active, .mobile-nav button[aria-current='page'] { color: var(--accent); background: var(--tint); font-weight: 650; }
  #toast { left: 50%; max-width: calc(100vw - 28px); bottom: calc(214px + env(safe-area-inset-bottom)); }
  html[data-theme] dialog { max-height: calc(100dvh - 32px - env(safe-area-inset-bottom)); }
  .dialog-header { padding: 12px 17px; }
  .dialog-body { padding: 16px 18px 22px; }
  .library-search, .sub-tabs button { min-height: 44px; }
  .library-search input { font-size: 16px; }
}

@media (max-width: 760px) {
  .ranking-table { min-width: 0; }
  .table-toolbar { display: block; }
  .table-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .table-tools .search-field { width: 100%; min-width: 0; max-width: none; height: 44px; }
  .filter-field select, .table-tools select, .mobile-sort-button { min-height: 44px; }
  .condition-summary { margin-top: 10px; width: 100%; font-size: 11px; }
  .table-tools .search-field input { font-size: 16px; }
  .ranking-table .weapon-row { grid-template-columns: 22px minmax(0, 1fr) 80px; gap: 3px 6px; padding-inline: 11px; }
  .weapon-name { font-size: 13px; }
  .weapon-row .ammo-cell { margin-left: 58px; }
  .weapon-sub { font-size: 10px; }
  .weapon-picture { width: 50px; height: 40px; }
  .weapon-row .time-cell .ttk-value { font-size: 20px; }
  .row-actions .outline-button, .variant-actions .outline-button,
  .variant-actions .text-button, .library-row .text-button,
  .table-footer .text-button, .table-footer #group-mode { min-height: 44px; }
  .row-actions .icon-button, .compare-card .icon-button { width: 44px; height: 44px; }
  .analysis-layout { display: block; }
  .analysis-side { margin-bottom: 16px; }
  .analysis-kpis { grid-template-columns: 1.15fr 1fr 1fr; gap: 10px; padding: 17px 13px; }
  .analysis-kpis strong { font-size: 24px; }
  .analysis-kpis > div > span { font-size: 11px; }
  .analysis-kpis strong small { font-size: 12px; }
  .analysis-table th, .analysis-table td { padding: 10px 8px; overflow-wrap: anywhere; }
  .analysis-table { table-layout: fixed; font-size: 11px; }
  .chart-container { overflow-x: auto; overscroll-behavior-inline: contain; }
  .ttk-chart { min-width: 540px; }
  .tray-inner { flex-wrap: wrap; }
  .tray-inner > p { order: 2; flex-basis: 100%; margin: 0; font-size: 10px; }
  .selected-tray { width: 100%; flex-wrap: wrap; gap: 6px; }
  .selected-tray .primary-button { margin-left: auto; min-width: 100px; }
  .selection-chip { max-width: 112px; min-height: 36px; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .portal-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  :root { --page-gutter: 14px; }
  .app-main { padding-top: calc(var(--topbar-height) + 18px); }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 12px; }
  #portal-view { gap: 18px; }
  .portal-panel, .tool-category, .feature-card { padding: 16px; }
  .portal-section-header { gap: 9px; margin-bottom: 13px; }
  .portal-section-header h2 { font-size: 16px; }
  .portal-section-header p { font-size: 11px; }
  .portal-section-header > a, .portal-section-header > button { font-size: 11px; }
  .quick-grid, .category-grid, .tool-directory,
  .portal-grid > aside, .portal-aside { grid-template-columns: minmax(0, 1fr); }
  .quick-grid { gap: 8px; }
  .quick-tool { min-height: 68px; padding: 12px; }
  .tool-copy strong { font-size: 13px; }
  .tool-copy small { font-size: 11px; }
  .daily-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .daily-cell { min-height: 76px; padding: 10px 6px; }
  .daily-cell strong { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat { padding: 13px 14px; }
  .stat strong { font-size: 23px; }
  .feature-card { min-height: 166px; }
  .feature-card h2 { font-size: 17px; }
  .feature-card p { font-size: 12px; }
  .search-bar input { font-size: 16px; }
  .home-feature { flex-direction: column; align-items: stretch; gap: 16px; min-height: 0; padding: 19px; }
  .home-feature h2 { font-size: 18px; }
  .home-feature p { font-size: 12px; }
  .home-weapon-image { flex-basis: auto; width: 100%; max-width: 250px; height: 100px; margin: 4px auto 0; }
  .portal-footer { flex-direction: column; gap: 8px; font-size: 10px; }
  .weapon-tabs { justify-content: flex-start; gap: 0; }
  .weapon-tabs button { flex: 1 0 auto; gap: 5px; padding-inline: 8px; font-size: 12px; }
  .weapon-tabs button svg { width: 15px; height: 15px; }
  .compare-card { padding: 17px; }
  .compare-card h2 { font-size: 19px; }
  .library-entry { flex-direction: column; padding: 17px; }
  .library-actions { gap: 7px; justify-content: flex-start; width: 100%; }
  .library-actions .outline-button { min-height: 44px; flex: 1; }
  .library-row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
  .library-row img { width: 48px; height: 38px; }
  .library-row.simple-row { grid-template-columns: minmax(0, 1fr) auto; }
  .library-row strong { font-size: 12px; }
  .library-row .text-button { padding-inline: 5px; font-size: 11px; }
  .detail-grid { gap: 9px; }
  .detail-grid > div { padding: 11px; }
  .detail-grid strong { font-size: 16px; }
  .condition-presets { grid-template-columns: minmax(0, 1fr); }
  .condition-preset { min-height: 58px; }
  .control-line { flex-wrap: wrap; gap: 12px; }
  .control-line input[type='range'] { flex: 1; min-width: 100px; }
  .source-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-facts > div { border-bottom: 1px solid var(--border); }
  .source-facts > div:nth-child(2n) { border-right: 0; }
  .source-facts > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .distribution-list { padding: 15px 12px; }
  .distribution-row { grid-template-columns: 34px minmax(0, 1fr) 46px 56px; gap: 7px; font-size: 11px; }
  .dialog-header h2 { font-size: 17px; }
  html[data-theme] dialog { max-width: calc(100vw - 20px); }
  .dialog-body { padding-inline: 13px; }
  .sub-tabs { gap: 0; overflow-x: auto; }
  .sub-tabs button { flex-shrink: 0; padding-inline: 8px; font-size: 12px; }
}

@media (max-width: 360px) {
  :root { --page-gutter: 10px; }
  .portal-topbar { padding-right: 10px; gap: 5px; }
  .topbar-label { font-size: 13px; }
  .theme-toggle { min-width: 76px; gap: 5px; padding-inline: 8px; font-size: 11px; }
  .hero h1 { font-size: 24px; }
  .portal-panel, .feature-card, .tool-category { padding: 13px; }
  .portal-section-header > a, .portal-section-header > button { max-width: 86px; white-space: normal; text-align: right; }
  .weapon-tabs button { padding-inline: 6px; font-size: 11px; }
  .weapon-tabs button svg { display: none; }
  .ranking-table .weapon-row { grid-template-columns: 19px minmax(0, 1fr) 72px; gap: 3px 5px; padding-inline: 9px; }
  .weapon-picture { width: 42px; }
  .weapon-row .ammo-cell { margin-left: 50px; }
  .weapon-row .time-cell .ttk-value { font-size: 18px; }
  .analysis-kpis strong { font-size: 21px; }
  .table-tools { grid-template-columns: minmax(0, 1fr) auto; }
  .mobile-sort-button { font-size: 11px; padding-inline: 8px; gap: 4px; }
  .daily-cell span { font-size: 10px; }
  .daily-cell strong { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar, #nav-scrim, .quick-tool, #toast { transition: none; }
  html { scroll-behavior: auto; }
}

/* Keep actions readable without decorative direction icons. */
#theme-toggle > svg:last-child,
.more-button > svg, #show-more > svg, #mobile-sort-order > svg, #sort-order > svg,
.text-button[data-nav] > svg, .text-button[data-open-analysis] > svg,
.text-button[data-detail-type] > svg, .text-button[data-library] > svg,
.row-actions .icon-button[data-expand] > svg,
.row-actions .icon-button[data-open-analysis] > svg { display:none; }
.row-actions .icon-button[data-expand],
.row-actions .icon-button[data-open-analysis] { min-width:44px; min-height:44px; padding:7px 5px; font-size:12px; }
.row-actions .icon-button[data-expand]::before { content:'配置'; }
.row-actions .icon-button[data-expand][aria-expanded='true']::before { content:'收起'; }
.row-actions .icon-button[data-open-analysis]::before { content:'分析'; }
#sort-order { flex-wrap:wrap; gap:4px; }
#time-heading[aria-sort='ascending'] #sort-order::after { content:'快到慢'; font-size:10px; }
#time-heading[aria-sort='descending'] #sort-order::after { content:'慢到快'; font-size:10px; }
