:root {
  /* ── Sonic palette ─────────────────────────── */
  --bg:           #E5E7EE;
  --shell:        #F4F5F9;
  --surface:      #FFFFFF;
  --surface-2:    #F1F2F8;
  --primary:      #E5267E;
  --primary-soft: #FF4D9D;
  --cyan:         #0AB4D6;
  --cyan-ink:     #0E7490;
  --yellow:       #F5B400;
  --amber-ink:    #B98300;
  --text:         #1C1233;
  --text-soft:    #6A6480;
  --text-dim:     #9A93AD;
  --border:       #E5E3EE;
  --good:         #16A34A;
  --close:        #D97706;
  --retry:        #E11D48;

  /* ── Backward-compat aliases for old names still in CSS ── */
  --surface-soft:      var(--surface-2);
  --blue:              var(--cyan);
  --text-muted:        var(--text-dim);
  --text-on-dark:      #ffffff;
  --text-on-dark-soft: var(--surface-2);

  /* ── Shadows (updated to Sonic ink color) ──── */
  --shadow-soft: 0 4px 24px rgba(28, 18, 51, 0.07);
  --shadow-pop:  0 12px 40px rgba(229, 38, 126, 0.18);

  /* ── Structure (unchanged) ──────────────────── */
  --radius-sm:   12px;
  --radius-md:   18px;
  --radius-lg:   26px;
  --radius-xl:   32px;
  --radius-pill: 999px;
  --page-width:  1120px;
  --transition:  0.2s ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h1 {
  font-weight: 750;
}

.site-container {
  width: min(var(--page-width), calc(100% - 48px));
  margin: 0 auto;
}

.subtle,
.hero-text {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.eyebrow,
.auth-eyebrow {
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* HEADER */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(244, 245, 249, 0.92);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background: var(--primary);
  flex: none;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 950;
  letter-spacing: -0.045em;
}

.brand-lite {
  font-style: italic;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--cyan-ink);
  margin-left: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-ui-language .menu-select {
  min-width: 150px;
  height: 44px;
  padding: 8px 14px;
  line-height: 1.4;
}

.profile-menu {
  position: relative;
}

.profile-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  color: white;
  font-weight: 900;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: 54px;
  z-index: 200;
  min-width: 230px;
  padding: 12px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.profile-dropdown button,
.menu-select {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 13px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.menu-select {
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.profile-dropdown button:hover {
  background: var(--surface-soft);
}

/* --- Plan badges & upgrade UI --- */
.pro-badge,
.trial-badge {
  display: block;
  margin: 2px 0 6px;
  padding: 7px 12px;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
}

.trial-badge {
  color: var(--text-muted);
}

/* 3-plan picker inside the profile dropdown */
.plan-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
}

.plan-picker .plan-option {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft, #f5f3ff);
  color: var(--text);
  text-align: left;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.plan-picker .plan-option:hover {
  border-color: var(--accent, #6d28d9);
}

.plan-picker .plan-option:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Welcome-week banner below the header */
.welcome-week-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface-soft, #f5f3ff);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.welcome-week-dismiss {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

/* Soft "X of N texts used today" counter near Start */
.text-quota-counter {
  display: block;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Contextual inline upgrade prompt */
.upgrade-inline {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-soft, #f5f3ff);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
}

.upgrade-inline--floating {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: 420px;
  box-shadow: var(--shadow-soft);
}

.upgrade-inline .upgrade-link {
  font-weight: 800;
  color: var(--accent, #6d28d9);
  cursor: pointer;
  text-decoration: none;
}

.upgrade-inline .upgrade-link:hover {
  text-decoration: underline;
}

.menu-label {
  display: block;
  margin: 6px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* BUTTONS */

.primary-btn,
.game-nav-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #ffffff;
  padding: 13px 24px;
  font-weight: 950;
  transition: var(--transition);
}

.primary-btn:hover,
.game-nav-btn-primary:hover {
  transform: translateY(-1px);
  background: var(--text);
  box-shadow: 0 16px 34px rgba(38, 28, 193, 0.30);
}

.game-nav-btn,
.tts-btn,
.slow-tts-btn,
.translate-btn,
.strip-btn,
.load-saved-text-btn {
  border: none;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-soft);
  padding: 10px 15px;
  font-weight: 850;
  transition: var(--transition);
}

.game-nav-btn:hover,
.tts-btn:hover,
.slow-tts-btn:hover,
.translate-btn:hover,
.strip-btn:hover,
.load-saved-text-btn:hover {
  background: rgba(58, 154, 255, 0.12);
  color: var(--primary);
}

/* Toggle buttons (Slow, Pinyin): real sliding switch */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-btn .switch {
  flex: none;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: rgba(91, 100, 114, 0.30);
  position: relative;
  transition: background var(--transition);
}

.toggle-btn .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--transition);
}

.toggle-btn.is-active {
  color: var(--primary);
}

.toggle-btn.is-active .switch {
  background: var(--primary);
}

.toggle-btn.is-active .switch::after {
  transform: translateX(14px);
}

/* Toolbar "More" overflow menu (distinct from the practice-card .more-btn) */
.tb-more {
  position: relative;
  display: inline-flex;
  flex: none;
}

.tb-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.tb-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 200;
  min-width: 190px;
  padding: 8px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tb-more-item {
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.92rem;
}

.tb-more-item:hover {
  background: var(--surface-soft);
  color: var(--primary);
}

.ghost-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: white;
  padding: 13px 22px;
  font-weight: 800;
}

.text-link-btn,
.auth-link-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 850;
  text-align: left;
}

.text-link-btn {
  margin-top: 14px;
  padding: 0;
}

.text-link-btn:hover,
.auth-link-btn:hover {
  color: var(--blue);
}

/* LANDING */

.landing-page {
  width: 100%;
}

.marketing-section {
  width: 100%;
}

body.product-active .marketing-section,
body.product-active > .footer {
  display: none !important;
}

body.auth-active .landing-page,
body.auth-active .marketing-section,
body.auth-active > .footer {
  display: none !important;
}

.landing-hero {
  margin: 60px 0 80px;
}

.landing-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 1fr);
  align-items: center;
  gap: 72px;
}

.landing-hero-copy {
  max-width: 560px;
}

.landing-hero-copy h1 {
  max-width: 560px;
  margin-bottom: 18px;
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  font-weight: 750;
}

.landing-hero-copy p {
  max-width: 480px;
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero-support {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.landing-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.landing-actions a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.landing-actions a:hover {
  color: var(--text);
}

.product-demo-card {
  width: 100%;
  max-width: 520px;
  justify-self: center;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}

.demo-video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: cover;
  border-radius: 16px;
}

.demo-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.demo-input,
.demo-result {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.demo-input {
  margin-bottom: 14px;
  font-size: 1rem;
  line-height: 1.6;
}

.demo-label {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.demo-sentence {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.demo-translation,
.demo-repeat,
.demo-speaking-cue,
.demo-saved {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.demo-buttons {
  display: flex;
  gap: 8px;
}

.demo-buttons span {
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  color: var(--text-soft);
}

.demo-btn-primary {
  border: 1px solid var(--text);
  font-weight: 700;
  color: var(--text);
}

.landing-how {
  margin: 0 auto 80px;
}

.landing-section-head {
  max-width: 760px;
  margin: 0 auto 34px;
  text-align: center;
}

.landing-section-head h2,
.landing-final-cta h2 {
  margin: 10px 0 14px;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  font-weight: 750;
}

.landing-section-head p,
.landing-final-cta p {
  margin: 0;
  color: var(--text-soft);
  font-size: 1.08rem;
  line-height: 1.65;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.how-card,
.benefit-card,
.landing-final-cta {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
}

.how-card {
  padding: 26px;
  box-shadow: 0 12px 34px rgba(20, 30, 50, 0.05);
}

.how-number {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 14px;
  background: var(--yellow);
  color: var(--text);
  font-weight: 950;
}

.how-card h3,
.benefit-card h3 {
  margin-bottom: 10px;
}

.how-card p,
.benefit-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.landing-benefits {
  margin-top: 60px;
}

.benefit-card {
  padding: 24px;
}

.benefit-card.dark {
  background: var(--text);
  color: white;
  border: none;
}

.benefit-card.dark p {
  color: var(--text-on-dark-soft);
}

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.landing-final-cta {
  margin: 56px auto 72px;
  padding: 40px 28px;
  text-align: center;
}

.landing-final-cta p {
  max-width: 520px;
  margin: 0 auto 22px;
}

.auth-note {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto 14px;
  color: var(--text-soft);
  text-align: center;
  font-weight: 650;
}

/* APP LAYOUT */

.main {
  width: 100%;
  margin: 0;
  padding: 44px 0 96px;
}

.app-screen {
  display: none;
}

.app-screen.active {
  display: block;
}

.workspace-card,
.start-panel {
  margin-bottom: 24px;
  padding: 36px;
  border-radius: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.workspace-head,
.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

/* Keep the action row from overflowing the card; let it wrap and right-align */
.workspace-head .card-buttons {
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

/* Full-text toolbar: stack under the title and wrap so nothing runs off the card */
#fullTextPanel .workspace-head {
  flex-direction: column;
  align-items: stretch;
}

#fullTextPanel .workspace-head .card-buttons {
  width: 100%;
  justify-content: flex-start;
}

.workspace-head h3,
.section-head h3 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

.workspace-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  margin-bottom: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.workspace-tab {
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-soft);
  padding: 9px 15px;
  font-weight: 850;
}

.workspace-tab.active,
.workspace-tab:hover {
  background: var(--surface);
  color: var(--primary);
}

.start-copy {
  max-width: 680px;
  margin-bottom: 24px;
}

.start-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(1.15rem, 2vw, 1.85rem);
  font-weight: 750;
}

textarea {
  width: 100%;
  min-height: 235px;
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-soft);
  color: var(--text);
  resize: vertical;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.7;
}

/* Paste-your-text field: ~30% narrower than the panel on wide screens */
#inputText {
  max-width: 740px;
}

textarea::placeholder {
  color: var(--text-muted);
}

.auth-input:focus,
textarea:focus,
.language-select:focus,
.deck-select:focus,
.menu-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(58, 154, 255, 0.14);
}

.composer-footer {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.language-select,
.deck-select {
  min-width: 128px;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text);
  font-weight: 800;
  outline: none;
}

.language-arrow {
  color: var(--text-muted);
  font-weight: 900;
}

/* LIBRARY / SAVED TEXTS */

.text-library-panel,
.saved-texts-panel {
  margin: 18px 0 22px;
  padding: 20px;
  border-radius: 24px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.text-library-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.text-library-item {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
  transition: var(--transition);
}

.text-library-item:hover {
  border-color: rgba(58, 154, 255, 0.45);
  transform: translateY(-1px);
}

.text-library-title {
  display: block;
  color: var(--text);
  font-weight: 900;
}

.text-library-meta {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.saved-texts-panel h3 {
  margin-bottom: 14px;
}

.saved-text-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.saved-text-item p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.saved-text-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.delete-saved-text-btn {
  border: none;
  border-radius: var(--radius-pill);
  background: rgba(255, 80, 80, 0.12);
  color: #b42318;
  padding: 10px 14px;
  font-weight: 850;
}

.delete-saved-text-btn:hover {
  background: rgba(255, 80, 80, 0.2);
}

/* FULL TEXT */

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

.full-text-box {
  margin-top: 20px;
  padding: 24px;
  border-radius: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.9;
  font-size: 1.08rem;
  word-break: break-word;
}

.full-text-pinyin {
  margin-top: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(58, 154, 255, 0.12);
  color: var(--primary);
  line-height: 1.8;
}

.word-save-hint {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* CARDS */

.cards-section {
  margin-bottom: 48px;
}

.cards-section .section-head {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  margin-top: 28px;
}

.card {
  width: 100%;
  max-width: 700px;
  padding: 36px 40px 32px;
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: 0 24px 60px rgba(28, 7, 112, 0.11);
  transform: translateY(-2px);
}

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

.card-progress {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-progress-total {
  color: var(--text-muted);
  font-weight: 600;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: white;
  font-size: 0.76rem;
  font-weight: 950;
}

.sentence {
  margin: 0 0 28px;
  color: var(--text);
  font-size: 1.45rem;
  line-height: 1.7;
  font-weight: 500;
}

.clickable-sentence {
  cursor: pointer;
}

.card-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.card-primary-btn {
  border: none;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #ffffff;
  padding: 11px 18px;
  font-weight: 950;
}

.record-btn {
  background: var(--blue);
  color: white;
}

.card-more {
  position: relative;
  margin-left: auto;
}

.more-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 1.35rem;
  font-weight: 900;
}

.more-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.more-menu {
  position: absolute;
  right: 0;
  top: 48px;
  z-index: 20;
  min-width: 190px;
  padding: 10px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.more-menu button {
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 850;
}

.more-menu button:hover {
  background: var(--surface-soft);
}

/* WORDS / PANELS */

.word {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}

.word:hover {
  background: rgba(255, 106, 43, 0.55);
  border-radius: 5px;
  border-color: var(--yellow);
}

.punctuation {
  display: inline;
}

.panel-box,
.translation-box,
.result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 0.96rem;
  line-height: 1.55;
}

.translation-box {
  background: rgba(58, 154, 255, 0.15);
  color: #e8f3ff;
}

.card .translation-box {
  background: rgba(58, 154, 255, 0.09);
  color: #1a3f7a;
}

#fullTextTranslation {
  color: var(--primary);
}

.pronunciation-box {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.card .pronunciation-box {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.pronunciation-box:empty,
.translation-box:empty {
  display: none;
}

.word-speaking {
  background: var(--yellow) !important;
  color: var(--text) !important;
  border-radius: 6px;
  padding: 1px 3px;
  box-shadow: 0 0 0 3px rgba(255, 106, 43, 0.28);
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.card .word-speaking {
  background: var(--yellow) !important;
  color: var(--text) !important;
}

.full-text-box .word-speaking {
  background: var(--yellow) !important;
  color: var(--text) !important;
}

.sentence-pinyin-box {
  background: rgba(58, 154, 255, 0.15);
  color: var(--text-on-dark-soft);
}

.card .sentence-pinyin-box {
  background: rgba(58, 154, 255, 0.07);
  color: var(--blue);
}

.word-popup {
  position: absolute;
  z-index: 999;
  min-width: 220px;
  max-width: 300px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(10, 180, 214, 0.4);
  box-shadow: 0 12px 32px rgba(28, 18, 51, 0.14);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
}

.popup-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-left {
  display: flex;
  flex-direction: column;
  flex: none;
}

.popup-word {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--cyan-ink);
}

.popup-pinyin {
  font-size: 0.78rem;
  color: var(--text-soft);
  font-weight: 500;
  margin-top: 2px;
}

.popup-translation {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
  color: var(--text);
}

.popup-save-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(245, 180, 0, 0.5);
  background: rgba(245, 180, 0, 0.14);
  color: var(--amber-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.popup-save-btn:hover {
  background: rgba(245, 180, 0, 0.28);
}

.popup-deck-select {
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
}

.example-pinyin {
  margin-top: 4px;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 700;
}

/* AUTH */

.auth-shell {
  width: 100%;
  margin: 48px 0 80px;
}

.auth-card {
  width: min(460px, calc(100% - 24px));
  margin: 0 auto;
  padding: 42px 34px;
  border-radius: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.auth-right {
  display: flex;
  flex-direction: column;
}

.auth-right label {
  margin: 16px 0 6px;
}

.auth-right h2 {
  margin-bottom: 10px;
  font-size: 2rem;
  font-weight: 750;
}

.auth-input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.auth-main-btn,
.auth-secondary-btn {
  width: 100%;
  height: 56px;
  margin-top: 24px;
  border-radius: 15px;
  font-weight: 900;
}

.auth-main-btn {
  border: none;
  background: var(--primary);
  color: #ffffff;
}

.auth-secondary-btn {
  margin-top: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.auth-link-btn {
  margin-top: 10px;
  padding: 0;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin: 24px 0;
  color: var(--text-muted);
}

.auth-divider span {
  height: 1px;
  background: var(--border);
}

.auth-message {
  min-height: 24px;
  margin: 18px 0 0;
  color: var(--text-soft);
  text-align: center;
}

#resetPasswordScreen {
  width: min(760px, calc(100% - 40px));
  margin: 70px auto;
}

.reset-password-card {
  display: block;
  min-height: auto;
}

.reset-password-panel {
  padding: 52px;
}

.reset-password-panel h2 {
  margin: 16px 0 12px;
  font-size: 2.2rem;
  font-weight: 750;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 30, 0.45);
  backdrop-filter: blur(10px);
}

.auth-modal {
  position: relative;
  width: min(440px, calc(100% - 32px));
  padding: 36px;
  border-radius: 28px;
  background: white;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.auth-modal h2 {
  margin-bottom: 14px;
  font-size: 2rem;
  font-weight: 750;
}

.auth-modal p {
  color: var(--text-soft);
  line-height: 1.6;
}

.auth-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-muted);
}

/* FLASHCARDS */

#screen-flashcards .workspace-card {
  padding: 40px;
}

#screen-flashcards .workspace-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  margin-bottom: 30px;
}

#screen-flashcards .flashcard-top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  margin-top: 10px;
}

#screen-flashcards .deck-select {
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

#screen-flashcards .game-nav-btn,
#screen-flashcards .game-nav-btn-primary {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

#screen-flashcards .flashcard-deck {
  margin-top: 28px;
}

.flashcard-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.flashcard-meta > span {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.flashcard-delete-btn {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.flashcard-delete-btn:hover {
  color: #d94f4f;
  background: rgba(217, 79, 79, 0.08);
}

.flashcard-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.flashcard-arrow {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.flashcard-arrow:hover {
  background: var(--surface-soft);
  box-shadow: 0 2px 14px rgba(28, 7, 112, 0.12);
}

#screen-flashcards .flashcard-card {
  width: 100%;
  max-width: 500px;
  perspective: 1200px;
  cursor: pointer;
}

.flashcard-card-inner {
  position: relative;
  width: 100%;
  min-height: 400px;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}

.flashcard-card.is-flipped .flashcard-card-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  min-height: 400px;
  backface-visibility: hidden;
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 32px rgba(28, 7, 112, 0.09);
}

.flashcard-front {
  align-items: center;
  text-align: center;
}

.flashcard-back {
  transform: rotateY(180deg);
  align-items: center;
  text-align: center;
}

.flashcard-front h3 {
  margin: 0;
  font-size: 3.8rem;
  line-height: 1.15;
  color: var(--text);
}

.flashcard-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.flashcard-pinyin {
  margin: 0;
  color: var(--blue);
  font-size: 1.05rem;
}

.flashcard-word-back {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.flashcard-translation {
  margin: 0;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
}

.flashcard-context-block {
  width: 100%;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.flashcard-sentence {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-soft);
  line-height: 1.6;
}

.flashcard-back .flashcard-pinyin {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.fc-audio-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 2px 0 6px;
}

.flashcard-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.flashcard-play-btn svg { stroke: var(--cyan-ink); flex: none; }

#flashcardSlowBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#flashcardSlowBtn.is-active {
  background: rgba(10, 180, 214, .12);
  border-color: rgba(10, 180, 214, .4);
  color: var(--cyan-ink);
}


.flashcard-empty {
  padding: 28px;
  border-radius: 22px;
  background: var(--surface-soft);
  border: 1px dashed var(--border);
  color: var(--text-soft);
  text-align: center;
}

.flashcard-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

#backToReaderBtn,
#backToReaderBtnWriting {
  margin-bottom: 10px;
  font-weight: 700;
  opacity: 0.7;
}

#backToReaderBtn:hover,
#backToReaderBtnWriting:hover {
  opacity: 1;
}

/* CALLIGRAPHY */

#writingInput {
  min-height: 160px;
}

#writingResult {
  margin-top: 16px;
}

.action-group {
  margin-top: 18px;
  display: flex;
  gap: 12px;
}

.download-pdf-link {
  display: inline-flex;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #ffffff;
  font-weight: 950;
  text-decoration: none;
}

/* AUTH STATE */

body.is-logged-out [data-tool-screen="flashcards"],
body.is-logged-out [data-tool-screen="calligraphy"],
body.is-logged-out #saveTextBtn,
body.is-logged-out #saveTextBtnReading {
  opacity: 0.45;
  pointer-events: none;
}

body.is-logged-out .landing-page {
  display: block;
}

body.is-logged-out #guestLoginBtn {
  display: inline-flex !important;
}

body.is-logged-out #logoutBtn,
body.is-logged-out .profile-menu,
body.is-logged-out #saveTextBtn,
body.is-logged-out #textLibraryPanel,
body.is-logged-out #savedTextsPanel {
  display: none !important;
}

body.is-logged-out .start-copy {
  margin-top: 8px;
}

body.is-logged-in #authScreen,
body.is-logged-in #guestLoginBtn,
body.is-logged-in .auth-note,
body.is-logged-in .marketing-section {
  display: none !important;
}

body.is-logged-in .main {
  display: block !important;
}

body.is-logged-in .header-language-controls,
body.is-logged-in .header-right,
body.is-logged-in #logoutBtn {
  display: flex !important;
}

body.is-logged-in .profile-menu,
body.is-logged-in .top-ui-language {
  display: block !important;
}

/* TABLET */

@media (min-width: 900px) {
  #screen-flashcards .workspace-head {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }

  #screen-flashcards .flashcard-top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .app-header {
    padding: 0 18px;
  }

  .main {
    width: 100%;
    padding-top: 28px;
  }

  .landing-hero-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 28px;
  }

  .landing-hero-copy,
  .product-demo-card {
    width: 100%;
    max-width: 100%;
  }

  .product-demo-card {
    align-self: stretch;
    justify-self: stretch;
    padding: 12px;
  }

  .demo-video {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
  }

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

  .workspace-card,
  .start-panel {
    padding: 26px;
  }

  .composer-footer,
  .workspace-head,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .language-switcher {
    width: 100%;
    justify-content: space-between;
  }

  .language-select {
    min-width: 0;
    width: 45%;
  }

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

/* .brand-mark img removed — logo is now inline SVG spark */

@media (min-width: 1200px) {
  .site-container {
    width: min(1120px, calc(100% - 120px));
  }

  .main .site-container {
    width: min(1120px, calc(100% - 120px));
  }

  .workspace-card,
  .start-panel {
    max-width: 1120px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 1500px) {
  .site-container {
    width: min(1120px, calc(100% - 180px));
  }

  .main .site-container {
    width: min(1120px, calc(100% - 180px));
  }
}

/* MOBILE */

@media (max-width: 640px) {
  .site-container {
    width: min(100% - 24px, var(--page-width));
  }

  .main .site-container {
    width: 100%;
  }

  .app-header {
    min-height: 68px;
  }

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

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  #guestLoginBtn {
    padding: 10px 16px;
    font-size: 0.95rem;
  }

  .top-ui-language .menu-select {
    min-width: 0;
    width: 96px;
    padding-inline: 9px;
  }

  .header-right {
    gap: 7px;
  }

  .landing-hero {
    margin: 28px 0 42px;
  }

  .landing-hero-copy h1 {
    font-size: 2.3rem;
  }

  .landing-actions a {
    display: none;
  }

  .product-demo-card {
    margin-top: 4px;
  }

  .workspace-card,
  .start-panel {
    width: 100%;
    padding: 22px;
    border-radius: 28px;
  }

  .start-panel {
    padding: 18px;
  }

  .start-copy h1 {
    font-size: 1.5rem;
  }

  textarea {
    min-height: 180px;
  }

  body.is-logged-out textarea {
    min-height: 120px;
  }

  .workspace-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    margin-bottom: 18px;
    border-radius: 18px;
  }

  .workspace-tab {
    width: 100%;
    font-size: 0.9rem;
    padding: 9px 13px;
    text-align: center;
  }

  body.product-active .app-shell .main {
    padding-top: 10px;
  }

  body.product-active .home-back-btn {
    margin: 0 12px 10px;
  }

  body.product-active #readerStart {
    border-radius: 22px 22px 0 0;
  }

  #fullTextPanel .workspace-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  #fullTextPanel .card-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #fullTextPanel .card-buttons button {
    width: 100%;
    padding: 11px 10px;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap;
  }

  #fullTextPanel .card-buttons .tb-more {
    display: flex;
  }

  #fullTextPanel .card-buttons .tb-more .tb-more-btn {
    width: 100%;
    justify-content: center;
  }

  .full-text-box {
    padding: 18px;
    font-size: 1rem;
    line-height: 1.75;
  }

  .card {
    max-width: 100%;
    padding: 24px 20px 20px;
    border-radius: 20px;
  }

  .sentence {
    font-size: 1.15rem;
    margin-bottom: 20px;
  }

  .card-action-row {
    flex-wrap: wrap;
  }

  .card-more {
    margin-left: 0;
  }

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

  .auth-card {
    padding: 32px 22px;
  }

  .reset-password-panel {
    padding: 32px 22px;
  }

  .auth-modal {
    width: calc(100% - 24px);
    padding: 24px 18px;
    border-radius: 22px;
  }

  .auth-modal h2 {
    font-size: 1.5rem;
  }

  .auth-modal-actions {
    flex-direction: column;
  }

  .auth-modal-actions button {
    width: 100%;
  }

  #screen-flashcards .workspace-card {
    padding: 18px;
    overflow: hidden;
  }

  #screen-flashcards .flashcard-card {
    max-width: 100%;
    margin: 0;
    order: -1;
    flex-basis: 100%;
  }

  .flashcard-area {
    flex-wrap: wrap;
    gap: 20px;
  }

  .flashcard-arrow {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }

  #screen-flashcards .flashcard-card-inner {
    min-height: 480px;
  }

  #screen-flashcards .flashcard-face {
    min-height: 480px;
    padding: 28px 24px 32px;
    overflow-y: auto;
  }

  #screen-flashcards .flashcard-front h3 {
    font-size: 2.8rem;
  }

  #screen-flashcards .flashcard-translation {
    font-size: 2rem;
  }

  #screen-flashcards .flashcard-sentence {
    font-size: 0.9rem;
    word-break: break-word;
  }

  #screen-flashcards .flashcard-back .flashcard-pinyin {
    word-break: break-word;
  }

}

@media (max-width: 380px) {
  #fullTextPanel .card-buttons {
    grid-template-columns: 1fr;
  }
}

.auth-success {
  text-align: center;
  padding: 24px 10px;
}

.auth-success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--text);
  font-size: 2rem;
  font-weight: 950;
}

.auth-success h2 {
  margin-bottom: 14px;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.03em;
}

.auth-success p {
  max-width: 440px;
  margin: 0 auto 26px;
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.65;
}
.magic-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 30, 0.45);
  backdrop-filter: blur(8px);
}

.magic-loading-overlay[hidden] {
  display: none !important;
}

.magic-loading-card {
  width: min(420px, calc(100% - 32px));
  padding: 32px 28px;
  border-radius: 28px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--border);
}

.magic-loading-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.2rem;
  color: var(--text);
}

.magic-loading-card p {
  margin: 0;
  color: var(--text-soft);
}

.magic-loading-card .magic-loader {
  margin: 0 auto 16px;
}

.magic-loading {
  margin-top: 22px;
  padding: 28px;
  border-radius: 24px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  text-align: center;
  color: var(--text);
}

.magic-loading strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.magic-loading p {
  margin: 0;
  color: var(--text-soft);
}

.magic-loader {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid rgba(58, 154, 255, 0.2);
  border-top-color: var(--blue);
  animation: magicSpin 0.8s linear infinite;
}

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

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast-success { background: #22c55e; }
.toast-error   { background: #ef4444; }
.toast-info    { background: var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; }
}

/* Inline modal (replaces alert/confirm/prompt) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-pop);
}
.modal-box p {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--text);
}
.modal-input {
  width: 100%;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.flashcard-speaking-result {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(58, 154, 255, 0.12);
  color: var(--text);
  line-height: 1.6;
  font-size: 0.95rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.flashcard-speaking-result strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.flashcard-speaking-result p {
  margin: 2px 0;
}

.flashcard-speaking-prompt {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.flashcard-hard-translation {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.flashcard-speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: center;
  margin-top: 2px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
}

.game-nav-btn:disabled,
.game-nav-btn-primary:disabled,
.flashcard-arrow:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.guest-nudge-box {
  max-width: 420px;
  text-align: center;
}

.guest-nudge-title {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--text);
}

.guest-nudge-body {
  margin: 0 0 20px;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

.guest-nudge-box .modal-actions {
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.import-modal-box {
  max-width: 520px;
}

.import-modal-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: var(--text);
}

.import-modal-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.import-modal-textarea {
  min-height: 180px;
  margin-top: 0;
  box-sizing: border-box;
}

.import-progress {
  margin: 10px 0 2px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* Voice picker panel — fixed floating card */
.voice-picker-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1200;
  width: 300px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  max-height: 360px;
  overflow-y: auto;
}

/* Composer voice button */
.voice-composer-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  height: 40px;
  font-size: 15px;
  color: var(--text-soft);
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.voice-composer-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.voice-picker-panel .voice-picker-heading {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.voice-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voice-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.voice-option:hover {
  border-color: var(--primary);
  background: var(--surface);
}
.voice-option.voice-selected {
  border-color: var(--primary);
  background: #ece9ff;
}
.voice-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.voice-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.voice-gender {
  font-size: 12px;
  color: var(--text-muted);
}
.voice-preview-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  width: 32px;
  height: 32px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.voice-preview-btn:hover {
  background: var(--text);
}
.voice-preview-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.voice-picker-empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 0;
}
/* Strong visible TTS word highlighting */
.word.word-speaking,
.sentence .word.word-speaking,
.full-text-box .word.word-speaking {
  background: var(--yellow) !important;
  color: var(--text) !important;
  border-radius: 7px;
  padding: 1px 4px;
  box-shadow: 0 0 0 2px rgba(255, 106, 43, 0.45);
}

/* ─── FOOTER ─────────────────────────────────── */

.footer {
  padding: 30px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.footer a {
  margin: 0 10px;
  text-decoration: none;
  color: var(--text-muted);
}

.footer a:hover {
  color: var(--primary);
}

.footer-copy {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.legal-page address {
  font-style: normal;
  line-height: 1.8;
  color: var(--text-soft);
  margin: 12px 0 20px;
}

/* ─── LEGAL PAGES ────────────────────────────── */

.legal-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  line-height: 1.7;
}

.legal-page h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin-bottom: 8px;
}

.legal-page h2 {
  margin-top: 2em;
  font-size: 1.15rem;
  color: var(--text);
}

.legal-page h3 {
  margin-top: 1.4em;
  font-size: 1rem;
  color: var(--text-soft);
}

.legal-page p,
.legal-page ul,
.legal-page table {
  color: var(--text-soft);
}

.legal-page ul {
  padding-left: 1.4em;
}

.legal-page a {
  color: var(--primary);
  text-decoration: none;
}

.legal-page a:hover {
  color: var(--blue);
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

.legal-table th,
.legal-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.legal-table th {
  color: var(--text);
  font-weight: 700;
  background: var(--surface-soft);
}

/* ─── ONBOARDING ─────────────────────────────── */

.onboarding-card {
  max-width: 640px;
  margin: 48px auto;
}

.language-step h2,
.skill-step h2 {
  margin-bottom: 32px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.onboarding-lang-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 36px;
}

.onboarding-lang-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.onboarding-lang-label {
  min-width: 110px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.onboarding-select {
  flex: 1;
  height: 52px;
  font-size: 1rem;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  appearance: auto;
}

.onboarding-select:focus {
  outline: none;
  border-color: var(--primary);
}

.onboarding-continue-btn {
  width: 100%;
  height: 54px;
  font-size: 1rem;
  font-weight: 700;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

/* Four-mode picker reads better as a 2x2 grid */
.skill-grid-modes {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 600px) {
  .skill-grid-modes {
    grid-template-columns: 1fr;
  }
}

.skill-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 22px 20px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--surface-soft);
  text-align: left;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.skill-card:hover {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.skill-card.skill-card-active {
  border-color: var(--primary);
  background: #ece9ff;
  box-shadow: var(--shadow-soft);
}

.skill-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.skill-card strong {
  font-size: 1rem;
  color: var(--text);
}

.skill-desc {
  font-size: 0.84rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.route-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 4px;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.route-choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 20px 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.route-choice-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.route-choice-card strong {
  font-size: 0.95rem;
  color: var(--text);
}

.route-choice-card span {
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.4;
}

/* READING EXERCISE (cloze / fill the gaps) */

.exercise-body {
  margin-top: 8px;
}

.exercise-note {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.5;
}

.exercise-empty {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.6;
}

.cloze-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.cloze-item:last-child {
  border-bottom: none;
}

.cloze-sentence {
  margin: 0 0 14px;
  font-size: 1.2rem;
  line-height: 1.9;
  color: var(--text);
}

/* The gap inside the sentence, filled as the learner picks an option */
.cloze-slot {
  display: inline-block;
  min-width: 84px;
  margin: 0 3px;
  padding: 1px 10px;
  border-bottom: 2px solid var(--primary);
  background: var(--surface-soft);
  border-radius: 8px 8px 0 0;
  color: var(--text);
  font-weight: 800;
  text-align: center;
}

.cloze-slot.cloze-correct {
  border-bottom-color: #1ca672;
  background: #e6f7ef;
  color: #0f7a52;
}

.cloze-slot.cloze-wrong {
  border-bottom-color: #e0556b;
  background: #fdecef;
  color: #b32b42;
}

.cloze-slot.cloze-revealed {
  font-style: italic;
}

/* The four answer choices */
.cloze-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cloze-option {
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.cloze-option:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cloze-option.selected {
  border-color: var(--primary);
  background: #ece9ff;
  color: var(--text);
}

.cloze-option.option-correct {
  border-color: #1ca672;
  background: #e6f7ef;
  color: #0f7a52;
}

.cloze-option.option-wrong {
  border-color: #e0556b;
  background: #fdecef;
  color: #b32b42;
}

.exercise-score {
  display: inline-flex;
  align-items: center;
  margin-bottom: 18px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-weight: 900;
  font-size: 0.95rem;
}

.exercise-score.all-correct {
  background: #e6f7ef;
  color: #0f7a52;
}

.home-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition);
}

.home-back-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

@media (max-width: 600px) {
  .onboarding-card {
    margin: 24px auto;
  }

  .onboarding-lang-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .onboarding-select {
    width: 100%;
  }

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

  .route-choice-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Azure pronunciation assessment results --- */
.pa-result { line-height: 1.5; }
.pa-overall { font-size: 1.05rem; margin: 0 0 .35rem; }
.pa-words { margin: .25rem 0; }
.pa-word { font-weight: 600; }
.pa-metrics { font-size: .85rem; color: #555; margin: .25rem 0; }
.pa-metric { white-space: nowrap; }
.pa-heard { font-size: .85rem; color: #777; margin: .25rem 0 0; }

/* --- Tutor-style pronunciation drill --- */
.pa-drill {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
}
.pa-drill-chunk {
  margin-top: .75rem;
  padding: .85rem;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.pa-drill-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pa-drill-target {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 .65rem;
}
.pa-drill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.card-secondary-btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  padding: 11px 18px;
  font-weight: 700;
}
.card-secondary-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pa-drill-actions button:disabled {
  opacity: .5;
  cursor: default;
}
.pa-drill-feedback { margin-top: .55rem; font-size: .95rem; }
.pa-drill-feedback p { margin: .25rem 0; }
.pa-drill-pass { color: #1a8a3a; }
.pa-drill-again { color: #c8860a; }
.pa-drill-moveon { color: var(--text-muted); }
.pa-drill-tries { font-size: .8rem; color: var(--text-muted); }
.pa-drill-heard { font-style: italic; color: #777; }
.pa-drill-done {
  margin-top: .75rem;
  font-size: 1.05rem;
  color: #1a8a3a;
}

/* Drill: per-syllable "what was off" breakdown */
.pa-drill-breakdown {
  margin: .4rem 0 0;
  font-size: .95rem;
  line-height: 1.5;
}
.pa-weak-label {
  font-weight: 700;
  color: var(--text-muted);
  margin-right: .25rem;
}
.pa-weak {
  display: inline-block;
  color: #c0392b;
  font-weight: 700;
}
.pa-weak em {
  font-style: normal;
  font-weight: 600;
  opacity: .85;
}

/* ── §3 App shell ───────────────────────────────── */

.app-shell {
  max-width: 700px;
  margin: 0 auto;
  background: var(--shell);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 720px) {
  .app-shell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 80px rgba(28, 18, 51, .07);
  }
}

/* Let the main grow to push the tab bar to the bottom */
.app-shell .main {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 16px;
}

/* Kill the inner width constraint — the shell is the constraint */
.app-shell .site-container,
.app-shell .main .site-container {
  width: 100%;
}

/* ── §3 Bottom tab bar ──────────────────────────── */

.sonic-tabbar {
  position: sticky;
  bottom: 0;
  z-index: 90;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 8px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(244, 245, 249, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.sonic-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}

.sonic-tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.sonic-tab.active {
  color: var(--primary);
}

/* ── §4 Onboarding dots + trial step ─────────────────────────── */
.ob-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 24px;
}
.ob-dot {
  width: 28px;
  height: 5px;
  border-radius: 99px;
  background: var(--surface-2);
}
.ob-dot-on {
  background: var(--primary);
}

.ob-trial-step {
  display: flex;
  flex-direction: column;
}
.ob-trial-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 24px;
}
.ob-trial-spark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
}
.ob-include-list {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  width: 100%;
  max-width: 340px;
}
.ob-include-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 500;
}

.onboarding-explore-btn {
  align-self: center;
  margin: 12px auto 0;
  padding: 8px 12px;
  text-align: center;
}
.ob-include-check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(22, 163, 74, 0.12);
  color: var(--good);
  display: grid;
  place-items: center;
  flex: none;
}

/* ── §4 Social auth buttons ─────────────────────────── */
.auth-social {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 4px;
}
.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  border-radius: 15px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.auth-google-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.auth-google-btn:hover {
  border-color: var(--primary);
}
.auth-apple-btn {
  border: none;
  background: #1C1233;
  color: #ffffff;
}
.auth-apple-btn:hover {
  background: #2a1a4a;
}

/* ── §4 Word-order exercise ─────────────────────────── */
.word-order-exercise {
  margin-top: 16px;
}
.wo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.wo-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  background: rgba(229, 38, 126, 0.10);
  padding: 3px 9px;
  border-radius: 6px;
  flex: none;
}
.wo-head h3 {
  font-size: 16px;
  font-weight: 800;
}
.wo-prompt {
  font-size: 13px;
  color: var(--text-soft);
  margin: 4px 0 14px;
}
.wo-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 56px;
  padding: 12px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.wo-slot {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 18px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.wo-slot:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.wo-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.wo-chip {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 18px;
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--transition);
}
.wo-chip.wo-chip-used {
  opacity: 0.32;
  pointer-events: none;
}
.wo-foot {
  display: flex;
  align-items: center;
  gap: 14px;
}
.wo-foot .primary-btn {
  flex: 1;
}
.wo-foot .text-link-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.wo-done {
  text-align: center;
  padding: 28px 0;
  font-weight: 700;
  color: var(--good);
}

/* ── Speaking: usage meter ─────────────────────────── */
.speak-usage-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.speak-meter-lite {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cyan-ink);
  background: rgba(10, 180, 214, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  flex: none;
}
.speak-meter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  flex: none;
}
.speak-meter-track {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}
.speak-meter-bar {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-soft));
  transition: width 0.3s ease;
}
.speak-meter-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* ── Speaking: tone feedback block ─────────────────────────── */
.tone-feedback {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.tone-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.tone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.tone-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}
.tone-hz {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
}
.tone-py {
  color: var(--text-soft);
  font-size: 13px;
}
.tone-msg {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}

/* ── Speaking: repeat-this-word card ─────────────────────────── */
.pa-repeat {
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  text-align: center;
  margin-top: 14px;
}
.pa-repeat-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.pa-repeat-word {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: clamp(36px, 8vw, 48px);
  font-weight: 700;
  color: var(--close);
  margin-top: 6px;
  letter-spacing: 0.04em;
}
.pa-repeat-py {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* ── Flashcards: SRS review buttons ─────────────────────────── */
.fc-review {
  padding: 18px 0 8px;
}
.fc-review-q {
  font-size: 12px;
  color: var(--text-soft);
  text-align: center;
  margin-bottom: 12px;
  font-weight: 600;
}
.fc-review-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.fc-rb {
  padding: 15px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: background var(--transition), border-color var(--transition);
}
.fc-rb small {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
}
.fc-rb-again {
  color: var(--retry);
  border-color: rgba(225, 29, 72, 0.35);
}
.fc-rb-again:hover { background: rgba(225, 29, 72, 0.06); }
.fc-rb-good {
  color: var(--close);
  border-color: rgba(217, 119, 6, 0.35);
}
.fc-rb-good:hover { background: rgba(217, 119, 6, 0.06); }
.fc-rb-easy {
  color: var(--good);
  border-color: rgba(22, 163, 74, 0.35);
}
.fc-rb-easy:hover { background: rgba(22, 163, 74, 0.06); }

/* ── Account screen ─────────────────────────────────────── */
#screen-account {
  padding: clamp(14px, 3.5vw, 24px) clamp(16px, 4vw, 30px);
}
.acct-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  gap: 10px;
}
.acct-appbar-title {
  font-size: 16px;
  font-weight: 800;
}
.acct-iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.acct-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.acct-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex: none;
}
.acct-name {
  font-size: 18px;
  font-weight: 800;
}
.acct-email {
  font-size: 13px;
  color: var(--text-soft);
}
.acct-plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 5px;
}
.acct-upgrade-row {
  display: flex;
  align-items: center;
  gap: 13px;
  background: linear-gradient(100deg, rgba(229,38,126,.10), rgba(10,180,214,.10));
  border: 1px solid rgba(229,38,126,.35);
  border-radius: 16px;
  padding: 15px 16px;
  margin-bottom: 14px;
  cursor: pointer;
}
.acct-upgrade-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
}
.acct-upgrade-t {
  font-weight: 800;
  font-size: 15px;
}
.acct-upgrade-s {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.acct-plan-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 14px;
}
.acct-plan-picker .plan-option {
  display: block;
  width: 100%;
  padding: 13px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.acct-plan-picker .plan-option:last-child {
  border-bottom: none;
}
.acct-plan-picker .plan-option:hover {
  background: var(--surface-2);
}
.acct-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
}
.acct-mrow {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: inherit;
  text-align: left;
  color: var(--text);
}
.acct-mrow:last-child {
  border-bottom: none;
}
.acct-mi {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--cyan-ink);
  display: grid;
  place-items: center;
  flex: none;
}
.acct-ml {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
}
.acct-mv {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 4px;
}
.acct-mrow-danger .acct-ml {
  color: var(--retry);
}
.acct-mrow-danger .acct-mi {
  background: rgba(225, 29, 72, 0.10);
  color: var(--retry);
}

/* ── Write / calligraphy screen ─────────────────────────── */
#screen-writing {
  padding: clamp(14px, 3.5vw, 24px) clamp(16px, 4vw, 30px);
}
.write-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: clamp(18px, 3vw, 28px);
}
.write-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--primary);
  margin-bottom: 4px;
}
.write-hint {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 4px;
}
/* Tighten the textarea inside the Sonic write card */
#screen-writing textarea {
  margin-top: 14px;
  border-radius: 14px;
  background: var(--surface-2);
  min-height: 160px;
}

/* ── Landing hero — Sonic ───────────────────────────────── */
.landing-hero {
  background:
    radial-gradient(820px 440px at 90% 10%, rgba(10,180,214,.08), transparent 60%),
    radial-gradient(700px 480px at 4% 95%, rgba(229,38,126,.08), transparent 60%);
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan-ink);
  background: rgba(10,180,214,.10);
  border: 1px solid rgba(10,180,214,.30);
  padding: 6px 13px;
  border-radius: 999px;
  margin-bottom: 22px;
}
.hero-eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  flex: none;
}
.hero-grad {
  background: linear-gradient(90deg, var(--primary), var(--cyan-ink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing-hero-copy-sub {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-soft);
  max-width: 480px;
  margin: 0 0 28px;
}
.hero-ghost-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.hero-ghost-link:hover {
  border-color: var(--cyan);
  color: var(--cyan-ink);
}
.hero-langs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 22px;
}
.hero-lang-chip {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

/* Hero demo card */
.hero-demo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 40px 80px -34px rgba(28,18,51,.18);
}
.hero-demo-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.hero-demo-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.hero-demo-score-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-demo-score-n {
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan-ink);
}
.hero-demo-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--cyan) 0 79%, var(--surface-2) 79% 100%);
}
.hero-demo-ring span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan-ink);
}
.hero-demo-sentence {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 6px;
}
.hds-w {
  border-bottom: 3px solid transparent;
  padding-bottom: 1px;
}
.hds-good  { color: var(--good);  border-color: rgba(22,163,74,.4); }
.hds-close { color: var(--close); border-color: rgba(217,119,6,.45); }
.hds-retry { color: var(--retry); border-color: rgba(225,29,72,.5); }
.hero-demo-pinyin {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 18px;
}
.hero-demo-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.hero-mic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  box-shadow: 0 0 0 6px rgba(229,38,126,.14);
}
.hero-wave {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
}
.hero-wave i {
  flex: 1;
  border-radius: 3px;
  background: var(--cyan);
  opacity: .9;
}
.hero-demo-time {
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.hero-demo-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hero-demo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 13px;
}
.hero-demo-word {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 17px;
  font-weight: 700;
}
.hero-demo-py {
  font-size: 12px;
  color: var(--text-soft);
  margin-left: 7px;
  font-weight: 500;
}
.hero-demo-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.hdp-good  { color: var(--good);  background: rgba(22,163,74,.12); }
.hdp-close { color: var(--close); background: rgba(217,119,6,.12); }
.hdp-retry { color: var(--retry); background: rgba(225,29,72,.12); }

/* How-it-works Sonic step numbers */
.how-number {
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  color: #fff;
}

/* ── Upgrade modal ──────────────────────────────────────── */
.upgrade-modal {
  max-width: 420px;
  padding: 28px 26px 22px;
}
.upgrade-modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}
.upgrade-modal-sub {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 16px !important;
}
.upgrade-modal-unlocks {
  list-style: none;
  padding: 13px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 600;
}
.upgrade-modal-unlocks li::before {
  content: "✓ ";
  color: var(--primary);
  font-weight: 700;
}
.upgrade-modal-plans {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.upgrade-plan-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid rgba(229, 38, 126, .45);
  background: rgba(229, 38, 126, .06);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.upgrade-plan-btn:hover {
  background: rgba(229, 38, 126, .12);
}
.upgrade-plan-secondary {
  border-color: var(--border);
  background: var(--surface);
}
.upgrade-plan-secondary:hover {
  background: var(--surface-2);
}
.upgrade-plan-save {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 2px 7px;
  border-radius: 6px;
  flex: none;
}
.upgrade-modal-cta {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 13px;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  box-shadow: 0 12px 26px -12px rgba(229, 38, 126, .55);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 10px;
}
.upgrade-modal-cta:hover {
  transform: translateY(-1px);
}
.upgrade-modal-reset {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 10px !important;
}
.upgrade-modal-dismiss {
  display: block;
  width: 100%;
  text-align: center;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
}
.upgrade-modal-dismiss:hover {
  color: var(--text);
}

/* Fix: .landing-actions a rule overrides ghost link color */
.landing-actions .hero-ghost-link {
  color: var(--text);
}
.landing-actions .hero-ghost-link:hover {
  color: var(--cyan-ink);
  border-color: var(--cyan);
}

/* Plan-state dot on the profile avatar button */
#profileMenuBtn[data-plan-badge]::after {
  content: "";
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--shell, var(--surface));
}
#profileMenuBtn[data-plan-badge="trial"]::after {
  background: var(--primary);
}
#profileMenuBtn[data-plan-badge="pro"]::after {
  background: var(--cyan);
}

/* ── Home dashboard ────────────────────────────────────────────── */
.hd-body {
  padding: clamp(18px, 4vw, 28px) clamp(16px, 4vw, 32px) 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Greeting */
.hd-greet {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.hd-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: var(--cyan-ink);
  flex: none;
}
.hd-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.hd-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 4px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.hd-plan-badge[data-variant="trial"] {
  color: var(--primary);
  background: rgba(229,38,126,.10);
  border-color: rgba(229,38,126,.25);
}
.hd-plan-badge[data-variant="pro"] {
  color: var(--cyan-ink);
  background: rgba(10,180,214,.10);
  border-color: rgba(10,180,214,.30);
}

/* Streak */
.hd-streak {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(100deg, rgba(245,180,0,.14), rgba(229,38,126,.06));
  border: 1px solid rgba(245,180,0,.35);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.hd-flame {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: rgba(245,180,0,.18);
  color: var(--amber-ink);
  display: grid;
  place-items: center;
  flex: none;
}
.hd-streak-n {
  font-size: 18px;
  font-weight: 800;
}
.hd-streak-s {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.hd-days {
  display: flex;
  gap: 5px;
  margin-left: auto;
  flex: none;
}
.hd-day {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.hd-day-on {
  background: var(--amber-ink);
  border-color: var(--amber-ink);
}

/* Stat tiles */
.hd-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.hd-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 13px;
}
.hd-stat-top {
  margin-bottom: 10px;
}
.hd-stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
}
.hd-stat-icon-read   { background: rgba(10,180,214,.12);  color: var(--cyan-ink); }
.hd-stat-icon-speak  { background: rgba(229,38,126,.10);  color: var(--primary); }
.hd-stat-icon-cards  { background: rgba(245,180,0,.16);   color: var(--amber-ink); }
.hd-stat-n {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.hd-stat-l {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 600;
  margin-top: 1px;
}

/* Resume card */
.hd-resume {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 22px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.hd-resume:hover { background: var(--surface-2); }
.hd-resume-thumb {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--cyan-ink);
  flex: none;
}
.hd-resume-meta { flex: 1; min-width: 0; }
.hd-resume-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-soft);
}
.hd-resume-title {
  font-size: 14px;
  font-weight: 700;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

/* Action grid */
.hd-sec {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-soft);
  margin: 0 2px 12px;
}

/* Video history */
.hd-video-history { margin-bottom: 8px; }
.hd-video-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.hd-video-list::-webkit-scrollbar { display: none; }
.hd-video-item {
  flex: none;
  width: 140px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 0.15s;
}
.hd-video-item:hover { opacity: 0.8; }
.hd-video-thumb {
  width: 140px;
  height: 79px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  background: var(--surface-2);
}
.hd-video-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-top: 5px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}
.hd-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.hd-action {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: box-shadow .15s;
}
.hd-action:hover { box-shadow: 0 4px 16px -6px rgba(28,18,51,.14); }
.hd-action-ico {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--cyan-ink);
}
.hd-action-nm {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.hd-action-ds {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.hd-action-feat {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  background: linear-gradient(100deg, rgba(229,38,126,.08), rgba(10,180,214,.08));
  border-color: rgba(229,38,126,.30);
}
.hd-action-ico-feat {
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  color: #fff;
}
.hd-action {
  position: relative;
}
.hd-action-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-ink);
  background: rgba(10,180,214,.12);
  padding: 2px 9px;
  border-radius: 999px;
}

/* ── Video screen ────────────────────────────────────────── */

/* Video screen — sticky player, window-scroll transcript */
.app-shell .main:has(#screen-video.active) {
  padding: 0;
}

.vid-body {
  display: flex;
  flex-direction: column;
}

/* Player area sticks to the top while captions scroll past */
.vid-pinned {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--shell, #f4f5f9);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(10px,2.5vw,14px) clamp(14px,3.5vw,24px) 10px;
  border-bottom: 1px solid var(--border);
}

/* Transcript scrolls naturally with the window */
.vid-scroll {
  padding: 0 clamp(14px,3.5vw,24px) 32px;
}

/* URL bar */
.vid-urlbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 12px;
}
.vid-yt-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #FF0000;
  display: grid;
  place-items: center;
  flex: none;
}
.vid-url-input {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.vid-url-input::placeholder { color: var(--text-dim); }
.vid-go-btn {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  border: none;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: inherit;
  flex: none;
}

/* Player */
.vid-player-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #160B2C;
  aspect-ratio: 16/9;
  max-height: 36vh;
}
.vid-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}
.vid-placeholder-txt {
  font-size: 13px;
  color: rgba(255,255,255,.4);
  font-weight: 500;
}
#vidPlayerContainer,
#vidPlayerContainer iframe {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  border: none;
  display: block;
}

/* Transport */
.vid-transport {
  display: flex;
  align-items: center;
  gap: 10px;
}
.vid-tbtn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  position: relative;
  font-family: inherit;
}
.vid-tbtn-play {
  width: 50px;
  height: 50px;
  border: none;
  color: #fff;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
}
.vid-tbtn.on {
  background: rgba(10,180,214,.12);
  border-color: rgba(10,180,214,.5);
  color: var(--cyan-ink);
}
.vid-tbtn-num {
  position: absolute;
  font-size: 9px;
  font-weight: 800;
  bottom: 5px;
  line-height: 1;
}
.vid-scrub {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.vid-scrubber-input {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  outline: none;
  cursor: pointer;
  min-width: 0;
}
.vid-scrubber-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}
.vid-scrubber-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}
.vid-time {
  font-size: 11px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: none;
}

/* States */
.vid-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  text-align: center;
}
.vid-state-txt {
  font-size: 14px;
  color: var(--text-soft);
}
.vid-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: vid-spin 0.7s linear infinite;
}
@keyframes vid-spin { to { transform: rotate(360deg); } }
.vid-nocap-icon { font-size: 40px; }
.vid-nocap-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.vid-nocap-sub {
  font-size: 14px;
  color: var(--text-soft);
  max-width: 280px;
}
.vid-nocap-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 20px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  max-width: 280px;
}
.vid-nocap-btn-pro {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  border: none;
  border-radius: 11px;
  padding: 10px 20px;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  max-width: 280px;
}

/* Caption area */
.vid-caption-area { display: flex; flex-direction: column; gap: 0; }
.vid-cap-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 6px;
  position: sticky;
  top: 0;
  background: var(--shell, #f4f5f9);
  z-index: 2;
}
.vid-toggle-btn {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 13px;
  cursor: pointer;
  font-family: inherit;
}
.vid-toggle-btn.on {
  background: rgba(10,180,214,.12);
  border-color: rgba(10,180,214,.5);
  color: var(--cyan-ink);
}

/* Compact continuous transcript */
.vid-capwrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0 24px;
}
.vid-line {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.vid-line.past { opacity: 0.45; }
.vid-line.current {
  border-color: rgba(229, 38, 126, 0.4);
  box-shadow: 0 0 0 3px rgba(229, 38, 126, 0.07);
  opacity: 1;
}
.vid-line:hover:not(.current) { background: var(--surface-2); }

/* Chinese ruby layout */
.vid-han {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 24px;
  font-weight: 600;
  line-height: 2.4;
  word-break: break-all;
}
.vid-ruby {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: bottom;
  margin: 0 2px;
  cursor: pointer;
  border-radius: 5px;
  padding: 0 2px;
  transition: background 0.1s;
}
.vid-ruby small {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  line-height: 1;
  margin-bottom: 3px;
  white-space: nowrap;
}
.vid-ruby:hover { background: rgba(10,180,214,.1); }
.vid-ruby.sel { background: rgba(10,180,214,.16); }
.vid-ruby.sel .vid-zh { color: var(--cyan-ink); }
.vid-zh { font-family: 'Noto Sans SC', sans-serif; }

/* Non-Chinese word spans */
.vid-text {
  font-size: 20px;
  line-height: 1.7;
  color: var(--text);
}
.vid-word {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
}
.vid-word:hover { background: rgba(10,180,214,.1); color: var(--cyan-ink); }

/* Translation line */
.vid-tr {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 6px;
  line-height: 1.5;
}

/* Per-line actions — pill buttons, visible only on the active line */
.vid-line-acts {
  display: none;
  gap: 8px;
  margin-top: 12px;
}
.vid-line.current .vid-line-acts { display: flex; }

.vid-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.vid-replay-btn:hover { background: var(--surface-2); }

.vid-speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 11px;
  border: none;
  background: linear-gradient(95deg, var(--primary), var(--primary-soft));
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
}
.vid-speak-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.vid-result-box {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13px;
}
.vid-result-box[hidden] { display: none; }

/* Pinyin off: hide the <small> ruby labels */
.vid-capwrap.vid-pinyin-off .vid-ruby small { display: none; }
.vid-capwrap.vid-pinyin-off .vid-ruby { vertical-align: middle; }

/* Trial video quota chip */
.vid-free-chip {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
}
.vid-free-chip span {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-ink);
  background: rgba(10, 180, 214, .12);
  border: 1px solid rgba(10, 180, 214, .3);
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: .01em;
}
