:root {
  color-scheme: light;
  --ink: #22212a;
  --muted: #777487;
  --line: #ddd9e8;
  --paper: #f7f5ff;
  --panel: #fff;
  --primary: #6d4aff;
  --primary-dark: #4b2e83;
  --green: #3b7864;
  --danger: #8d2929;
  --shadow: 0 22px 60px rgb(75 46 131 / 12%);
  --radius: 24px;
  font-family: Inter, Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 16% 0%, rgb(255 255 255 / 95%), transparent 31rem), var(--paper);
  line-height: 1.5;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgb(109 74 255 / 42%); outline-offset: 4px; }
.shell { width: min(1040px, calc(100% - 36px)); min-height: 100vh; margin: 0 auto; padding: 24px 0 28px; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--primary-dark); font-size: .94rem; font-weight: 850; letter-spacing: -.035em; text-decoration: none; }
.brand-mark { width: 25px; height: 25px; display: flex; align-items: end; justify-content: center; gap: 3px; padding: 4px; border-radius: 8px; background: var(--primary-dark); }
.brand-mark i { width: 3px; border-radius: 3px; background: #fff; }
.brand-mark i:nth-child(1) { height: 7px; opacity: .7; }.brand-mark i:nth-child(2) { height: 12px; opacity: .85; }.brand-mark i:nth-child(3) { height: 16px; }
.status-pill { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgb(255 255 255 / 74%); color: var(--primary-dark); font-size: .72rem; font-weight: 700; }
.add-nav { min-height: 38px; padding: 7px 12px; border-color: var(--line); font-size: .75rem; }
.add-view { width: min(720px, 100%); flex: 1; align-self: center; padding: 20px 0 44px; }
.add-heading { margin: 0 0 22px; }
.add-heading h1 { margin: 8px 0; color: var(--primary-dark); font-size: clamp(2.4rem, 8vw, 4.1rem); line-height: .98; letter-spacing: -.07em; }
.add-heading > p:last-child { max-width: 520px; margin: 0; color: var(--muted); }
.entry-stage, .saved-stage { padding: clamp(19px, 4vw, 30px); border: 1px solid var(--line); border-radius: 23px; background: rgb(255 255 255 / 88%); box-shadow: 0 12px 36px rgb(75 46 131 / 6%); }
.field-label { display: block; margin-bottom: 9px; color: var(--primary-dark); font-size: .8rem; font-weight: 800; }
#new-terms, .draft-row input, .draft-row select { width: 100%; min-height: 48px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: .92rem; }
#new-terms { min-height: 150px; resize: vertical; line-height: 1.7; }
#new-terms:focus, .draft-row input:focus, .draft-row select:focus { outline: 3px solid rgb(109 74 255 / 16%); border-color: #aa9beb; }
.field-hint { margin: 8px 0 17px; color: var(--muted); font-size: .72rem; }
.entry-stage .button-primary, .saved-stage .button-primary { background: var(--primary); color: #fff; }
.entry-stage .message, .draft-stage .message { color: var(--danger); }
.draft-list { display: grid; gap: 10px; }
.draft-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 112px; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.draft-row input, .draft-row select { min-width: 0; min-height: 43px; padding: 9px 10px; font-size: .82rem; }
.draft-actions { display: flex; gap: 10px; margin-top: 15px; }
.draft-actions .button-primary { flex: 1; background: var(--primary); color: #fff; }
.draft-actions .button-light { border-color: var(--line); }
.saved-stage h2 { margin: 8px 0; color: var(--primary-dark); font-size: clamp(1.7rem, 6vw, 2.5rem); letter-spacing: -.055em; }
.saved-stage > p:not(.eyebrow) { color: var(--muted); }
.saved-list { display: grid; gap: 8px; margin: 19px 0; }
.saved-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.saved-row strong { overflow-wrap: anywhere; color: var(--primary-dark); font-size: .84rem; }
.saved-status { color: var(--muted); font-size: .72rem; text-align: right; }
.retry-audio { min-height: 34px; padding: 6px 9px; border-color: var(--line); font-size: .7rem; }
.home-view { flex: 1; }
.hero { min-height: 520px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); align-items: center; gap: 34px; padding: clamp(30px, 5vw, 62px); overflow: hidden; border-radius: 30px; background: linear-gradient(132deg, var(--primary-dark), #6b49bb 54%, #8777ce); color: #fff; box-shadow: var(--shadow); }
.hero-copy { max-width: 590px; }
.eyebrow { margin: 0; color: var(--primary); font-size: .7rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: #ddd5ff; }
.hero h1, .complete-view h1 { max-width: 650px; margin: 11px 0 17px; font-size: clamp(3rem, 6.8vw, 6rem); line-height: .92; letter-spacing: -.075em; }
.hero-lede { max-width: 500px; margin: 0; color: rgb(255 255 255 / 78%); font-size: 1rem; }
.practice-card { display: flex; flex-direction: column; align-items: center; padding: 26px 24px 24px; border: 1px solid rgb(255 255 255 / 30%); border-radius: 26px; background: rgb(255 255 255 / 12%); text-align: center; backdrop-filter: blur(8px); }
.sound-orbit { position: relative; width: 126px; height: 126px; display: grid; place-items: center; margin: 0 auto 16px; }
.orbit { position: absolute; inset: 0; border: 1px solid rgb(255 255 255 / 35%); border-radius: 50%; }
.orbit-a { transform: scale(.72); border-color: rgb(255 255 255 / 48%); }
.orbit-b { transform: scale(.96); border-right-color: #fff; rotate: -25deg; }
.sound-core { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: var(--primary-dark); font-size: 1.75rem; }
.due-count { margin: 0; font-size: clamp(2.3rem, 5vw, 3.3rem); font-weight: 850; letter-spacing: -.075em; line-height: 1; font-variant-numeric: tabular-nums; }
.due-label { margin: 8px 0 21px; color: rgb(255 255 255 / 75%); font-size: .83rem; }
.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 17px; border: 1px solid transparent; border-radius: 14px; font-size: .84rem; font-weight: 800; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease; cursor: pointer; }
.button:disabled { opacity: .72; cursor: wait; }
.button-primary { width: 100%; background: #fff; color: var(--primary-dark); }
.button-primary:hover:not(:disabled), .button-light:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgb(25 10 70 / 20%); }
.button-light { background: #fff; color: var(--primary-dark); }
.message { min-height: 1.2em; margin: 10px 0 0; color: inherit; font-size: .78rem; }
.home-view .message { color: rgb(255 255 255 / 82%); }
.practice-note { display: flex; align-items: center; gap: 16px; margin: 20px 0 0; padding: 18px 22px; border: 1px solid #d9d2c7; border-radius: 20px 20px 20px 7px; background: #f5f2ed; box-shadow: 8px 8px 0 #ebe6de; }
.note-mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border: 1px solid #8874c7; border-radius: 50%; color: #8874c7; font-size: 1.15rem; }
.practice-note p { margin: 0; color: #6d6862; font-size: .88rem; }.practice-note strong { color: #49443f; }
.audio-library { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 17px 0 0; padding: 16px 19px; border: 1px solid var(--line); border-radius: 17px; background: rgb(255 255 255 / 76%); }
.audio-library-copy p { margin: 0; }.audio-library-copy p:first-child { color: var(--primary-dark); font-size: .82rem; font-weight: 800; }.audio-library-copy p:last-child { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.audio-library-action { display: flex; align-items: center; gap: 12px; }
.audio-library-action .button { min-height: 40px; padding: 8px 13px; border-color: var(--line); font-size: .76rem; white-space: nowrap; }
.audio-library-action .button:disabled { cursor: default; }
#audio-sync-progress { width: 88px; height: 8px; accent-color: var(--primary); }
.review-view { flex: 1; display: flex; flex-direction: column; }
.review-heading { width: min(760px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 4px auto 12px; }
.progress-label { margin: 0; color: var(--muted); font-size: .77rem; font-variant-numeric: tabular-nums; }
.review-card { width: min(760px, 100%); margin: 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: rgb(255 255 255 / 84%); box-shadow: 0 12px 36px rgb(75 46 131 / 7%); }
.listen-stage { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 22px; background: linear-gradient(145deg, #f0edff, #fff); text-align: center; }
.stage-label { margin: 0 0 20px; color: var(--primary-dark); font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.audio-button { width: 122px; height: 122px; display: grid; place-items: center; margin: 0; border: 1px solid #d9d0ff; border-radius: 50%; background: #fff; color: var(--primary); box-shadow: 0 14px 30px rgb(75 46 131 / 11%); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.audio-button:hover { transform: scale(1.04); box-shadow: 0 18px 34px rgb(75 46 131 / 17%); }
.audio-button svg { width: 54px; height: 54px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; }
.audio-status { min-height: 1.3em; margin: 18px 0 21px; color: var(--muted); font-size: .83rem; }
.answer-panel { padding: 26px clamp(18px, 4vw, 36px) 28px; border-top: 1px solid var(--line); }
.answer-spanish { margin: 0; color: var(--primary-dark); font-size: clamp(1.8rem, 5vw, 2.65rem); font-weight: 850; letter-spacing: -.06em; line-height: 1.05; }
.answer-target { margin: 12px 0 0; color: var(--primary); font-size: .8rem; font-weight: 800; }
.answer-english { margin: 8px 0 24px; color: var(--muted); font-size: 1rem; }
.rating-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.rating { min-height: 76px; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; transition: transform .14s ease, border-color .14s ease, background-color .14s ease; }
.rating:hover { transform: translateY(-1px); border-color: #bcb0ed; background: #faf9ff; }
.rating:disabled { cursor: wait; opacity: .6; }
.rating strong { color: var(--primary-dark); font-size: .86rem; }.rating span { color: var(--muted); font-size: .68rem; line-height: 1.3; }
.rating-again { border-color: #ead4d4; }.rating-again strong { color: var(--danger); }
.answer-panel .message { color: var(--muted); text-align: center; }
.complete-view { width: min(620px, 100%); flex: 1; align-self: center; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 48px 0; }
.complete-mark { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 50%; background: #e8f3ef; color: var(--green); font-size: 1.6rem; font-weight: 800; }
.complete-view h1 { margin: 10px 0 15px; color: var(--primary-dark); font-size: clamp(2.8rem, 7vw, 5rem); }
.complete-copy { max-width: 480px; margin: 0 0 22px; color: var(--muted); }
.extra-status { min-height: 1.2em; margin: -12px 0 18px; color: var(--muted); font-size: .82rem; }
.complete-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.complete-view .button-primary { width: auto; background: var(--primary); color: #fff; }
.complete-view .button-light { border-color: var(--line); }
.footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .71rem; }
.is-playing .audio-button { animation: listening-pulse 1.4s ease-in-out infinite; }
@keyframes listening-pulse { 50% { box-shadow: 0 0 0 12px rgb(109 74 255 / 8%), 0 14px 30px rgb(75 46 131 / 11%); } }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 600px); padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(17px, env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 15px; }
  .topbar { flex-wrap: wrap; }
  .status-pill { margin-left: auto; }
  .complete-actions { width: 100%; }
  .complete-actions .button { flex: 1; }
  .hero { min-height: 0; grid-template-columns: 1fr; gap: 24px; padding: clamp(25px, 7vw, 38px); border-radius: 25px; }
  .hero h1 { max-width: 500px; font-size: clamp(3rem, 11vw, 4.5rem); }
  .practice-card { width: 100%; padding: 20px; border-radius: 21px; }
  .sound-orbit { width: 102px; height: 102px; margin-bottom: 10px; }.sound-core { width: 48px; height: 48px; }
  .practice-note { margin-top: 17px; padding: 15px; }
  .audio-library { align-items: flex-start; flex-direction: column; gap: 12px; padding: 15px; }
  .audio-library-action { width: 100%; }
  .audio-library-action .button { width: 100%; }
  #audio-sync-progress { flex: 0 0 78px; }
  .review-heading { margin-top: 5px; }
  .review-card { border-radius: 23px; }
  .listen-stage { min-height: min(55vh, 390px); padding: 24px 18px; }
  .audio-button { width: 112px; height: 112px; }
  .rating-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rating { min-height: 61px; padding: 9px 12px; }
  .add-view { padding-top: 9px; }
  .draft-row { grid-template-columns: 1fr 1fr; }
  .draft-row .draft-spanish { grid-column: 1 / -1; }
  .draft-row select { grid-column: 1 / -1; }
  .saved-row { grid-template-columns: 1fr auto; }
  .saved-status { grid-column: 1; grid-row: 2; text-align: left; }
  .retry-audio { grid-column: 2; grid-row: 1 / span 2; }
  .footer { font-size: .65rem; }
}

@media (max-width: 390px) {
  .shell { width: calc(100% - 20px); }
  .hero { padding: 23px 19px; }
  .hero h1 { font-size: 2.8rem; }
  .status-pill { font-size: .66rem; }
  .footer span:last-child { text-align: right; }
}

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