:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --ink: #172026;
  --muted: #69737a;
  --panel: #ffffff;
  --line: #d8ddd9;
  --teal: #0f766e;
  --coral: #d95d39;
  --amber: #d99a25;
  --green: #2f8f5b;
  --red: #c24135;
  --blue: #3366a3;
  --shadow: 0 18px 55px rgba(23, 32, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #f7f4ee 0%, #eef5f3 48%, #f8f1e9 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(216, 221, 217, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(18px);
}

.topbar,
.sentence-row,
.transport,
.panel-title {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.status-pill {
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  background: #fff;
}

.status-pill.ready {
  border-color: rgba(47, 143, 91, 0.35);
  color: var(--green);
}

.status-pill.warn {
  border-color: rgba(217, 154, 37, 0.45);
  color: #9a650b;
}

.sentence-panel,
.recorder-panel,
.insight-panel,
.word-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sentence-panel {
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sentence-row {
  gap: 12px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fbfcfb;
  outline: none;
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.icon-button,
.ghost-button,
.record-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    opacity 0.16s ease;
}

.icon-button {
  flex: 0 0 48px;
  height: 48px;
  background: var(--teal);
  color: #fff;
  font-size: 18px;
}

.practice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.recorder-panel,
.insight-panel,
.word-panel {
  padding: 16px;
}

.meter-wrap {
  position: relative;
  overflow: hidden;
  height: 260px;
  border: 1px solid #cfd8d4;
  border-radius: 8px;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 0 /
      48px 100%,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 /
      100% 52px,
    #17191c;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-wave {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  pointer-events: none;
}

.empty-wave.hidden {
  display: none;
}

.transport {
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.live-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.live-metrics span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
}

.live-metrics b {
  color: var(--ink);
}

.record-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 18px;
  background: var(--coral);
  color: #fff;
  font-weight: 800;
}

.record-button.recording {
  background: var(--red);
}

.record-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.22);
}

.ghost-button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

audio {
  width: 100%;
  display: none;
}

audio.has-audio {
  display: block;
}

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

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

.score-box,
.metric-box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  justify-content: space-between;
  min-height: 92px;
  padding: 16px;
  border-radius: 8px;
  background: #172026;
  color: #fff;
}

.metric-box {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.score-box span,
.metric-box span {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.metric-box span,
.metric-box small {
  color: var(--muted);
  font-weight: 700;
}

.score-box strong {
  font-size: 44px;
  line-height: 1;
}

.metric-box strong {
  font-size: 30px;
  line-height: 1;
}

.tips {
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 14px;
}

.tip {
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f5f8fb;
  color: #26333a;
}

.tip.warn {
  border-color: var(--amber);
  background: #fff8ea;
}

.tip.bad {
  border-color: var(--red);
  background: #fff1ef;
}

.word-panel,
.diagnosis-panel,
.issue-panel {
  margin-top: 14px;
}

.diagnosis-panel,
.issue-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.panel-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title span {
  color: var(--muted);
  font-weight: 700;
}

.reading-guide {
  font-size: 18px;
  line-height: 2;
}

.reading-guide span {
  position: relative;
  display: inline-block;
  margin-right: 7px;
}

.reading-guide span.stress {
  font-weight: 900;
}

.reading-guide span.weak {
  color: #8b949b;
}

.reading-guide span.warn {
  color: #9a650b;
  font-weight: 850;
}

.reading-guide span.bad {
  color: var(--red);
  font-weight: 900;
}

.reading-guide em {
  display: block;
  color: var(--amber);
  font-size: 13px;
  font-style: normal;
  line-height: 1;
  text-align: center;
}

.reading-guide .bad em {
  color: var(--red);
}

.pause-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pause-line span {
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff8ea;
  color: #7a520d;
  font-weight: 750;
}

.recognized-text {
  color: #26333a;
  font-size: 16px;
  line-height: 1.7;
}

.issue {
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 10px 12px;
  background: #f5f8fb;
}

.issue + .issue {
  margin-top: 10px;
}

.issue.good {
  border-color: var(--green);
  background: #eef8f2;
}

.issue.warn {
  border-color: var(--amber);
  background: #fff8ea;
}

.issue.bad {
  border-color: var(--red);
  background: #fff1ef;
}

.issue strong {
  display: block;
  margin-bottom: 6px;
}

.issue ul {
  margin: 0;
  padding-left: 20px;
  color: #26333a;
  line-height: 1.6;
}

.word-table {
  display: grid;
  gap: 8px;
}

.word-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 72px 74px 86px minmax(170px, 1.5fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.word-row.head {
  min-height: 40px;
  background: #eef2f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.word-row.warn {
  border-color: rgba(217, 154, 37, 0.5);
  background: #fffaf0;
}

.word-row.bad {
  border-color: rgba(194, 65, 53, 0.5);
  background: #fff4f2;
}

.word-row strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.word-row small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.bar {
  height: 34px;
  display: flex;
  align-items: end;
  gap: 2px;
}

.bar.mini {
  height: 34px;
}

.bar span {
  flex: 1;
  min-width: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.good {
  background: var(--green);
}

.badge.warn {
  background: var(--amber);
}

.badge.bad {
  background: var(--red);
}

@media (max-width: 900px) {
  .app {
    width: min(100vw - 20px, 720px);
    padding: 10px 0;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .sentence-row {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    align-self: flex-start;
  }

  .icon-button {
    width: 100%;
    flex-basis: 44px;
  }

  .practice-grid {
    grid-template-columns: 1fr;
  }

  .meter-wrap {
    height: 210px;
  }

  .score-grid {
    grid-template-columns: 1fr;
  }

  .word-row,
  .word-row.head {
    grid-template-columns: 1fr 1fr;
  }

  .word-row.head {
    display: none;
  }
}
