/* factory — pages for the production-chain game. Lives in @layer pages, so it layers cleanly over layout/ui. */
@layer pages {
  .brand { display: none; }
  .hud { gap: 10px; }

  /* power gauge: the single most important number in the game, so it owns the top bar */
  .power { flex: 1 1 auto; min-width: 0; padding: 8px 14px 9px; border-radius: var(--r-lg); background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .power-top { display: flex; align-items: baseline; gap: 8px; }
  .power-ico { font-size: 16px; }
  .power-top b { font-size: 22px; font-weight: 900; line-height: 1; }
  .power-mw { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink-2); }
  .power-bar { height: 8px; margin: 6px 0 4px; border-radius: 999px; background: rgba(0, 0, 0, .35); overflow: hidden; }
  .power-bar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--buy), var(--info)); transition: width .3s; }
  .power.warn .power-bar i { background: linear-gradient(90deg, #ffb938, var(--hot)); }
  .power.bad .power-bar i { background: linear-gradient(90deg, var(--bad), var(--hot)); }
  .power.bad .power-top b { color: var(--bad-ink); }
  .power-sub { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 8px; font-size: 12px; color: var(--ink-3); }
  .power-detail { margin-top: 5px; color: var(--ink-2); font-size: 12px; }
  .power-detail summary { cursor: pointer; min-height: 28px; display: list-item; padding: 5px 0; font-weight: 700; }
  .power-detail dl { margin: 4px 0; }
  .power-detail dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 2px 0; }
  .power-detail dd { margin: 0; font-weight: 800; }
  .power-detail p { line-height: 1.6; color: var(--ink-3); }

  /* alerts: one scrolling line, faded at the right edge so it reads as "more →" instead of being clipped */
  .alerts { flex: none; display: flex; gap: 8px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .alerts::-webkit-scrollbar { display: none; }
  .alerts:empty { display: none; }
  .alert { flex: none; min-height: 44px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px var(--line); }
  .alert.bad { color: var(--bad-ink); box-shadow: inset 0 0 0 1.5px var(--bad); }
  .alert.warn { color: var(--dust-ink); box-shadow: inset 0 0 0 1.5px rgba(255, 226, 122, .5); }
  .alert.good { color: var(--good-ink); box-shadow: inset 0 0 0 1.5px var(--buy); }

  /* drawn icons: one 24px glyph tinted by --ic, sitting on a soft chip of the same hue */
  .fd-ic { width: 24px; height: 24px; flex: none; color: var(--ic, var(--ink-2)); fill: currentColor; stroke: none; }
  .fd-ic .hi { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
  .fd-ic.sm { width: 15px; height: 15px; vertical-align: -3px; margin-right: 2px; }
  .emo { font-size: 20px; line-height: 1; }
  .power-ico { width: 18px; height: 18px; align-self: center; }

  /* resources: icon · name · stock/cap · net rate · fixed action slot, so every row lines up */
  .res-list { display: grid; gap: 6px; }
  .res-row { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 58px; align-items: center; gap: 8px; min-height: 50px; padding: 6px 10px 11px 8px; overflow: hidden; border-radius: var(--r-md); background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .rr-ico { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: rgba(255, 255, 255, .08); }
  .rr-ico .fd-ic { width: 22px; height: 22px; }
  .rr-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rr-val { display: flex; align-items: baseline; gap: 1px; justify-self: end; }
  .rr-n { font-size: 16px; font-weight: 900; }
  .rr-cap { font-size: 12px; color: var(--ink-3); }
  .rr-rate { text-align: right; font-size: 13px; font-weight: 800; color: var(--ink-3); }
  .rr-rate.up { color: var(--good-ink); } .rr-rate.down { color: var(--bad-ink); }
  .rr-bar { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 4px; border-radius: 999px; background: rgba(0, 0, 0, .3); overflow: hidden; }
  .rr-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--info); }
  .res-row.full .rr-bar i { background: var(--hot); } .res-row.full .rr-n { color: var(--dust-ink); }
  .res-row.t0 { opacity: 1; } .res-row.t3 .rr-n { color: var(--info-ink); }
  .project { margin-top: 12px; }
  .pj-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--ink-2); }
  .pj-row b { color: var(--ink); }

  /* planet plate */
  .planet { margin-bottom: 12px; padding: 12px 14px; }
  .pl-top { display: flex; align-items: center; gap: 10px; }
  .pl-top b { font-size: 17px; font-weight: 900; }
  .pl-dot { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 34% 30%, #fff8, var(--pc, #c9895a) 55%, #0006); box-shadow: 0 0 14px var(--pc, #c9895a); }
  .pl-sub { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--ink-3); }
  .pl-desc { margin-top: 6px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
  .pl-env, .pl-out { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
  .env { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, .08); }
  .env.pos { color: var(--good-ink); box-shadow: inset 0 0 0 1.5px rgba(61, 220, 132, .4); } .env.neg { color: var(--bad-ink); box-shadow: inset 0 0 0 1.5px rgba(255, 93, 122, .4); }
  .pl-lbl { font-size: 12px; font-weight: 800; color: var(--ink-3); }
  .outpost { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; color: var(--ink); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px var(--pc, var(--line)); }
  .goal { margin-bottom: 12px; padding: 12px 14px; box-shadow: inset 0 0 0 2px rgba(92, 200, 255, .5), 0 var(--depth) 0 var(--edge); }
  .goal-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 800; }
  .goal-step { color: var(--info-ink); letter-spacing: .08em; } .goal-rw { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
  .goal-text { margin-top: 4px; font-size: 16px; font-weight: 900; line-height: 1.35; }
.goal-num { margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-style: normal; font-size: 13px; background: rgba(255, 255, 255, .12); }
  .goal-bar { height: 5px; margin-top: 9px; border-radius: 999px; background: rgba(0, 0, 0, .3); overflow: hidden; }
  .goal-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--buy), var(--info)); }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; min-height: 48px; padding: 8px 14px; justify-content: flex-start; text-align: left; line-height: 1.4; font-size: 14px; }
  #map-filter button { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 4px; font-size: 13px; }
  #map-filter button i { font-size: 11px; font-weight: 800; opacity: .75; }
  #star-map .map-node.dim { opacity: .28; }
  #star-map .map-node.hit .node-ring { stroke: #fff; stroke-width: 3.5; }
  #star-map .map-node.hit .node-halo { fill: rgba(255, 226, 122, .35); }
  .btn-mini { flex: none; min-height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 800;
    color: var(--ink-2); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px var(--line); }
  .btn-mini:disabled { opacity: .45; }
  .seg-wide { margin-bottom: 10px; }
  .seg-wide button { padding: 0 6px; }
  .bc-buy.full { opacity: .9; }

  /* build card: header (icon, name, recipe, tools) then a foot row (state, draw, buy) — about 96px instead of 150px */
  .build-list { display: grid; gap: 8px; }
  .bcard { padding: 10px 12px 12px; border-radius: var(--r-lg); background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 var(--depth) 0 var(--edge); }
  .bcard.idle .bc-ico { opacity: .8; }
  .bc-top { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
  .bc-ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: rgba(255, 255, 255, .08); }
  .bc-ico .fd-ic { width: 28px; height: 28px; }
  .bc-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .bc-name { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 900; }
  .bc-n { padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 20px; color: var(--ink); background: rgba(255, 255, 255, .12); white-space: nowrap; }
  .bc-rec { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; font-size: 13px; color: var(--ink-2); }
  .cx { display: inline-flex; align-items: center; font-weight: 800; color: var(--ink); white-space: nowrap; }
  .bc-rec .arrow, .bc-rec .op { margin: 0 2px; color: var(--ink-3); } .bc-rec .per { color: var(--ink-3); } .bc-rec .mw { color: var(--dust-ink); }
  .bc-ctl { display: flex; gap: 6px; }
  .bc-mini { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; font-size: 16px; font-weight: 900; color: var(--ink-2); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px var(--line); }
  .bc-mini .fd-ic { width: 18px; height: 18px; color: currentColor; }
  .bc-mini.on { color: var(--hot-ink); background: var(--hot); box-shadow: none; } .bc-mini:disabled { opacity: .35; }
.bc-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 800; }
.bc-state.warn { color: var(--hot); } .bc-draw { color: var(--ink-3); }
.bc-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.bcard.paused { opacity: .72; box-shadow: inset 0 0 0 1.5px var(--hot); }
.bc-ctl { display: flex; gap: 6px; flex: none; }
.bc-mini.armed { width: auto; min-width: 76px; padding: 0 8px; gap: 4px; color: var(--bad-ink, #ff8a8a); background: rgba(255, 90, 90, .16); box-shadow: inset 0 0 0 1.5px rgba(255, 90, 90, .8); font-size: 12px; }
.bc-mini.armed .chip { padding: 2px 6px 2px 3px; font-size: 12px; background: none; box-shadow: none; }
  .bc-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
  .bc-state { flex: 1 1 auto; min-width: 0; font-size: 12px; font-weight: 800; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bc-state.ok { color: var(--good-ink); } .bc-state.warn { color: var(--dust-ink); } .bc-state.bad { color: var(--bad-ink); }
  .bc-draw { flex: none; font-size: 12px; color: var(--ink-3); }
  .bc-buy { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: var(--r-md); color: var(--buy-ink); background: linear-gradient(180deg, #6df0a4, var(--buy)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 3px 0 var(--buy-edge); }
  .bc-buy:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 0 0 var(--buy-edge); }
  
  .bc-cost { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.chip { gap: 4px; padding: 3px 9px 3px 5px; border-radius: 999px; font-size: 13px; font-weight: 900; line-height: 1; color: var(--ink);
  background: color-mix(in srgb, var(--ic, #888) 16%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ic, #888) 55%, transparent); }
.chip .fd-ic { width: 18px; height: 18px; flex: none; color: var(--ic, currentColor); }
.chip i { font-style: normal; font-weight: 700; opacity: .7; }
.chip.short { color: var(--bad-ink, #ff8a8a); background: rgba(255, 90, 90, .14); box-shadow: inset 0 0 0 1.5px rgba(255, 90, 90, .7); }
.chip.short b { color: inherit; }
.chip.short .fd-ic { filter: saturate(.7); } .bc-act { font-size: 13px; font-weight: 900; padding-left: 8px; border-left: 1.5px solid rgba(5, 49, 26, .25); }
  .bc-buy:disabled { color: var(--ink-3); background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px var(--line); }
  .bc-buy:disabled .fd-ic { color: var(--ink-3); }

  /* decrees */
  .decree-list { display: grid; gap: 8px; }
  .dcard { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--r-md); background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .dcard.locked { opacity: .5; }
  .dcard.on { box-shadow: inset 0 0 0 2.5px var(--core), 0 3px 0 var(--core-edge), 0 0 16px rgba(167, 139, 255, .35); }
  .dcard:active:not(.locked):not(.on) { transform: translateY(3px); }
  .dc-ico { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: rgba(255, 255, 255, .08); }
  .dc-ico .fd-ic { width: 26px; height: 26px; }
  .dc-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .dc-main b { font-size: 15px; font-weight: 900; } .dc-fx { font-size: 12px; color: var(--ink-2); line-height: 1.45; }
  .dc-need { font-size: 12px; font-weight: 700; color: var(--ink-3); }
  .dc-state { padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 900; white-space: nowrap; color: var(--core-text); background: rgba(167, 139, 255, .16); }
  .dcard.on .dc-state { color: var(--core-ink); background: linear-gradient(180deg, #c9b8ff, var(--core)); }

  /* tech cards */
  .tech-list { display: grid; gap: 8px; }
  .branch-head { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; font-weight: 900; }
  .tcard { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--r-md); background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .tcard.locked { opacity: .5; } .tcard.open { opacity: .82; }
  .tcard.ready { box-shadow: inset 0 0 0 2px var(--buy), 0 3px 0 var(--edge), 0 0 16px rgba(61, 220, 132, .3); }
  .tcard.done { box-shadow: inset 0 0 0 2px rgba(61, 220, 132, .45); opacity: .85; }
  .tcard.ready:active { transform: translateY(3px); }
  .tc-ico { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: rgba(255, 255, 255, .08); }
  .tc-ico .fd-ic { width: 26px; height: 26px; }
  .tc-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .tc-main b { font-size: 15px; font-weight: 900; } .tc-fx { font-size: 12px; color: var(--ink-2); }
  .tc-need { font-size: 12px; font-weight: 700; color: var(--ink-3); } .tcard.ready .tc-need { color: var(--good-ink); }
  .tc-cost { display: flex; gap: 8px; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 900; white-space: nowrap; background: rgba(255, 255, 255, .1); }
  .tcard.done .tc-cost { display: none; }
  /* responsive: phone = one pane + bottom tabs; desktop = three live columns, each scrolling on its own */
  /* the wrapper must not create a box on phones, or the four panes stop behaving as tabs */
  .side-col { display: contents; }

  @media (min-width: 1000px) {
    body { display: block; }
    .app { max-width: none; height: 100dvh; border-radius: 0; background: transparent; box-shadow: none; display: grid; grid-template-columns: 1fr 1.15fr 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "hud hud hud" "alerts alerts alerts" "board board board"; padding: 0 20px 16px; gap: 0 18px; }
    .hud { grid-area: hud; padding: 14px 0 10px; }
    .brand { display: flex; flex-direction: column; margin-right: 8px; line-height: 1.1; }
    .brand b { font-size: 22px; font-weight: 900; } .brand span { font-size: 11px; letter-spacing: .24em; color: var(--ink-3); }
    .power { max-width: 520px; }
    .alerts { grid-area: alerts; padding: 0 0 8px; }
    .board { grid-area: board; min-height: 0; }
    .tabs { display: none; }
    .tab-body { display: grid; grid-template-columns: 1fr 1.15fr 1fr; grid-template-rows: minmax(0, 1fr); gap: 18px; padding: 0; overflow: hidden; }
    .tab-pane, .tab-pane.active { display: block; min-height: 0; overflow-y: auto; padding: 4px 6px 24px 2px; animation: none; }
    #pane-overview { grid-column: 1; } #pane-build { grid-column: 2; }
    /* tech and map share the third column and scroll together, so neither is ever unreachable */
    .side-col { display: flex; flex-direction: column; grid-column: 3; min-height: 0; overflow-y: auto; padding: 4px 6px 24px 2px; }
    .side-col .tab-pane, .side-col .tab-pane.active { display: block; overflow: visible; padding: 0; flex: none; }
    #pane-map { order: -1; margin-bottom: 18px; }
  }
}

/* toasts are styled in the overlays layer, which outranks pages — so the wide-screen position is set from inside it */
@layer overlays {
  @media (min-width: 1000px) {
    body .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; }
  }
}