:root {
  color-scheme: dark;
  --bg: #101310;
  --surface: #171c18;
  --surface-2: #1e241f;
  --surface-3: #252a25;
  --line: #343d36;
  --text: #eef3ec;
  --muted: #9da89e;
  --dim: #707a72;
  --btc: #f7931a;
  --green: #42d392;
  --teal: #38c7b8;
  --red: #f15d6f;
  --yellow: #f2c94c;
  --violet: #9aa5ff;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(247, 147, 26, 0.10), transparent 34rem),
    linear-gradient(180deg, #121712 0%, #0f130f 45%, #111310 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px clamp(14px, 2.8vw, 34px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(16, 19, 16, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(247, 147, 26, 0.45);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(247, 147, 26, 0.22), rgba(56, 199, 184, 0.10));
  color: var(--btc);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.nav-links {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.nav-links a,
.ghost-button,
.auto-refresh-pill {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.nav-links a {
  display: grid;
  min-width: 54px;
  place-items: center;
  padding: 0 12px;
  font-size: 13px;
}

.nav-links a.active {
  background: var(--surface-3);
  color: var(--text);
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.auto-refresh-pill {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border: 1px solid rgba(66, 211, 146, 0.28);
  background: rgba(66, 211, 146, 0.08);
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}

.ghost-button:hover,
.nav-links a:hover {
  color: var(--text);
  border-color: rgba(247, 147, 26, 0.45);
}

.page-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 18px auto 28px;
}

.headline-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.6fr) repeat(3, minmax(155px, 0.75fr));
  gap: 12px;
  margin-bottom: 12px;
}

.market-plate,
.mini-stat,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)), var(--surface);
  box-shadow: var(--shadow);
}

.market-plate {
  min-height: 146px;
  padding: 18px;
}

.plate-kicker,
.panel-head,
.mini-stat span,
.compact span {
  color: var(--muted);
  font-size: 12px;
}

.price-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-top: 6px;
}

.price-line span {
  color: var(--btc);
  font-size: clamp(34px, 6vw, 62px);
  font-weight: 800;
  line-height: 1;
}

.price-line small {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.plate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.mini-stat {
  display: flex;
  min-height: 146px;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
}

.mini-stat strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 24px;
  line-height: 1.12;
}

.mini-stat small {
  color: var(--dim);
  font-size: 12px;
}

.range-input {
  width: 100%;
  accent-color: var(--btc);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panel-head {
  display: flex;
  min-height: 24px;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head span {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.panel-head a {
  color: var(--teal);
  font-size: 12px;
  text-decoration: none;
}

.panel-head small {
  color: var(--muted);
  text-align: right;
}

.metric-value {
  margin-top: 4px;
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--dim);
}

.sentiment-panel {
  min-height: 206px;
}

.gauge-wrap {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.gauge {
  position: relative;
  width: 150px;
  height: 118px;
}

.gauge-arc {
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  height: 76px;
  border-radius: 76px 76px 0 0;
  background:
    conic-gradient(from 270deg at 50% 100%,
      var(--red) 0deg,
      var(--btc) 55deg,
      var(--yellow) 95deg,
      var(--green) 140deg,
      var(--green) 180deg,
      transparent 181deg);
}

.gauge-cover {
  position: absolute;
  top: 38px;
  right: 32px;
  left: 32px;
  height: 38px;
  border-radius: 60px 60px 0 0;
  background: var(--surface);
}

.gauge-needle {
  position: absolute;
  bottom: 42px;
  left: 50%;
  z-index: 4;
  width: 2px;
  height: 43px;
  border-radius: 3px;
  background: var(--text);
  transform: translateX(-50%) rotate(-90deg);
  transform-origin: 50% 100%;
  transition: transform 500ms ease;
}

.gauge-needle::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--text);
  transform: translateX(-50%);
}

.gauge strong {
  position: absolute;
  top: 84px;
  left: 0;
  right: 0;
  z-index: 3;
  text-align: center;
  font-size: 26px;
}

.gauge-wrap p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.compact {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: space-between;
}

.compact strong {
  color: var(--text);
  font-size: 26px;
  line-height: 1.05;
}

.compact small {
  color: var(--dim);
  font-size: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.prob-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.prob-tile {
  min-height: 84px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.prob-tile span {
  color: var(--muted);
  font-size: 12px;
}

.prob-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.halving-cycle-panel {
  margin-bottom: 12px;
}

.cycle-chart-wrap {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.cycle-y-axis {
  display: flex;
  height: 310px;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 0 28px;
  color: var(--dim);
  font-size: 11px;
  text-align: right;
}

.cycle-chart {
  min-height: 310px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    rgba(255, 255, 255, 0.025);
  background-size: 100% 47px, 12.5% 100%, 100% 100%;
}

.cycle-chart svg {
  display: block;
  width: 100%;
  height: 310px;
}

.cycle-axis-label {
  fill: var(--dim);
  font-size: 11px;
}

.cycle-peak-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(16, 19, 16, 0.82);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.cycle-peak-price {
  fill: var(--muted);
  font-size: 10px;
  paint-order: stroke;
  stroke: rgba(16, 19, 16, 0.82);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.cycle-peak-dot {
  stroke: #101310;
  stroke-width: 2;
}

.cycle-projection-label {
  fill: var(--btc);
  font-size: 11px;
  font-weight: 800;
  paint-order: stroke;
  stroke: rgba(16, 19, 16, 0.88);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.cycle-projection-price {
  fill: var(--text);
  font-size: 10px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(16, 19, 16, 0.88);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.cycle-projection-dot {
  stroke: #101310;
  stroke-width: 2;
}

.cycle-line {
  fill: none;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.cycle-line.projected {
  stroke-dasharray: 7 6;
  stroke-width: 2.4;
}

.cycle-current-marker {
  fill: var(--btc);
  stroke: #101310;
  stroke-width: 2;
}

.cycle-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.legend-item.projected .legend-swatch {
  background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px);
}

.cycle-projection-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.projection-card {
  min-height: 108px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.projection-card span,
.projection-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.projection-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.08;
}

.projection-card small {
  margin-top: 4px;
  color: var(--dim);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
  font-size: 13px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
}

td {
  color: var(--text);
}

.flywheel-summary,
.balance-grid,
.mnav-grid,
.filing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.flywheel-summary div,
.balance-grid div,
.mnav-grid div,
.filing-grid div {
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.flywheel-summary span,
.balance-grid span,
.mnav-grid span,
.filing-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.flywheel-summary strong,
.balance-grid strong,
.mnav-grid strong,
.filing-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.1;
}

.chart-panel {
  margin-bottom: 12px;
}

.miner-chart {
  display: grid;
  gap: 6px;
}

.miner-row {
  display: grid;
  grid-template-columns: minmax(92px, 160px) minmax(0, 1fr) 80px;
  gap: 10px;
  align-items: center;
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
}

.miner-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  position: relative;
  height: 13px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 4px;
  background: var(--red);
}

.bar-fill.ok {
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.price-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--btc);
}

.status-pill {
  display: inline-flex;
  min-width: 52px;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.status-pill.ok {
  background: rgba(66, 211, 146, 0.18);
  color: var(--green);
}

.status-pill.bad {
  background: rgba(241, 93, 111, 0.16);
  color: var(--red);
}

.probability-head .market-plate {
  min-height: 132px;
}

.probability-columns {
  align-items: start;
}

.prob-list {
  display: grid;
  gap: 8px;
}

.prob-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 76px 74px;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
}

.prob-row strong {
  color: var(--text);
}

.prob-bar {
  overflow: hidden;
  height: 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
}

.prob-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--teal), var(--btc));
}

.prob-row.achieved .prob-bar span {
  background: linear-gradient(90deg, var(--green), var(--teal));
}

.prob-row.low-confidence {
  opacity: 0.58;
}

.pdf-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(24px, 1fr);
  align-items: end;
  min-height: 230px;
  gap: 6px;
  padding-top: 16px;
}

.pdf-col {
  display: grid;
  align-items: end;
  gap: 6px;
  min-height: 210px;
  text-align: center;
}

.pdf-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--btc), rgba(247, 147, 26, 0.28));
}

.pdf-label {
  color: var(--dim);
  font-size: 10px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  justify-self: center;
}

.method-panel {
  margin-bottom: 12px;
}

.preferred-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.pref-card {
  min-height: 124px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.pref-card strong,
.pref-card span,
.pref-card small {
  display: block;
}

.pref-card strong {
  color: var(--text);
  font-size: 17px;
}

.pref-card span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.pref-card small {
  margin-top: 3px;
  color: var(--dim);
  font-size: 11px;
}

.trigger-list {
  display: grid;
  gap: 8px;
}

.trigger {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
}

.trigger b {
  color: var(--text);
}

.trigger.on {
  border-color: rgba(241, 93, 111, 0.45);
}

.trigger.off {
  border-color: rgba(66, 211, 146, 0.38);
}

.runway-readout {
  display: grid;
  min-height: 128px;
  align-content: center;
  gap: 8px;
}

.runway-readout strong {
  font-size: 42px;
  line-height: 1;
}

.runway-readout span {
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  padding: 4px 14px 24px;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
}

#error-line {
  color: var(--red);
}

.positive {
  color: var(--green) !important;
}

.warning {
  color: var(--yellow) !important;
}

.negative {
  color: var(--red) !important;
}

.accent {
  color: var(--btc) !important;
}

.teal {
  color: var(--teal) !important;
}

@media (max-width: 1040px) {
  .headline-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-plate {
    grid-column: span 2;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preferred-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cycle-projection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .brand small {
    display: none;
  }

  .nav-links,
  .ghost-button {
    width: 100%;
  }

  .nav-links a {
    flex: 1;
  }

  .headline-grid,
  .dashboard-grid,
  .two-column,
  .metric-strip,
  .preferred-grid {
    grid-template-columns: 1fr;
  }

  .market-plate {
    grid-column: auto;
  }

  .market-plate,
  .mini-stat {
    min-height: auto;
  }

  .mini-stat {
    gap: 10px;
  }

  .gauge-wrap,
  .flywheel-summary,
  .balance-grid,
  .mnav-grid,
  .filing-grid {
    grid-template-columns: 1fr;
  }

  .prob-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cycle-chart-wrap {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .cycle-y-axis {
    height: 340px;
    min-height: 340px;
    padding: 12px 0 38px;
    font-size: 10px;
  }

  .cycle-chart {
    height: 340px;
    min-height: 340px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .cycle-chart svg {
    width: 880px;
    min-width: 880px;
    height: 340px;
    min-height: 340px;
  }

  .cycle-chart::-webkit-scrollbar {
    height: 6px;
  }

  .cycle-chart::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
  }

  .cycle-axis-label {
    font-size: 13px;
  }

  .cycle-peak-label,
  .cycle-projection-label {
    font-size: 14px;
    stroke-width: 5px;
  }

  .cycle-peak-price,
  .cycle-projection-price {
    font-size: 12px;
    stroke-width: 5px;
  }

  .cycle-line {
    stroke-width: 3;
  }

  .cycle-line.projected {
    stroke-width: 3.2;
    stroke-dasharray: 9 7;
  }

  .miner-row {
    grid-template-columns: minmax(74px, 96px) minmax(0, 1fr) 66px;
    gap: 8px;
  }

  .prob-row {
    grid-template-columns: 64px minmax(0, 1fr) 58px;
  }

  .prob-row .prob-volume {
    display: none;
  }

  .pdf-chart {
    overflow-x: auto;
    grid-auto-columns: 32px;
  }
}

@media (max-width: 430px) {
  .page-shell {
    width: min(100vw - 20px, 1180px);
  }

  .price-line span {
    font-size: 36px;
  }

  .prob-grid {
    grid-template-columns: 1fr;
  }

  .cycle-projection-grid {
    grid-template-columns: 1fr;
  }
}
