/* ============================================================
   Hearing Disability Calculator — styles
   Single-column tool page, dralwrdi.online identity v2.0.
   ============================================================ */

:root {
  --bg: #F7FBFB;
  --panel-bg: #ffffff;
  --ink: #0A2533;
  --muted: #64798A;
  --line: #D8E5E8;
  --accent: #12A5A5;
  --accent-ink: #ffffff;
  --aqua: #E9F6F6;
  --right: #d32f2f;
  --left:  #1565c0;
  --amber: #F2B04E;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(10, 37, 51, .07), 0 10px 28px rgba(10, 37, 51, .09);
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px max(20px, env(safe-area-inset-left)) 14px max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: var(--panel-bg);
}
.brandbar { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brandbar img { display: block; border-radius: 7px; }
.brandbar .nm { font-weight: 600; font-size: 14px; letter-spacing: -.2px; }
.brandbar .nm i { color: var(--accent); font-style: normal; }
.back { margin-inline-start: auto; font-size: 13px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }

/* ---------------- Page frame ---------------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 40px 20px 24px; }

.intro { text-align: center; margin-bottom: 28px; }
.eyebrow {
  display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 10px;
}
.intro h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: -.02em; font-weight: 700; }
.intro .lead { color: var(--muted); font-size: 15px; max-width: 480px; margin: 0 auto; }

/* ---------------- Input card ---------------- */
.card {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  margin-bottom: 22px;
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--right { background: var(--right); }
.dot--left { background: var(--left); }

/* ---- Frequency / threshold sliders ---- */
.freq-legend {
  display: grid; grid-template-columns: 52px 1fr 1fr; gap: 0 18px;
  padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.freq-legend__ear {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}

.freq-row {
  display: grid; grid-template-columns: 52px 1fr 1fr; gap: 0 18px; align-items: center;
  padding: 14px 0;
}
.freq-row + .freq-row { border-top: 1px solid var(--aqua); }
.freq-row__label { font-family: var(--mono); font-size: 13.5px; font-weight: 500; color: var(--ink); }

.ear-input { display: flex; flex-direction: column; gap: 7px; }
.ear-input__top { display: flex; align-items: center; justify-content: space-between; }
.ear-input__name { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.ear-input__val { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); min-width: 44px; text-align: right; }
.ear-input__row { display: flex; align-items: center; gap: 8px; }

.step {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
.step:hover:not(:disabled) { background: var(--aqua); color: var(--ink); }
.step:disabled { opacity: .35; cursor: not-allowed; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1;
  height: 6px; border-radius: 999px; background: var(--line);
  outline: none; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--fill) calc(var(--val) * 1%), var(--line) calc(var(--val) * 1%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -5px;
  border-radius: 50%; background: var(--fill); border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(10, 37, 51, .35); cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--fill); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--fill);
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(10, 37, 51, .35); cursor: pointer;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(18, 165, 165, .25); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(18, 165, 165, .25); }

.hint { font-size: 12px; color: var(--muted); margin: 14px 0 0; line-height: 1.5; }

.card-actions { display: flex; justify-content: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

.btn {
  font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: #F1F8F8; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { background: var(--aqua); color: var(--ink); }

/* ---------------- Results ---------------- */
.results {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 24px 20px;
  margin-bottom: 22px;
}

.gauge-panel { position: relative; display: flex; justify-content: center; }
.gauge { width: 100%; max-width: 320px; height: auto; overflow: visible; }
.gauge__track { fill: none; stroke: var(--aqua); stroke-width: 14; stroke-linecap: round; }
.gauge__fill { fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round; transition: stroke-dashoffset .5s cubic-bezier(.4,0,.2,1), stroke .5s; }
#gaugeSwirl { fill: var(--accent); transition: cx .5s cubic-bezier(.4,0,.2,1), cy .5s cubic-bezier(.4,0,.2,1), fill .5s; }

.gauge__readout {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.gauge__num { font-family: var(--mono); font-size: 34px; font-weight: 600; color: var(--accent); line-height: 1; transition: color .5s; }
.gauge__label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.stat {
  border-radius: 10px; padding: 12px 14px; background: var(--aqua);
  display: flex; flex-direction: column; gap: 3px; border-left: 3px solid transparent;
}
.stat--right { border-left-color: var(--right); }
.stat--left { border-left-color: var(--left); }
.stat__ear { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.stat__pta { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.stat__pct { font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--ink); }

.better-note { font-size: 12.5px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* ---------------- Formula explainer ---------------- */
.formula {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-bg);
  padding: 4px 22px; margin-bottom: 32px;
}
.formula summary {
  cursor: pointer; padding: 14px 0; font-weight: 600; font-size: 13.5px; color: var(--ink);
  list-style: none;
}
.formula summary::-webkit-details-marker { display: none; }
.formula summary::before { content: "+"; color: var(--accent); font-weight: 700; margin-right: 9px; display: inline-block; width: 12px; }
.formula[open] summary::before { content: "\2212"; }
.formula ol { margin: 0 0 12px; padding-left: 20px; font-size: 13.5px; color: var(--ink); }
.formula li { margin-bottom: 10px; }
.formula li:last-child { margin-bottom: 0; }
.formula code { background: var(--aqua); padding: 2px 6px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; display: inline-block; margin-top: 4px; }
.formula .hint { margin: 0 0 14px; }

.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 0 20px 32px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  .wrap { padding: 28px 16px 20px; }
  .intro h1 { font-size: 24px; }
  .card, .results { padding: 18px 16px 16px; }
  .stat-grid { gap: 10px; }
  .gauge__num { font-size: 28px; }

  /* Stack each frequency's two ear sliders instead of cramming three grid
     columns into a narrow viewport — each ear-input already carries its own
     "Right"/"Left" label, so the legend row would be redundant here. */
  .freq-legend { display: none; }
  .freq-row { grid-template-columns: 1fr; gap: 10px; padding: 16px 0; }
  .freq-row__label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
}
