:root {
  color-scheme: dark;
  --bg: #12101a;
  --card: #1b1826;
  --card-elev: #211d2f;
  --border: #3a324d;
  --border-hover: #53486e;
  --text: #f3efe6;
  --muted: #a69eb8;
  --accent: #ff9429;
  --hp: #ef4444;
  --mp: #3b82f6;
  --info: #38bdf8;
  --gold: #fbbf24;
  --ok: #4ade80;
  --purple: #c084fc;
}

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

body {
  background: radial-gradient(circle at top center, #221c35 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
  padding: 16px;
  min-height: 100vh;
}

.wrap { max-width: 1360px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

/* Icons */
.ui-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.done-icon { color: var(--ok); }

/* Header & Navigation */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
h1 { font-size: 1.25rem; line-height: 1.2; }
h2 { font-size: 1rem; font-weight: 700; line-height: 1.25; }
.muted { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }
.muted.small { font-size: 0.75rem; margin-top: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #334155;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pill.live,
.pill.active-state { background: rgba(52, 211, 153, 0.18); color: var(--ok); border: 1px solid rgba(52, 211, 153, 0.3); }
.pill.paused { background: rgba(250, 204, 21, 0.14); color: var(--gold); border: 1px solid rgba(250, 204, 21, 0.3); }
.pill.offline { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.28); }
.pill.wake { border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; font-family: inherit; }
.pill.wake:hover:not(:disabled) { border-color: var(--border-hover); color: var(--text); background: var(--card-elev); }
.pill.wake.active { background: rgba(250, 204, 21, 0.16); border-color: rgba(250, 204, 21, 0.55); color: var(--gold); }
.pill.wake:disabled { opacity: 0.45; cursor: not-allowed; }
.pill.icon-pill { padding: 0 10px; }
.pill.icon-only { width: 28px; min-width: 28px; padding: 0; }

.tabs-bar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .tabs-bar { grid-template-columns: repeat(4, 1fr); } }
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tab-btn:hover:not(.active) { color: var(--text); border-color: var(--border-hover); background: var(--card-elev); }
.tab-btn.active {
  color: #fff7ed;
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 148, 41, 0.24), rgba(255, 148, 41, 0.1));
  box-shadow: inset 0 1px 0 rgba(255, 215, 130, 0.18);
}

.tab-view { display: flex; flex-direction: column; gap: 12px; }

/* Unified Production Form Controls */
input[type="text"],
input[type="number"],
input[type="url"],
select {
  width: 100%;
  height: 38px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.25;
  vertical-align: middle;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:hover,
input[type="number"]:hover,
input[type="url"]:hover,
select:hover { border-color: var(--border-hover); }
input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
input[type="url"]:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 148, 41, 0.25);
}
input::placeholder { color: #7c7491; }

/* Cards & HUD Layout */
.hud-layout { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: stretch; }
@media (min-width: 960px) { .hud-layout { grid-template-columns: minmax(0, 1.65fr) minmax(310px, 1fr); } }
.hud-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hud-side { display: flex; flex-direction: column; min-height: 260px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 224, 160, 0.06), 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* Setup View */
.config { display: flex; flex-direction: column; gap: 14px; }
.config-group { display: flex; flex-direction: column; gap: 8px; }
.config-group.divider { border-top: 1px solid var(--border); padding-top: 12px; }
.bridge-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .bridge-grid { grid-template-columns: repeat(3, 1fr); } }
.bridge-node { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.bridge-val { font-size: 0.86rem; font-weight: 700; color: var(--text); }
.bridge-val.online { color: var(--ok); }
.row-worker { display: grid; grid-template-columns: 1fr; gap: 8px; }
.row-codec { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.config .actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.config .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  background: var(--accent);
  color: #120c05;
  border: none;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.84rem;
  font-family: inherit;
  white-space: nowrap;
}
.config .actions button:disabled { background: #1e293b; color: var(--muted); border: 1px solid var(--border); cursor: not-allowed; opacity: 0.7; }
.config .actions .btn-sec { background: #1e293b; color: var(--text); border: 1px solid var(--border); }

/* Character Level & Sprint Banners */
.level-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.level-identity,
.level-eta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.level-badge {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--gold);
}
.job-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  color: #ffedd5;
  background: rgba(255, 148, 41, 0.18);
  border: 1px solid rgba(255, 148, 41, 0.45);
  padding: 0 10px;
  border-radius: 999px;
}
.level-exp-detail { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.level-pct { font-size: 0.88rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fde68a; }
.eta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ok);
  background: rgba(74, 222, 128, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.35);
  padding: 0 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.progress-track { width: 100%; height: 10px; background: #0d0b14; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #facc15 55%, #a3e635); transition: width 0.25s ease; }
.progress-fill.sprint-fill { background: linear-gradient(90deg, #ff9429, #fbbf24 65%, #4ade80); }
.progress-fill.done { background: var(--ok); }

/* Metric Cards Grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.label-row .label { margin-bottom: 0; white-space: nowrap; }
.label { font-size: 0.7rem; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 4px; text-transform: uppercase; }
.mini-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  color: #ffedd5;
  background: rgba(255, 148, 41, 0.16);
  border: 1px solid rgba(255, 148, 41, 0.32);
  padding: 0 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.val { font-size: 1.45rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.val.small { font-size: 0.85rem; }
.sub { font-size: 0.74rem; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.breakdown-list:empty { display: none; }
.breakdown-chip { font-size: 0.68rem; color: var(--text); background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }
.hp { color: var(--hp); }
.mp { color: var(--mp); }
.gold { color: var(--gold); }

/* Live Feed */
.feed-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.feed-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 9px;
  font-size: 0.71rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.feed-chip:hover:not(.active) { color: var(--text); border-color: var(--border-hover); }
.feed-chip.active { color: #fff7ed; border-color: var(--accent); background: rgba(255, 148, 41, 0.22); }
.feed { list-style: none; display: flex; flex-direction: column; gap: 6px; flex: 1; max-height: 410px; overflow-y: auto; font-size: 0.83rem; margin-top: 8px; }
.feed li { padding: 7px 9px; background: rgba(255, 255, 255, 0.03); border-radius: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.feed li.major { border-left: 3px solid var(--ok); background: rgba(74, 222, 128, 0.08); }
.feed .ts { color: var(--muted); font-size: 0.74rem; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Best Maps */
.guide-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.how-it-works { font-size: 0.78rem; color: var(--muted); max-width: 440px; }
.how-it-works summary { cursor: pointer; color: var(--accent); font-weight: 700; list-style: none; }
.how-it-works summary::-webkit-details-marker { display: none; }
.how-body { margin-top: 6px; padding: 9px 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; line-height: 1.45; color: var(--muted); }
.how-body strong { color: var(--text); }
.guide-filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; align-items: end; }
@media (min-width: 640px) { .guide-filters { grid-template-columns: 96px 1.25fr 1fr 1.35fr; } }
.filter-field { display: flex; flex-direction: column; gap: 5px; }
.filter-field .label { margin-bottom: 0; }
.guide-list { display: flex; flex-direction: column; gap: 8px; }
.guide-empty { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; color: var(--muted); text-align: center; font-size: 0.88rem; }
.guide-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: border-color 0.15s ease; }
.guide-card:hover { border-color: rgba(255, 148, 41, 0.45); }
.guide-card[open] { border-color: rgba(255, 148, 41, 0.65); }
.guide-summary { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto 76px auto; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.guide-summary::-webkit-details-marker { display: none; }
.guide-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.guide-rank { font-size: 0.88rem; font-weight: 800; color: var(--muted); text-align: center; }
.guide-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.guide-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.guide-map-name { font-size: 0.96rem; font-weight: 700; color: var(--text); }
.guide-meta { font-size: 0.76rem; color: var(--muted); }
.guide-reason { font-size: 0.78rem; color: #cfc8de; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guide-tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; max-width: 340px; }
.guide-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  white-space: nowrap;
}
.guide-pill.pos { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.1); }
.guide-pill.info { color: var(--info); border-color: rgba(56, 189, 248, 0.35); background: rgba(56, 189, 248, 0.1); }
.guide-pill.gold { color: var(--gold); border-color: rgba(251, 191, 36, 0.38); background: rgba(251, 191, 36, 0.12); }
.guide-pill.warn { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.1); }
.guide-score-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.guide-score-val { font-size: 0.98rem; font-weight: 800; color: var(--text); line-height: 1; text-align: right; }
.guide-score-val span { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.guide-score-val.high { color: var(--ok); }
.guide-score-val.mid { color: var(--accent); }
.guide-score-val.low { color: var(--muted); }
.guide-score-bar { width: 100%; height: 4px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.guide-score-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.guide-score-fill.high { background: var(--ok); }
.guide-score-fill.low { background: #64748b; }
.guide-chevron { font-size: 0.74rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.guide-card[open] .guide-chevron { color: var(--accent); }
.guide-details { border-top: 1px solid var(--border); padding: 12px 14px; background: rgba(13, 11, 20, 0.45); display: flex; flex-direction: column; gap: 10px; }
.detail-metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 720px) { .detail-metrics { grid-template-columns: repeat(4, 1fr); } }
.detail-metric { background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--muted); }
.detail-metric strong { color: var(--text); font-size: 0.8rem; }
.mob-table-wrap { overflow-x: auto; }
.mob-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.mob-table th,
.mob-table td { padding: 7px 8px; border-bottom: 1px solid rgba(58, 50, 77, 0.6); text-align: left; vertical-align: middle; }
.mob-table th { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mob-table th.num,
.mob-table td.num { text-align: right; }
.el-tag { display: inline-flex; align-items: center; font-size: 0.68rem; font-weight: 700; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); }
.el-tag.pos { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.el-tag.warn { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.guide-details-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.guide-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hs-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffedd5;
  text-decoration: none;
  border: 1px solid rgba(255, 148, 41, 0.4);
  background: rgba(255, 148, 41, 0.14);
  padding: 0 9px;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
}
.hs-link:hover:not(:disabled) { background: rgba(255, 148, 41, 0.28); }
.hs-link.muted-pill,
.hs-link:disabled { color: var(--muted); border-color: var(--border); background: rgba(255, 255, 255, 0.04); cursor: not-allowed; opacity: 0.7; }
@media (max-width: 720px) {
  .guide-summary { grid-template-columns: 30px minmax(0, 1fr) 68px; gap: 8px; }
  .guide-tags,
  .guide-chevron { grid-column: 2 / -1; justify-content: flex-start; max-width: none; }
  .guide-reason { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .guide-card,
  .progress-fill,
  .pill,
  .tab-btn { transition: none; }
}

/* Map Log */
.history-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.splits-filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; align-items: end; }
@media (min-width: 720px) { .splits-filters { grid-template-columns: 126px 150px 1fr auto; } }
.check-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 6px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.check-field:hover { color: var(--text); }
.check-field input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.table-wrap { overflow-x: auto; }
.splits-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.splits-table th,
.splits-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.splits-table th.num,
.splits-table td.num { text-align: right; }
.splits-table th.num + th:not(.num),
.splits-table td.num + td:not(.num) { padding-left: 20px; }
.splits-table th { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.active-split-row { background: rgba(255, 148, 41, 0.07); }
.live-row-pill { display: inline-flex; align-items: center; font-size: 0.62rem; font-weight: 800; color: var(--ok); background: rgba(74, 222, 128, 0.14); border: 1px solid rgba(74, 222, 128, 0.35); border-radius: 999px; padding: 2px 6px; margin-right: 4px; vertical-align: middle; }
.split-mob-chip { display: inline-block; font-size: 0.7rem; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; margin: 1px 3px 1px 0; }
.empty-cell { text-align: center !important; color: var(--muted); padding: 20px !important; }

/* Toasts */
.toast-container { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; max-width: 340px; }
.toast { background: #1c1929; border: 1px solid var(--ok); color: var(--text); border-radius: 10px; padding: 10px 14px; font-size: 0.84rem; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); }
.toast strong { color: var(--ok); display: block; font-size: 0.78rem; margin-bottom: 2px; }

/* Live HUD Sprint Banner & Active Challenges Widget */
.sprint-banner { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.sprint-banner-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sprint-banner-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sprint-banner-title strong { font-size: 0.94rem; }
.sprint-banner-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hud-challenges { display: flex; flex-direction: column; gap: 8px; }
.hud-ch-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 720px) { .hud-ch-list { grid-template-columns: repeat(3, 1fr); } }
.hud-ch-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; }
.hud-ch-item.done { border-color: rgba(74, 222, 128, 0.45); }
.hud-ch-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.76rem; }
.hud-ch-title { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--text); min-width: 0; }
.hud-ch-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-ch-val { color: var(--muted); font-size: 0.72rem; flex-shrink: 0; }
.hud-ch-more { grid-column: 1 / -1; text-align: center; padding-top: 2px; }
.mini-track { height: 5px; background: #0d0b14; border-radius: 999px; overflow: hidden; }
.mini-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.mini-fill.done { background: var(--ok); }

/* Target Sessions Planner */
.plan-sprint-btn,
.start-sprint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--accent);
  color: #120c05;
  border: none;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: filter 0.15s ease;
}
.plan-sprint-btn { height: 28px; font-size: 0.74rem; padding: 0 11px; }
.start-sprint-btn { height: 38px; font-size: 0.86rem; padding: 0 18px; }
.plan-sprint-btn:hover,
.start-sprint-btn:hover { filter: brightness(1.08); }
.session-builder-card { display: flex; flex-direction: column; gap: 14px; }
.context-banner { background: rgba(255, 148, 41, 0.12); border: 1px solid rgba(255, 148, 41, 0.4); border-radius: 8px; padding: 9px 12px; font-size: 0.82rem; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.templates-section { display: flex; flex-direction: column; gap: 6px; }
.templates-row { display: flex; flex-wrap: wrap; gap: 6px; }
.templates-row .pill.active { background: rgba(255, 148, 41, 0.22); border-color: var(--accent); color: #fff7ed; font-weight: 800; box-shadow: 0 0 0 1px rgba(255, 148, 41, 0.45); }
.session-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.session-mix-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.calc-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.calc-summary { display: flex; flex-direction: column; gap: 3px; font-size: 0.84rem; }

/* Challenges Board & Drag-and-Drop Library */
.lib-filter-select { width: auto; min-width: 170px; }
.drop-zone { transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease; }
.drop-zone.drag-over {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 148, 41, 0.09), var(--card));
  box-shadow: 0 0 0 2px rgba(255, 148, 41, 0.3);
}
.drop-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--border-hover);
  border-radius: 9px;
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  background: rgba(18, 16, 26, 0.5);
}
.drop-empty strong { color: var(--text); }
.drag-handle { display: inline-flex; align-items: center; color: #7c7491; cursor: grab; padding: 2px 0; }
.drag-handle.muted-handle { opacity: 0.3; cursor: default; }
.is-dragging { opacity: 0.45; }

.ch-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 780px) { .ch-grid { grid-template-columns: repeat(3, 1fr); } }
.ch-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 9px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: grab;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ch-card:hover { border-color: var(--border-hover); border-left-color: var(--accent); }
.ch-card.done { border-color: rgba(74, 222, 128, 0.45); border-left-color: var(--ok); }
.ch-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ch-card-lead { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ch-card h3 { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; line-height: 1.3; margin-top: 0; }
.ch-cat { display: inline-flex; align-items: center; gap: 4px; font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.ch-cat-icon { color: var(--accent); }
.ch-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.ch-pct { font-size: 0.82rem; font-weight: 800; color: var(--gold); margin-right: 2px; }
.ch-meta { display: flex; justify-content: space-between; align-items: center; font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.lib-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 720px) { .lib-list { grid-template-columns: repeat(2, 1fr); } }
.lib-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: grab;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.lib-row:hover:not(.is-active) { border-color: var(--border-hover); background: rgba(255, 148, 41, 0.05); }
.lib-row.is-active { cursor: default; border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.05); }
.lib-row-lead { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lib-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 148, 41, 0.12);
  border: 1px solid rgba(255, 148, 41, 0.25);
  flex-shrink: 0;
}
.lib-row-text { min-width: 0; }
.lib-row strong { display: block; font-size: 0.84rem; margin-top: 1px; line-height: 1.25; }
.lib-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.active-state-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ok);
  background: rgba(74, 222, 128, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 999px;
  min-height: 26px;
  padding: 0 9px;
}

/* Utility visibility override — always last in cascade */
.hidden { display: none; }
.tab-view.hidden,
.filter-field.hidden,
.context-banner.hidden,
.session-mix-grid.hidden,
.pill.hidden,
.progress-track.hidden { display: none; }

/* R11 Net Balance & Supplies Used */
.val.neg, td.neg { color: #f87171; }
.breakdown-chip.editable {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.breakdown-chip.editable:hover {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
}
.supply-cost-editor {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.supply-cost-editor.hidden { display: none; }
.supply-cost-editor input {
  width: 78px;
  height: 28px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-size: 12px;
}
.mini-btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: rgba(245, 158, 11, 0.16);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.mini-btn.ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
}
.mini-btn:hover { filter: brightness(1.15); }
.split-supply-note {
  font-size: 11px;
  color: #f87171;
  opacity: 0.9;
}
.breakdown-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.item-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0 2px;
  font-size: 0.74rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted rgba(161, 152, 184, 0.4);
}
.site-footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.site-footer .sep { opacity: 0.45; }

/* Option B Planner & Vault Sub-Navigation */
.planner-subbar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
@media (min-width: 640px) { .planner-subbar { grid-template-columns: repeat(4, 1fr); } }
.sub-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sub-tab-btn:hover:not(.active) { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.sub-tab-btn.active {
  color: #fff7ed;
  border-color: rgba(255, 148, 41, 0.55);
  background: rgba(255, 148, 41, 0.16);
}
.sub-view { display: flex; flex-direction: column; gap: 12px; }

/* Build & Combat Simulator (R9 — Option B Refined) */
.build-strip-card { display: flex; flex-direction: column; gap: 12px; }
.build-sync-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.build-sync-left,
.build-sync-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.build-gear-drawer {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.synced-drawer-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 820px) { .synced-drawer-grid { grid-template-columns: 1.2fr 1fr; } }
.gear-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.gear-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}
.gear-slot { color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.gear-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gear-stats { color: var(--gold); font-size: 0.73rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

.build-stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
@media (min-width: 720px) {
  .build-stats-row { grid-template-columns: repeat(9, minmax(0, 1fr)) 2.4fr 0.9fr; }
}
.compact-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.compact-stat .label { margin-bottom: 0; font-size: 0.66rem; }
.compact-stat input,
.compact-stat select { height: 34px; padding: 4px 8px; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.compact-stat.skill-select-col { grid-column: span 2; }
@media (min-width: 720px) { .compact-stat.skill-select-col { grid-column: span 1; } }

.build-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.build-buffs-row { display: flex; flex-wrap: wrap; gap: 6px; }
.buff-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.buff-chip:hover { border-color: var(--border-hover); color: var(--text); }
.buff-chip.active {
  background: rgba(255, 148, 41, 0.18);
  border-color: rgba(255, 148, 41, 0.6);
  color: #ffedd5;
}
.build-summary-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.summary-chip strong { color: var(--text); }

.build-mobs-card { display: flex; flex-direction: column; gap: 10px; }
.build-mobs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.build-mobs-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.add-mob-box { display: flex; align-items: center; gap: 6px; }
.add-mob-box input { width: 200px; height: 34px; font-size: 0.82rem; }
.build-mobs-controls select { width: 165px; height: 34px; font-size: 0.82rem; }
.build-table td, .build-table th { white-space: nowrap; }
.htk-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.71rem;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.htk-chip strong { color: var(--text); }
.hit-perfect { color: var(--ok); font-weight: 700; }
.hit-warn { color: var(--gold); font-weight: 700; }
.hit-low { color: var(--hp); font-weight: 700; }
.row-remove-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.78rem;
}
.row-remove-btn:hover { color: var(--hp); border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.1); }

/* Investment Portfolio (R12 — Option B Refined) */
.pf-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pf-arm-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pf-arm-meta { display: flex; flex-direction: column; gap: 1px; }
.pf-arm-meta strong { font-size: 0.86rem; }
.pf-arm-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 148, 41, 0.55);
  background: rgba(255, 148, 41, 0.16);
  color: #ffedd5;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pf-arm-btn:hover { background: rgba(255, 148, 41, 0.25); }
.pf-arm-btn.armed {
  background: rgba(74, 222, 128, 0.18);
  border-color: var(--ok);
  color: var(--ok);
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}
.pf-right-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pf-add-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}
@media (min-width: 760px) {
  .pf-add-grid { grid-template-columns: 2.2fr 0.7fr 1.1fr 1.1fr auto; }
}
.pf-add-submit .start-sprint-btn { height: 38px; padding: 0 16px; width: 100%; }

.pf-visuals-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 860px) {
  .pf-visuals-grid { grid-template-columns: 1.18fr 1fr; }
}
.pf-trend-card,
.pf-alloc-card { display: flex; flex-direction: column; gap: 10px; }
.pf-kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.pf-kpi-val { font-size: 1.18rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pf-kpi-val.pos { color: var(--ok); }
.pf-kpi-val.neg { color: var(--hp); }
.pf-trend-wrap { width: 100%; height: 128px; }
.pf-chart-svg { width: 100%; height: 100%; display: block; }
.pf-grid-line { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.pf-axis-txt { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

.pf-alloc-body {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.pf-donut-wrap { display: flex; align-items: center; justify-content: center; }
.pf-donut-big { fill: var(--text); font-size: 20px; font-weight: 800; }
.pf-donut-sub { fill: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 0.08em; }
.pf-alloc-legend { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pf-alloc-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 36px 56px;
  gap: 7px;
  align-items: center;
  font-size: 0.77rem;
}
.pf-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pf-alloc-name { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-alloc-pct { color: var(--muted); text-align: right; }
.pf-alloc-val { color: var(--gold); text-align: right; font-weight: 700; }
.pf-cat-bar { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.06); }

.pf-ledger-card { display: flex; flex-direction: column; gap: 10px; }
.pf-table td, .pf-table th { white-space: nowrap; }
.pf-row { cursor: pointer; }
.pf-row:hover { background: rgba(255, 255, 255, 0.03); }
.pf-item-cell { display: inline-flex; align-items: center; gap: 7px; }
.pf-inline-input {
  width: 92px !important;
  height: 28px !important;
  padding: 2px 7px !important;
  font-size: 0.78rem !important;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pf-inline-input.qty { width: 64px !important; }
.pf-src-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-left: 5px;
  text-transform: uppercase;
}
.pf-src-pill.cozy { color: var(--info); border-color: rgba(56, 189, 248, 0.4); }
.pf-src-pill.custom { color: var(--gold); border-color: rgba(251, 191, 36, 0.4); }
.pf-pl-pos { color: var(--ok); font-weight: 700; }
.pf-pl-neg { color: var(--hp); font-weight: 700; }
.pf-detail-row td { background: rgba(13, 11, 20, 0.6); padding: 10px 14px; }
.pf-history-box { display: flex; flex-direction: column; gap: 6px; }
.pf-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
}
.pf-history-meta { display: inline-flex; align-items: center; gap: 10px; }
.pf-history-meta strong.pos { color: var(--ok); }
.pf-history-meta strong.neg { color: var(--hp); }
.pf-spark-svg { width: 100%; height: 64px; display: block; }

.hidden { display: none; }
