:root {
  --bg: #fffaf0;
  --card: #ffffff;
  --ink: #20304a;
  --muted: #526a88;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --blue-soft: #eaf3ff;
  --coral: #e11d48;
  --coral-soft: #fff1f2;
  --green: #0f766e;
  --yellow: #f59e0b;
  --line: #dbe8f8;
  --shadow: 0 22px 50px rgba(37, 99, 235, 0.1), 0 4px 14px rgba(30, 41, 59, 0.05);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    "Noto Sans CJK SC", "Noto Color Emoji", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 620px at 6% -12%, #ffe6ad 0%, transparent 55%),
    radial-gradient(900px 520px at 102% -4%, #d8ecff 0%, transparent 52%),
    radial-gradient(900px 620px at 88% 104%, #d8f7e6 0%, transparent 55%),
    var(--bg);
}

::selection {
  background: #bfdbfe;
  color: #12325c;
}

/* ---------- playful background ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.doodle {
  position: absolute;
  font-weight: 900;
  line-height: 1;
  color: rgba(37, 99, 235, 0.1);
  user-select: none;
}

.doodle-a {
  top: 12%;
  left: 4%;
  font-size: clamp(4rem, 9vw, 7rem);
  transform: rotate(-12deg);
}

.doodle-b {
  right: 5%;
  bottom: 20%;
  font-size: clamp(3.5rem, 8vw, 6rem);
  color: rgba(225, 29, 72, 0.08);
  transform: rotate(10deg);
}

.doodle-note {
  top: 9%;
  right: 10%;
  font-size: clamp(2.4rem, 5vw, 4rem);
  color: rgba(245, 158, 11, 0.22);
  transform: rotate(12deg);
}

.doodle-star {
  top: 48%;
  left: 7%;
  font-size: 1.4rem;
  color: rgba(245, 158, 11, 0.3);
}

.doodle-star-two {
  top: auto;
  bottom: 12%;
  left: auto;
  right: 8%;
  color: rgba(16, 185, 129, 0.25);
}

/* ---------- layout ---------- */
.app {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 880px);
  margin: 0 auto;
  padding: 6px 0 56px;
}

.noscript {
  margin: 0 0 20px;
  padding: 14px 18px;
  color: #7c2d12;
  font-size: 0.92rem;
  font-weight: 600;
  background: #fff1e8;
  border: 1px solid #fdba74;
  border-radius: 14px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1.5px solid var(--line);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  width: min(100% - 32px, 880px);
  margin: 0 auto;
  padding: 10px 0;
}

.topbar.is-task-wide .topbar-inner {
  width: min(100% - 48px, 1100px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 1.5rem;
  background: linear-gradient(150deg, #ffe9a8, #ffd166);
  border: 2px solid #fff;
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.24);
  transform: rotate(-3deg);
}

.brand-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.view-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--blue-soft);
  border-radius: 999px;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.view-tab:hover {
  color: var(--blue-deep);
}

.view-tab.is-active {
  color: var(--blue-deep);
  font-weight: 800;
  background: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.16);
}

.view-tab-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  background: #fff;
  border-radius: 999px;
}

.view-tab.is-active .view-tab-count {
  color: #fff;
  background: var(--blue);
}

/* ---------- account ---------- */
.account {
  position: relative;
  margin-left: auto;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  color: var(--ink);
  font: inherit;
  background: #fff;
  border: 1.5px solid var(--blue);
  border-radius: 999px;
  cursor: pointer;
}

.account-btn.is-user {
  border-color: var(--line);
}

.account-btn[aria-expanded="true"] {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.account-btn-signin {
  padding: 0 20px;
  color: var(--blue-deep);
  font-size: 0.95rem;
  font-weight: 800;
}

.account-btn-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 4px;
}

.account-avatar,
.account-initial {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.account-initial {
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 900;
  background: #ffd166;
}

.account-btn-name {
  max-width: 140px;
  font-size: 0.88rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chevron {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: min(300px, 100vw - 24px);
  padding: 16px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(30, 41, 59, 0.14);
}

.account-guest,
.account-user {
  display: grid;
  gap: 12px;
}

.account-signin {
  min-height: 40px;
}

.account-who {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-name {
  font-size: 0.95rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email:empty {
  display: none;
}

.account-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.account-cloud {
  margin: 0;
  padding: 8px 10px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.5;
  background: #ecfdf5;
  border-radius: 10px;
}

.account-logout {
  min-height: 44px;
  color: #9f1239;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  background: var(--coral-soft);
  border: 1.5px solid #fecdd3;
  border-radius: 12px;
  cursor: pointer;
}

.account-logout:hover {
  border-color: #fda4af;
}

.account-logout:disabled {
  opacity: 0.6;
  cursor: default;
}

.account-status {
  margin: 16px 0 0;
}

/* Keep scrolled-to targets clear of the sticky top bar. */
#sentence-card,
.task-form,
.task-row {
  scroll-margin-top: 84px;
}

/* ---------- cards ---------- */
.card {
  padding: clamp(22px, 4vw, 34px);
  margin-top: 22px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 22px;
}

.step-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, #4f8df7, var(--blue));
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
  transform: rotate(-3deg);
}

.step-badge-coral {
  background: linear-gradient(145deg, #fb7185, var(--coral));
  box-shadow: 0 8px 18px rgba(225, 29, 72, 0.24);
  transform: rotate(3deg);
}

h2 {
  margin: 2px 0 5px;
  font-size: clamp(1.18rem, 2.8vw, 1.42rem);
  line-height: 1.3;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- sentence input ---------- */
textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 18px 20px;
  resize: vertical;
  color: var(--ink);
  font: inherit;
  font-size: clamp(1.08rem, 2.5vw, 1.3rem);
  font-weight: 600;
  line-height: 1.55;
  background: #f7fbff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea::placeholder {
  color: #9badc4;
  font-weight: 500;
}

textarea:hover {
  border-color: #c3dcf7;
}

textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12);
}

textarea.shake {
  animation: shake 0.4s ease;
  border-color: var(--coral);
}

.sentence-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: #5b708b;
}

.save-note::before {
  content: "✓";
  margin-right: 5px;
  color: #16a34a;
  font-weight: 800;
}

#char-count {
  font-variant-numeric: tabular-nums;
}

/* ---------- example chips ---------- */
.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.examples-label {
  margin-right: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.example-chip {
  padding: 8px 14px;
  color: #2d4a70;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: #f7fbff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.example-chip:hover {
  transform: translateY(-1px);
  background: #eef6ff;
  border-color: #9cc6f7;
}

.example-chip:active {
  transform: translateY(0) scale(0.98);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 26px;
  color: #fff;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:disabled {
  transform: none;
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, #4b8bf8, var(--blue));
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 15px 28px rgba(37, 99, 235, 0.34);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.icon-stop,
.icon-stop-record {
  display: none;
  width: 18px;
  height: 18px;
}

.btn-listen {
  min-width: 186px;
}

.btn-listen.is-speaking {
  background: linear-gradient(135deg, #fb7185, var(--coral));
  box-shadow: 0 12px 24px rgba(225, 29, 72, 0.26);
}

.btn-listen.is-speaking .icon-speaker {
  display: none;
}

.btn-listen.is-speaking .icon-stop {
  display: block;
}

.speak-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px;
  background: #f1f7ff;
  border: 1px solid #e0ecfb;
  border-radius: 999px;
}

.speed-label {
  padding: 0 8px 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.speed-btn {
  padding: 8px 16px;
  color: #47617f;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.speed-btn:hover {
  color: var(--blue);
}

.speed-btn.is-active {
  color: var(--blue-deep);
  background: #fff;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.16);
}

/* ---------- status ---------- */
.status {
  margin: 12px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--blue);
}

.status:empty {
  display: none;
}

.status.is-warn {
  color: #b45309;
}

.status.is-success {
  color: var(--green);
}

/* ---------- recording ---------- */
.record-card {
  background: #fffdfb;
}

.record-card.is-recording {
  background: linear-gradient(180deg, #fff7f4, #fffdfb);
  border-color: #ffd9d2;
  box-shadow: 0 22px 50px rgba(225, 29, 72, 0.12), 0 4px 14px rgba(30, 41, 59, 0.05);
}

.record-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 2px;
  text-align: center;
}

.read-along {
  margin: 0 0 22px;
  padding: 14px 18px;
  background: #f7fbff;
  border-left: 4px solid #93c5fd;
  border-radius: 12px;
}

.read-along[hidden] {
  display: none;
}

.read-along-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.read-along-text {
  margin: 0;
  color: #1e3a5f;
  font-size: clamp(1.02rem, 2.4vw, 1.18rem);
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.record-live {
  margin-bottom: 18px;
}

.timer {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 44px;
  margin: 0 auto 8px;
}

.wave span {
  width: 5px;
  height: 14px;
  background: linear-gradient(180deg, #fb7185, var(--coral));
  border-radius: 3px;
  animation: wave 0.9s ease-in-out infinite;
}

.wave span:nth-child(2n) {
  animation-delay: 0.12s;
}

.wave span:nth-child(3n) {
  animation-delay: 0.24s;
}

.wave span:nth-child(4n) {
  animation-delay: 0.36s;
}

.wave span:nth-child(5n) {
  animation-delay: 0.48s;
}

.record-live-hint {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #7a5a67;
}

.btn-record {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  min-height: 64px;
  padding: 0 30px;
  color: #fff;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fb7185, var(--coral));
  border: 2px solid transparent;
  border-radius: 999px;
  box-shadow: 0 14px 28px rgba(225, 29, 72, 0.26);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn-record:hover {
  transform: translateY(-2px);
  box-shadow: 0 17px 32px rgba(225, 29, 72, 0.32);
}

.btn-record:active {
  transform: translateY(0) scale(0.98);
}

.btn-record .icon {
  width: 24px;
  height: 24px;
}

.btn-record.is-recording {
  color: #be123c;
  background: #fff1f2;
  border-color: #fda4af;
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4);
  animation: record-pulse 1.7s ease-out infinite;
}

.btn-record.is-recording .icon-mic {
  display: none;
}

.btn-record.is-recording .icon-stop-record {
  display: block;
}

.btn-record:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

/* ---------- playback ---------- */
.playback {
  margin-top: 22px;
  padding: 18px;
  background: #f2fbf5;
  border: 1.5px dashed #b9e6c9;
  border-radius: 20px;
}

.playback-title {
  margin: 0 0 10px;
  color: #166534;
  font-size: 0.95rem;
  font-weight: 800;
}

.playback audio {
  display: block;
  width: 100%;
  height: 44px;
}

.playback-hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: #4d7c5d;
  line-height: 1.5;
}

/* ---------- tasks ---------- */
[hidden] {
  display: none !important;
}

.step-badge-green {
  background: linear-gradient(145deg, #34d399, var(--green));
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.24);
  transform: rotate(3deg);
}

.btn-soft {
  min-height: 48px;
  padding: 0 22px;
  color: var(--blue-deep);
  font-size: 0.98rem;
  background: var(--blue-soft);
  border: 1.5px solid #c9defa;
}

.btn-soft:hover {
  background: #dcebff;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-photo {
  min-height: 48px;
  padding: 0 22px;
  font-size: 0.98rem;
}

.btn-photo:disabled {
  cursor: wait;
}

.task-photo-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.task-item {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.task-open {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 16px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  background: #f7fbff;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.task-open:hover {
  background: #eef6ff;
  border-color: #9cc6f7;
}

.task-item.is-active .task-open {
  background: #ecfdf5;
  border-color: #6ee7b7;
}

.task-name {
  font-size: 1rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.task-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.task-item.is-active .task-meta {
  color: var(--green);
}

.task-delete {
  flex: 0 0 auto;
  padding: 0 14px;
  color: #9f1239;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 14px;
  cursor: pointer;
}

.task-delete:hover {
  background: var(--coral-soft);
  border-color: #fecdd3;
}

.task-empty {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--muted);
}

.task-form {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 18px;
  background: #fbfdff;
  border: 1.5px dashed #c9defa;
  border-radius: 20px;
}

.field-label {
  margin-top: 6px;
  font-size: 0.88rem;
  font-weight: 700;
}

.field-label:first-child {
  margin-top: 0;
}

.field-optional {
  margin-left: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.task-form input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: #f7fbff;
  border: 2px solid var(--line);
  border-radius: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.task-form input[type="text"]:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12);
}

.task-form textarea {
  min-height: 132px;
  font-size: 1.02rem;
}

.field-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

.task-preview {
  padding: 12px 16px;
  background: #f2fbf5;
  border: 1.5px solid #cdeedb;
  border-radius: 14px;
}

.task-preview.is-warn {
  background: #fff7ed;
  border-color: #fed7aa;
}

.task-preview-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: #166534;
}

.task-preview.is-warn .task-preview-title {
  color: #b45309;
}

.task-preview-list {
  max-height: 180px;
  margin: 8px 0 0;
  padding: 0 0 0 36px;
  overflow-y: auto;
  color: #1e3a5f;
  font-size: 0.92rem;
  line-height: 1.7;
}

.task-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.task-form-actions .btn {
  min-height: 50px;
}

.app.is-task-wide {
  width: min(100% - 48px, 1100px);
}

.task-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.task-panel-name {
  margin: 0;
  font-size: clamp(1.12rem, 2.6vw, 1.3rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.task-panel-progress {
  display: grid;
  gap: 5px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.task-bar {
  display: block;
  width: 170px;
  max-width: 100%;
  height: 8px;
  overflow: hidden;
  background: #e6eef9;
  border-radius: 999px;
}

.task-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #34d399, var(--green));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.task-panel-gap {
  flex: 1 1 auto;
}

.task-panel-head .speed-control {
  padding: 4px;
}

.task-panel-head .speed-btn {
  padding: 7px 13px;
  font-size: 0.82rem;
}

.link-btn {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--blue-deep);
  border-color: #9cc6f7;
}

/* ---------- task sentence rows ---------- */
.task-panel.is-wide .task-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.task-detail-slot:empty {
  display: none;
}

.task-panel.is-wide .task-detail-slot {
  position: sticky;
  top: 16px;
}

.task-sentences {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  background: #f7fbff;
  border: 2px solid var(--line);
  border-radius: 18px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.task-row.is-current {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.task-row-main {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 2px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.task-row-num {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--blue-deep);
  font-size: 0.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: #dbeafe;
  border-radius: 50%;
}

.task-row.is-current .task-row-num {
  color: #fff;
  background: var(--blue);
}

.task-row-body {
  display: block;
  min-width: 0;
}

.task-row-text {
  display: block;
  font-size: clamp(1rem, 2.3vw, 1.08rem);
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-row-mark {
  display: block;
  margin-top: 2px;
  color: #166534;
  font-size: 0.76rem;
  font-weight: 800;
}

.task-row-mark.is-scored {
  color: var(--yellow);
  font-size: 0.98rem;
  letter-spacing: 0.08em;
}

.task-row-acts {
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn.is-listen {
  color: var(--blue-deep);
  background: var(--blue-soft);
  border: 1.5px solid #c9defa;
}

.icon-btn.is-mic {
  color: var(--coral);
  background: var(--coral-soft);
  border: 1.5px solid #fecdd3;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.icon-btn:disabled {
  opacity: 0.4;
  transform: none;
  cursor: not-allowed;
}

.task-panel.is-busy .task-row-main {
  cursor: not-allowed;
}

/* One column: the current row grows and holds the practice panel. */
.task-panel:not(.is-wide) .task-row.is-current {
  grid-template-columns: minmax(0, 1fr);
  padding: 14px 12px;
}

.task-panel:not(.is-wide) .task-row.is-current .task-row-acts,
.task-panel:not(.is-wide) .task-row.is-current .task-row-mark {
  display: none;
}

.task-panel:not(.is-wide) .task-row.is-current .task-row-text {
  font-size: clamp(1.12rem, 2.8vw, 1.35rem);
  font-weight: 700;
}

.task-panel:not(.is-wide).is-recording .task-row.is-current {
  background: #fff7f4;
  border-color: #fda4af;
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.08);
}

.task-panel:not(.is-wide).is-recording .task-row.is-current .task-row-num {
  background: var(--coral);
}

/* ---------- task practice panel ---------- */
.task-row .task-detail {
  margin-top: 4px;
}

.task-detail-head {
  display: none;
}

.task-panel.is-wide .task-detail {
  padding: 22px 24px 24px;
  background: #fff;
  border: 2px solid var(--blue);
  border-radius: 22px;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.1);
}

.task-panel.is-wide .task-detail.is-recording {
  background: #fff7f4;
  border-color: #fda4af;
  box-shadow: 0 0 0 5px rgba(225, 29, 72, 0.08);
}

.task-panel.is-wide .task-detail-head {
  display: block;
}

.task-detail-pos {
  display: inline-block;
  padding: 4px 12px;
  color: var(--blue-deep);
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: #dbeafe;
  border-radius: 999px;
}

.task-detail.is-recording .task-detail-pos {
  color: #be123c;
  background: #ffe4e6;
}

.task-detail-sentence {
  margin: 14px 0 18px;
  font-size: clamp(1.5rem, 2.7vw, 2rem);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.task-detail .record-live {
  margin: 2px 0 12px;
  text-align: center;
}

.task-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.task-detail-actions .btn,
.task-detail-actions .btn-record {
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 52px;
  padding: 0 12px;
  font-size: 1rem;
}

.task-panel.is-wide .task-detail-actions {
  gap: 14px;
}

.task-panel.is-wide .task-detail-actions .btn,
.task-panel.is-wide .task-detail-actions .btn-record {
  min-height: 60px;
  font-size: 1.12rem;
}

.task-detail-note {
  display: none;
  margin: 10px 0 0;
  color: #7a5a67;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}

.task-detail.is-recording .task-detail-note {
  display: block;
}

.task-result {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f2fbf5;
  border: 1.5px dashed #b9e6c9;
  border-radius: 16px;
}

.task-result-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.task-result .score-stars {
  font-size: 1.8rem;
  letter-spacing: 0.1em;
}

.task-panel.is-wide .task-result {
  margin-top: 16px;
  padding: 16px 18px;
}

.task-panel.is-wide .task-result .score-stars {
  font-size: 2.3rem;
}

.mine-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin-left: auto;
  padding: 0 14px;
  color: #166534;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
  background: #fff;
  border: 1.5px solid #b9e6c9;
  border-radius: 999px;
  cursor: pointer;
}

.mine-btn:hover {
  background: #ecfdf5;
}

.mine-btn svg {
  width: 16px;
  height: 16px;
}

.mine-btn .icon-pause,
.mine-btn.is-playing .icon-play {
  display: none;
}

.mine-btn.is-playing .icon-pause {
  display: block;
}

.task-result .btn-star {
  margin-top: 10px;
}

.task-result .score-result {
  text-align: left;
}

.task-result .score-message {
  margin-top: 10px;
  font-size: 0.92rem;
}

.task-panel.is-wide .task-result .score-words {
  font-size: 1.3rem;
}

.task-foot {
  margin-top: 14px;
}

/* ---------- scoring ---------- */
.score {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1.5px dashed #b9e6c9;
}

.btn-star {
  width: 100%;
  min-height: 50px;
  color: #6b4203;
  background: linear-gradient(135deg, #ffe08a, #fbbf24);
  box-shadow: 0 10px 22px rgba(245, 158, 11, 0.26);
}

.btn-star:hover {
  box-shadow: 0 13px 26px rgba(245, 158, 11, 0.32);
}

.score-result {
  text-align: center;
}

.score-stars {
  margin: 0;
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: 0.08em;
  animation: star-pop 0.45s ease;
}

.score-stars .star {
  color: #d5dde8;
}

.score-stars .star.is-on {
  color: var(--yellow);
  text-shadow: 0 3px 10px rgba(245, 158, 11, 0.35);
}

.score-message {
  margin: 6px 0 0;
  color: #166534;
  font-size: 1rem;
  font-weight: 800;
}

.score-words {
  margin: 10px 0 0;
  color: #1e3a5f;
  font-size: clamp(1rem, 2.3vw, 1.12rem);
  font-weight: 700;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.score-words .is-missed {
  padding: 1px 5px;
  color: #9a3412;
  background: #ffedd5;
  border-bottom: 2px solid #fb923c;
  border-radius: 6px;
}

.score-words button.is-missed {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  margin: 2px 0;
  padding: 2px 12px 2px 9px;
  font: inherit;
  border: 0;
  border-bottom: 2px solid #fb923c;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.score-words button.is-missed::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 4V5L7 9H3Zm12.5-.9v7.8a4.5 4.5 0 0 0 0-7.8Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 9v6h4l5 4V5L7 9H3Zm12.5-.9v7.8a4.5 4.5 0 0 0 0-7.8Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.score-words button.is-missed:hover {
  background: #fed7aa;
  transform: translateY(-1px);
}

.score-words button.is-missed.is-speaking {
  color: #fff;
  background: #f97316;
  border-bottom-color: #c2410c;
}

.score-heard {
  margin: 8px 0 0;
  color: #4d7c5d;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.score-heard:empty {
  display: none;
}

.score-note {
  margin: 10px 0 0;
  color: #4d7c5d;
  font-size: 0.76rem;
  line-height: 1.5;
}

@keyframes star-pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- tips & footer ---------- */
.tips {
  margin-top: 22px;
  padding: 22px 26px;
  background: linear-gradient(135deg, #fff3cf, #fff9e8);
  border: 1.5px solid #ffe3a3;
  border-radius: 24px;
}

.tips h2 {
  margin: 0;
  font-size: 1.05rem;
  color: #8a5a08;
}

.tips ol {
  margin: 10px 0 0 20px;
  padding: 0;
}

.tips li {
  padding-left: 4px;
  color: #7c5a1e;
  font-size: 0.92rem;
  line-height: 1.8;
}

.tips li::marker {
  color: var(--yellow);
  font-weight: 800;
}

.app-footer {
  margin-top: 28px;
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: #5b708b;
  font-size: 0.82rem;
}

/* ---------- accessibility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--blue-deep);
  outline-offset: 3px;
}

textarea:focus-visible {
  outline: none;
}

/* ---------- animations ---------- */
@keyframes wave {
  0%,
  100% {
    height: 12px;
  }
  50% {
    height: 38px;
  }
}

@keyframes record-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.35);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(225, 29, 72, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .app {
    width: min(100% - 24px, 880px);
    padding: 0 0 40px;
  }

  /* Two rows on phones, so it scrolls away instead of sticking. */
  .topbar {
    position: relative;
  }

  .topbar-inner,
  .topbar.is-task-wide .topbar-inner {
    width: min(100% - 24px, 880px);
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .view-tabs {
    order: 3;
    flex: 1 1 100%;
  }

  .view-tab {
    flex: 1 1 0;
  }

  .account-btn-user {
    padding: 0 4px;
  }

  .account-btn-name,
  .account-chevron {
    display: none;
  }

  #sentence-card,
  .task-form,
  .task-row {
    scroll-margin-top: 12px;
  }

  .doodle-a {
    top: 7%;
  }

  .doodle-b {
    bottom: 9%;
  }

  .card {
    padding: 20px;
    border-radius: 24px;
  }

  .card-head {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 18px;
  }

  .step-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1.05rem;
  }

  .examples {
    gap: 7px;
  }

  .example-chip {
    padding: 7px 12px;
    font-size: 0.8rem;
  }

  .speak-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-listen {
    width: 100%;
  }

  .speed-control {
    align-self: center;
  }

  .btn-record {
    max-width: none;
  }

  .task-form {
    padding: 14px;
  }

  .task-form-actions .btn {
    flex: 1 1 auto;
  }

  .tips {
    padding: 20px;
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .wave span {
    height: 22px;
  }

  .wave span:nth-child(2n) {
    height: 34px;
  }

  .wave span:nth-child(3n) {
    height: 16px;
  }
}
