:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-deep: #efe5d6;
  --surface: rgba(255, 251, 245, 0.92);
  --surface-strong: rgba(255, 248, 239, 0.98);
  --text: #1d2530;
  --muted: #637083;
  --line: rgba(44, 67, 96, 0.12);
  --accent: #0c7a72;
  --accent-strong: #095c56;
  --warm: #d96d3e;
  --blue: #3f7fc7;
  --green: #2d8b57;
  --shadow: 0 18px 45px rgba(54, 47, 36, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  background:
    radial-gradient(circle at top, rgba(12, 122, 114, 0.16), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(217, 109, 62, 0.18), transparent 20%),
    linear-gradient(180deg, var(--bg) 0%, #f8f3eb 52%, #f1e6d6 100%);
  color: var(--text);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
}

.hero-card,
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--surface-strong), var(--surface));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card {
  padding: 22px;
}

.hero-card::after,
.panel::after {
  content: "";
  position: absolute;
  inset: auto -20% -45% auto;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(12, 122, 114, 0.18), transparent 70%);
  pointer-events: none;
}

.status-pill,
.hero-meta span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.2rem;
}

.hero-copy {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.68;
  font-size: 0.98rem;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-meta span {
  background: rgba(29, 37, 48, 0.06);
  color: var(--text);
}

.author-line {
  margin-top: 16px;
  color: var(--accent-strong);
  font-weight: 700;
}

.content-stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill {
  border: 1px solid var(--line);
  background: rgba(29, 37, 48, 0.05);
  color: var(--muted);
  flex-shrink: 0;
}

.status-pill.active {
  background: rgba(45, 139, 87, 0.14);
  color: #1e6b45;
}

.status-pill.idle,
.status-pill.soft {
  background: rgba(12, 122, 114, 0.08);
  color: var(--accent-strong);
}

.status-pill.warn {
  background: rgba(217, 109, 62, 0.16);
  color: #9c4a23;
}

.hero-meter {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.note-readout {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 20px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(140deg, rgba(12, 122, 114, 0.14), rgba(255, 255, 255, 0.45)),
    #fdf8f0;
}

.note-name {
  font-size: clamp(3.2rem, 16vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-weight: 800;
}

.note-detail,
.pitch-hint,
.trend-head,
.metric-label,
.field span,
.tips-list {
  color: var(--muted);
}

.note-detail,
.pitch-hint {
  font-size: 0.94rem;
}

.meter-card,
.trend-panel,
.score-sheet,
.pattern-strip {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.meter-scale,
.trend-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
}

.tuner-track {
  position: relative;
  height: 14px;
  margin: 14px 0 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #de7f58 0%, #e7c764 25%, #b7d77b 50%, #e7c764 75%, #de7f58 100%);
}

.tuner-center {
  position: absolute;
  top: -5px;
  left: calc(50% - 1px);
  width: 2px;
  height: 24px;
  background: rgba(29, 37, 48, 0.52);
}

.tuner-needle {
  position: absolute;
  top: -6px;
  left: calc(50% - 10px);
  width: 20px;
  height: 26px;
  border-radius: 10px;
  background: var(--text);
  box-shadow: 0 8px 20px rgba(29, 37, 48, 0.22);
  transform: translateX(0);
  transition: transform 120ms ease-out, background-color 120ms ease-out;
}

.metric-grid,
.result-grid,
.hold-grid,
.controls-grid,
.answer-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.metric-grid,
.result-grid,
.hold-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.controls-grid,
.answer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-box,
.mini-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.metric-box strong,
.mini-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

.mini-card {
  position: relative;
  overflow: hidden;
}

.mini-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
}

.accent-orange::before {
  background: var(--warm);
}

.accent-blue::before {
  background: var(--blue);
}

.accent-green::before {
  background: var(--green);
}

.trend-panel {
  margin-top: 16px;
}

canvas {
  width: 100%;
  height: 190px;
  margin-top: 12px;
  display: block;
}

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

.field span {
  font-size: 0.88rem;
  font-weight: 700;
}

.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  touch-action: manipulation;
}

.action-row {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  padding: 0 16px;
  font-weight: 800;
  touch-action: manipulation;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 24px rgba(12, 122, 114, 0.28);
}

.secondary-btn {
  background: linear-gradient(135deg, #f8a86d, #d96d3e);
  color: #fff;
  box-shadow: 0 12px 24px rgba(217, 109, 62, 0.24);
}

.ghost-btn {
  background: rgba(29, 37, 48, 0.06);
  color: var(--text);
}

.pattern-strip,
.score-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  min-height: 66px;
}

.pattern-strip-large {
  min-height: 84px;
}

.note-pill {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 58px;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: rgba(12, 122, 114, 0.1);
  color: var(--accent-strong);
  font-weight: 800;
  text-align: center;
}

button.note-pill {
  align-items: center;
  justify-content: center;
}

button.note-pill:hover {
  background: rgba(12, 122, 114, 0.16);
}

.note-pill small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.note-pill.current {
  background: linear-gradient(135deg, rgba(12, 122, 114, 0.18), rgba(63, 127, 199, 0.16));
  outline: 2px solid rgba(12, 122, 114, 0.18);
}

.note-pill.done {
  background: rgba(45, 139, 87, 0.16);
  color: #236544;
}

.note-pill.fail {
  background: rgba(217, 109, 62, 0.18);
  color: #8f4a24;
}

.note-pill.ear-answer {
  width: 100%;
}

.note-pill.correct {
  background: rgba(45, 139, 87, 0.16);
  border-color: rgba(45, 139, 87, 0.36);
}

.note-pill.wrong {
  background: rgba(217, 109, 62, 0.16);
  border-color: rgba(217, 109, 62, 0.34);
}

.tips-list {
  margin: 14px 0 0;
  padding-left: 20px;
  line-height: 1.75;
}

@media (min-width: 700px) {
  .app-shell {
    padding-left: 20px;
    padding-right: 20px;
  }

  .hero-meter {
    grid-template-columns: 1.1fr 1fr;
    align-items: stretch;
  }

  .metric-grid,
  .result-grid,
  .hold-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .controls-grid.controls-grid-three {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .controls-grid:not(.controls-grid-three) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .action-row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
