*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #f4f0e8;
  --ink: #1f2328;
  --muted: #667085;
  --panel: #fffaf0;
  --line: #ddd2bf;
  --accent: #a5342f;
  --accent-dark: #7d2521;
  --gold: #c48a2c;
  --green: #276749;
  --blue: #285b8f;
  --shadow: 0 14px 36px rgba(31, 35, 40, 0.1);
}

body {
  width: 100%;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.15;
}

h2 {
  font-size: 20px;
}

.eyebrow {
  margin-bottom: 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.today-card {
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: right;
}

.today-card span,
.daily-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.today-card strong,
.daily-box strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.layout {
  display: block;
  width: 100%;
  max-width: min(960px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 3vw, 28px) 36px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.drill-panel,
.plan-panel,
.library-panel {
  padding: 12px;
}

.plan-panel,
.library-panel {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 0;
}

.mode-card {
  min-width: 0;
  min-height: 48px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.mode-card.active {
  border-color: var(--accent);
  outline: 2px solid rgba(165, 52, 47, 0.18);
}

.mode-card strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  line-height: 1.2;
}

.mode-card span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quick-sentence-panel {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.quick-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.quick-title strong {
  color: var(--accent);
}

.sentence-dock {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.sentence-jump {
  min-width: 0;
  min-height: 34px;
  padding: 4px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdf9f1;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.sentence-jump strong,
.sentence-jump span {
  display: block;
}

.sentence-jump strong {
  font-size: 13px;
  line-height: 1.1;
}

.sentence-jump span {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sentence-jump.active {
  border-color: var(--accent);
  background: #fff1df;
  outline: 2px solid rgba(165, 52, 47, 0.16);
}

.practice-box {
  min-width: 0;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.method-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.scene-panel {
  margin-top: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.method-card {
  min-width: 0;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdf9f1;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.method-card strong,
.method-card span {
  display: block;
}

.method-card strong {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 15px;
}

.method-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.method-card:hover {
  border-color: var(--accent);
}

.score-compact {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.auto-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.auto-result > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdf9f1;
}

.auto-result span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.auto-result strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-result > div:first-child {
  grid-column: 1 / -1;
  display: block;
}

.auto-result > div:first-child strong {
  margin-top: 4px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.nasal-focus {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
}

.nasal-strip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.nasal-strip > span {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  line-height: 24px;
}

.nasal-pill {
  padding: 4px 8px;
  border-radius: 8px;
  background: #eef4ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.nasal-pill.missed {
  background: #fff0ea;
  color: var(--accent);
}

.practice-meta,
.stress-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.practice-meta span,
.stress-token {
  padding: 4px 9px;
  border-radius: 8px;
  background: #f1e7d6;
  color: #6d4b1f;
  font-size: 12px;
  font-weight: 700;
}

.practice-text {
  margin-bottom: 12px;
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.read-label {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.tip-box {
  margin-bottom: 10px;
  padding: 7px 9px;
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: #fff7e8;
  color: #604516;
  font-size: 12px;
  line-height: 1.45;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.secondary-btn {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.ghost-btn {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.full {
  width: 100%;
}

audio {
  display: none;
  width: 100%;
  margin-top: 14px;
}

audio.has-recording {
  display: block;
}

.audio-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.export-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.score-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.score-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.score-item label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 800;
}

.score-item input {
  width: 100%;
  accent-color: var(--accent);
}

.daily-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.score-summary {
  margin-top: 10px;
}

.coach-panel {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.coach-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.coach-title strong {
  color: var(--accent);
  font-size: 12px;
}

.coach-list {
  display: grid;
  gap: 6px;
}

.coach-list > p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.coach-item {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.coach-item span {
  display: inline-block;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.coach-item strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.coach-item p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.coach-item.danger {
  border-color: rgba(165, 52, 47, 0.36);
  background: #fff5ef;
}

.coach-item.danger span {
  color: var(--accent);
}

.coach-item.good {
  border-color: rgba(39, 103, 73, 0.32);
  background: #f3fbf6;
}

.coach-item.good span {
  color: var(--green);
}

.daily-box > div {
  display: block;
  min-width: 0;
  min-height: 42px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.day-card {
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.day-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
}

.day-card p {
  color: var(--muted);
  font-size: 13px;
}

.search {
  width: min(100%, 320px);
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.sentence-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sentence-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.sentence-card:hover {
  border-color: var(--accent);
}

.sentence-card .tag {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.sentence-card p {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sentence-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

@media (max-width: 920px) {
  .sentence-dock,
  .week-grid,
  .sentence-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  html,
  body {
    max-width: 100vw;
  }

  .topbar,
  .section-head {
    align-items: center;
    flex-direction: row;
  }

  .topbar {
    width: 100vw;
    gap: 8px;
    padding: 7px 10px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar .eyebrow {
    font-size: 10px;
  }

  .section-head {
    gap: 8px;
    margin-bottom: 8px;
  }

  .section-head h2 {
    font-size: 14px;
    line-height: 1.25;
  }

  .section-head .eyebrow {
    font-size: 10px;
  }

  .ghost-btn {
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .layout {
    display: block;
    width: 100vw;
    max-width: 100vw;
    padding: 8px 10px 36px;
  }

  .panel {
    width: 100%;
    max-width: 100%;
    margin-bottom: 16px;
  }

  .drill-panel,
  .plan-panel,
  .library-panel {
    padding: 8px;
  }

  .today-card,
  .search {
    width: 100%;
    text-align: left;
  }

  .today-card {
    display: none;
  }

  .today-card span,
  .today-card strong {
    margin: 0;
    font-size: 12px;
  }

  .week-grid,
  .method-grid,
  .sentence-list {
    grid-template-columns: 1fr;
  }

  .sentence-dock {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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

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

  .mode-card {
    min-height: 36px;
    padding: 5px;
  }

  .mode-card strong {
    font-size: 10px;
  }

  .mode-card span {
    display: none;
  }

  .quick-sentence-panel,
  .scene-panel {
    padding: 6px;
  }

  .sentence-jump {
    min-height: 30px;
    padding: 3px 2px;
  }

  .sentence-jump strong {
    font-size: 12px;
  }

  .sentence-jump span {
    display: none;
  }

  .daily-box {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .practice-text {
    font-size: 22px;
    line-height: 1.32;
  }

  .practice-box {
    padding: 10px;
  }

  .practice-meta,
  .stress-line {
    gap: 5px;
    margin-bottom: 8px;
  }

  .practice-meta span,
  .stress-token {
    padding: 3px 7px;
    font-size: 11px;
  }

  .tip-box {
    padding: 6px 8px;
    font-size: 11px;
  }

  .practice-box .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .practice-box .controls button {
    width: 100%;
    min-height: 34px;
    padding: 0 8px;
    font-size: 12px;
  }
}
