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

:root {
  --bg-0: #171310;
  --bg-1: #221c17;
  --card-bg: rgba(255, 246, 235, 0.045);
  --card-border: rgba(255, 246, 235, 0.1);
  --card-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  --text: #f6efe6;
  --text-dim: rgba(246, 239, 230, 0.62);
  --text-dimmer: rgba(246, 239, 230, 0.4);
  --accent: #e08a3e;
  --accent-strong: #f3a75c;
  --accent-bg: rgba(224, 138, 62, 0.16);
  --input-bg: rgba(255, 246, 235, 0.06);
  --input-border: rgba(255, 246, 235, 0.14);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(120% 50% at 50% -10%, rgba(243, 167, 92, 0.08), transparent 60%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-0) 100%);
  color: var(--text);
}

#page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 56px;
}

#intro {
  max-width: 640px;
  width: 100%;
  text-align: center;
  margin-bottom: 22px;
}
#eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
#intro h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
#tagline {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- Tabs ---------- */
#tabs {
  width: 100%;
  max-width: 640px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }

.tabBtn {
  flex: 1 0 auto;
  white-space: nowrap;
  padding: 11px 14px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.tabBtn[aria-selected="true"] {
  background: var(--accent);
  color: #1a1310;
}

/* ---------- Panels & cards ---------- */
#panels {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  padding: 22px 20px;
}

.card h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hint {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 18px;
}

.microHint {
  font-size: 12.5px;
  color: var(--text-dimmer);
  line-height: 1.4;
  margin-top: 8px;
}

/* ---------- Fields ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="number"] {
  width: 100%;
  font-size: 20px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 12px 14px;
  -moz-appearance: textfield;
}
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(224, 138, 62, 0.08);
}
input[type="range"] {
  width: 100%;
  margin-bottom: 10px;
  accent-color: var(--accent);
}

select {
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background-color: #2a231c;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 12px 14px;
  color-scheme: dark;
}
select:focus {
  outline: none;
  border-color: var(--accent);
}
select option {
  background-color: #2a231c;
  color: var(--text);
}

.inlineRow {
  display: flex;
  gap: 10px;
}
.inlineRow input {
  flex: 1;
  min-width: 0;
}

.linkBtn {
  background: none;
  border: none;
  padding: 0;
  margin-left: 2px;
  color: var(--accent-strong);
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.fieldGroup {
  margin-bottom: 16px;
}
.segLabel {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.segmented {
  display: flex;
  gap: 6px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 4px;
}
.segBtn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.segBtn.active {
  background: var(--accent);
  color: #1a1310;
}

.hidden { display: none !important; }

/* ---------- Diagrams ---------- */
.diagram {
  margin: 2px 0 8px;
  position: relative;
}
.diagramReadout {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-strong);
  background: rgba(224, 138, 62, 0.1);
  border: 1px solid rgba(224, 138, 62, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  word-break: break-word;
}
.diagram--pair {
  display: flex;
  gap: 12px;
}
.diagram--pair .diagramSvg {
  flex: 1 1 0;
  min-width: 0;
}
.diagramSvg {
  width: 100%;
  height: auto;
  display: block;
}
.dLine {
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 2;
  stroke-linecap: round;
}
.dDash {
  fill: none;
  stroke: var(--text-dimmer);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}
.dDashShort {
  fill: none;
  stroke: var(--text-dimmer);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}
.dAccent {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.dArrow {
  stroke: var(--text-dim);
  stroke-width: 1.5;
}
.dArc {
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 1.5;
}
.dShape {
  fill: rgba(224, 138, 62, 0.12);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.dRightAngle {
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 1.5;
}
.dLabel {
  fill: var(--text-dim);
  font-size: 10px;
  font-family: inherit;
}
.dLabelStrong {
  fill: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  font-family: inherit;
}

/* ---------- Results ---------- */
.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}
.resultTile {
  background: var(--accent-bg);
  border: 1px solid rgba(224, 138, 62, 0.3);
  border-radius: 14px;
  padding: 14px 14px 12px;
  text-align: center;
}
.resultTile.wide {
  grid-column: 1 / -1;
}
.resultLabel {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.resultValue {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.resultSub {
  font-size: 11.5px;
  color: var(--text-dimmer);
  margin-top: 4px;
}

.resetBtn {
  margin-top: 14px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.resetBtn:active { background: var(--input-bg); }

.calloutBox {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
  background: rgba(255, 246, 235, 0.04);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 14px;
}
.calloutBox strong {
  color: var(--accent-strong);
}

#pageFooter {
  max-width: 640px;
  width: 100%;
  text-align: center;
  margin-top: 28px;
}
#pageFooter p {
  font-size: 12px;
  color: var(--text-dimmer);
  line-height: 1.5;
}

@media (min-width: 560px) {
  #intro h1 { font-size: 32px; }
  .resultValue { font-size: 32px; }
}
