/* Shared styles for Inverteum coding tools */
:root {
  --bg: #f8f6f3;
  --paper: #fffcf8;
  --ink: #1a1a1a;
  --ink-soft: #5c5954;
  --rule: #e4e0d8;
  --rule-strong: #1a1a1a;
  --lime: #d9fb99;
  --accent: #111;
  --focus: 0 0 0 3px rgba(217, 251, 153, 0.8);
  --font: "Wix Madefor Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "Familjen Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.page {
  width: min(920px, calc(100% - 80px));
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}
@media (max-width: 900px) {
  .page { width: min(920px, calc(100% - 40px)); padding-top: 1.25rem; }
}

.intro h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.intro .lede {
  margin: 0 0 1.25rem;
  max-width: 40rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}
.note {
  margin: 0 0 1.75rem;
  max-width: 42rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.5rem;
  margin-bottom: 1.15rem;
}
.panel h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.panel .lede {
  margin: 0 0 1.15rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0 0 0.5rem;
}
@media (min-width: 720px) {
  .stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}
.stat {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
}
.stat.highlight {
  background: var(--lime);
  border-color: #c6e88a;
}
.stat-label {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-soft);
}
.stat.highlight .stat-label { color: #333; }
.stat-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-sub {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.explain {
  margin: 0.85rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.drawdown-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  margin-bottom: 1.15rem;
}
@media (max-width: 640px) {
  .drawdown-controls { grid-template-columns: 1fr; }
}
.field label {
  display: block;
  font-weight: 650;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}
.field input[type="number"],
.field input[type="date"],
.field input[type="text"] {
  width: 100%;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  outline: none;
}
.field input:focus-visible,
.btn:focus-visible,
.weight-row input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: #111;
}
.range-wrap input[type="range"] {
  width: 100%;
  accent-color: #111;
}

.recovery-visual {
  margin: 0.25rem 0 0.5rem;
  height: 84px;
  width: 100%;
}
.recovery-visual svg { display: block; width: 100%; height: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 1rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 1.05rem;
  border-radius: 40px;
  border: 1px solid #000;
  background: var(--bg);
  color: #000;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}
.btn:hover,
.btn:focus-visible {
  background: #000;
  color: var(--lime);
  border-color: #000;
}
.btn.primary {
  background: #000;
  color: var(--lime);
}
.btn.primary:hover,
.btn.primary:focus-visible {
  background: var(--lime);
  color: #000;
  border-color: #000;
}

.table-wrap { overflow-x: auto; margin: 0 0 0.85rem; }
table.entries {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.entries th,
table.entries td {
  text-align: left;
  padding: 0.4rem 0.4rem 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.entries th {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 650;
}
table.entries input {
  width: 100%;
  min-width: 7.5rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}
table.entries .col-remove { width: 2.5rem; text-align: right; }
.row-remove {
  border: 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.3rem;
}
.row-remove:hover { color: #000; }

.chart {
  width: 100%;
  height: 220px;
  margin: 0.75rem 0 0.25rem;
}
.chart svg { display: block; width: 100%; height: 100%; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.15rem;
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.swatch {
  width: 12px;
  height: 3px;
  background: currentColor;
  display: inline-block;
}

.weights { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.weight-row {
  display: grid;
  grid-template-columns: minmax(11rem, 1.35fr) 6.25rem minmax(8rem, 1.5fr);
  grid-template-rows: auto 10px;
  gap: 0.35rem 0.8rem;
  align-items: center;
}
.weight-row .asset-name { grid-column: 1; grid-row: 1; }
.weight-row .weight-num { grid-column: 2; grid-row: 1; }
.weight-row input[type="range"] {
  grid-column: 3;
  grid-row: 1;
  width: 100%;
  accent-color: #111;
}
.weight-row .bar { grid-column: 3; grid-row: 2; }
.weight-row .weight-pct { display: none; }
@media (max-width: 640px) {
  .weight-row {
    grid-template-columns: 1fr 6.25rem;
    grid-template-rows: auto auto 10px;
  }
  .weight-row .asset-name { grid-column: 1; grid-row: 1; }
  .weight-row .weight-num { grid-column: 2; grid-row: 1; }
  .weight-row input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
  .weight-row .bar { grid-column: 1 / -1; grid-row: 3; }
}
.asset-name { font-weight: 650; }
.asset-name a {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}
.asset-name a:hover,
.asset-name a:active {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.asset-name a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 4px;
  outline: 3px solid rgba(217, 251, 153, 0.9);
  outline-offset: 3px;
}
.weight-num {
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  width: 100%;
}
.bar {
  position: relative;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 99px;
  overflow: hidden;
}
.bar i {
  position: absolute;
  top: 0;
  height: 100%;
  background: #111;
}
.bar i.short { background: #8a857c; }

.error {
  margin: 0.5rem 0 0;
  color: #8a1f11;
  font-size: 0.9rem;
}
.error:empty { display: none; }

.presets { margin-bottom: 1.1rem; }
