:root {
  --bg: #f6eedf;
  --paper: rgba(255, 251, 244, 0.94);
  --panel: #fff1d8;
  --panel-strong: #fff8ea;
  --accent: #e97447;
  --accent-strong: #cd5b30;
  --accent-2: #2f8f84;
  --ink: #243043;
  --muted: #5f6f82;
  --line: rgba(36, 48, 67, 0.12);
  --shadow: 0 26px 64px rgba(203, 124, 61, 0.17);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.78) 0, rgba(255, 255, 255, 0) 38%),
    linear-gradient(90deg, rgba(47, 143, 132, 0.08) 0 16px, transparent 16px 100%),
    linear-gradient(180deg, #fff9ef 0%, #fbe8cd 55%, #f7e5cb 100%);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.deck {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 18px 0 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
}

.app-brand {
  display: grid;
  gap: 2px;
}

.app-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.topbar-copy {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 10px;
}

.top-tabs {
  width: fit-content;
  margin: 0;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 24px rgba(255, 255, 255, 0.35);
}

.tab,
button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  opacity: 0.68;
  text-decoration: none;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  opacity: 1;
}

.tab.manage-tab {
  opacity: 0.5;
}

.tab.manage-tab.active {
  opacity: 0.92;
}

.hero-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.manage-head p,
.count,
.debug p,
.meta {
  color: var(--muted);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.panel,
.practice-surface {
  padding: 30px;
  border-radius: 30px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.practice-surface {
  max-width: 804px;
  margin: 0 auto;
  padding: 34px 36px;
  background: linear-gradient(180deg, var(--panel-strong) 0%, rgba(255, 253, 247, 0.94) 100%);
  border: 1px solid rgba(36, 48, 67, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.step-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(47, 143, 132, 0.12);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.step-chip strong {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: rgba(47, 143, 132, 0.16);
  font-size: 0.78rem;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-button {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-content: center;
  min-width: 142px;
  min-height: 82px;
  padding: 13px 16px;
  border-radius: 22px;
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(232, 111, 71, 0.12);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.icon-button:hover:not(:disabled),
.icon-button:focus-visible:not(:disabled),
.text-action:hover:not(:disabled),
.text-action:focus-visible:not(:disabled),
button.delete:hover:not(:disabled),
button.delete:focus-visible:not(:disabled) {
  transform: translateY(-1px);
}

.button-icon {
  font-size: 1.75rem;
}

.button-label {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.icon-button.play {
  background: linear-gradient(180deg, #ffd973 0%, #ffc850 100%);
  color: #6d4200;
}

.icon-button.quiet {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(36, 48, 67, 0.08);
}

.reveal-panel {
  min-height: 128px;
  margin-top: 22px;
  padding: 20px 22px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid rgba(39, 48, 67, 0.08);
  transition: background-color 180ms ease;
}

.reveal-panel.is-revealed {
  background: #fff0c5;
}

.reveal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.label {
  margin: 0 0 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
}

.reveal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.text-action {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(36, 48, 67, 0.08);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.revealed-text {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.55;
  transition:
    filter 180ms ease,
    opacity 180ms ease;
}

.revealed-text.is-blurred {
  filter: blur(8px);
  opacity: 0.72;
}

.manage-head,
.status-line,
.sentence-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.manage-head,
.sentence-row {
  justify-content: space-between;
}

.manage-head {
  align-items: end;
}

.count {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  font-weight: 800;
  white-space: nowrap;
}

.manage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(280px, 0.82fr);
  gap: 22px;
  margin-top: 24px;
  align-items: start;
}

.manage-main,
.manage-side {
  display: grid;
  gap: 18px;
}

.manage-side {
  position: sticky;
  top: 18px;
}

.manage-section {
  padding: 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

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

.section-head h3 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.08;
}

.section-note {
  max-width: 22ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  text-align: right;
}

.audio-lab {
  display: grid;
  gap: 16px;
  align-items: stretch;
}

.audio-status {
  display: grid;
  gap: 10px;
}

.progress-track {
  overflow: hidden;
  width: min(320px, 100%);
  height: 8px;
  border-radius: 999px;
  background: rgba(39, 48, 67, 0.08);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 100%);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(39, 48, 67, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

.debug summary {
  cursor: pointer;
  font-weight: 800;
}

.composer {
  display: grid;
  gap: 10px;
}

.status-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.composer button,
.audio-lab button {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fff;
  color: inherit;
  font: inherit;
}

.sentence-list {
  display: grid;
  gap: 12px;
}

.sentence-row {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.sentence-copy {
  max-width: 70ch;
}

.sentence-copy p {
  margin: 0;
  line-height: 1.5;
}

.sentence-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-action {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(36, 48, 67, 0.08);
}

button.delete {
  padding: 10px 14px;
  border-radius: 16px;
  background: #ffd5ca;
  color: #7b2d20;
  font-weight: 800;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .deck {
    width: min(100%, calc(100% - 32px));
  }

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

  .manage-side {
    position: static;
  }

  .section-head {
    flex-direction: column;
  }

  .section-note {
    max-width: none;
    text-align: left;
  }
}

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .app-brand {
    gap: 4px;
  }

  .top-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .panel {
    padding: 22px;
  }

  .practice-surface {
    padding: 26px 24px;
  }
}

@media (max-width: 780px) {
  .deck {
    width: calc(100% - 24px);
    padding-top: 14px;
  }

  .app-title {
    font-size: 0.96rem;
  }

  .topbar-copy {
    font-size: 0.9rem;
  }

  .manage-head,
  .status-line,
  .sentence-row,
  .sentence-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .count {
    width: fit-content;
  }

  .manage-section {
    padding: 18px;
    border-radius: 20px;
  }

  .panel,
  .practice-surface {
    padding: 20px 18px;
    border-radius: 24px;
  }

  .icon-button {
    min-width: 116px;
    min-height: 78px;
    padding: 12px;
  }

  .reveal-head {
    flex-direction: column;
  }
}
