:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --right: #c92a2a;
  --left: #1d4ed8;
  --warning: #9a3412;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(180deg, #edf4f2 0%, var(--bg) 28%, #eef2f6 100%);
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px 14px;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 1.35rem;
  line-height: 1.15;
}

.eyebrow,
.kicker {
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 1.5rem;
  line-height: 1;
}

.progress-wrap {
  margin: 6px 0 16px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #dce5ed;
}

.progress-bar {
  width: 20%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .25s ease;
}

.screen {
  display: none;
}

.hidden {
  display: none !important;
}

.screen.active {
  display: block;
}

.panel {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(131, 149, 170, .28);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 14px 42px rgba(22, 37, 55, .08);
}

.hero-panel {
  padding-top: 28px;
}

.panel h2 {
  margin: 7px 0 10px;
  font-size: clamp(1.45rem, 7vw, 2.2rem);
  line-height: 1.05;
}

.panel p {
  color: var(--muted);
  line-height: 1.45;
}

.notice,
.status,
.hint {
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef7f4;
  color: var(--primary-dark);
  font-size: .95rem;
}

.check-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 4px;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.35;
}

.check-list li::marker {
  color: var(--primary);
  font-weight: 900;
}

.status:empty,
.hint:empty {
  display: none;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.actions.stacked {
  flex-direction: column;
}

.actions.two > * {
  flex: 1;
}

.primary,
.secondary,
.play-button,
.hold-button,
.choice-grid button {
  min-height: 52px;
  border-radius: 8px;
  padding: 13px 16px;
  font-weight: 800;
}

.primary,
.play-button,
.hold-button {
  color: #fff;
  background: var(--primary);
}

.primary:active,
.play-button:active,
.hold-button:active {
  background: var(--primary-dark);
}

.secondary,
.choice-grid button {
  color: var(--text);
  background: #eef2f6;
  border: 1px solid #d4dde7;
}

.secondary.danger {
  color: var(--danger);
}

.play-button {
  width: 100%;
  margin: 14px 0 8px;
}

.hold-button {
  width: 100%;
  min-height: 120px;
  margin: 16px 0 8px;
  font-size: 1.15rem;
  touch-action: none;
  user-select: none;
}

.hold-button.active {
  background: var(--primary-dark);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .28);
}

.tone-control {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  gap: 14px;
  align-items: center;
  margin: 18px 0 8px;
}

.round-button,
.play-circle {
  border-radius: 999px;
  color: #fff;
  background: #5bb8b7;
  box-shadow: 0 8px 22px rgba(15, 118, 110, .16);
}

.round-button {
  width: 64px;
  height: 64px;
  padding: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
}

.play-circle {
  min-height: 116px;
  padding: 16px;
  font-weight: 900;
}

.round-button:active,
.play-circle:active {
  background: var(--primary);
}

.wide {
  grid-column: 1 / -1;
  width: 100%;
}

.speech-calibration {
  margin-top: 12px;
}

.field-label {
  display: block;
  margin: 14px 0 6px;
  color: var(--text);
  font-weight: 800;
}

.field {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  font-size: 0.82rem;
}

.question {
  margin: 18px 0 10px;
  color: var(--text) !important;
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-grid button.selected,
.choice-grid button:active {
  outline: 3px solid rgba(15, 118, 110, .22);
  background: #dff3ee;
}

.test-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.ear-badge {
  border-radius: 99px;
  padding: 7px 10px;
  color: #fff;
  font-size: .8rem;
  font-weight: 900;
  white-space: nowrap;
}

.ear-badge.right {
  background: var(--right);
}

.ear-badge.left {
  background: var(--left);
}

.ear-badge.neutral {
  color: var(--text);
  background: #e7edf4;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 2px;
}

.metric-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.metric-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
}

.summary {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.summary-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.summary-card p {
  margin: 0;
}

.recommendation-card {
  border-color: rgba(15, 118, 110, .24);
  background: #eef7f4;
}

.recommendation-card h3 {
  color: var(--primary-dark);
}

.chart-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.chart-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.chart-title h3 {
  margin: 0;
  font-size: 1rem;
}

.chart-title span,
.legend {
  color: var(--muted);
  font-size: .82rem;
}

canvas {
  width: 100%;
  height: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-weight: 800;
}

.legend-right {
  color: var(--right);
}

.legend-left {
  color: var(--left);
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 12px;
  }

  .panel {
    padding: 18px;
  }

  .choice-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .actions.two {
    flex-direction: column;
  }
}
