*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Colour tokens (dark mode default — sci-fi cyan) ──
   The previous amber palette is preserved as the .container.scifi block at
   the bottom of this file was inverted: the cyan palette is now the global
   default, while body.light below provides a paler cyan/navy variant for
   the light theme. */
:root {
  /* Tells the browser to render native form-control chrome (date / time
     picker icons, <select> arrows, scrollbars) in dark mode so they read
     against the cyan panel. Without this they default to the black-on-
     white icons baked into the OS and basically disappear against #050912. */
  color-scheme: dark;

  --bg:            #050912;
  --bg-inset:      #0a1424;
  --border:        rgba(93, 217, 255, 0.22);
  --border-subtle: rgba(93, 217, 255, 0.10);
  --text:          #cfeaff;
  --text-muted:    #88b8d8;
  --text-dim:      #5d8cae;
  --text-faint:    #3a607a;
  --accent:        #5dd9ff;
  --accent-hover:  #8ee9ff;
  --accent-press:  #2fb8e0;
  --placeholder:   #2a4866;
  --hint:          #3a607a;

  --summary-color:         #5d8cae;
  --chevron-color:         #5dd9ff;
  --group-header-color:    #4a7d9c;
  --section-heading-color: #5dd9ff;
  --sep-color:             rgba(93, 217, 255, 0.25);

  --faction-btn-color:        #88b8d8;
  --faction-btn-border:       rgba(93, 217, 255, 0.18);
  --faction-btn-hover-color:  #cfeaff;
  --faction-btn-hover-border: rgba(93, 217, 255, 0.6);
  --faction-btn-hover-bg:     rgba(93, 217, 255, 0.05);
  --faction-btn-active-color: #5dd9ff;
  --faction-btn-active-border: #5dd9ff;
  --faction-btn-active-bg:    rgba(93, 217, 255, 0.10);

  /* Wahapedia link colour: magenta sits opposite the cyan main palette. */
  --waha-color:        #ff6acd;
  --waha-border:       rgba(255, 106, 205, 0.35);
  --waha-hover-color:  #ff8ddb;
  --waha-hover-border: #ff6acd;
  --waha-hover-bg:     rgba(255, 106, 205, 0.08);

  --footer-color:      #3a607a;
  --footer-link-color: #88b8d8;
  --footer-link-hover: #cfeaff;
  --no-units-color:    #5d8cae;

  --toggle-bg:          rgba(93, 217, 255, 0.06);
  --toggle-border:      rgba(93, 217, 255, 0.25);
  --toggle-color:       #88b8d8;
  --toggle-hover-bg:    rgba(93, 217, 255, 0.12);
  --toggle-hover-color: #cfeaff;
}

/* ── Light mode overrides (light sci-fi: pale-cyan/navy) ── */
body.light {
  /* Light-mode counterpart — restore the OS's light-mode form-control chrome. */
  color-scheme: light;

  --bg:            #eaf3f8;
  --bg-inset:      #f7fbfd;
  --border:        #b9d3df;
  --border-subtle: #d7e6ee;
  --text:          #0a1a26;
  --text-muted:    #2f4d63;
  --text-dim:      #547089;
  --text-faint:    #8aa2b6;
  --accent:        #117ea8;
  --accent-hover:  #1494c4;
  --accent-press:  #0b6286;
  --placeholder:   #a8bccb;
  --hint:          #8aa2b6;

  --summary-color:         #547089;
  --chevron-color:         #117ea8;
  --group-header-color:    #6c8499;
  --section-heading-color: #117ea8;
  --sep-color:             #b9d3df;

  --faction-btn-color:        #2f4d63;
  --faction-btn-border:       #cadce6;
  --faction-btn-hover-color:  #0a1a26;
  --faction-btn-hover-border: #117ea8;
  --faction-btn-hover-bg:     #dceaf2;
  --faction-btn-active-color: #117ea8;
  --faction-btn-active-border:#117ea8;
  --faction-btn-active-bg:    #cfe6f2;

  --waha-color:        #b81f8a;
  --waha-border:       #e0b3d2;
  --waha-hover-color:  #8e186b;
  --waha-hover-border: #b81f8a;
  --waha-hover-bg:     #f9e4ef;

  --footer-color:      #8aa2b6;
  --footer-link-color: #547089;
  --footer-link-hover: #0a1a26;
  --no-units-color:    #8aa2b6;

  --toggle-bg:          #dceaf2;
  --toggle-border:      #b9d3df;
  --toggle-color:       #2f4d63;
  --toggle-hover-bg:    #cfe1ec;
  --toggle-hover-color: #0a1a26;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 30px 20px;
  overflow-x: hidden;   /* nothing should ever force a sideways scroll */
  transition: background 0.2s, color 0.2s;
}

/* Site-wide contact footer (rendered by MainLayout under every page). */
.app-footer {
  text-align: center;
  padding: 16px;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--text-faint);
}
.app-footer-label { margin-right: 4px; }
.app-footer a {
  color: var(--accent);
  text-decoration: none;
  margin: 0 6px;
  font-weight: 600;
}
.app-footer a:hover { color: var(--accent-hover); text-decoration: underline; }

.container {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Shared app navigation bar ── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin: -30px -20px 18px;
  padding: 0 20px;
}
.app-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;        /* wrap to a 2nd row rather than overflow sideways */
  gap: 8px;
  min-height: 52px;
}
.app-nav-tabs {
  display: flex;
  gap: 4px;
  align-items: stretch;
  flex-wrap: wrap;
}

.app-nav-hamburger {
  display: none;    /* desktop: tabs are inline, no hamburger needed */
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.app-nav-hamburger:hover { background: var(--toggle-hover-bg); color: var(--toggle-hover-color); }
.app-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.app-nav-link:hover { background: var(--bg-inset); color: var(--text); }
.app-nav-link.active {
  background: var(--accent);
  color: #1e1e2e;
}
body.light .app-nav-link.active { background: #7c3aed; color: #fff; }

/* Disabled teaser tab — not a link, can't be clicked or focused. */
.app-nav-link-soon {
  cursor: default;
  opacity: 0.55;
  font-style: italic;
  gap: 6px;
}
.app-nav-link-soon:hover { background: none; color: var(--text-muted); }
.app-nav-soon-badge {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #1e1e2e;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.app-nav-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.app-nav-ext   { display: inline-flex; align-items: center; line-height: 0; }
.app-nav-ext img { height: 45px; width: auto; border: 0; display: block; }
.app-nav-theme {
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
}
.app-nav-theme:hover { background: var(--toggle-hover-bg); color: var(--toggle-hover-color); }

.app-nav-subscribe {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: filter 0.15s ease;
}
.app-nav-subscribe:hover { filter: brightness(1.1); }

/* Save buttons shown to non-subscribers as a conversion teaser — the star
   signals it's a premium action; clicking routes to the plans page. */
.save-locked {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.save-locked:hover {
  background: var(--accent) !important;
  color: #1e1e2e !important;
}

/* Page-specific action buttons next to the hamburger (Map Builder's Build Menu /
   Lists / Undo on mobile). Hidden until the nav is in hamburger mode. */
.app-nav-actions { display: none; gap: 6px; align-items: center; margin-right: auto; }
.app-nav-action {
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text);
  font: 600 11px/1 system-ui, sans-serif;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.app-nav-action:hover { background: var(--accent); color: var(--bg); }

/* Collapse the tab strip into a hamburger dropdown early — the tab list +
   account menu + Subscribe + theme toggle crowd (and wrap) the bar well before
   phone widths, wasting vertical space. Also collapse on short/landscape-phone
   screens (e.g. 932×430) where a full nav row eats scarce vertical space. Kept in
   step with the Map Builder's drawer breakpoint so its action buttons appear
   exactly when its panels collapse. */
@media (max-width: 960px), (max-height: 540px) {
  .app-nav-actions { display: flex; }
  .app-nav-hamburger {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 1.2rem;
  }
  .app-nav-inner     { position: relative; }
  .app-nav-tabs {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 101;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    padding: 8px 10px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  }
  .app-nav-tabs.open { display: flex; }
  .app-nav-link      { padding: 8px 12px; font-size: 0.9rem; }
}

@media (max-width: 600px) {
  .app-nav { margin: -16px -10px 14px; padding: 0 10px; }
  .app-nav-ext img { height: 45px; }
}

/* Full-screen mode (toggled by the Map Builder button): hide our chrome so the
   page gets the whole viewport, on top of the browser's own fullscreen. */
body.app-fullscreen { padding: 0; }
body.app-fullscreen .app-nav,
body.app-fullscreen .app-footer { display: none; }
body.app-fullscreen .mb-layout { top: 0; }

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

h1 {
  color: var(--accent);
  font-size: 1.8rem;
  letter-spacing: 1px;
}

h1 a.title-link {
  color: inherit;
  text-decoration: none;
}

h1 a.title-link:hover {
  text-decoration: underline;
}


.theme-toggle {
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.theme-toggle:hover {
  background: var(--toggle-hover-bg);
  color: var(--toggle-hover-color);
}

.top-bar-right {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  body { padding: 16px 10px; }

  h1 { font-size: 1.4rem; }

  .top-bar-right {
    gap: 6px;
  }

  .output-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* Mobile unit row: unit name leads, then Attach / Wahapedia / Datasheet
     follow inline. Drop the dash separator and shrink the enhancement chips
     to their initials so the controls all stay on one row. */
  .unit-row { gap: 4px 6px; }
  .unit-row .unit-name        { order: -1; }
  .unit-row .stats-btn        { width: auto; }
  .unit-row .sep              { display: none; }
  /* Enhancement chips: full text kept in DOM for screen readers and the
     hover/long-press tooltip; visually show the initials only. View Mode
     frees up the row so we can show the full name again. */
  .unit-row .unit-enhancement          { font-size: 0; }
  .unit-row .unit-enhancement::before  { content: attr(data-initials); font-size: 0.72rem; }
  .output-section.view-mode .unit-row .unit-enhancement         { font-size: 0.72rem; }
  .output-section.view-mode .unit-row .unit-enhancement::before { content: none; }
  /* Same trick for the Wahapedia link → "WH". */
  .unit-row .link-waha          { font-size: 0; }
  .unit-row .link-waha::before  { content: "WH"; font-size: 0.82rem; }

  .datasheet { font-size: 0.78rem; }

  .ds-table { font-size: 0.76rem; }

  .ds-section { padding: 8px 10px; }
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ── Examples ── */
.examples-section {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.examples-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.examples-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.example-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  letter-spacing: 0;
}

.example-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: none;
}

/* ── Input ── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

label {
  font-size: 0.88rem;
  color: var(--text-muted);
}

textarea {
  width: 100%;
  height: 280px;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 0.83rem;
  font-family: 'Consolas', 'Courier New', monospace;
  resize: vertical;
  line-height: 1.55;
  transition: border-color 0.15s, height 0.2s, background 0.2s, color 0.2s;
}

textarea.expanded {
  height: auto;
  min-height: 280px;
  overflow-y: hidden;
}

.expand-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 4px 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.expand-btn:hover {
  background: var(--bg-inset);
  color: var(--text);
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea::placeholder { color: var(--placeholder); }

.btn-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.details-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  margin-left: auto;
}

.details-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Details view ── */
.details-view {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}

.detail-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-section-line {
  color: var(--accent);
  font-weight: 700;
  margin-top: 10px;
}

.detail-unit-line { color: var(--text); }

.detail-links {
  display: inline-flex;
  gap: 8px;
  margin-left: 12px;
  vertical-align: middle;
}

/* ── Buttons ── */
button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 10px 26px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.15s;
}

button:hover  { background: var(--accent-hover); }
button:active { background: var(--accent-press); }

/* ── Output ── */
.output-section { margin-bottom: 36px; }
.hidden { display: none !important; }

.output-top-bar {
  display: flex;
  align-items: left;
  gap: 10px;
  margin-bottom: 20px;
}

.output-top-bar button {
  white-space: nowrap;
}


/* ── Faction picker ── */
.faction-picker details { border: none; }

.faction-summary {
  font-size: 0.8rem;
  color: var(--summary-color);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  user-select: none;
}

.faction-summary::-webkit-details-marker { display: none; }

.faction-summary::after {
  content: '▾';
  font-size: 1rem;
  color: var(--chevron-color);
  transition: transform 0.15s;
}

details[open] .faction-summary::after { transform: rotate(-180deg); }

.faction-summary:hover { color: var(--text); }

.faction-groups {
  margin-top: 12px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.faction-group-header {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--group-header-color);
  margin-bottom: 6px;
}

.faction-buttons {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.faction-btn {
  background: transparent;
  color: var(--faction-btn-color);
  border: 1px solid var(--faction-btn-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.faction-btn:hover {
  color: var(--faction-btn-hover-color);
  border-color: var(--faction-btn-hover-border);
  background: var(--faction-btn-hover-bg);
}

.faction-btn.active {
  color: var(--faction-btn-active-color);
  border-color: var(--faction-btn-active-border);
  background: var(--faction-btn-active-bg);
  font-weight: 600;
}

/* ── Unit list ── */
.section { margin-bottom: 26px; }

.section-heading {
  color: var(--section-heading-color);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.unit-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.unit-list li {
  display: flex;
  flex-direction: column;
}

.unit-name {
  font-size: 0.93rem;
  color: var(--accent);
  flex-shrink: 0;
}

.unit-enhancement {
  font-size: 0.72rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}

.unit-list li .sep {
  color: var(--sep-color);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.unit-list li a {
  text-decoration: none;
  font-size: 0.82rem;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.unit-list li a.link-waha       { color: var(--waha-color);   border-color: var(--waha-border);   }

.unit-list li a.link-waha:hover {
  color: var(--waha-hover-color);
  border-color: var(--waha-hover-border);
  background: var(--waha-hover-bg);
}

/* Also applies to links inside .details-view */
.detail-links a {
  text-decoration: none;
  font-size: 0.82rem;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.detail-links a.link-waha       { color: var(--waha-color);   border-color: var(--waha-border);   }

.detail-links a.link-waha:hover {
  color: var(--waha-hover-color);
  border-color: var(--waha-hover-border);
  background: var(--waha-hover-bg);
}

#components-reconnect-modal { display: none !important; }

/* ── Footer ── */
footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8rem;
  color: var(--footer-color);
}

footer a { color: var(--footer-link-color); text-decoration: none; }
footer a:hover { color: var(--footer-link-hover); }

.faction-note {
  margin-top: 14px;
  font-size: 0.76rem;
  color: var(--text-faint);
  font-style: italic;
}

.no-units {
  color: var(--no-units-color);
  font-style: italic;
  font-size: 0.88rem;
  margin-top: 12px;
}

/* ── Machine Spirit loader ── */
.machine-spirit {
  margin-top: 48px;
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-size: 0.92rem;
  letter-spacing: 0.5px;
  animation: ms-pulse 1.6s ease-in-out infinite;
}

@keyframes ms-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

/* ── Share / copy button ── */
.copy-btn {
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  background: var(--toggle-hover-bg);
  color: var(--toggle-hover-color);
}

.copy-btn.copied {
  color: #6abf6a;
  border-color: #3a6a3a;
}

/* ── Map Builder promo ── */
.mapbuilder-promo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mapbuilder-promo-btn {
  display: inline-block;
  padding: 6px 14px;
  background: #cba6f7;
  color: #1e1e2e;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.mapbuilder-promo-btn:hover { background: #d4b0ff; }

.mapbuilder-promo-badge {
  display: inline-block;
  padding: 2px 7px;
  background: #a6e3a1;
  color: #1e1e2e;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mapbuilder-promo-text {
  font-size: 0.82rem;
  color: var(--text-dim);
}

body.light .mapbuilder-promo-btn          { background: #7c3aed; color: #fff; }
body.light .mapbuilder-promo-btn:hover    { background: #6d28d9; }
body.light .mapbuilder-promo-badge        { background: #16a34a; color: #fff; }

/* ── AoS warning ── */
.site-notice {
  font-size: 0.82rem;
  color: #c0903a;
  border: 1px solid #6a4a10;
  background: #1a1000;
  border-radius: 5px;
  padding: 8px 14px;
  margin-bottom: 14px;
}

body.light .site-notice {
  color: #8a5a10;
  border-color: #d0a060;
  background: #fffaf0;
}

.aos-warning {
  font-size: 0.82rem;
  color: #c05050;
  border: 1px solid #6a2020;
  background: #1a0808;
  border-radius: 5px;
  padding: 8px 14px;
  margin-bottom: 14px;
}

body.light .aos-warning {
  color: #a03030;
  border-color: #d08080;
  background: #fff5f5;
}

.aos-warning a { color: inherit; text-decoration: underline; }

/* ── Blazor error UI ── */
#blazor-error-ui {
  background: #2a0808;
  border-top: 1px solid #6a2020;
  color: #d4c9b0;
  bottom: 0;
  padding: 10px 16px;
  position: fixed;
  width: 100%;
  z-index: 1000;
  display: none;
  gap: 12px;
  align-items: center;
}

#blazor-error-ui.blazor-error-boundary { display: flex; }

#blazor-error-ui .reload { color: var(--waha-color); }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: auto; }

/* ── Unit item & stats toggle ── */
.unit-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; padding: 2px 0; }

/* View Mode toggle — sits between the rules/stratagems and the unit list,
   hides Attach/Wahapedia/Unmerge so the list reads cleaner. Persisted via
   `&v=1` in the share URL so a shared view-only link stays that way. */
.view-mode-bar { margin: 10px 0 6px; }
.view-mode-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.view-mode-btn:hover  { color: var(--text); border-color: var(--faction-btn-hover-border); background: var(--bg-inset); }
.view-mode-btn.active { color: var(--accent); border-color: var(--accent-press); }

/* ── Rules section (army + detachment) ── */
.rules-section { margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.rules-panel-wrap { display: flex; flex-direction: column; }
.rules-btn {
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.rules-btn:hover  { color: var(--text); border-color: var(--faction-btn-hover-border); background: var(--bg-inset); }
.rules-btn.active { color: var(--accent); border-color: var(--accent-press); }
.rules-panel-wrap .datasheet { margin-top: 6px; min-width: min(480px, 100%); max-width: 100%; padding: 12px 16px; overflow-wrap: break-word; word-break: break-word; }
.rules-panel-wrap .ds-ability { padding: 6px 0; line-height: 1.55; }

.stratagems-title { width: 100%; flex-basis: 100%; margin: 8px 0 4px 0; font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: 0.04em; text-transform: uppercase; }
.stratagems-section .rules-btn { min-width: 180px; text-align: center; }
.stratagem-list { display: flex; flex-direction: column; gap: 8px; }
.phase-group { display: flex; flex-direction: column; gap: 6px; }
.phase-toggle {
  font-family: inherit;
  width: 100%;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.phase-toggle:hover { color: var(--text); border-color: var(--faction-btn-hover-border); }
.phase-cards {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.stratagem {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stratagem--opponent {
  background: rgba(220, 60, 60, 0.10);
  border-color: rgba(220, 60, 60, 0.45);
  border-left: 4px solid rgba(220, 60, 60, 0.85);
  padding-left: 13px;
}
.stratagem-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.stratagem-name-wrap { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; }
.stratagem-name { font-weight: 700; font-size: 0.95rem; color: var(--text); letter-spacing: 0.02em; }
.stratagem-tag { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 7px; border-radius: 10px; flex-shrink: 0; white-space: nowrap; }
.stratagem-tag--core       { background: rgba(140, 140, 140, 0.18); color: var(--text-muted); border: 1px solid rgba(140,140,140,0.25); }
.stratagem-tag--detachment { background: rgba(203, 166, 247, 0.18); color: #cba6f7; border: 1px solid rgba(203,166,247,0.4); }
.stratagem-tag--faction    { background: rgba(137, 180, 250, 0.18); color: #89b4fa; border: 1px solid rgba(137,180,250,0.4); }
.stratagem-cp { font-size: 0.75rem; font-weight: 600; color: var(--accent); white-space: nowrap; padding: 2px 8px; border: 1px solid var(--accent-press); border-radius: 10px; }
.stratagem-desc { font-size: 0.86rem; line-height: 1.5; margin-top: 6px; color: var(--text); }
.stratagem-desc b { color: var(--accent); }

.stats-btn {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.stats-btn:hover  { color: var(--text); border-color: var(--faction-btn-hover-border); background: var(--bg-inset); }
.stats-btn.active { color: var(--accent); border-color: var(--accent-press); }

/* ── Datasheet panel ── */
.datasheet {
  margin: 4px 0 10px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: clip;
  font-size: 0.82rem;
}

.ds-section {
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px;
}
.ds-section:last-child { border-bottom: none; }

.ds-section-title {
  font-size: 0.68rem;
  letter-spacing: .06em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 7px;
}

.ds-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.80rem;
}
.ds-table th, .ds-table td {
  padding: 4px 8px;
  text-align: center;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.ds-table thead th {
  background: var(--bg-inset);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.70rem;
  letter-spacing: .04em;
}
.ds-table td:first-child,
.ds-table th:first-child { text-align: left; white-space: normal; }

.ds-weapon-kw-cell {
  text-align: left !important;
  white-space: normal !important;
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
  padding-top: 2px !important;
  padding-bottom: 5px !important;
  border-top: none !important;
}

.ds-ability {
  margin-bottom: 6px;
  line-height: 1.45;
  color: var(--text);
}
.ds-ability:last-child { margin-bottom: 0; }
.ds-ability-name {
  font-weight: 600;
  color: var(--accent);
  margin-right: 2px;
}
.ds-ability-desc { color: var(--text-muted); }
.ds-sub-ability {
  margin-left: 1rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--accent);
  opacity: 0.85;
}

.ds-keywords {
  padding: 7px 12px;
  font-size: 0.74rem;
  color: var(--text-dim);
  font-style: italic;
}

.ds-toolbar {
  display: flex;
  justify-content: flex-start;
  padding: 8px 12px 0;
}

.ds-equipped-toggle {
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ds-equipped-toggle input {
  cursor: pointer;
  accent-color: var(--accent);
}

.ds-missing {
  padding: 10px 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Light mode datasheet ── */
body.light .ds-table thead th { background: var(--bg-inset); }
body.light .ds-ability-desc   { color: var(--text-muted); }

/* ── Cookie / storage notice ── */
#cookie-notice {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  background: var(--bg-inset);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.80rem;
  z-index: 999;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  line-height: 1.5;
}

#cookie-notice a { color: var(--waha-color); text-decoration: none; }
#cookie-notice a:hover { text-decoration: underline; }

#cookie-notice button {
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 5px;
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

#cookie-notice button:hover {
  background: var(--toggle-hover-bg);
  color: var(--toggle-hover-color);
}

/* ── Refresh data button ── */
.refresh-data-btn {
  background: var(--toggle-bg);
  color: var(--toggle-color);
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.refresh-data-btn:hover:not(:disabled) {
  background: var(--toggle-hover-bg);
  color: var(--toggle-hover-color);
}

.refresh-data-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── QR code modal ── */
.qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.qr-modal {
  background: #ffffff;
  border-radius: 12px;
  padding: 28px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 320px;
  width: 90%;
}

.qr-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  letter-spacing: 0.3px;
}

.qr-url {
  font-size: 0.78rem;
  color: #555;
  word-break: break-all;
  text-align: center;
  line-height: 1.5;
}

.qr-close-btn {
  background: #222;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 24px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.qr-close-btn:hover  { background: #444; }

/* ─── Account / Auth ──────────────────────────────────────────────────── */

.account-menu { position: relative; display: inline-flex; align-items: center; }
.account-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--toggle-border, var(--bg-inset));
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 220px;
}
.account-menu-trigger:hover { background: var(--accent); color: #1e1e2e; }
.account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.account-caret { opacity: 0.7; font-size: 0.7rem; }

.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32), 0 2px 6px rgba(0, 0, 0, 0.18);
  padding: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: account-dropdown-in 0.12s ease-out;
}
@keyframes account-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.account-dropdown-item {
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  font-size: 0.88rem;
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
.account-dropdown-item:hover { background: var(--accent); color: #1e1e2e; }
.account-dropdown-logout    { color: var(--text-muted); }
.account-dropdown-logout:hover { color: #1e1e2e; }
.account-dropdown-cta       { color: var(--accent); font-weight: 700; }
.account-dropdown-cta:hover { background: var(--accent); color: #1e1e2e; }

.account-login-link { /* uses .app-nav-link styling already */ }

/* Inline form helpers that aren't part of the canonical .app-form-field
   pattern (kept here because they're Account-specific). */
.account-checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--text-muted);
  margin: 4px 0 18px; cursor: pointer; user-select: none;
}
.account-links {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem;
}
.account-links a       { color: var(--accent); text-decoration: none; transition: color 0.15s; }
.account-links a:hover { color: var(--accent-hover); text-decoration: underline; }

@media (max-width: 480px) {
  .app-page.app-page-narrow {
    padding: 1.5rem 1.25rem;
  }
  .app-page h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }
}

/* ─── Admin ───────────────────────────────────────────────────────────────
   Page chrome (.app-page), table (.m-table), and buttons (.m-btn variants)
   come from the canonical primitives below. Only admin-specific UI lives
   here: row-state styling, the tag, the modal. */

.m-table tbody tr.locked         { opacity: 0.55; }
.m-table tbody tr.locked:hover   { opacity: 0.85; }
.admin-actions-col               { white-space: nowrap; text-align: right; }
.admin-tag {
  display: inline-block; margin-left: 6px;
  background: var(--accent); color: #1e1e2e;
  font-size: 0.66rem; padding: 2px 8px;
  border-radius: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700;
  vertical-align: middle;
}

.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.admin-modal {
  background: var(--surface, #1e1e2e);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.admin-modal h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }
.admin-modal p { font-size: 0.9rem; line-height: 1.5; margin: 0 0 0.75rem; }
.admin-modal-note { color: var(--text-muted); }
.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1.25rem;
}

@media (max-width: 640px) {
  .m-table { font-size: 0.84rem; }
  .m-table th, .m-table td { padding: 8px 6px; }
}

.qr-close-btn:active { background: #111; }

/* ─── Saved Lists Panel ─────────────────────────────────────────────────── */

.saved-lists-panel {
  margin: 1rem 0 1.5rem;
  padding: 14px 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.saved-lists-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.saved-lists-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.saved-lists-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.saved-lists-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.saved-lists-current {
  flex: 1 1 auto;
  font-size: 0.88rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-lists-current strong {
  color: var(--text);
  margin-left: 4px;
}
.saved-list-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.saved-list-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.saved-list-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.saved-list-btn.primary {
  background: var(--accent);
  color: #1e1e2e;
  border-color: var(--accent);
}
.saved-list-btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #1e1e2e;
}
.saved-list-btn.ghost {
  border-color: transparent;
  color: var(--text-muted);
}
.saved-list-btn.ghost:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text);
}

.saved-lists-empty {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 6px 0 0;
}
.saved-lists-empty em { color: var(--text-muted); font-style: normal; }

.saved-lists-items {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}
.saved-list-item {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: 6px;
  transition: background 0.1s;
}
.saved-list-item:hover { background: var(--bg); }
.saved-list-item.current {
  background: rgba(200, 168, 75, 0.08);
  outline: 1px solid rgba(200, 168, 75, 0.35);
}
.saved-list-load {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  min-width: 0;
  border-radius: 6px;
}
.saved-list-name {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.saved-list-meta {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.saved-list-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0 10px;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
}
.saved-list-action:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}
.saved-list-action.danger:hover:not(:disabled) {
  background: rgba(220, 50, 50, 0.15);
  color: #e25c5c;
}
.saved-list-action:disabled { opacity: 0.35; cursor: not-allowed; }

/* Modal */
.saved-list-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 1rem;
  animation: saved-list-modal-fade 0.12s ease-out;
}
.saved-list-modal {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  padding: 1.5rem 1.5rem 1.25rem;
  width: 100%;
  max-width: 420px;
  animation: saved-list-modal-pop 0.15s ease-out;
}
.saved-list-modal h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text);
}
.saved-list-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 1rem;
}
@keyframes saved-list-modal-fade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes saved-list-modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

@media (max-width: 540px) {
  .saved-lists-actions { gap: 6px; }
  .saved-list-btn      { padding: 5px 10px; font-size: 0.82rem; }
  .saved-list-meta     { display: none; }
}

/* ─── Subscribe / Billing ───────────────────────────────────────────────── */

.app-page.subscribe-page     { max-width: 760px; }
.subscribe-lede {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 1.5rem;
}
.subscribe-lede strong { color: var(--accent); }

.subscribe-benefits {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.subscribe-benefits li {
  position: relative;
  padding: 10px 12px 10px 36px;
  background: var(--surface-muted, rgba(255,255,255,0.04));
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
}
.subscribe-benefits li::before {
  content: "✓";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 700;
}
.subscribe-benefits li:last-child {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.subscribe-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 1.25rem;
}
@media (max-width: 540px) { .subscribe-plans { grid-template-columns: 1fr; } }

.subscribe-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 1.25rem 1.25rem 1.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.subscribe-plan:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(200, 168, 75, 0.12);
}
.subscribe-plan:active:not(:disabled) { transform: translateY(1px); }
.subscribe-plan:disabled { opacity: 0.55; cursor: not-allowed; }
.subscribe-plan.featured {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(200, 168, 75, 0.05), var(--bg));
}
.subscribe-plan-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--accent);
  color: #1e1e2e;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 10px;
}
.subscribe-plan-name {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.subscribe-plan-price {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.subscribe-plan-price span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}
.subscribe-plan-note {
  font-size: 0.82rem;
  color: var(--text-dim);
}
.subscribe-plan-cta {
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent);
}

.subscribe-footnote {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}
.subscribe-footnote em { color: var(--text-muted); font-style: normal; font-weight: 600; }

.billing-summary {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.billing-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.billing-row + .billing-row { border-top: 1px solid var(--border-subtle); }
.billing-row strong { color: var(--text); font-weight: 600; }

.billing-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Shared button + input primitives ────────────────────────────────── */
/* Same shape Models.razor's <style> defines locally — hoisted here so
   other pages (Games/*) can reuse without duplicating. Models page still
   has its own copy which wins via source order; harmless. */
.m-btn {
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text);
  font: 600 0.88rem system-ui, sans-serif;
  padding: 10px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.m-btn:hover:not(:disabled) { border-color: var(--accent); }
.m-btn:disabled              { opacity: 0.5; cursor: default; }
.m-btn-primary               { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.m-btn-del                   { color: #f38ba8; padding: 7px 12px; }

.m-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text);
  font: 0.9rem system-ui, sans-serif;
  padding: 8px 12px;
  border-radius: 7px;
}
.m-input:focus         { outline: none; border-color: var(--accent); }
.m-input::placeholder  { color: var(--placeholder); }

/* ── Find a Game (feature-specific) ─────────────────────────────────────
   Page chrome (.app-page / .app-page-header / .app-lede / .app-empty /
   .app-error-text / .app-form-field / .app-form-actions / .app-info-bar /
   .app-pill) lives in the canonical primitives block at the end of this
   file. Only Games-specific UI lives here.  */

.games-loc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.games-loc-card {
  display: block; padding: 0.85rem 1rem; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: 8px;
  color: inherit; text-decoration: none; transition: border-color 0.12s;
}
.games-loc-card:hover { border-color: var(--accent); }
.games-loc-name { font-weight: 600; font-size: 1.02rem; }
.games-loc-addr { color: var(--text-dim); font-size: 0.88rem; margin-top: 0.15rem; }
.games-loc-meta {
  display: flex; justify-content: space-between; margin-top: 0.6rem;
  font-size: 0.8rem; color: var(--text-muted);
}
.games-loc-mode { color: var(--accent); }
.games-loc-notes {
  margin-top: 0.75rem;
  padding: 0.75rem 0.9rem 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(93, 217, 255, 0.06), rgba(93, 217, 255, 0.02));
  border: 1px solid rgba(93, 217, 255, 0.18);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  box-shadow: inset 0 0 18px rgba(93, 217, 255, 0.04);
}
.games-loc-notes strong {
  display: inline-block;
  margin-right: 0.5rem;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 6px rgba(93, 217, 255, 0.3);
}
body.light .games-loc-notes {
  background:
    linear-gradient(180deg, rgba(17, 126, 168, 0.06), rgba(17, 126, 168, 0.02));
  border-color: rgba(17, 126, 168, 0.22);
  border-left-color: var(--accent);
  box-shadow: none;
}
body.light .games-loc-notes strong { text-shadow: none; }

.games-join-row {
  display: flex; gap: 0.5rem; margin: 0.5rem 0 0.25rem;
  flex-wrap: wrap;
}
.games-join-row .m-input { flex: 1; min-width: 220px; }
/* Hint under the join row — warns admins that rotating the URL invalidates
   any previously-shared link. */
.games-join-hint {
  font-size: 0.82rem; color: var(--text-dim);
  margin: 0 0 1rem; line-height: 1.5; max-width: 70ch;
}
.games-join-hint strong { color: #f0d090; }

/* Calendar game-type filter dropdown — sits left of the points chips. */
.games-cal-gtfilter { width: auto; min-width: 140px; max-width: 220px; }

/* Game-type admin list — one row per type with a Remove button. */
.games-gt-list  { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.games-gt-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.4rem 0.6rem; background: var(--bg);
  border: 1px solid var(--border-subtle); border-radius: 2px;
  font-family: 'Consolas', 'Courier New', monospace; font-size: 0.85rem;
}
.games-gt-hint { font-size: 0.78rem; color: var(--text-dim); margin: 0.75rem 0 0; line-height: 1.5; }

/* Edit-location panel — same chrome as the post-game form. */
.games-edit-location {
  margin: 0.5rem 0 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
}
.games-edit-location h3 { margin: 0 0 0.75rem; color: var(--accent);
                          font-family: 'Consolas', 'Courier New', monospace;
                          text-transform: uppercase; letter-spacing: 0.08em; }

/* "I can play any time" checkbox shown directly under the time input. */
.games-anytime-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 4px; cursor: pointer;
  font-size: 0.85rem; color: var(--text-muted);
  user-select: none;
}

/* Dormant-location banner — appears between the join row and the calendar
   when no admin has an active subscription. Uses the warn-amber hue from
   the sci-fi palette so it stands out without screaming. */
.games-dormant {
  margin: 0.25rem 0 1rem;
  background: rgba(230, 190, 110, 0.08);
  border: 1px solid rgba(230, 190, 110, 0.45);
  border-left: 3px solid #f0d090;
  color: var(--text);
  align-items: flex-start;
}
.games-dormant strong       { color: #f0d090; }
.games-dormant-icon         { font-size: 1.1rem; line-height: 1; color: #f0d090; flex-shrink: 0; }

.games-radio-group {
  border: 1px solid var(--border-subtle); border-radius: 8px;
  padding: 0.75rem 1rem; margin: 0.5rem 0;
}
.games-radio-group legend { padding: 0 0.5rem; color: var(--text-muted); font-size: 0.88rem; }
.games-radio-group label { display: block; padding: 0.35rem 0; line-height: 1.4; }
.games-radio-group input { margin-right: 0.5rem; }

/* Calendar */
.games-calendar { margin-top: 1rem; border-top: 1px solid var(--border-subtle); padding-top: 1rem; }
.games-cal-nav {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.games-cal-nav h2 { margin: 0 auto; }
.games-cal-filter {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem; font-size: 0.9rem; color: var(--text-muted);
}
.games-cal-openonly { display: inline-flex; align-items: center; gap: 0.3rem; margin-left: 0.5rem; }
.m-btn-chip {
  padding: 4px 12px !important; font-size: 0.85rem !important;
  border-radius: 999px !important;
}
.m-btn-chip.active { background: var(--accent); color: #1e1e2e; border-color: var(--accent); }

.games-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto auto; gap: 0.4rem;
  background: var(--bg-inset); padding: 0.5rem; border-radius: 8px;
  border: 1px solid var(--border-subtle);
}
.games-cal-dayhead {
  text-align: center; padding: 0.4rem 0.2rem; font-size: 0.78rem;
  color: var(--text-muted); border-bottom: 1px solid var(--border-subtle);
}
.games-cal-dayhead.today { color: var(--accent); }
.games-cal-dayname { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.games-cal-daydate { color: var(--text-dim); font-size: 0.75rem; }
.games-cal-blocks {
  grid-column: 1 / span 7;
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem;
  min-height: 90px; padding-top: 0.3rem;
  grid-auto-rows: minmax(70px, auto);
}
.games-cal-block {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0.4rem 0.55rem; border-radius: 6px;
  background: var(--accent); color: #1e1e2e; font-size: 0.82rem;
  text-decoration: none; line-height: 1.25; overflow: hidden;
}
.games-cal-block.open    { background: #6f8bd0; color: #fff; }
.games-cal-block.paired  { background: #6fa07a; color: #fff; }
.games-cal-block:hover   { filter: brightness(1.05); }
.games-cal-block-title   { font-weight: 700; }
.games-cal-block-poster  { font-size: 0.76rem; opacity: 0.85; }
.games-cal-block-time    { font-size: 0.75rem; opacity: 0.85; }
.games-cal-block-tag     { font-size: 0.7rem; margin-top: 2px; font-weight: 700; letter-spacing: 0.05em; }
.games-cal-empty {
  align-self: center; justify-self: center; padding: 1rem;
  color: var(--text-dim); font-size: 0.9rem;
}

/* View toggle (Week / Month) pill pair inside the calendar nav. */
.games-cal-view-toggle {
  display: inline-flex; gap: 0.25rem;
  padding: 2px; border-radius: 999px;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
}

/* ── Month grid ── 7 weekday-headers, then 6 week-rows. Each week-row is
   its own 7-col sub-grid so multi-day bars can span columns within it. */
.games-cal-month {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; padding: 0.5rem; border-radius: 8px;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
}
.games-cal-month .games-cal-dayname {
  text-align: center; padding: 0.35rem 0.2rem;
  font-size: 0.74rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

/* Each week-row spans the full 7 columns of the outer grid and is itself a
   7-col sub-grid. Lane height (20px) leaves enough room for 3 bars + day
   number above; min-height keeps cells from collapsing when empty. */
.games-cal-mweek {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 22px;        /* row 1 = day-number row, then auto rows for bars */
  grid-auto-rows: 20px;
  gap: 2px 4px;
  min-height: 100px;
}
.games-cal-mday {
  background: var(--bg); border: 1px solid var(--border-subtle);
  border-radius: 4px; position: relative;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  /* No padding — bars (separate grid items) provide their own. */
}
.games-cal-mday:hover  { background: rgba(93, 217, 255, 0.06); border-color: rgba(93, 217, 255, 0.30); }
.games-cal-mday:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(93, 217, 255, 0.45), 0 0 12px rgba(93, 217, 255, 0.25);
}
.games-cal-mday.off    { opacity: 0.35; }
.games-cal-mday.today  { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(93, 217, 255, 0.4); }
.games-cal-mday.today:hover { border-color: var(--accent); }
.games-cal-mday-num {
  position: absolute; top: 2px; right: 6px;
  font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
  font-family: 'Consolas', 'Courier New', monospace;
  z-index: 0;
}
.games-cal-mday.today .games-cal-mday-num { color: var(--accent); }

/* Game bars — span 1..7 columns inside the week-row. cont-left/right cap
   the bar with arrows + flat edges so the user can tell the run continues. */
.games-cal-mspan {
  display: flex; gap: 4px; align-items: center;
  padding: 0 6px;
  margin: 0 1px;
  background: rgba(93, 217, 255, 0.12);
  border-left: 2px solid var(--accent);
  color: var(--text); text-decoration: none;
  font-size: 0.72rem; line-height: 18px; height: 18px;
  white-space: nowrap; overflow: hidden;
  border-radius: 3px;
  z-index: 1;
  transition: background 0.12s, box-shadow 0.12s;
}
.games-cal-mspan:hover    { background: rgba(93, 217, 255, 0.22); box-shadow: 0 0 6px rgba(93, 217, 255, 0.3); }
.games-cal-mspan.paired   { background: rgba(110, 200, 130, 0.12); border-left-color: #8cd89c; }
.games-cal-mspan.paired:hover { background: rgba(110, 200, 130, 0.22); box-shadow: 0 0 6px rgba(110, 200, 130, 0.3); }
/* Continuation cues: flat edge + arrow on the side that runs into the
   previous or next week-row. */
.games-cal-mspan.cont-left  { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: none; padding-left: 4px; }
.games-cal-mspan.cont-right { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 4px; }
.games-cal-mspan-arrow      { color: var(--accent); font-size: 0.7rem; opacity: 0.85; flex-shrink: 0; }
.games-cal-mspan.paired .games-cal-mspan-arrow { color: #8cd89c; }
.games-cal-mspan-time       { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.games-cal-mspan.paired .games-cal-mspan-time { color: #8cd89c; }
.games-cal-mspan-pts        { font-weight: 600; flex-shrink: 0; }
.games-cal-mspan-poster     { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.games-cal-mchip-more {
  position: absolute; bottom: 2px; left: 4px;
  font-size: 0.66rem; color: var(--text-dim);
  font-family: 'Consolas', 'Courier New', monospace;
  z-index: 2;
}

@media (max-width: 640px) {
  .games-cal-mweek            { grid-template-rows: 18px; grid-auto-rows: 16px; min-height: 80px; }
  .games-cal-mday-num         { font-size: 0.7rem; top: 1px; right: 4px; }
  .games-cal-mspan            { font-size: 0.66rem; line-height: 14px; height: 14px; padding: 0 4px; }
  .games-cal-mspan-poster     { display: none; }
  .games-cal-month .games-cal-dayname { font-size: 0.66rem; padding: 0.25rem 0.1rem; }
}

/* Post form */
.games-post-form {
  margin-top: 1rem; padding: 1rem; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: 8px;
}
.games-post-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem;
}
.games-post-notes, .games-post-list { grid-column: 1 / -1; }
.games-points-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Admin sections */
.games-admin {
  margin-top: 1rem; padding: 0.75rem 1rem;
  background: var(--bg-inset); border: 1px solid var(--border-subtle); border-radius: 8px;
}
.games-admin summary { cursor: pointer; font-weight: 600; padding: 0.25rem 0; }
.games-members-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; font-size: 0.9rem; }
.games-members-table th, .games-members-table td {
  text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-subtle);
}
.games-members-table tr.blocked { opacity: 0.55; }
.games-member-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }

/* Game detail — outer wrappers reuse .app-section */
.games-request, .games-requests-list, .games-paired {
  margin-top: 1.25rem; padding: 1rem; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: 8px;
}
/* Vertical rhythm for direct children — h3 → p → button etc. don't collapse
   into each other. Element-specific margins win when present. */
.games-request    > * + *,
.games-paired     > * + * { margin-top: 0.75rem; }
/* Stand-out styling for the "Your note" recap — muted, italic, slight
   indent so it reads as a quote rather than the same priority as the
   body copy above it. */
.games-request-mynote {
  color: var(--text-muted); font-size: 0.92rem;
  padding-left: 0.6rem; border-left: 2px solid var(--border-subtle);
}

.games-request-row {
  padding: 0.6rem 0.75rem; border: 1px solid var(--border-subtle);
  border-radius: 6px; margin-bottom: 0.5rem;
}
.games-request-row.past { opacity: 0.65; padding: 0.4rem 0.75rem; }
.games-request-who { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.games-request-time { color: var(--text-dim); font-size: 0.8rem; margin-left: auto; }
.games-request-msg {
  margin: 0.4rem 0; padding: 0.4rem 0.6rem;
  background: var(--bg); border-radius: 4px; font-style: italic; color: var(--text-muted);
}
.games-request-actions { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.games-tag {
  display: inline-block; padding: 1px 6px; background: var(--accent); color: #1e1e2e;
  border-radius: 4px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.games-paired-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0.75rem 0;
}
@media (max-width: 700px) { .games-paired-grid { grid-template-columns: 1fr; } }
.games-list-pane {
  padding: 0.5rem 0.75rem; background: var(--bg);
  border: 1px solid var(--border-subtle); border-radius: 6px;
}
.games-list-pre {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; color: var(--text);
}
.games-list-pane-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.35rem;
}
.games-list-pane-head h4 { margin: 0; }
.games-list-pane-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.games-list-pane-btns .m-btn { padding: 4px 10px; font-size: 0.8rem; }
.games-list-pane-actions-row { margin: 0.5rem 0 0.75rem; }
.games-list-pane-actions-row .m-btn { padding: 6px 14px; }

/* Post-pair list editor — appears below the two list panes. */
.games-list-editor {
  margin-top: 0.75rem; padding: 0.85rem 1rem;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  border-radius: 2px;
}
.games-list-editor h4 { margin: 0 0 0.5rem; color: var(--accent); }
.games-list-editor-email {
  display: inline-flex; gap: 0.5rem; align-items: flex-start;
  margin: 0.25rem 0 0.5rem; cursor: pointer;
  font-size: 0.88rem; color: var(--text-muted);
}

.games-contact-reveal {
  margin-top: 0.75rem; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border-subtle); border-radius: 6px;
  font-size: 0.9rem;
}
.games-contact-reveal label { display: inline-flex; gap: 0.4rem; align-items: center; }

.games-chat { margin-top: 1rem; }
.games-chat-list {
  max-height: 320px; overflow-y: auto;
  padding: 0.5rem; background: var(--bg);
  border: 1px solid var(--border-subtle); border-radius: 6px;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.games-chat-msg {
  padding: 0.4rem 0.6rem; background: var(--bg-inset);
  border-radius: 8px; max-width: 75%; align-self: flex-start;
}
.games-chat-msg.mine { background: var(--accent); color: #1e1e2e; align-self: flex-end; }
.games-chat-meta {
  display: flex; gap: 0.5rem; font-size: 0.72rem; opacity: 0.75; margin-bottom: 2px;
}
.games-chat-body { white-space: pre-wrap; word-break: break-word; font-size: 0.92rem; }
.games-chat-input { display: flex; gap: 0.5rem; margin-top: 0.5rem; align-items: flex-start; }
.games-chat-input .m-input { flex: 1; }

/* System notice in the chat stream (e.g. "X updated their list"). Centered,
   italic, dim — visually distinct from user-typed bubbles. */
.games-chat-system {
  align-self: center; max-width: 90%;
  display: inline-flex; gap: 0.5rem; align-items: baseline;
  padding: 2px 10px; margin: 4px 0;
  font-size: 0.78rem; font-style: italic; color: var(--text-dim);
  border-top: 1px dashed var(--border-subtle);
  border-bottom: 1px dashed var(--border-subtle);
}
.games-chat-system-time { color: var(--text-faint); font-size: 0.72rem; }

/* My Games */
.games-mine-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.games-mine-row {
  display: flex; justify-content: space-between; gap: 0.75rem;
  padding: 0.65rem 0.85rem; border: 1px solid var(--border-subtle);
  border-radius: 8px; background: var(--bg-inset); flex-wrap: wrap;
}
.games-mine-row.pending { border-left: 3px solid #6f8bd0; }
.games-mine-row.paired  { border-left: 3px solid #6fa07a; }
.games-mine-meta   { display: flex; flex-direction: column; gap: 2px; min-width: 240px; flex: 1; }
.games-mine-link   {
  color: var(--text); text-decoration: none;
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline;
}
.games-mine-link:hover  { color: var(--accent); }
.games-mine-points { color: var(--accent); font-weight: 600; font-size: 0.88rem; }
.games-mine-loc    { color: var(--text-dim); font-size: 0.85rem; }
.games-mine-notes  { color: var(--text-muted); font-size: 0.82rem; font-style: italic; }
.games-mine-paired { color: var(--text-muted); font-size: 0.85rem; }
.games-mine-actions {
  display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
}
.games-mine-closed { margin-top: 0.5rem; }
.games-mine-closed summary { color: var(--text-dim); cursor: pointer; padding: 0.25rem 0; }
.games-member-email { color: var(--text-dim); font-size: 0.85rem; }

/* Identity-bar inner styling. The outer shell is .app-info-bar. */
.games-identity-label       { color: var(--text-muted); flex: 1; min-width: 0; }
.games-identity-label strong{ color: var(--text); }
.games-identity-input       { max-width: 320px; }
.games-identity-edit        { padding: 5px 12px; font-size: 0.82rem; }

/* ============================================================================
   ── Canonical primitives ──
   The shared visual vocabulary used across every page. Older feature-specific
   classes (.games-*, .account-*, .mh-*, .models-*, .admin-*) are being
   migrated onto these — feature CSS below should add ONLY what's genuinely
   feature-specific (calendar grid, members table, dice tray, etc.).

   Naming:
     .app-*  page-chrome + layout primitives (page, header, lede, section,
             card, pill, info-bar, form-field, errors)
     .m-*    inline form-control primitives (btn, btn-primary, btn-del,
             input, textarea, select, table)
   ============================================================================ */

/* ── Page chrome (sci-fi panel) ──
   .app-page is the canonical page container. The sci-fi flair (scanlines,
   angled corner, cyan glow, monospace heading) is global — every page that
   uses .app-page gets it. The decoration sits in ::before/::after, so
   children render above it via .app-page > * { z-index: 1 }. */
.app-page {
  position: relative;
  padding: 26px 24px 30px;
  max-width: 1200px;
  margin: 1.5rem auto 2rem;
  background:
    radial-gradient(ellipse at top, rgba(93, 217, 255, 0.06), transparent 60%),
    linear-gradient(180deg, #07101e 0%, #050912 100%);
  border: 1px solid rgba(93, 217, 255, 0.20);
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 1px rgba(93, 217, 255, 0.04),
    0 0 40px rgba(93, 217, 255, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.55);
}
/* Hairline scanlines — subtle "HUD" texture. */
.app-page::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(93, 217, 255, 0.03) 0,
    rgba(93, 217, 255, 0.03) 1px,
    transparent 1px, transparent 3px);
}
/* Angled top-right corner — sci-fi HUD cut. */
.app-page::after {
  content: "";
  position: absolute; top: -1px; right: -1px;
  width: 30px; height: 30px;
  background: linear-gradient(135deg, transparent 50%, var(--accent) 50%, var(--accent) 58%, transparent 58%);
  opacity: 0.75; pointer-events: none;
}
.app-page > *          { position: relative; z-index: 1; }

.app-page h1 {
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--text);
  text-shadow:
    0 0 8px rgba(93, 217, 255, 0.55),
    0 0 22px rgba(93, 217, 255, 0.25);
}
.app-page h2 {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.05rem; color: var(--accent);
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase; letter-spacing: 1.5px;
  text-shadow: 0 0 6px rgba(93, 217, 255, 0.25);
}
.app-page h3           { margin: 0 0 0.75rem; font-size: 1.05rem; }
.app-page h4           { margin: 0.5rem 0; font-size: 0.95rem; color: var(--text-muted); }
.app-page-narrow       { max-width: 720px; }   /* short-text + small forms */
.app-page-form         { max-width: 480px; }   /* login / register / single-field profile */
.app-page-wide         { max-width: 1400px; }  /* dense tools (Mathammer) */

/* Light-mode panel: drop the dark gradient + heavy glow, keep the corner cut + scanlines tinted to the accent. */
body.light .app-page,
body.light .container.scifi {
  background:
    radial-gradient(ellipse at top, rgba(17, 126, 168, 0.05), transparent 60%),
    var(--bg-inset);
  border-color: rgba(17, 126, 168, 0.25);
  box-shadow:
    inset 0 0 0 1px rgba(17, 126, 168, 0.04),
    0 0 30px rgba(17, 126, 168, 0.06),
    0 16px 40px rgba(10, 26, 38, 0.08);
}
body.light .app-page::before,
body.light .container.scifi::before {
  background-image: repeating-linear-gradient(
    0deg,
    rgba(17, 126, 168, 0.04) 0,
    rgba(17, 126, 168, 0.04) 1px,
    transparent 1px, transparent 3px);
}
body.light .app-page h1, body.light .app-page h2,
body.light .container.scifi h1, body.light .container.scifi .stratagems-title,
body.light .container.scifi .unit-name { text-shadow: none; }

.app-page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.app-page-actions      { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.app-lede              { color: var(--text-dim); max-width: 65ch; margin-bottom: 1rem; line-height: 1.6; }
.app-empty             { color: var(--text-dim); padding: 1rem 0; }

/* ── Forms ── */
.app-form-field        { display: flex; flex-direction: column; gap: 6px; margin-bottom: 1rem; }
.app-form-field > span { font-size: 0.78rem; color: var(--accent); font-weight: 600; letter-spacing: 0.06em;
                         text-transform: uppercase; font-family: 'Consolas', 'Courier New', monospace; }
.app-form-field > small{ font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }
.app-form-actions      { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* Bare <input>/<textarea>/<select> inside an .app-form-field get the
   canonical input styling automatically — no need to add class="m-input"
   on every Blazor <InputText>. Wrapped in :is(...) so child combinators
   pick up direct descendants only (the EditForm sits between for some
   pages — using a non-direct selector is fine here since fields are
   always one level inside the wrapper). */
.app-form-field input:not([type="checkbox"]):not([type="radio"]),
.app-form-field textarea,
.app-form-field select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 9px 12px;
  font: 0.95rem 'Consolas', 'Courier New', monospace;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.app-form-field input:focus,
.app-form-field textarea:focus,
.app-form-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(93, 217, 255, 0.4), 0 0 12px rgba(93, 217, 255, 0.2);
}
.app-form-field input::placeholder,
.app-form-field textarea::placeholder { color: var(--placeholder); }
/* Native browser autofill bg shouldn't override our dark panel. */
.app-form-field input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  caret-color: var(--text);
}
body.light .app-form-field input:focus,
body.light .app-form-field textarea:focus,
body.light .app-form-field select:focus {
  box-shadow: 0 0 0 1px rgba(17, 126, 168, 0.4), 0 0 12px rgba(17, 126, 168, 0.2);
}

/* ── Cards, sections, info bars, pills ── */
.app-section {
  margin-top: 1rem; padding: 1rem; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: 8px;
}
.app-card {
  display: block; padding: 0.85rem 1rem; background: var(--bg-inset);
  border: 1px solid var(--border-subtle); border-radius: 8px;
  color: inherit; text-decoration: none; transition: border-color 0.12s;
}
.app-card:hover        { border-color: var(--accent); }
.app-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.app-info-bar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.55rem 0.85rem; margin: 0.5rem 0 1rem;
  background: var(--bg-inset); border: 1px solid var(--border-subtle);
  border-radius: 8px; font-size: 0.9rem;
}
.app-info-bar.accent   { border-left: 3px solid var(--accent); }

.app-pill {
  display: inline-block; padding: 2px 10px;
  border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-inset); color: var(--text-muted);
}
.app-pill-info         { background: #6f8bd0; color: #fff; }
.app-pill-success      { background: #6fa07a; color: #fff; }
.app-pill-muted        { background: #7a7a8a; color: #fff; }
.app-pill-warning      { background: var(--accent); color: var(--bg); }

/* ── Errors / success ── */
.app-error {
  background: rgba(220, 50, 50, 0.08);
  border: 1px solid rgba(220, 50, 50, 0.35);
  border-left: 3px solid #d24545;
  color: #e25c5c;
  border-radius: 6px; padding: 10px 14px;
  font-size: 0.88rem; margin-top: 12px; line-height: 1.45;
  display: flex; flex-direction: column; gap: 4px;
}
.app-success {
  background: rgba(120, 180, 100, 0.08);
  border: 1px solid rgba(120, 180, 100, 0.35);
  border-left: 3px solid #6fa07a;
  color: #9fd0a0; border-radius: 6px;
  padding: 10px 14px; font-size: 0.88rem;
  margin-top: 12px; line-height: 1.45;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
}
.app-success > p { margin: 0; }
/* Compact inline error (e.g. under an input). Use .app-error for the
   full boxed alert. */
.app-error-text         { color: #d8645c; margin-top: 0.5rem; font-size: 0.88rem; }

/* ── Form control primitives (extend m-btn / m-input) ── */
.m-textarea {
  width: 100%; border: 1px solid var(--border); background: var(--bg-inset);
  color: var(--text); font: 0.9rem system-ui, sans-serif;
  padding: 8px 12px; border-radius: 7px; resize: vertical; min-height: 70px;
}
.m-textarea:focus       { outline: none; border-color: var(--accent); }
.m-textarea::placeholder{ color: var(--placeholder); }
.m-textarea-mono        { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }

.m-select {
  width: 100%; border: 1px solid var(--border); background: var(--bg-inset);
  color: var(--text); font: 0.9rem system-ui, sans-serif;
  padding: 8px 12px; border-radius: 7px;
}
.m-select:focus         { outline: none; border-color: var(--accent); }

.m-btn-sm               { padding: 5px 12px; font-size: 0.8rem; }
.m-btn-block            { display: block; width: 100%; text-align: center; }

/* ── Tables ── */
.m-table                { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.m-table th, .m-table td{ text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border-subtle); }
.m-table th             { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.m-table tbody tr:hover td { background: var(--bg); }

/* ============================================================================
   ── Sci-fi theme overrides for the Home (army-list) page ──
   The cyan palette and panel chrome are global now (see :root + .app-page
   above). The `.container.scifi` wrapper on Home is kept only as a scoping
   marker so the component-specific overrides below — datasheets,
   stratagems, faction picker, unit names — fire only on that page.
   ============================================================================ */

/* .container.scifi: kept as the Home / landing-page marker so the
   component-specific overrides below (faction-btn, datasheet, stratagem
   etc.) only fire on that page. The palette is global now (in :root) and
   the panel chrome is shared with .app-page via the comma-grouped
   selectors below. */
.container.scifi {
  position: relative;
  padding: 26px 24px 30px;
  background:
    radial-gradient(ellipse at top, rgba(93, 217, 255, 0.06), transparent 60%),
    linear-gradient(180deg, #07101e 0%, #050912 100%);
  border: 1px solid rgba(93, 217, 255, 0.20);
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 1px rgba(93, 217, 255, 0.04),
    0 0 40px rgba(93, 217, 255, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.55);
}

/* Hairline scanlines — very subtle, reads as texture rather than noise. */
.container.scifi::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(93, 217, 255, 0.03) 0,
    rgba(93, 217, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 0;
}

/* Angled top-right corner — classic sci-fi HUD panel cut. */
.container.scifi::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 30px;
  height: 30px;
  background:
    linear-gradient(135deg, transparent 50%, #5dd9ff 50%, #5dd9ff 58%, transparent 58%);
  pointer-events: none;
  opacity: 0.75;
}

.container.scifi > * { position: relative; z-index: 1; }

/* ── Header ── */
.container.scifi h1 {
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 1.5rem;
  color: #cfeaff;
  text-shadow:
    0 0 8px rgba(93, 217, 255, 0.55),
    0 0 22px rgba(93, 217, 255, 0.25);
}
.container.scifi h1 a.title-link { color: inherit; }
.container.scifi h1 a.title-link::before {
  content: "// ";
  color: var(--accent);
  opacity: 0.7;
}

.container.scifi .subtitle {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.container.scifi .subtitle::before {
  content: "> ";
  color: var(--accent);
}

/* ── Textarea (terminal panel) ── */
.container.scifi textarea {
  background:
    linear-gradient(180deg, rgba(93, 217, 255, 0.03), transparent 30%),
    var(--bg-inset);
  border: 1px solid rgba(93, 217, 255, 0.25);
  border-radius: 2px;
  font-family: 'Consolas', 'Courier New', monospace;
  box-shadow: inset 0 0 24px rgba(93, 217, 255, 0.05);
}
.container.scifi textarea:focus {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 24px rgba(93, 217, 255, 0.08),
    0 0 0 1px rgba(93, 217, 255, 0.4),
    0 0 18px rgba(93, 217, 255, 0.25);
}

/* ── Primary buttons (Generate Links, Save, etc.) with corner cuts ── */
.container.scifi .input-section button,
.container.scifi .btn-row > button {
  background: linear-gradient(180deg, rgba(93, 217, 255, 0.20), rgba(93, 217, 255, 0.06));
  color: #cfeaff;
  border: 1px solid var(--accent);
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
  padding: 9px 22px;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  box-shadow:
    inset 0 0 0 1px rgba(93, 217, 255, 0.18),
    0 0 12px rgba(93, 217, 255, 0.18);
  transition: box-shadow 0.15s, background 0.15s, color 0.15s;
}
.container.scifi .input-section button:hover,
.container.scifi .btn-row > button:hover {
  background: linear-gradient(180deg, rgba(93, 217, 255, 0.32), rgba(93, 217, 255, 0.10));
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(93, 217, 255, 0.45),
    0 0 22px rgba(93, 217, 255, 0.5);
}

/* ── Secondary toolbar buttons (copy, refresh, expand) ── */
.container.scifi .copy-btn,
.container.scifi .refresh-data-btn,
.container.scifi .expand-btn {
  background: rgba(93, 217, 255, 0.04);
  border: 1px solid rgba(93, 217, 255, 0.30);
  border-radius: 2px;
  color: #88b8d8;
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.container.scifi .copy-btn:hover,
.container.scifi .refresh-data-btn:hover:not(:disabled),
.container.scifi .expand-btn:hover {
  background: rgba(93, 217, 255, 0.12);
  color: #cfeaff;
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(93, 217, 255, 0.28);
}
.container.scifi .copy-btn.copied {
  color: #5dffb8;
  border-color: rgba(93, 255, 184, 0.6);
  box-shadow: 0 0 12px rgba(93, 255, 184, 0.3);
}

/* ── Faction picker ── */
.container.scifi .faction-summary,
.container.scifi .faction-group-header {
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.container.scifi .faction-group-header {
  color: var(--accent);
  text-shadow: 0 0 6px rgba(93, 217, 255, 0.25);
}
.container.scifi .faction-btn {
  border-radius: 2px;
  font-family: 'Consolas', 'Courier New', monospace;
  letter-spacing: 0.5px;
}
.container.scifi .faction-btn.active {
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 14px rgba(93, 217, 255, 0.35);
}

/* ── Rules / View Mode / Stats toggles ── */
.container.scifi .rules-btn,
.container.scifi .view-mode-btn,
.container.scifi .stats-btn {
  border-radius: 2px;
  font-family: 'Consolas', 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  transition: box-shadow 0.15s, color 0.15s, border-color 0.15s;
}
.container.scifi .rules-btn.active,
.container.scifi .view-mode-btn.active,
.container.scifi .stats-btn.active {
  box-shadow: 0 0 12px rgba(93, 217, 255, 0.35);
}

/* ── Section headings ── */
.container.scifi .section-heading {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(93, 217, 255, 0.3);
  border-bottom-color: rgba(93, 217, 255, 0.25);
}

/* ── Datasheet panels ── */
.container.scifi .datasheet {
  background:
    linear-gradient(180deg, rgba(93, 217, 255, 0.05), transparent 40%),
    var(--bg-inset);
  border: 1px solid rgba(93, 217, 255, 0.22);
  border-radius: 2px;
  box-shadow: inset 0 0 18px rgba(93, 217, 255, 0.04);
}
.container.scifi .ds-section-title { color: var(--accent); }
.container.scifi .ds-ability-name { text-shadow: 0 0 6px rgba(93, 217, 255, 0.3); }
.container.scifi .ds-sub-ability { border-left-color: var(--accent); }

/* ── Stratagem cards with angled corners ── */
.container.scifi .stratagem {
  background:
    linear-gradient(180deg, rgba(93, 217, 255, 0.06), transparent 30%),
    var(--bg-inset);
  border: 1px solid rgba(93, 217, 255, 0.22);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}
.container.scifi .stratagems-title {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(93, 217, 255, 0.35);
}
.container.scifi .stratagem-name { color: #cfeaff; }
.container.scifi .stratagem-cp {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 8px rgba(93, 217, 255, 0.25);
}

/* ── Unit list ── */
.container.scifi .unit-name {
  color: var(--accent);
  text-shadow: 0 0 6px rgba(93, 217, 255, 0.25);
}
.container.scifi .unit-enhancement {
  border-radius: 2px;
  box-shadow: inset 0 0 8px rgba(93, 217, 255, 0.2);
}

/* ── AoS warning re-tinted to fit ── */
.container.scifi .aos-warning {
  color: #ff8ddb;
  background: rgba(255, 106, 205, 0.08);
  border-color: rgba(255, 106, 205, 0.4);
}

/* ── Mobile padding (keep the panel from running edge-to-edge on phones) ── */
@media (max-width: 600px) {
  .container.scifi { padding: 18px 14px 24px; }
  .container.scifi h1 { letter-spacing: 2px; font-size: 1.25rem; }
}
