:root {
  --bg: #f4efe6;
  --bg-accent: #e6d3b7;
  --ink: #1d1a17;
  --muted: #5e564f;
  --panel: rgba(255, 250, 242, 0.82);
  --line: rgba(29, 26, 23, 0.14);
  --action: #b4552d;
  --action-ink: #fff7f1;
  --shadow: 0 18px 48px rgba(66, 39, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 85, 45, 0.22), transparent 28%),
    radial-gradient(circle at right 20%, rgba(117, 78, 30, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg), #efe4d4 58%, #eadac5);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  padding: 20px 0 24px;
}

.eyebrow,
.stat-label,
.detail-label,
.field span {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--action);
  font-size: 0.82rem;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.95;
}

.lede {
  max-width: 60ch;
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.lede-secondary {
  margin-top: 0;
  font-size: 0.9rem;
}

.lede-secondary.is-error {
  color: #8e2d16;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.support-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-top: 16px;
}

.support-copy {
  display: grid;
  gap: 8px;
}

.support-title,
.support-address {
  margin: 0;
}

.support-title {
  font-size: 0.95rem;
}

.support-address {
  margin-top: 6px;
  color: var(--muted);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.84rem;
  word-break: break-all;
}

.support-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.support-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--action);
  color: var(--action-ink);
  white-space: nowrap;
}

.support-button-secondary {
  background: #fffaf4;
  color: var(--ink);
  border-color: var(--line);
}

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.qr-modal.is-hidden {
  display: none;
}

.qr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 26, 23, 0.42);
}

.qr-dialog {
  position: relative;
  z-index: 1;
  width: min(360px, calc(100% - 32px));
  margin: min(8vh, 64px) auto 0;
  padding: 18px;
}

.qr-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.qr-close {
  min-height: 36px;
  padding: 0 12px;
}

.qr-modal-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
}

.qr-modal-address {
  margin-top: 12px;
}

.mode-panel {
  padding: 18px;
  margin-bottom: 16px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffaf4;
  color: var(--ink);
}

.mode-button.is-active {
  background: var(--action);
  color: var(--action-ink);
  border-color: transparent;
}

.controls {
  display: flex;
  gap: 14px;
  align-items: end;
  padding: 18px;
  margin-bottom: 16px;
}

.field {
  flex: 1;
  display: grid;
  gap: 8px;
}

.is-hidden {
  display: none;
}

.field span {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
}

select,
input,
button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

select,
input {
  width: 100%;
  padding: 0 14px;
  background: #fffaf4;
}

button {
  padding: 0 18px;
  background: var(--action);
  color: var(--action-ink);
  border-color: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.stats-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 20px;
}

.diagram-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 20px;
  padding: 20px;
  margin-top: 16px;
}

.chart-panel {
  padding: 20px;
  margin-top: 16px;
}

.chart-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.chart-title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.chart-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  max-width: 62ch;
}

.chart-summary {
  min-width: 260px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.7);
}

.chart-summary-line {
  margin: 0;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.84rem;
  line-height: 1.6;
}

.chart-wrap {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(247, 237, 223, 0.92));
}

.sleeping-chart {
  display: block;
  width: 100%;
  height: 420px;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.chart-grid-line {
  stroke: rgba(29, 26, 23, 0.1);
  stroke-width: 1;
}

.chart-grid-line-vertical {
  stroke-dasharray: 4 8;
}

.chart-grid-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

.chart-line {
  fill: none;
  stroke: #b4552d;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-selected-line {
  stroke: rgba(29, 26, 23, 0.34);
  stroke-width: 2;
  opacity: 0;
}

.chart-selected-dot {
  fill: #1d1a17;
  stroke: #fffaf4;
  stroke-width: 2;
  opacity: 0;
}

.chart-hover-line {
  stroke: rgba(180, 85, 45, 0.45);
  stroke-width: 1.5;
  stroke-dasharray: 6 6;
  opacity: 0;
}

.chart-hover-dot {
  fill: #b4552d;
  stroke: #fffaf4;
  stroke-width: 2;
  opacity: 0;
}

.chart-selected-line.is-visible,
.chart-selected-dot.is-visible,
.chart-hover-line.is-visible,
.chart-hover-dot.is-visible {
  opacity: 1;
}

.diagram-title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.diagram-text {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.diagram-share {
  margin: 0 0 18px;
  color: var(--ink);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.86rem;
}

.diagram-legend {
  display: grid;
  gap: 10px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.7);
  border: 1px solid var(--line);
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.legend-sleeping {
  background: #b4552d;
}

.legend-active {
  background: #d7b071;
}

.legend-unissued {
  background: #ece1d0;
  border: 1px solid rgba(29, 26, 23, 0.16);
}

.legend-label {
  min-width: 0;
}

.legend-value {
  white-space: nowrap;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.9rem;
}

.diagram-visual {
  display: grid;
  place-items: center;
}

.supply-ring {
  --sleeping-pct: 0%;
  --active-pct: 0%;
  width: min(100%, 320px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    conic-gradient(
      #b4552d 0 var(--sleeping-pct),
      #d7b071 var(--sleeping-pct) var(--active-pct),
      #ece1d0 var(--active-pct) 100%
    );
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.supply-ring-inner {
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 250, 242, 0.95);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
}

.ring-caption {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

.ring-value {
  font-size: clamp(1rem, 2vw, 1.3rem);
  line-height: 1.2;
}

.stat-card {
  padding: 20px;
}

.stat-label,
.detail-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.stat-value {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  line-height: 1.05;
  white-space: nowrap;
}

#total-btc {
  font-size: clamp(1.15rem, 2.4vw, 2rem);
}

.detail-value {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  word-break: break-word;
}

@media (max-width: 860px) {
  .support-footer,
  .mode-toggle,
  .controls,
  .stats-grid,
  .detail-grid,
  .diagram-panel,
  .chart-header {
    grid-template-columns: 1fr;
  }

  .controls {
    display: grid;
    align-items: stretch;
  }

  .support-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100%, calc(100% - 20px));
    padding: 24px 0 40px;
  }

  .stat-card,
  .detail-grid {
    padding: 16px;
  }

  .sleeping-chart {
    height: 320px;
  }

  .chart-summary {
    min-width: 0;
  }

}
