/* ==========================================================================
   Flashlingo UI refresh (2026-09-28)
   A styling layer loaded LAST from index.html, on top of style.css,
   audio-progress.css and conjugation.css. It only restyles: no class names,
   markup or behaviour change. Deleting its <link> in index.html restores the
   previous look exactly (also tagged in git as ui-before-refresh-2026-09-28).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f6f5fb;
  --bg-glow-1: rgba(255, 92, 122, 0.14);
  --bg-glow-2: rgba(108, 92, 255, 0.14);
  --surface: #ffffff;
  --surface-2: #f1f0f8;
  --text: #16151d;
  --text-muted: #6b6980;
  --primary: #ff4f6d;
  --primary-dark: #e8375a;
  --primary-2: #ff8a4c;
  --accent: #5b4dff;
  --accent-soft: #ecebff;
  --success: #12b981;
  --success-soft: #dcf7ec;
  --warn: #f5a524;
  --border: #e7e5f0;
  --ring: rgba(91, 77, 255, 0.35);
  --grad-primary: linear-gradient(135deg, var(--primary-2) 0%, var(--primary) 55%, #f0407f 100%);
  --grad-accent: linear-gradient(135deg, #7b6bff 0%, var(--accent) 100%);
  --grad-brand: linear-gradient(120deg, var(--primary-2), var(--primary) 45%, var(--accent));
  --shadow-sm: 0 1px 2px rgba(22, 21, 29, 0.05), 0 2px 8px rgba(22, 21, 29, 0.04);
  --shadow: 0 1px 2px rgba(22, 21, 29, 0.04), 0 10px 30px -8px rgba(22, 21, 29, 0.12);
  --shadow-lg: 0 2px 4px rgba(22, 21, 29, 0.04), 0 24px 48px -12px rgba(22, 21, 29, 0.22);
  --glow-primary: 0 10px 24px -8px rgba(255, 79, 109, 0.6);
  --glow-accent: 0 10px 24px -8px rgba(91, 77, 255, 0.55);
  --radius: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: 'Twemoji Country Flags', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0b12;
    --bg-glow-1: rgba(255, 79, 109, 0.16);
    --bg-glow-2: rgba(108, 92, 255, 0.2);
    --surface: #16151f;
    --surface-2: #1e1d2a;
    --text: #f3f2fa;
    --text-muted: #9c9ab2;
    --primary: #ff5a78;
    --primary-dark: #ff7a92;
    --primary-2: #ff9a5c;
    --accent: #8f84ff;
    --accent-soft: #25224a;
    --success: #34d399;
    --success-soft: #0f2e24;
    --warn: #fbbf24;
    --border: #2a2838;
    --ring: rgba(143, 132, 255, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 12px 32px -10px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, 0.85);
    --glow-primary: 0 10px 28px -8px rgba(255, 90, 120, 0.55);
    --glow-accent: 0 10px 28px -8px rgba(143, 132, 255, 0.5);
    color-scheme: dark;
  }
}

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

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(60vmax 40vmax at 0% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(60vmax 40vmax at 100% 0%, var(--bg-glow-2), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.45;
}

/* Form controls don't inherit the page font by default. */
button,
input,
select,
textarea {
  font-family: inherit;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

#app {
  padding: 28px 18px 72px;
}

/* ---------- Header ---------- */
.app-header {
  margin-bottom: 26px;
  padding-top: 2px;
}

.app-header h1 {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--primary);
}

.tagline {
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.lang-select-btn,
.account-select-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}

@media (hover: hover) {
  .lang-select-btn:hover,
  .account-select-btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
  }
}

.account-select-btn {
  font-weight: 700;
  background: var(--grad-accent);
  color: #fff;
  border-color: transparent;
}

.lang-dropdown,
.account-dropdown {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: fl-pop 0.18s var(--ease);
  transform-origin: top left;
}

.account-dropdown {
  transform-origin: top right;
  padding: 10px;
}

.lang-option {
  border-radius: 10px;
  font-weight: 500;
  transition: background 0.15s;
}

.lang-option:hover:not([disabled]) {
  background: var(--surface-2);
}

.account-signout-btn {
  border-radius: var(--radius-sm);
  background: var(--grad-primary);
  font-weight: 600;
}

/* ---------- Panels ---------- */
.panel {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-title,
.tools-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.tools-section {
  margin-top: 26px;
}

.tools-heading {
  margin: 0 4px 12px;
}

/* ---------- Segmented controls ---------- */
.browse-mode-toggle {
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 14px;
}

.mode-btn {
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 0.2s var(--ease), color 0.2s, box-shadow 0.2s;
}

.mode-btn:hover:not(.active) {
  color: var(--text);
}

.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.study-view-toggle {
  gap: 6px;
}

.study-view-btn {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: transparent;
  transition: all 0.2s var(--ease);
}

.study-view-btn:hover:not(.active) {
  color: var(--text);
  border-color: var(--text-muted);
}

.study-view-btn.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* ---------- Chapter groups ---------- */
.chapter-group {
  border-bottom: 1px solid var(--border);
}

.chapter-group:last-child {
  border-bottom: none;
}

.chapter-title {
  padding: 14px 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}

.chapter-title::-webkit-details-marker {
  display: none;
}

.chapter-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.65rem;
  transition: transform 0.25s var(--ease), background 0.2s, color 0.2s;
}

.chapter-group[open] .chapter-arrow {
  background: var(--accent-soft);
  color: var(--accent);
}

.chapter-group[open] .chapter-content {
  animation: fl-rise 0.3s var(--ease);
}

/* ---------- Level sections (N5 … N1, TOPIK 1 … 6) ---------- */
.level-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.level-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: fl-rise 0.3s var(--ease);
}

.level-picker-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2px 6px 6px;
}

.level-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.level-picker-item:hover {
  background: var(--accent-soft);
}

.level-picker-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.level-group {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.level-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.level-title::-webkit-details-marker {
  display: none;
}

.level-title:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 18px;
}

.level-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.level-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.level-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.level-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.level-group:not([open]) .level-arrow {
  transform: rotate(-90deg);
}

.level-group[open] .level-arrow {
  background: var(--accent-soft);
  color: var(--accent);
}

.level-content {
  padding: 0 12px 4px;
  border-top: 1px solid var(--border);
}

.level-group[open] .level-content {
  animation: fl-rise 0.3s var(--ease);
}

/* ---------- Category / tool cards ---------- */
.category-list,
.chapter-content {
  gap: 10px;
}

.category-card {
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}

/* Custom cards used a dashed outline; a soft tinted fill reads as "yours"
   without the dated dashed look. */
.category-card.custom {
  border-style: solid;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

@media (hover: hover) {
  .category-card:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  }
}

.category-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  border-radius: 14px;
  background: var(--surface-2);
}

.category-card.custom .category-icon {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.category-label {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.category-meta {
  font-size: 0.8rem;
  line-height: 1.45;
  margin-top: 2px;
}

.category-card.custom.pending-scan-banner {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border-color: var(--accent);
}

.engine-option {
  font-weight: 500;
}

input[type='radio'],
input[type='checkbox'] {
  accent-color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: 14px;
  padding: 10px 18px;
  font-weight: 700;
  letter-spacing: -0.005em;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s, filter 0.2s, opacity 0.15s;
}

@media (hover: hover) {
  .btn:hover:not([disabled]) {
    transform: translateY(-1px);
  }
}

.btn:active:not([disabled]) {
  transform: translateY(0) scale(0.97);
}

.btn-primary,
.btn-start {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--glow-primary);
}

.btn-primary:hover:not([disabled]),
.btn-start:hover:not([disabled]) {
  background: var(--grad-primary);
  filter: brightness(1.06) saturate(1.05);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-secondary:hover:not([disabled]) {
  background: color-mix(in srgb, var(--accent) 18%, var(--accent-soft));
}

.btn-quiz {
  border-radius: 12px;
  padding: 7px 11px;
}

.btn-quiz:hover:not([disabled]) {
  background: var(--accent-soft);
}

.btn-icon {
  border-radius: 12px;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--surface-2);
}

.btn[disabled] {
  box-shadow: none;
}

/* ---------- Inputs ---------- */
.add-single-word-form input,
.add-word-form input,
.form-group input,
.type-form input,
.new-playlist-form input,
.bulk-target-edit,
.bulk-context-edit,
.library-sort select,
.conj-search {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.add-single-word-form input:focus,
.add-word-form input:focus,
.form-group input:focus,
.type-form input:focus,
.new-playlist-form input:focus,
.bulk-target-edit:focus,
.bulk-context-edit:focus,
.conj-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.library-search {
  background: var(--surface);
  border-radius: 999px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.library-search:focus-within {
  box-shadow: 0 0 0 4px var(--ring);
}

/* ---------- Dialogs ---------- */
dialog {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

dialog[open] {
  animation: fl-pop 0.22s var(--ease);
}

dialog::backdrop {
  background: rgba(12, 11, 18, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.add-word-form h2 {
  letter-spacing: -0.02em;
}

/* ---------- Drill / Learn / Listening ---------- */
.drill-header {
  margin-bottom: 22px;
}

.drill-header .btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.progress-bar {
  height: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}

.progress-fill {
  background: linear-gradient(90deg, #34d399, var(--success));
  border-radius: 999px;
  transition: width 0.45s var(--ease);
  position: relative;
}

/* Glossy highlight on the fill. */
.progress-fill::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.progress-badge {
  font-variant-numeric: tabular-nums;
}

.check-icon {
  width: 22px;
  height: 22px;
  box-shadow: 0 4px 10px -3px var(--success);
}

.drill-meta {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.drill-instruction {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 52px;
}

.stack-layer {
  background: var(--surface);
  border-color: var(--border);
  border-radius: 20px 20px 0 0;
}

.drill-card {
  border-radius: 26px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
    var(--surface);
  transition: opacity 0.3s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* The card is re-rendered on each state change, so its flip plays exactly
   when a card turns over (answer shown / correct). Transform only, no fill,
   so it never fights the is-leaving opacity fade. */
.drill-card.is-revealed,
.drill-card.is-correct {
  animation: fl-flip 0.5s var(--ease);
}

.drill-card.is-revealed {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow-lg), 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

.drill-card.is-correct {
  border-color: var(--success);
  box-shadow: var(--shadow-lg), 0 0 0 5px color-mix(in srgb, var(--success) 20%, transparent);
}

.drill-word {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.drill-primary {
  font-size: 2.5rem;
  font-weight: 800;
}

.drill-secondary {
  font-weight: 700;
}

/* The English meaning under the word: clearly bigger than the small reading
   above it, still smaller than the main word. Longer meanings wrap onto
   several centered lines instead of running off the card. */
.drill-meaning {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.drill-card.is-correct .drill-meaning {
  color: var(--success);
}

@media (max-width: 600px) {
  .drill-meaning {
    font-size: 1.35rem;
  }
}

.listening-mystery {
  font-size: 4.4rem;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.feedback.wrong {
  color: var(--primary);
  font-weight: 600;
  animation: fl-shake 0.35s ease;
}

.voice-status {
  font-weight: 600;
}

.script-chip {
  border-radius: 999px;
}

/* Extras (Example, Conjugate…) stay as a row of buttons under the card. */
.card-tools {
  gap: 8px;
  margin: 16px 0 6px;
}

.card-tool-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), border-color 0.15s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

@media (hover: hover) {
  .card-tool-btn:hover {
    filter: none;
    transform: translateY(-1px);
    border-color: var(--accent);
    color: var(--accent);
  }
}

.card-tool-btn.active {
  background: var(--grad-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-accent);
}

.example-sentence {
  border-radius: 18px;
  border: 1px solid var(--border);
  animation: fl-rise 0.3s var(--ease);
}

.example-play,
.replay-btn,
.next-btn {
  transition: transform 0.15s var(--ease), background 0.2s;
}

.example-play:hover,
.replay-btn:hover,
.next-btn:hover:not([disabled]) {
  background: color-mix(in srgb, var(--accent) 18%, var(--accent-soft));
}

.controls-row {
  gap: 10px;
}

.card-tools + .controls-row {
  margin-top: 16px;
}

.mic-btn {
  border-radius: 22px;
  background: var(--grad-primary);
  box-shadow: var(--glow-primary);
}

.mic-btn.listening {
  background: var(--grad-accent);
  box-shadow: var(--glow-accent);
  animation: fl-mic-pulse 1.4s ease-in-out infinite;
}

.next-btn,
.replay-btn {
  border-radius: 22px;
}

.learn-btn {
  padding: 16px 18px;
  font-size: 1rem;
  border-radius: 18px;
}

.type-form input {
  padding: 13px 16px;
  border-radius: 16px;
}

.type-form .btn {
  border-radius: 16px;
}

.input-mode-toggle {
  display: flex;
  width: max-content;
  margin: 20px auto 0;
  padding: 4px;
  gap: 2px;
  border-radius: 14px;
  background: var(--surface-2);
}

.mode-icon-btn {
  padding: 7px 14px;
  font-size: 0.82rem;
  transition: background 0.2s, color 0.2s;
}

.mode-icon-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Complete screen ---------- */
.complete-screen {
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 44px 24px 28px;
  animation: fl-pop 0.4s var(--ease);
}

.complete-emoji {
  font-size: 3.4rem;
  animation: fl-bounce 0.9s var(--ease) 0.1s both;
}

.complete-screen h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stats-row {
  gap: 10px;
}

.stat {
  flex: 1;
  max-width: 120px;
  padding: 14px 8px;
  border-radius: 18px;
  background: var(--surface-2);
}

.stat-value {
  font-weight: 800;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  margin-top: 2px;
}

/* ---------- Bulk add / review ---------- */
.bulk-words-list {
  border-radius: var(--radius-md);
}

.bulk-review-card {
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bulk-review-card:hover {
  box-shadow: var(--shadow-sm);
}

.bulk-delete-btn,
.bulk-ignore-btn {
  border-radius: 10px;
}

.bulk-delete-btn:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.loading-spinner {
  border-width: 4px;
  border-color: var(--surface-2);
  border-top-color: var(--primary);
  border-right-color: var(--accent);
}

/* ---------- Audio progress ---------- */
.audio-progress-panel {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}

.audio-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.audio-progress-fill {
  background: var(--grad-accent);
  border-radius: 999px;
}

/* ---------- Library & Playlists ---------- */
.track-row {
  border-radius: 14px;
  padding: 9px 8px;
  transition: background 0.15s;
}

.track-row:hover {
  background: var(--surface-2);
}

.track-play {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--glow-accent);
  transition: transform 0.15s var(--ease);
}

.track-play:hover {
  transform: scale(1.06);
}

.track-action {
  transition: all 0.15s var(--ease);
}

.track-action.added {
  background: var(--grad-accent);
  border-color: transparent;
}

.playlist-item {
  border-radius: 18px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s, border-color 0.2s;
}

@media (hover: hover) {
  .playlist-item:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  }
}

.playlist-art,
.playlist-hero-art {
  background: var(--grad-brand);
  border-radius: 14px;
}

.playlist-hero-art {
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.playlist-hero-name {
  font-weight: 800;
  letter-spacing: -0.03em;
}

.playlist-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: fl-rise 0.2s var(--ease);
}

.playlist-chip {
  transition: all 0.15s var(--ease);
}

.library-adding-banner {
  border-radius: var(--radius-md);
}

/* ---------- Verb conjugator ---------- */
.conj-sheet {
  border-radius: 28px 28px 0 0;
}

.conj-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.conj-verb {
  border-radius: var(--radius-md);
}

/* ---------- Admin badge ---------- */
.admin-badge {
  box-shadow: var(--shadow-lg);
}

/* ---------- Motion ---------- */
@keyframes fl-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes fl-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes fl-flip {
  0% { transform: perspective(900px) rotateY(-90deg) scale(0.96); }
  60% { transform: perspective(900px) rotateY(8deg) scale(1.01); }
  100% { transform: perspective(900px) rotateY(0) scale(1); }
}

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

@keyframes fl-bounce {
  0% { transform: scale(0.3) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

@keyframes fl-mic-pulse {
  0%, 100% { box-shadow: var(--glow-accent); transform: scale(1); }
  50% { box-shadow: 0 12px 34px -6px color-mix(in srgb, var(--accent) 70%, transparent); transform: scale(1.015); }
}

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

/* ---------- Phone widths ---------- */
@media (max-width: 600px) {
  #app {
    padding: 20px 14px 64px;
  }

  .app-header h1 {
    font-size: 2.1rem;
  }

  .drill-instruction {
    font-size: 1.45rem;
    margin-bottom: 48px;
  }
}

/* ---------- Library filters (word type / mark) ---------- */
.library-filters:not([hidden]) { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; padding: 5px 12px; border-radius: 999px; font: inherit; font-size: 0.8rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer; white-space: nowrap; transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.filter-chip:hover { border-color: var(--accent); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Study mode switch (slim: current mode + small swap pill) ---------- */
.mode-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 14px;
}

.mode-switch-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.mode-switch-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.mode-switch-btn:hover {
  color: var(--text);
  background: var(--surface);
}

/* ---------- Study mode swap icon (top-right corner) ---------- */
.mode-swap-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.mode-swap-btn.with-account {
  right: 56px;
}

.mode-swap-btn:hover,
.mode-swap-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.mode-swap-btn::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  white-space: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 30;
}

@media (hover: hover) {
  .mode-swap-btn:hover::after { opacity: 1; }
}
.mode-swap-btn:focus-visible::after { opacity: 1; }

/* ---------- Add Words tab: one box, method buttons ---------- */
.add-method-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.add-method-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.add-method-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.experimental-toggle {
  display: block;
  margin: 14px 0 0;
  padding: 6px 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.experimental-toggle:hover { opacity: 0.8; }
.experimental-toggle + .category-card { margin-top: 8px; }

/* ---------- Library edit mode ----------
   Rows stay clean (play + word); the pencil in the top right reveals the
   add-to-playlist and priority buttons on every row at once. */
.library-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-edit-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(128, 128, 128, 0.3));
  background: var(--surface-2);
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.library-edit-btn:hover {
  transform: scale(1.06);
}

.library-edit-btn.active {
  background: var(--grad-accent);
  border-color: transparent;
  box-shadow: var(--glow-accent);
}

.track-list:not(.edit-mode) .mark-group,
.track-list:not(.edit-mode) .track-action {
  display: none;
}

.track-list.edit-mode .mark-btn,
.track-list.edit-mode .mark-group:not(.marked) .mark-btn.active.mark-neutral {
  opacity: 0.8;
}

.track-list.edit-mode .mark-btn.active.mark-more,
.track-list.edit-mode .mark-btn.active.mark-less {
  opacity: 1;
}

/* Instant tooltips for the priority mark buttons (native title tooltips lag). */
.mark-btn {
  position: relative;
}

.mark-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 3px);
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid rgba(128, 128, 128, 0.35);
  color: var(--text, #fff);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: opacity 0.08s, transform 0.08s;
}

.mark-btn[data-tip]:hover::after,
.mark-btn[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Library filter button + panel ---------- */
.library-searchrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-searchrow .library-search {
  flex: 1;
  min-width: 0;
}

.library-filter-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.library-filter-btn:hover {
  border-color: var(--accent);
}

.library-filter-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.filter-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--grad-accent);
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
  text-align: center;
}

.library-filters:not([hidden]) {
  padding: 12px;
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
  animation: fl-pop 0.18s var(--ease);
}

.filter-group-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.library-filters .filter-row {
  flex-wrap: wrap;
  overflow: visible;
}

.filter-clear {
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 2px 0;
}

/* ---------- My Words card + review choice dialog ---------- */
.category-card.mywords-card {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.mywords-title { font-size: 1.25rem; }
.mywords-actions {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.review-choice-dialog { padding: 22px 18px 16px; max-width: min(94vw, 460px); width: 100%; background: var(--surface); color: inherit; }
.review-choice-form h2 { margin: 0 0 16px; font-size: 1.15rem; text-align: center; letter-spacing: -0.02em; }
.review-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.review-mode-card {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 14px 6px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.review-mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.review-mode-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.review-mode-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.rm-icon { font-size: 1.5rem; line-height: 1.2; }
.rm-name { font-weight: 700; font-size: 0.78rem; line-height: 1.2; }
.rm-desc { font-size: 0.68rem; line-height: 1.25; color: var(--text-muted); }
.review-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 6px; }
.review-words-pill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 200px; min-width: 0; }
.review-words-pill > span, .review-switch > span { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.review-choice-scope { flex: 1; min-width: 0; max-width: 100%; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: inherit; font: inherit; font-size: 0.85rem; }
.review-choice-scope:disabled { opacity: 0.6; }
.review-choice-hint { flex-basis: 100%; margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.review-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.review-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.review-switch i { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--border); transition: background 0.2s; }
.review-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.35); transition: transform 0.2s var(--ease); }
.review-switch input:checked + i { background: var(--grad-accent); }
.review-switch input:checked + i::after { transform: translateX(16px); }
.review-switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.review-start { display: block; width: 100%; margin-top: 16px; padding: 14px; font-size: 1rem; }
.review-cancel { display: block; margin: 10px auto 0; border: none; background: none; color: var(--text-muted); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 6px 12px; }
.review-cancel:hover { color: var(--text); text-decoration: underline; }

/* ---------- Library filter panel polish ---------- */
.library-filters:not([hidden]) { gap: 14px; padding: 14px; background: linear-gradient(180deg, var(--surface-2), var(--surface)); box-shadow: var(--shadow-sm); }
.filter-group-label { margin-bottom: 8px; font-weight: 700; }
.library-filters .filter-row { gap: 8px; }
.filter-chip { padding: 6px 13px; background: var(--surface-2); font-weight: 500; }
.filter-chip:hover { transform: translateY(-1px); color: var(--text); }
.filter-chip.active { background: var(--grad-accent); border-color: transparent; box-shadow: 0 2px 10px var(--ring); }
.filter-chip[data-mark="more"]::before, .filter-chip[data-mark="neutral"]::before, .filter-chip[data-mark="less"]::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; vertical-align: 1px;
}
.filter-chip[data-mark="more"]::before { background: #f0736a; }
.filter-chip[data-mark="neutral"]::before { background: #9aa0b4; }
.filter-chip[data-mark="less"]::before { background: #4cc38a; }
.filter-clear { padding: 4px 0 0; font-weight: 600; }
.library-filter-btn svg { opacity: 0.8; }
.library-filters .filter-row { gap: 6px; }
.filter-chip { padding: 6px 11px; font-size: 0.78rem; }
.filter-chip[data-mark]::before { margin-right: 5px !important; }
.review-words-pill { flex: 1 1 100%; flex-wrap: nowrap; }
.review-words-pill .review-choice-hint { display: none; }
.review-options { row-gap: 12px; }
.review-switch { width: 100%; justify-content: space-between; padding: 2px 4px; }
.review-choice-scope { text-overflow: ellipsis; }
.review-hint-row { flex-basis: 100%; margin: -6px 0 0 !important; }
.review-words-pill .review-choice-hint { display: none; }

/* ---------- My Words: count link + Add Words window ---------- */
.add-words-dialog { padding: 18px 14px 14px; width: min(94vw, 520px); max-height: 88vh; overflow-y: auto; background: var(--surface); color: inherit; }
.add-words-dialog .tools-section { margin: 0; }
.add-words-close {
  position: sticky; top: 0; float: right; z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font: inherit; cursor: pointer;
}
.add-words-close:hover { color: var(--text); border-color: var(--accent); }

/* Listen Along (Experimental) sits beside the other add options, dimmed */
.add-method-btn.experimental { opacity: 0.7; font-style: italic; }
.add-method-btn.experimental.active { opacity: 1; }

/* Conjugator: everyday forms by default, "Show all" expander, popular highlight. */
.conj-all {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px 10px;
}
.conj-all > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  color: var(--accent);
}
.conj-all > summary::-webkit-details-marker { display: none; }
.conj-all[open] > summary .conj-chevron { transform: rotate(180deg); }
.conj-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.conj-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: color-mix(in srgb, #f5b301 30%, transparent);
  border: 1px solid #f5b301;
}
.conj-forms .conj-row {
  padding: 8px 8px;
  border-radius: 10px;
}
.conj-all .conj-forms .conj-row.is-popular {
  background: color-mix(in srgb, #f5b301 18%, transparent);
  border-bottom-color: transparent;
}
.conj-group-tag {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
@media (max-width: 600px) {
  .conj-row { gap: 8px; }
  .conj-all { padding: 0 10px 8px; }
}

/* ---------- Library row actions (tap a word to expand) ---------- */
.track-row.expandable {
  cursor: pointer;
}

.track-row.expanded {
  background: var(--surface-2);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.word-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px 12px 60px;
  margin-bottom: 4px;
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
  animation: fl-pop 0.16s var(--ease);
}

.word-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.83rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.word-action-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.track-chevron {
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  color: var(--text-muted);
  opacity: 0.55;
  transition: transform 0.15s var(--ease), opacity 0.15s;
}

.track-row:hover .track-chevron,
.track-row.expanded .track-chevron {
  opacity: 1;
}

.track-row.expanded .track-chevron {
  transform: rotate(180deg);
}

.word-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.word-action-btn:disabled:hover {
  border-color: var(--border);
  box-shadow: none;
}

.word-action-hint {
  align-self: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.word-actions .example-sentence {
  flex: 1 1 100%;
  margin: 4px 0 0 -48px;
}
/* Fixed size so the Add Words window doesn't jump between options; content scrolls inside */
.add-words-dialog { height: min(470px, 88vh); height: min(470px, 88dvh); overflow-y: auto; overscroll-behavior: contain; }


.add-words-dialog.no-pop[open] { animation: none; }

/* The window takes focus itself, so the ✕ never lights up on open or option switch */
.add-words-dialog:focus { outline: none; }
.add-words-close { -webkit-tap-highlight-color: transparent; transition: none; }
.add-words-close:focus:not(:focus-visible) { outline: none; box-shadow: none; background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }
.add-words-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Add Words window: everything centered (✕ stays in the corner) */
.add-words-dialog .tools-heading { text-align: center; margin: 4px 0 12px; }
.add-words-dialog .add-method-row { justify-content: center; flex-wrap: wrap; }
.add-words-dialog .category-card { flex-direction: column; align-items: center; text-align: center; }
.add-words-dialog .category-info { width: 100%; }
.add-words-dialog .category-actions { justify-content: center; align-items: center; width: 100%; margin-top: 10px; }
.add-words-dialog .engine-select { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.add-words-dialog .inbox-email-line { justify-content: center; text-align: center; }
.add-words-dialog .inbox-qr { margin-left: auto; margin-right: auto; }
.add-words-dialog .inbox-email-row .btn, .add-words-dialog .inbox-email-row .category-actions { margin-left: auto; margin-right: auto; }
.add-words-dialog .engine-option { justify-content: center; }

/* Review screen: ✕ sits on the card's top-right corner; ignore is a text button */
.bulk-review-list { padding: 12px 12px 4px 4px; }
.bulk-review-card { position: relative; }
.bulk-review-card .bulk-delete-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.95rem;
  z-index: 1;
  box-shadow: var(--shadow-sm);
}
.bulk-review-card .bulk-ignore-btn {
  grid-column: 1 / -1;
  justify-self: start;
  width: auto;
  height: auto;
  margin-left: 0;
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 999px;
}

/* Library word editor */
.word-edit-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; width: 100%; }
.word-edit-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-muted); }
.word-edit-form input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 0.95rem; }
.word-edit-buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Post-review summary ---------- */
.review-summary {
  width: 100%;
  margin: 22px 0 6px;
  text-align: left;
}
.summary-heading {
  margin: 18px 0 8px;
  font-size: 1rem;
  font-weight: 800;
}
.review-summary .track-list.summary-bookmarked {
  border-left: 3px solid var(--accent, #f5a623);
  padding-left: 6px;
}

/* All card tools (Conjugations, Playlist, Bookmark…) stay on ONE line; on
   narrow screens they shrink a little, and only wrap if truly too narrow. */
.card-tools {
  flex-wrap: nowrap;
  justify-content: center;
}
.card-tools .card-tool-btn {
  white-space: nowrap;
  min-width: 0;
}
@media (max-width: 480px) {
  .card-tools { gap: 5px; }
  .card-tools .card-tool-btn { padding: 7px 10px; font-size: 0.8rem; }
}
@media (max-width: 350px) {
  .card-tools { gap: 4px; }
  .card-tools .card-tool-btn { padding: 6px 8px; font-size: 0.74rem; }
}
@media (max-width: 290px) {
  .card-tools { flex-wrap: wrap; }
}

/* Add-to-playlist card tool: icon-only round button, same ＋ as the Library. */
.card-tools .card-tool-btn.card-tool-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}
