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

body {
  background: #0c0c0c;
  color: #c8c8c8;
  font-family: 'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

input {
  user-select: text;
}

/* ── SCROLLBAR ── */
* {
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a2a2a;
}

::-webkit-scrollbar-thumb:hover {
  background: #3d3d3d;
}

/* ── TOP BAR ── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  background: #0c0c0c;
}

#topbar-n {
  font-size: 13px;
  color: #c8c8c8;
  letter-spacing: 0.03em;
}

#topbar-divider {
  width: 1px;
  height: 18px;
  background: #1e1e1e;
  margin: 0 16px;
}

#topbar-rate {
  font-size: 11px;
  color: #555;
  letter-spacing: 0.03em;
}

.topbar-divider {
  width: 1px;
  height: 18px;
  background: #1e1e1e;
  margin: 0 16px;
}

#topbar-seq {
  font-size: 11px;
  color: #6a8aaa;
  letter-spacing: 0.03em;
}

#topbar-iter {
  font-size: 13px;
  color: #8a6820;
  letter-spacing: 0.03em;
}

/* ── TAB BAR ── */
#tabbar {
  position: fixed;
  top: 42px;
  left: 0;
  right: 0;
  height: 34px;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  align-items: stretch;
  z-index: 100;
  background: #0c0c0c;
}

.tab {
  background: transparent;
  border: none;
  border-right: 1px solid #1e1e1e;
  color: #444;
  font-family: inherit;
  font-size: 11px;
  padding: 0 20px;
  cursor: pointer;
  letter-spacing: 0.08em;
  position: relative;
  transition: color 0.08s;
}

.tab:hover:not(.active) {
  color: #888;
}

.tab.active {
  color: #c8c8c8;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: #c8c8c8;
}

/* ── TAB: iteration accent ── */
#tab-iteration:hover:not(.active) {
  color: #7a5818;
}

#tab-iteration.active {
  color: #b88828;
}

#tab-iteration.active::after {
  background: #b88828;
}

/* ── ITER SUBTAB BAR ── */
#iter-subtabbar {
  display: none;
  position: fixed;
  top: 76px; /* 42 topbar + 34 tabbar */
  left: 0;
  right: 0;
  height: 34px;
  border-bottom: 1px solid #1e1e1e;
  align-items: stretch;
  z-index: 100;
  background: #0c0c0c;
}

#iter-subtabbar.visible {
  display: flex;
}

.iter-subtab {
  background: transparent;
  border: none;
  border-right: 1px solid #1e1e1e;
  color: #444;
  font-family: inherit;
  font-size: 11px;
  padding: 0 20px;
  cursor: pointer;
  letter-spacing: 0.08em;
  position: relative;
  transition: color 0.08s;
}

.iter-subtab:hover:not(.active) {
  color: #7a5818;
}

.iter-subtab.active {
  color: #b88828;
}

.iter-subtab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: #b88828;
}

/* ── ITER SUBPANELS ── */
.iter-subpanel {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
}

.iter-subpanel.active {
  display: flex;
}

/* ── BACKGROUND LAYERS ── */
#particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 600ms ease;
}

#grid-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 75% at 50% 45%, black 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 45%, black 0%, transparent 100%);
}

/* ── PANELS ── */
.panel {
  display: none;
  position: relative;
  z-index: 2;
}

.panel.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ── MAIN PANEL ── */
#upgrade-column {
  width: 100%;
  max-width: 480px;
  padding-top: 116px; /* 42 topbar + 34 tabbar + 40 breathing room */
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

#prestige-column {
  width: 100%;
  max-width: 760px;
  padding-top: 28px;
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* ── SETTINGS PANEL ── */
#settings-column {
  width: 100%;
  max-width: 480px;
  padding-top: 116px;
  padding-bottom: 24px;
  padding-left: 20px;
  padding-right: 20px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #1a1a1a;
  border-top: none;
  padding: 12px 14px;
  gap: 16px;
}

.settings-row:first-child {
  border-top: 1px solid #1a1a1a;
}

.settings-row:hover {
  border-color: #2e2e2e;
}

.settings-row:hover + .settings-row {
  border-top-color: #2e2e2e;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-name {
  font-size: 12px;
  color: #e8e8e8;
  letter-spacing: 0.04em;
}

.settings-dev {
  display: none;
}

.settings-dev .settings-name {
  color: #555;
}

.settings-desc {
  font-size: 10px;
  color: #444;
  letter-spacing: 0.02em;
}

.settings-btn {
  background: transparent;
  border: 1px solid #2e2e2e;
  color: #888;
  font-family: inherit;
  font-size: 10px;
  padding: 4px 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.settings-btn:hover {
  background: #c8c8c8;
  color: #0c0c0c;
  border-color: #c8c8c8;
}

.settings-btn.danger {
  border-color: #4a1a1a;
  color: #a04040;
}

.settings-btn.danger:hover {
  background: #6b0000;
  color: #e0b0b0;
  border-color: #6b0000;
}

#autosave-toast {
  position: fixed;
  bottom: 16px;
  right: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #333;
  letter-spacing: 0.1em;
  pointer-events: none;
  opacity: 0;
  z-index: 999;
}

#autosave-toast.autosave-active {
  animation: autosave-fade 2.5s ease forwards;
}

@keyframes autosave-fade {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── MANUAL ── */
#manual-column {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  padding: 120px 0 40px;
}

.manual-section-gap {
  margin-top: 20px;
}

.manual-block {
  padding: 14px 16px;
  border: 1px solid #181818;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.manual-block.first-in-group {
  border-top: 1px solid #181818;
}

.manual-p {
  font-size: 11px;
  color: #666;
  line-height: 1.75;
  letter-spacing: 0.02em;
}

.manual-hl {
  color: #aaa;
}

.manual-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
  border-left: 1px solid #222;
}

.manual-entry-name {
  font-size: 11px;
  color: #c0c0c0;
  letter-spacing: 0.04em;
}

.manual-entry-sub {
  font-size: 10px;
  color: #5a5a5a;
  line-height: 1.65;
  letter-spacing: 0.02em;
}

.manual-dim {
  color: #383838;
}

.manual-unlock {
  font-size: 10px;
  color: #404040;
  letter-spacing: 0.03em;
  padding-left: 6px;
}

.manual-kv-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
}

.manual-kv {
  display: flex;
  gap: 0;
  font-size: 10px;
  line-height: 1.5;
}

.manual-kv-key {
  color: #3a3a3a;
  flex-shrink: 0;
  width: 68px;
  letter-spacing: 0.03em;
}

.manual-kv-val {
  color: #555;
  letter-spacing: 0.02em;
}

#manual-spoiler-warning {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.manual-spoiler-line {
  width: 100%;
  height: 1px;
  background: #c04020;
  opacity: 0.6;
}

.manual-spoiler-label {
  margin: 0;
  font-size: 13px;
  font-weight: bold;
  color: #e05030;
  letter-spacing: 0.06em;
  text-align: center;
}

.manual-spoiler-sub {
  margin: 0;
  font-size: 11px;
  color: #804030;
  text-align: center;
  letter-spacing: 0.04em;
}

.manual-unknown-header {
  color: #222;
}

.manual-unknown-block {
  border-color: #141414;
}

.manual-unknown-block .manual-p {
  color: #222;
}

.settings-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-top: 1px solid #181818;
  font-size: 10px;
  color: #2e2e2e;
  letter-spacing: 0.05em;
}

.settings-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 12px 0 20px;
  opacity: 0.55;
  transition: opacity 0.3s;
}

.settings-logo:hover {
  opacity: 0.85;
}

.settings-logo-img {
  width: 340px;
  max-width: 100%;
  display: block;
}

/* ── SECTION LAYOUT ── */
.section-header {
  font-size: 9px;
  color: #2e2e2e;
  letter-spacing: 0.16em;
  padding: 0 0 7px 1px;
}

.section-gap {
  height: 28px;
}

/* ── UPGRADE CARD ── */
/* Border collapse: all cards share borders; first-in-group gets top border */
.upgrade-card {
  display: flex;
  align-items: center;
  border: 1px solid #1a1a1a;
  border-top: none;
  padding: 10px 12px;
  gap: 12px;
}

.upgrade-card.first-in-group {
  border-top: 1px solid #1a1a1a;
}

.upgrade-card:hover {
  border-color: #2e2e2e;
}

.upgrade-card + .upgrade-card:hover {
  border-top-color: #2e2e2e;
}

.upgrade-card:hover + .upgrade-card {
  border-top-color: #2e2e2e;
}

.upgrade-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upgrade-icon svg {
  display: block;
}

.upgrade-info {
  flex: 1;
  min-width: 0;
}

.upgrade-name {
  font-size: 12px;
  color: #e8e8e8;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.upgrade-desc {
  font-size: 10px;
  color: #555;
  letter-spacing: 0.02em;
}

.upgrade-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.upgrade-cost {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.02em;
}

.upgrade-cost.cannot-afford {
  color: #444;
}

.buy-btn {
  background: transparent;
  border: 1px solid #2e2e2e;
  color: #888;
  font-family: inherit;
  font-size: 10px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.buy-btn:hover:not(:disabled) {
  background: #c8c8c8;
  color: #0c0c0c;
  border-color: #c8c8c8;
}

.buy-btn:disabled {
  color: #333;
  border-color: #222;
  cursor: default;
}

/* ── RESET ROW (axiom + theorem side by side) ── */
#reset-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: flex-start;  /* each card expands independently */
  justify-content: center;
}

.reset-card {
  flex: 0 0 calc(50% - 4px);  /* always exactly half width regardless of content */
  max-width: calc(50% - 4px);
  min-width: 0;
  border: 1px solid #1a1a1a;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.reset-card:hover {
  border-color: #2e2e2e;
}

.reset-card-icon {
  width: 36px;
  height: 36px;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.reset-card-icon svg {
  display: block;
}

.reset-card-label {
  font-size: 9px;
  color: #555;
  letter-spacing: 0.12em;
}

.reset-card-count {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.04em;
}

.reset-card-boost {
  font-size: 10px;
  color: #557;
  letter-spacing: 0.03em;
}

.reset-card-req {
  font-size: 10px;
  color: #444;
  letter-spacing: 0.02em;
}

.reset-btn {
  width: 100%;
  margin-top: 4px;
  background: transparent;
  border: 1px solid #2e2e2e;
  color: #888;
  font-family: inherit;
  font-size: 10px;
  padding: 5px 8px;
  cursor: pointer;
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.reset-btn:hover:not(:disabled) {
  background: #c8c8c8;
  color: #0c0c0c;
  border-color: #c8c8c8;
}

.reset-btn:disabled {
  color: #333;
  border-color: #1e1e1e;
  cursor: default;
}

/* ── Milestone drawer (inside reset card) ── */
.ms-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px dotted #222;
  cursor: pointer;
  font-size: 9px;
  color: #333;
  letter-spacing: 0.06em;
  transition: color 0.1s;
  user-select: none;
}

.ms-toggle:hover {
  color: #666;
}

.ms-arrow {
  font-size: 8px;
  flex-shrink: 0;
}

.ms-drawer {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.reset-card.ms-open .ms-drawer {
  max-height: 400px;
}

/* Milestone rows inside a drawer — borderless, dotted separators */
.ms-drawer .milestone-row,
.ms-drawer .theorem-milestone-row {
  border: none;
  border-top: 1px dotted #1e1e1e;
  margin-top: 0;
  padding: 5px 2px;
}

.ms-drawer .milestone-row.first-in-group,
.ms-drawer .theorem-milestone-row.first-in-group {
  border-top: 1px dotted #1e1e1e;
  margin-top: 4px;
}

/* ── MILESTONE ROWS ── */
/* first-in-group connects to reset-row above (shared top border via margin) */
.milestone-row.first-in-group {
  margin-top: 8px;
  border-top: 1px solid #1a1a1a;
}

.milestone-row {
  display: grid;
  grid-template-columns: 20px 38px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #1a1a1a;
  border-top: none;
  padding: 7px 12px;
}

.ms-indicator {
  font-size: 10px;
  text-align: center;
  color: #4a7a5e;
}

.ms-req {
  font-size: 9px;
  color: #3a5a4a;
  letter-spacing: 0.06em;
}

.ms-name {
  font-size: 11px;
  color: #a8c8b8;
  letter-spacing: 0.04em;
}

.ms-desc {
  font-size: 10px;
  color: #3d6050;
  letter-spacing: 0.02em;
  text-align: right;
  white-space: pre-line;
}


/* ── THEOREM MILESTONE ROWS ── */
/* Same layout as axiom milestones but with an indigo/violet palette */
.theorem-milestone-row.first-in-group {
  margin-top: 8px;
  border-top: 1px solid #1a1a1a;
}

.theorem-milestone-row {
  display: grid;
  grid-template-columns: 20px 38px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #1a1a1a;
  border-top: none;
  padding: 7px 12px;
}

.theorem-milestone-row .ms-indicator {
  color: #4a5a8a;
}

.theorem-milestone-row .ms-req {
  color: #3a4a7a;
}

.theorem-milestone-row .ms-name {
  color: #a8b0d8;
}

.theorem-milestone-row .ms-desc {
  color: #3d4570;
}

.ms-locked {
  opacity: 0.38;
}

.ms-locked .ms-indicator {
  color: #555;
}

/* ── BRANCHED MILESTONE ROW ── */
.milestone-row.ms-branched {
  grid-template-columns: 20px 38px 24px 1fr;
  align-items: center;
}

.ms-branch-svg {
  display: block;
  flex-shrink: 0;
}

.ms-branch-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ms-branch-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  height: 20px;
}

.ms-branch-item .ms-desc {
  white-space: nowrap;
}

/* ── DEV INPUT GROUP ── */
.dev-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.dev-input {
  background: transparent;
  border: 1px solid #222;
  color: #555;
  font-family: inherit;
  font-size: 10px;
  padding: 4px 8px;
  width: 90px;
  letter-spacing: 0.04em;
  outline: none;
}

.dev-input:focus {
  border-color: #3a3a3a;
  color: #888;
}

/* ── MISC ── */
.level-badge {
  font-size: 9px;
  color: #444;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

/* ── SEQUENCES PANEL ── */
#sequences-column {
  width: 100%;
  max-width: 600px;
  padding-top: 116px;
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* ── FORMULA CARD ── */
.seq-formula-card {
  border: 1px solid #1a1a1a;
  border-top: none;
  display: flex;
  flex-direction: column;
}

.seq-formula-card.first-in-group {
  border-top: 1px solid #1a1a1a;
}

.seq-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #111;
}

.seq-formula-box {
  padding: 28px 32px 22px;
  text-align: center;
  background: #060607;
  border-bottom: 1px solid #111;
  color: #b8b8c0;
  overflow-x: auto;
}

.seq-formula-box .katex {
  font-size: 1.6em;
}

.seq-formula-box .katex-display {
  margin: 0;
}

/* ── VARIABLE ALLOCATION ── */
.seq-vars-section {
  padding: 12px 14px;
  border-bottom: 1px solid #111;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seq-var-free-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.seq-var-free {
  font-size: 10px;
  color: #3a3a3a;
  letter-spacing: 0.04em;
}

.seq-var-free.pts-avail {
  color: #8a8a8a;
}

.seq-var-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seq-var-letter {
  font-size: 15px;
  color: #9090a0;
  letter-spacing: 0.02em;
  font-style: italic;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.seq-var-val-pts {
  font-size: 10px;
  color: #666;
  letter-spacing: 0.03em;
  width: 48px;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.seq-var-slider {
  flex: 1;
  min-width: 60px;
  height: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: #252525;
  outline: none;
  cursor: pointer;
  border-radius: 0 !important;
}

.seq-var-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  background: #666;
  cursor: pointer;
  border: none;
}

.seq-var-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #666;
  border: none;
  cursor: pointer;
  border-radius: 0;
}

.seq-var-slider:hover::-webkit-slider-thumb { background: #c8c8c8; }
.seq-var-slider:hover::-moz-range-thumb     { background: #c8c8c8; }

.seq-var-effect {
  font-size: 10px;
  color: #4a6a4a;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  width: 110px;
  text-align: right;
}

.seq-card-divider {
  height: 1px;
  background: #111;
}

.seq-card-controls {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seq-controls-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ── PANEL CARDS (Reset) ── */
.seq-section-gap {
  margin-top: 22px;
}

.seq-panel-card {
  border: 1px solid #1a1a1a;
  border-top: none;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.seq-panel-card.first-in-group {
  border-top: 1px solid #1a1a1a;
}

.seq-panel-card:hover {
  border-color: #2e2e2e;
}

.seq-panel-label {
  font-size: 10px;
  color: #444;
  letter-spacing: 0.05em;
}

.seq-reset-warning {
  color: #7a4a3a;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.confirm-box {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 220px;
}

.confirm-label {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.06em;
  text-align: center;
}

.confirm-btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.confirm-btn {
  background: transparent;
  border: 1px solid #333;
  color: #666;
  font-family: inherit;
  font-size: 10px;
  padding: 4px 18px;
  cursor: pointer;
  letter-spacing: 0.06em;
}

.confirm-yes {
  border-color: #4a1a1a;
  color: #a04040;
}

.confirm-yes:hover {
  background: #1a0808;
  color: #cc5050;
}

.confirm-no:hover {
  background: #111;
  color: #aaa;
}

.seq-reformulate-card {
  border: 1px solid #2a3a1e;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #080a06;
}

.seq-ref-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seq-ref-label {
  font-size: 10px;
  color: #555;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.seq-ref-bar-wrap {
  flex: 1;
  height: 2px;
  background: #181818;
}

.seq-ref-bar-fill {
  height: 100%;
  width: 0%;
  background: #3a5a28;
  transition: width 0.25s ease, background 0.25s ease;
}

.seq-ref-bar-fill.ref-ready {
  background: #7aaa58;
}

.seq-ref-count {
  font-size: 10px;
  color: #3a4a30;
  flex-shrink: 0;
  letter-spacing: 0.04em;
  min-width: 7ch;
  text-align: right;
}

.seq-ref-count.ref-ready {
  color: #7aaa58;
}

.seq-reformulate-info {
  font-size: 10px;
  color: #3a4a30;
  letter-spacing: 0.03em;
  margin-top: 6px;
}

.seq-reformulate-unlock-hint {
  font-size: 11px;
  color: #6a9a6a;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.seq-reformulate-target {
  font-size: 11px;
  color: #6a8a52;
  letter-spacing: 0.06em;
}

.seq-reformulate-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid #3a5a28;
  color: #7aaa58;
  font-family: inherit;
  font-size: 10px;
  padding: 5px 18px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.seq-reformulate-btn:hover:not(:disabled) {
  background: #3a5a28;
  color: #c0e0a0;
  border-color: #3a5a28;
}

.seq-reformulate-btn:disabled {
  color: #2e3a24;
  border-color: #222a1a;
  cursor: default;
}

.seq-pts-preview {
  font-size: 11px;
  color: #888;
  letter-spacing: 0.03em;
}

.seq-reserve-display {
  font-size: 10px;
  color: #555;
  letter-spacing: 0.03em;
}

.seq-pts-cap-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seq-pts-cap-bar-wrap {
  flex: 1;
  height: 2px;
  background: #181818;
}

.seq-pts-cap-bar-fill {
  height: 100%;
  width: 0%;
  background: #3a5a28;
  transition: width 0.25s ease, background 0.25s ease;
}

.seq-pts-cap-bar-fill.pts-cap-full {
  background: #555;
}

.seq-pts-cap-count {
  font-size: 10px;
  color: #3a4a30;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.seq-pts-cap-count.pts-cap-full {
  color: #555;
}

.seq-ref-display {
  font-size: 10px;
  color: #5a7a4a;
  letter-spacing: 0.03em;
}

.seq-panel-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid #2e2e2e;
  color: #888;
  font-family: inherit;
  font-size: 10px;
  padding: 4px 14px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.seq-panel-btn:hover:not(:disabled) {
  background: #c8c8c8;
  color: #0c0c0c;
  border-color: #c8c8c8;
}

.seq-panel-btn:disabled {
  color: #333;
  border-color: #1e1e1e;
  cursor: default;
}

.seq-icon {
  width: 36px;
  height: 36px;
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

.seq-icon svg { display: block; }

.seq-info { min-width: 0; }

.seq-name {
  font-size: 12px;
  color: #e8e8e8;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

/* Progress blocks */
.seq-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.seq-blocks { display: flex; gap: 4px; }

.seq-block {
  width: 18px;
  height: 18px;
  border: 1px solid #1e1e1e;
  position: relative;
  flex-shrink: 0;
}

.seq-block.filled {
  border-color: #3a3a3a;
}

.seq-block.filled::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: #5a5a5a;
}

.seq-prog-count {
  font-size: 10px;
  color: #333;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Stats */
.seq-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  width: 100%;
}

.seq-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.seq-stat-label {
  font-size: 9px;
  color: #444;
  letter-spacing: 0.06em;
}

.seq-stat-val {
  font-size: 10px;
  color: #888;
  letter-spacing: 0.03em;
}

.seq-stat-val.softcapped {
  color: #c07830;
}

/* Buy button */
.seq-btn {
  background: transparent;
  border: 1px solid #2e2e2e;
  color: #888;
  font-family: inherit;
  font-size: 10px;
  padding: 4px 14px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.seq-btn:hover:not(:disabled) {
  background: #c8c8c8;
  color: #0c0c0c;
  border-color: #c8c8c8;
}

.seq-btn:disabled {
  color: #333;
  border-color: #1e1e1e;
  cursor: default;
}

/* ── Iteration panel ──────────────────────────────────────────────────────── */

#iter-sigma-column {
  width: 100%;
  max-width: 520px;
  padding-top: 150px;
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

#iteration-column {
  width: 100%;
  max-width: 520px;
  padding-top: 150px; /* 42 topbar + 34 tabbar + 34 subtabbar + 40 breathing room */
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.iteration-card {
  border: 2px solid #3a2808;
  padding: 28px 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: #060401;
}

.iteration-card.first-in-group {
  border-top: 2px solid #3a2808;
}

.iteration-card:hover {
  border-color: #5a4010;
}

.iteration-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.iteration-label {
  font-size: 10px;
  color: #6a4c14;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.iter-divider {
  width: 100%;
  height: 1px;
  background: #261a04;
  margin: 6px 0;
}

.iter-stat-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  font-size: 11px;
}

.iter-stat-label {
  color: #4a3410;
}

.iter-stat-val {
  color: #8a6820;
}

.iter-val-mult {
  color: #b88828;
}

.iter-val-dim {
  color: #3a2a10;
}

.iter-warning {
  font-size: 10px;
  color: #3a2608;
  text-align: center;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.iterate-btn {
  width: 100%;
  background: none;
  border: 1px solid #4a3210;
  color: #7a5818;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 7px 0;
  cursor: pointer;
  letter-spacing: 0.1em;
  margin-top: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.iterate-btn:hover:not(:disabled) {
  border-color: #8a6020;
  color: #c89030;
}

.iterate-btn:disabled {
  color: #261a04;
  border-color: #1a1002;
  cursor: default;
}

/* ── Epoch ───────────────────────────────────────────────────────────────── */

#epoch-column {
  width: 100%;
  max-width: 520px;
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.epoch-card {
  border: 2px solid #3a2808;
  background: #060401;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 10px;
}

.epoch-card.first-in-group {
  margin-top: 0;
  border-top: 2px solid #5a3e08;
}

.epoch-card:hover {
  border-color: #5a4010;
}

.epoch-card-done {
  border-color: #5a4010;
  background: #080501;
}

.epoch-card-done:hover {
  border-color: #7a5818;
}

.epoch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.epoch-card-num {
  font-size: 11px;
  color: #b88828;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.epoch-card-cost {
  font-size: 10px;
  color: #6a4c14;
  letter-spacing: 0.06em;
}

.epoch-done-badge {
  font-size: 10px;
  color: #b88828;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.epoch-divider {
  width: 100%;
  height: 1px;
  background: #261a04;
  margin: 10px 0;
}

.epoch-card-done .epoch-divider {
  background: #261a04;
}

.epoch-effects {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epoch-effect-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.epoch-effect-dot {
  font-size: 11px;
  color: #5a4010;
  margin-top: 1px;
  flex-shrink: 0;
  width: 10px;
}

.epoch-card-done .epoch-effect-dot {
  color: #826018;
}

.epoch-effect-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.epoch-effect-name {
  font-size: 11px;
  color: #8a6820;
  letter-spacing: 0.04em;
}

.epoch-card-done .epoch-effect-name {
  color: #a07828;
}

.epoch-effect-sub {
  font-size: 10px;
  color: #4a3410;
  letter-spacing: 0.04em;
}

.epoch-card-done .epoch-effect-sub {
  color: #6a5018;
}

/* ── Epoch milestone toggle (collapsible) ── */
.epoch-ms-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 7px;
  cursor: pointer;
  font-size: 12px;
  color: #5a4010;
  letter-spacing: 0.08em;
  transition: color 0.1s;
  user-select: none;
}

.epoch-ms-toggle:hover {
  color: #8a6820;
}

.epoch-ms-arrow {
  font-size: 20px;
  flex-shrink: 0;
  color: #6a4c14;
  transition: color 0.1s;
}

.epoch-ms-toggle:hover .epoch-ms-arrow {
  color: #b88828;
}

/* ── Epoch effect drawer ── */
.epoch-ms-drawer {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.epoch-card.epoch-ms-open .epoch-ms-drawer {
  max-height: 300px;
}

/* ── Epoch effect rows (inside drawer) ── */
.epoch-ms-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #2a1c06;
  padding: 5px 0;
}

.epoch-ms-row.first-in-group {
  margin-top: 6px;
}

.epoch-ms-indicator {
  font-size: 14px;
  text-align: center;
  color: #7a5818;
}

.epoch-ms-name {
  font-size: 10px;
  color: #7a5818;
  letter-spacing: 0.04em;
}

.epoch-ms-val {
  font-size: 10px;
  color: #b88828;
  letter-spacing: 0.04em;
  text-align: right;
  white-space: nowrap;
}

/* ── Epoch locked ── */
.epoch-card-locked {
  border-color: #1e1408;
  opacity: 0.45;
}

.epoch-locked-label {
  font-size: 10px;
  color: #3a2808;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.epoch-btn {
  margin-top: 4px;
  background: none;
  border: 1px solid #4a3210;
  color: #7a5818;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  cursor: pointer;
  align-self: flex-end;
}

.epoch-btn:hover:not(:disabled) {
  border-color: #b88828;
  color: #b88828;
}

.epoch-btn:disabled {
  color: #5a4010;
  border-color: #3a2808;
  cursor: default;
}

/* ── Sigma Automation ─────────────────────────────────────────────────────── */

/* ── sigma main card ── */
.sigma-main-card {
  border: 2px solid #3a2808;
  background: #060401;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sigma-main-card.first-in-group {
  border-top: 2px solid #3a2808;
}

.sigma-main-card:hover {
  border-color: #5a4010;
}

.sigma-main-divider {
  width: 100%;
  height: 1px;
  background: #1e1204;
}

.sigma-formula-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.sigma-katex-wrap {
  display: inline-block;
  font-size: 1.1em;
  color: #8a6820;
  flex-shrink: 0;
}

.sigma-katex-wrap .katex,
.sigma-katex-wrap .katex * {
  color: #8a6820;
}

.sigma-slots-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sigma-slot {
  flex: 1;
  height: 46px;
  border: 1px dashed #2a1c06;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 6px;
  transition: border-color 0.08s;
  min-width: 0;
  position: relative;
}

.sigma-slot-filled {
  border-style: solid;
  border-color: #4a3210;
}

.sigma-slot-hover {
  border-color: #7a5818;
  border-style: solid;
}

.sigma-slot-empty {
  color: #281c06;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sigma-slot-label {
  color: #7a5818;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sigma-slot-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: #120c04;
}

.sigma-slot-bar-fill {
  height: 100%;
  width: 0%;
}

.sigma-slot-bar-fill.bar-active {
  background: #826018;
}

.sigma-slot-bar-fill.bar-waiting {
  background: #2a1c06;
}

.sigma-slot-bar-fill.bar-queued {
  background: transparent;
}

.sigma-slot-remove {
  background: none;
  border: none;
  color: #3a2808;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.08s;
}

.sigma-slot-remove:hover {
  color: #8a6820;
}

.sigma-status {
  font-size: 10px;
  color: #4a3410;
  letter-spacing: 0.06em;
  text-align: center;
}

/* ── freq exchange card ── */
.sigma-exchange-card {
  border: 2px solid #3a2808;
  background: #060401;
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sigma-exchange-card.first-in-group {
  border-top: 2px solid #3a2808;
}

.sigma-exchange-card:hover {
  border-color: #5a4010;
}

.sigma-freq-card-label {
  font-size: 10px;
  color: #5a4010;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sigma-exch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.sigma-exch-cell {
  flex: 1;
  border: 1px solid #3a2808;
  background: #030200;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sigma-exch-cell-label {
  font-size: 10px;
  color: #4a3410;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sigma-exch-cell-val {
  font-size: 18px;
  color: #b88828;
  letter-spacing: 0.04em;
}

.sigma-exch-arrow {
  font-size: 16px;
  color: #3a2808;
  flex-shrink: 0;
}

.sigma-freq-divider {
  width: 100%;
  height: 1px;
  background: #1e1204;
  margin: 4px 0;
}

.sigma-exch-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 11px;
}

.sigma-exch-cost {
  color: #4a3410;
}

.sigma-freq-btn {
  width: 100%;
  background: none;
  border: 1px solid #4a3210;
  color: #7a5818;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 6px 0;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: border-color 0.08s, color 0.08s;
}

.sigma-freq-btn:hover:not(:disabled) {
  border-color: #8a6020;
  color: #c89030;
}

.sigma-freq-btn:disabled {
  color: #261a04;
  border-color: #1a1002;
  cursor: default;
}

/* ── harmonic amplifier card ── */
.sigma-amp-card {
  border: 2px solid #3a2808;
  background: #060401;
  padding: 18px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sigma-amp-card:hover {
  border-color: #5a4010;
}

.sigma-amp-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sigma-amp-icon {
  width: 52px;
  height: 36px;
  flex-shrink: 0;
}

.sigma-amp-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.sigma-amp-name {
  font-size: 12px;
  color: #8a6820;
  letter-spacing: 0.06em;
}

.sigma-amp-desc {
  font-size: 10px;
  color: #4a3410;
  letter-spacing: 0.04em;
}

.sigma-amp-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.sigma-amp-stat-label {
  color: #4a3410;
}

.sigma-amp-stat-val {
  color: #8a6820;
}

.sigma-amp-divider {
  width: 100%;
  height: 1px;
  background: #1e1204;
  margin: 4px 0;
}

/* ── automations list ── */
.sigma-items-card {
  border: 1px solid #1c1204;
  background: #030200;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sigma-items-header {
  font-size: 10px;
  color: #3a2808;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.sigma-item {
  border: 1px dashed #3a2808;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  cursor: grab;
  user-select: none;
  transition: border-color 0.08s;
}

.sigma-item:hover {
  border-color: #4a3210;
  border-style: solid;
}

.sigma-item:active,
.sigma-item-dragging {
  cursor: grabbing;
  border-color: #7a5818;
  border-style: solid;
}

.sigma-item-handle {
  color: #5a4010;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.08s;
}

.sigma-item:hover .sigma-item-handle {
  color: #6a4c14;
}

.sigma-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sigma-item-label {
  color: #7a5818;
  font-size: 11px;
  letter-spacing: 0.05em;
  transition: color 0.08s;
}

.sigma-item:hover .sigma-item-label {
  color: #8a6820;
}

.sigma-item-desc {
  color: #4a3410;
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* ── button pulse & flash animations ── */
@keyframes sigma-pulse {
  0%   { border-color: #4a3210; color: #7a5818; }
  80%  { border-color: #4a3210; color: #888; }
  100% { border-color: #8a6820; color: #b88828; }
}

.sigma-pulse {
  animation: sigma-pulse linear infinite;
}

@keyframes sigma-btn-flash {
  0%   { border-color: #ffffff; color: #ffffff; }
  100% { border-color: inherit; color: inherit; }
}

.sigma-btn-flash {
  animation: sigma-btn-flash 0.4s ease-out forwards;
}

/* ── Orbit ─────────────────────────────────────────────────────────────────── */

#iter-orbit-column {
  width: 100%;
  max-width: 520px;
  padding-top: 150px;
  padding-bottom: 80px;
  padding-left: 20px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.orbit-canvas-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid #0a2a2a;
  border-top: 1px solid #0a2a2a;
  padding: 20px 12px 14px;
  gap: 12px;
  background: #010a0a;
}

.orbit-canvas-card.first-in-group {
  border-top: 1px solid #0a2a2a;
}

.orbit-canvas {
  display: block;
  background: transparent;
}

.orbit-stats-row {
  display: flex;
  gap: 20px;
  align-items: center;
}

.orbit-stat {
  font-size: 13px;
  color: #30b0b0;
  letter-spacing: 0.04em;
}

.orbit-stat-dim {
  font-size: 11px;
  color: #1a6060;
  letter-spacing: 0.03em;
}

.orbit-layer-header {
  margin-top: 18px;
  color: #1a5050;
}

.orbit-ext-header {
  margin-top: 20px;
}

.orbit-reset-warning {
  font-size: 10px;
  color: #1a4040;
  letter-spacing: 0.04em;
  padding: 12px 0 6px;
  text-align: center;
}

.orbit-new-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.orbit-progress-ring {
  flex-shrink: 0;
}

.orbit-reset-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #0d3030;
  color: #1a6060;
  font-family: inherit;
  font-size: 11px;
  padding: 8px 0;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
}

.orbit-reset-btn:hover:not(:disabled) {
  background: #030f0f;
  color: #30b0b0;
  border-color: #1a6060;
}

.orbit-reset-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
