/* Talkook design system — mobile-first */
@font-face {
  font-family: "IRSans";
  src: url("../font_fa/irsans.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  /* Deep ink + luminous teal */
  --mv-bg: #071018;
  --mv-bg-elevated: #0b1520;
  --mv-surface: rgba(18, 32, 48, 0.94);
  --mv-surface-solid: #132233;
  --mv-surface-2: #1a2d42;
  --mv-border: rgba(156, 190, 220, 0.14);
  --mv-border-strong: rgba(156, 190, 220, 0.28);
  --mv-text: #f3f7fb;
  --mv-text-soft: #c9d7e6;
  --mv-muted: #8ea3b8;
  --mv-accent: #2ec4a0;
  --mv-accent-bright: #5eead4;
  --mv-accent-deep: #14967c;
  --mv-accent-soft: rgba(46, 196, 160, 0.16);
  --mv-accent-ink: #04211c;
  --mv-on-accent: #04211c;
  --mv-info: #7dd3fc;
  --mv-info-soft: rgba(56, 189, 248, 0.14);
  --mv-violet: #c4b5fd;
  --mv-violet-soft: rgba(167, 139, 250, 0.14);
  --mv-warn: #fbbf24;
  --mv-warn-soft: rgba(251, 191, 36, 0.14);
  --mv-danger: #fb7185;
  --mv-danger-soft: rgba(251, 113, 133, 0.14);
  --mv-glow-a: rgba(46, 196, 160, 0.18);
  --mv-glow-b: rgba(56, 160, 210, 0.1);
  --mv-media-from: #102033;
  --mv-media-to: #1b334a;
  --mv-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
  --mv-overlay: rgba(2, 8, 18, 0.72);
  --mv-header-bg: color-mix(in srgb, var(--mv-bg-elevated) 80%, transparent);
  --mv-nav-bg: color-mix(in srgb, var(--mv-bg-elevated) 90%, transparent);
  /* Study / annotation colors (readable on dark surfaces) */
  --mv-c-red: #f87171;
  --mv-c-rose: #fb7185;
  --mv-c-orange: #fb923c;
  --mv-c-amber: #fbbf24;
  --mv-c-yellow: #facc15;
  --mv-c-lime: #a3e635;
  --mv-c-emerald: #34d399;
  --mv-c-teal: #2dd4bf;
  --mv-c-cyan: #22d3ee;
  --mv-c-sky: #38bdf8;
  --mv-c-blue: #60a5fa;
  --mv-c-indigo: #818cf8;
  --mv-c-violet: #a78bfa;
  --mv-c-purple: #c084fc;
  --mv-c-pink: #f472b6;
  --mv-c-slate: #cbd5e1;
  --mv-c-gray: #94a3b8;
  --mv-c-white: #f8fafc;
  --mv-study-typed: #6ee7b7;
  --mv-study-typed-bg: rgba(16, 185, 129, 0.22);
  --mv-study-typed-line: rgba(52, 211, 153, 0.95);
  --mv-study-reveal: #fde68a;
  --mv-study-reveal-bg: rgba(245, 158, 11, 0.24);
  --mv-study-hidden-bg: rgba(245, 158, 11, 0.12);
  --mv-study-hidden-line: rgba(251, 191, 36, 0.95);
  --mv-study-open-bg: rgba(245, 158, 11, 0.3);
  --mv-study-open-outline: rgba(251, 191, 36, 0.7);
  --mv-study-pop-bg: #111827;
  --mv-study-pop-border: rgba(251, 191, 36, 0.32);
  --mv-study-pop-action-bg: rgba(245, 158, 11, 0.2);
  --mv-study-pop-action-text: #fef3c7;
  --mv-study-pop-meaning: #fde68a;
  --mv-study-sticky-bg: color-mix(in srgb, var(--mv-bg-elevated) 94%, transparent);
  --mv-study-sticky-border: var(--mv-border-strong);
  --mv-radius: 1.25rem;
  --mv-radius-sm: 0.9rem;
  --mv-header-h: 3.75rem;
  --mv-nav-h: 4.5rem;
  --mv-safe-b: env(safe-area-inset-bottom, 0px);
  --mv-safe-t: env(safe-area-inset-top, 0px);
}

html[data-theme="light"] {
  color-scheme: light;
  /* Cool paper + saturated teal — high contrast on white */
  --mv-bg: #eef2f7;
  --mv-bg-elevated: #f8fafc;
  --mv-surface: #ffffff;
  --mv-surface-solid: #ffffff;
  --mv-surface-2: #e7eef6;
  --mv-border: rgba(15, 36, 56, 0.12);
  --mv-border-strong: rgba(15, 36, 56, 0.22);
  --mv-text: #0f1c2e;
  --mv-text-soft: #243b53;
  --mv-muted: #52687e;
  --mv-accent: #0f766e;
  --mv-accent-bright: #0d9488;
  --mv-accent-deep: #0f766e;
  --mv-accent-soft: rgba(15, 118, 110, 0.12);
  --mv-accent-ink: #ffffff;
  --mv-on-accent: #ffffff;
  --mv-info: #0369a1;
  --mv-info-soft: rgba(3, 105, 161, 0.1);
  --mv-violet: #6d28d9;
  --mv-violet-soft: rgba(109, 40, 217, 0.1);
  --mv-warn: #b45309;
  --mv-warn-soft: rgba(180, 83, 9, 0.12);
  --mv-danger: #be123c;
  --mv-danger-soft: rgba(190, 18, 60, 0.1);
  --mv-glow-a: rgba(13, 148, 136, 0.12);
  --mv-glow-b: rgba(14, 116, 144, 0.08);
  --mv-media-from: #d7e3ef;
  --mv-media-to: #c2d4e6;
  --mv-shadow: 0 12px 30px rgba(15, 28, 46, 0.08);
  --mv-overlay: rgba(15, 28, 46, 0.45);
  --mv-header-bg: color-mix(in srgb, #f8fafc 88%, transparent);
  --mv-nav-bg: color-mix(in srgb, #ffffff 92%, transparent);
  /* Study / annotation colors (saturated for paper backgrounds) */
  --mv-c-red: #dc2626;
  --mv-c-rose: #e11d48;
  --mv-c-orange: #ea580c;
  --mv-c-amber: #d97706;
  --mv-c-yellow: #ca8a04;
  --mv-c-lime: #65a30d;
  --mv-c-emerald: #059669;
  --mv-c-teal: #0f766e;
  --mv-c-cyan: #0891b2;
  --mv-c-sky: #0284c7;
  --mv-c-blue: #2563eb;
  --mv-c-indigo: #4f46e5;
  --mv-c-violet: #7c3aed;
  --mv-c-purple: #9333ea;
  --mv-c-pink: #db2777;
  --mv-c-slate: #475569;
  --mv-c-gray: #64748b;
  --mv-c-white: #0f172a;
  --mv-study-typed: #047857;
  --mv-study-typed-bg: rgba(5, 150, 105, 0.14);
  --mv-study-typed-line: #059669;
  --mv-study-reveal: #92400e;
  --mv-study-reveal-bg: rgba(217, 119, 6, 0.16);
  --mv-study-hidden-bg: rgba(217, 119, 6, 0.1);
  --mv-study-hidden-line: #d97706;
  --mv-study-open-bg: rgba(217, 119, 6, 0.2);
  --mv-study-open-outline: rgba(180, 83, 9, 0.65);
  --mv-study-pop-bg: #ffffff;
  --mv-study-pop-border: rgba(180, 83, 9, 0.35);
  --mv-study-pop-action-bg: rgba(217, 119, 6, 0.14);
  --mv-study-pop-action-text: #92400e;
  --mv-study-pop-meaning: #92400e;
  --mv-study-sticky-bg: color-mix(in srgb, #ffffff 94%, transparent);
  --mv-study-sticky-border: var(--mv-border-strong);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  overflow-x: clip;
}

body.mv-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  overscroll-behavior-y: none;
  background:
    radial-gradient(900px 420px at 10% -10%, var(--mv-glow-a), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, var(--mv-glow-b), transparent 45%),
    linear-gradient(180deg, var(--mv-bg-elevated), var(--mv-bg) 40%, var(--mv-bg));
  background-attachment: fixed;
  color: var(--mv-text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-overflow-scrolling: touch;
}

/* iOS Safari: fixed backgrounds are janky / can blank out */
@supports (-webkit-touch-callout: none) {
  body.mv-body {
    background-attachment: scroll;
  }
}

/* Avoid iOS zoom-on-focus; keep tap targets comfortable on phones */
@media (max-width: 767px) {
  body.mv-body {
    background-attachment: scroll;
  }

  input,
  textarea,
  select,
  button,
  .mv-field,
  .study-type-input,
  .mv-search-field input,
  .mv-search input {
    font-size: 16px !important;
  }

  .mv-btn,
  .mv-chip,
  .mv-nav-item,
  .mv-icon-btn,
  .study-icon-btn,
  .study-btn,
  a,
  button {
    touch-action: manipulation;
  }

  /*
    Safari iOS: backdrop-filter + large shadows on sticky/fixed chrome
    are the main scroll jank source. Keep solid surfaces instead.
  */
  .mv-header,
  .mv-bottom-nav,
  .mv-card,
  .mv-toast,
  .mv-rotate-gate,
  .study-setup-actions,
  .study-video-dock,
  .mv-modal-backdrop,
  .mv-confirm-backdrop,
  .mv-crop-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .mv-header {
    background: var(--mv-bg-elevated);
  }

  .mv-bottom-nav {
    background: var(--mv-bg-elevated);
  }

  .mv-card {
    background: var(--mv-surface-solid);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  }

  .mv-toast {
    background: var(--mv-surface-solid);
  }

  .mv-btn-primary,
  .mv-desk-cta,
  .study-btn-play,
  .study-btn-next {
    box-shadow: none;
  }

  .mv-card-interactive {
    transition: border-color 0.15s ease;
  }

  .mv-card-interactive:hover {
    transform: none;
  }

  .study-speech-btn.is-listening {
    animation: none;
  }

  .mv-course-tile {
    content-visibility: auto;
    contain-intrinsic-size: 320px;
    background: var(--mv-surface-solid);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  }

  .study-video-dock__player {
    /* Keep video decoding on its own layer on iOS */
    transform: translateZ(0);
  }
}

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

html.mv-landscape-blocked,
html.mv-landscape-blocked body {
  overflow: hidden !important;
  touch-action: none;
}

html[dir="rtl"] body.mv-body {
  font-family: "IRSans", Tahoma, "Segoe UI", sans-serif;
  text-align: right;
}

html[dir="rtl"] [dir="ltr"] {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
}

.mv-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.mv-rotate-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top, 0px))
    max(1.25rem, env(safe-area-inset-right, 0px))
    max(1.25rem, env(safe-area-inset-bottom, 0px))
    max(1.25rem, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--mv-bg) 92%, #000);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mv-rotate-gate.is-visible,
.mv-rotate-gate:not([hidden]) {
  display: flex;
}

.mv-rotate-gate[hidden] {
  display: none !important;
}

.mv-rotate-gate__card {
  width: min(22rem, 100%);
  text-align: center;
  border-radius: 1.35rem;
  border: 1px solid var(--mv-border);
  background: color-mix(in srgb, var(--mv-surface-solid, var(--mv-surface)) 94%, transparent);
  padding: 1.35rem 1.2rem 1.45rem;
  box-shadow: var(--mv-shadow);
}

.mv-rotate-gate__icon {
  display: grid;
  place-items: center;
  margin: 0 auto 0.85rem;
  color: var(--mv-accent);
}

.mv-rotate-gate__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--mv-text);
  line-height: 1.3;
}

.mv-rotate-gate__hint {
  margin: 0.55rem 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--mv-muted);
}

.mv-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--mv-safe-t);
  border-bottom: 1px solid var(--mv-border);
  background: var(--mv-header-bg);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.mv-header-inner {
  max-width: 42rem;
  margin: 0 auto;
  min-height: var(--mv-header-h);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mv-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.mv-brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.85rem;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--mv-on-accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: none;
  flex-shrink: 0;
  overflow: hidden;
}

.mv-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.mv-auth-brand {
  display: flex;
  justify-content: center;
  margin: 0 auto 1.1rem;
}

.mv-auth-logo {
  width: min(16rem, 78vw);
  height: auto;
  display: block;
  object-fit: contain;
}

.mv-brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.mv-brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.mv-app-version {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--mv-accent) 28%, var(--mv-border));
  background: color-mix(in srgb, var(--mv-accent) 12%, transparent);
  color: var(--mv-accent);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 0.22rem 0.42rem;
  font-variant-numeric: tabular-nums;
}

.mv-brand-sub {
  font-size: 0.7rem;
  color: var(--mv-muted);
  line-height: 1.2;
  margin-top: 0.1rem;
  max-width: 11rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mv-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.mv-icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  color: var(--mv-text-soft);
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mv-icon-btn:active {
  transform: scale(0.96);
}

.mv-icon-btn:hover {
  border-color: color-mix(in srgb, var(--mv-accent) 45%, var(--mv-border));
  color: var(--mv-accent);
}

.mv-main {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.85rem 0.85rem calc(var(--mv-nav-h) + var(--mv-safe-b) + 1.1rem);
  flex: 1;
  min-width: 0;
}

/* Study / immersive pages: reclaim bottom space on phones */
.mv-focus-mode .mv-bottom-nav {
  display: none;
}

.mv-focus-mode .mv-main {
  padding-bottom: calc(1rem + var(--mv-safe-b));
}

.mv-focus-mode .mv-header-actions {
  display: none;
}

@media (min-width: 768px) {
  .mv-header-inner,
  .mv-main {
    max-width: 56rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .mv-main {
    padding-top: 1.5rem;
    padding-bottom: 2.5rem;
  }

  .mv-bottom-nav {
    display: none !important;
  }

  .mv-desktop-nav {
    display: flex !important;
  }

  .mv-header-actions {
    display: none !important;
  }

  .mv-brand-sub {
    max-width: none;
  }
}

.mv-desktop-nav {
  display: none;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.mv-desk-link {
  text-decoration: none;
  color: var(--mv-muted);
  font-size: 0.875rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.85rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.mv-desk-link:hover,
.mv-desk-link.is-active {
  color: var(--mv-accent);
  background: var(--mv-accent-soft);
}

.mv-desk-cta {
  background: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep));
  color: var(--mv-on-accent) !important;
  font-weight: 700;
}

.mv-desk-cta:hover {
  filter: brightness(1.04);
  background: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep)) !important;
  color: var(--mv-on-accent) !important;
}

.mv-messages {
  position: fixed;
  top: calc(var(--mv-header-h, 3.75rem) + var(--mv-safe-t, 0px) + 0.65rem);
  inset-inline: 0.85rem;
  z-index: 90;
  display: grid;
  gap: 0.5rem;
  width: auto;
  max-width: min(28rem, calc(100vw - 1.7rem));
  margin-inline: auto;
  padding: 0;
  pointer-events: none;
}

.mv-toast {
  pointer-events: auto;
  border: 1px solid color-mix(in srgb, var(--mv-accent) 40%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-surface-solid, var(--mv-surface)) 92%, var(--mv-accent-soft));
  color: var(--mv-text);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: var(--mv-shadow);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  animation: mv-rise 0.35s ease both;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.mv-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.mv-bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  padding: 0.45rem 0.65rem calc(0.45rem + var(--mv-safe-b));
  border-top: 1px solid var(--mv-border);
  background: var(--mv-nav-bg);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
}

.mv-bottom-nav-inner {
  max-width: 28rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
}

.mv-bottom-nav-inner.is-guest {
  grid-template-columns: repeat(3, 1fr);
  max-width: 22rem;
}

.mv-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 3.35rem;
  border-radius: 1rem;
  text-decoration: none;
  color: var(--mv-muted);
  font-size: 0.68rem;
  font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.mv-nav-item svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 1.8;
}

.mv-nav-item.is-active {
  color: var(--mv-accent);
  background: var(--mv-accent-soft);
}

.mv-nav-item:active {
  transform: scale(0.97);
}

.mv-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.mv-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--mv-accent);
  letter-spacing: 0.02em;
}

.mv-title {
  margin: 0;
  font-size: clamp(1.45rem, 4.8vw, 2rem);
  font-weight: 760;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--mv-text);
}

.mv-lead {
  margin: 0.45rem 0 0;
  color: var(--mv-muted);
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 36rem;
}

.mv-card {
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  border-radius: var(--mv-radius);
  box-shadow: var(--mv-shadow);
  backdrop-filter: blur(8px);
}

.mv-card-interactive {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mv-card-interactive:hover {
  border-color: color-mix(in srgb, var(--mv-accent) 40%, var(--mv-border));
  transform: translateY(-1px);
}

.mv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.65rem;
  padding: 0.65rem 1rem;
  border-radius: 0.95rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.mv-btn:active {
  transform: scale(0.98);
}

.mv-busy-spin {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: mv-busy-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.mv-page-busy {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: none;
}

.mv-page-busy[hidden] {
  display: none !important;
}

.mv-page-busy__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  overflow: hidden;
  background: color-mix(in srgb, var(--mv-accent, #10b981) 18%, transparent);
}

.mv-page-busy__bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--mv-accent, #10b981), transparent);
  animation: mv-page-busy-slide 1s ease-in-out infinite;
}

@keyframes mv-page-busy-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.mv-page-busy__card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--mv-border-strong, #334155) 80%, transparent);
  background: color-mix(in srgb, var(--mv-surface-solid, #0f172a) 92%, transparent);
  color: var(--mv-text-soft, #cbd5e1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
}

html.is-page-busy,
html.is-page-busy body {
  cursor: progress;
}

.mv-nav-item.is-busy-overlay,
.mv-desk-link.is-busy-overlay,
.mv-icon-btn.is-busy-overlay {
  opacity: 0.72;
  pointer-events: none;
}

.mv-nav-item.is-busy-overlay::after,
.mv-desk-link.is-busy-overlay::after,
.mv-icon-btn.is-busy-overlay::after {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  margin-inline-start: 0.25rem;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: mv-busy-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

/* Generic overlay busy (links that keep their own content). */
a.is-busy-overlay:not(.mv-nav-item):not(.mv-desk-link):not(.mv-icon-btn):not(.mv-course-cover):not(.mv-course-cover-square) {
  position: relative;
  opacity: 0.78;
  pointer-events: none;
}

.mv-course-tile.is-navigating,
.mv-course-row.is-navigating,
.mv-explore-row.is-navigating,
.mv-card-interactive.is-navigating {
  position: relative;
  pointer-events: none;
}

.mv-course-tile.is-navigating::after,
.mv-course-row.is-navigating::after,
.mv-explore-row.is-navigating::after,
.mv-card-interactive.is-navigating::after,
a.mv-course-cover-square.is-busy-overlay::after,
a.mv-course-cover.is-busy-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: inherit;
  background: color-mix(in srgb, #020617 42%, transparent);
  backdrop-filter: none;
}

.mv-course-tile.is-navigating::before,
.mv-course-row.is-navigating::before,
.mv-explore-row.is-navigating::before,
.mv-card-interactive.is-navigating::before,
a.mv-course-cover-square.is-busy-overlay::before,
a.mv-course-cover.is-busy-overlay::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 6;
  width: 1.35rem;
  height: 1.35rem;
  margin: -0.675rem 0 0 -0.675rem;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, #fff 28%, transparent);
  border-top-color: #fff;
  animation: mv-busy-spin 0.7s linear infinite;
}

[data-course-feed-loading] {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding-block: 0.85rem;
  color: color-mix(in srgb, var(--mv-muted, #94a3b8) 100%, transparent);
  font-size: 0.875rem;
}

[data-course-feed-loading]:not([hidden]) {
  display: flex;
}

[data-course-feed].is-loading [data-course-feed-sentinel] {
  min-height: 1.5rem;
}

[data-reviews-loading] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

[data-reviews-loading].hidden {
  display: none;
}

.mv-busy-text {
  min-width: 0;
}

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

button.is-busy,
a.is-busy,
.mv-btn.is-busy,
.study-btn.is-busy,
.study-icon-btn.is-busy,
.study-speech-btn.is-busy,
.study-speak-action-btn.is-busy,
.study-speak-end-btn.is-busy,
.study-setup-start-btn.is-busy,
.study-setup-mini-btn.is-busy,
.level-btn.is-busy,
.mv-search-submit.is-busy,
.mv-desk-link.is-busy,
.mv-chip.is-busy,
input.is-busy {
  pointer-events: none;
  cursor: wait;
}

a.is-busy-link {
  pointer-events: none;
}

form.is-busy-form {
  cursor: wait;
}

/* Keep original label; fade it and show a centered spinner without resizing. */
button.is-busy-keep,
a.is-busy-keep,
.mv-btn.is-busy-keep,
.study-btn.is-busy-keep,
.study-icon-btn.is-busy-keep,
.study-speech-btn.is-busy-keep,
.study-speak-action-btn.is-busy-keep,
.study-speak-end-btn.is-busy-keep,
.study-setup-start-btn.is-busy-keep,
.study-setup-mini-btn.is-busy-keep,
.level-btn.is-busy-keep,
.mv-search-submit.is-busy-keep,
.mv-chip.is-busy-keep {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

button.is-busy-keep::before,
a.is-busy-keep::before,
.mv-btn.is-busy-keep::before,
.study-btn.is-busy-keep::before,
.study-icon-btn.is-busy-keep::before,
.study-speech-btn.is-busy-keep::before,
.study-speak-action-btn.is-busy-keep::before,
.study-speak-end-btn.is-busy-keep::before,
.study-setup-start-btn.is-busy-keep::before,
.study-setup-mini-btn.is-busy-keep::before,
.level-btn.is-busy-keep::before,
.mv-search-submit.is-busy-keep::before,
.mv-chip.is-busy-keep::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: color-mix(in srgb, currentColor 10%, transparent);
  opacity: 0.55;
  pointer-events: none;
}

button.is-busy-keep::after,
a.is-busy-keep::after,
.mv-btn.is-busy-keep::after,
.study-btn.is-busy-keep::after,
.study-icon-btn.is-busy-keep::after,
.study-speech-btn.is-busy-keep::after,
.study-speak-action-btn.is-busy-keep::after,
.study-speak-end-btn.is-busy-keep::after,
.study-setup-start-btn.is-busy-keep::after,
.study-setup-mini-btn.is-busy-keep::after,
.level-btn.is-busy-keep::after,
.mv-search-submit.is-busy-keep::after,
.mv-chip.is-busy-keep::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 0.9rem;
  height: 0.9rem;
  margin: -0.45rem 0 0 -0.45rem;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  animation: mv-busy-spin 0.7s linear infinite;
  pointer-events: none;
}

.study-icon-btn.is-busy-keep::after,
.mv-icon-btn.is-busy-keep::after,
.mv-search-submit.is-busy-keep::after {
  width: 0.8rem;
  height: 0.8rem;
  margin: -0.4rem 0 0 -0.4rem;
}

/* Study page: busy never changes control footprint */
#study-root .study-btn.is-busy-keep,
#study-root .study-speech-btn.is-busy-keep,
#study-root .study-speak-action-btn.is-busy-keep,
#study-root .study-setup-start-btn.is-busy-keep,
#study-root .study-setup-mini-btn.is-busy-keep,
#study-root .level-btn.is-busy-keep {
  white-space: nowrap;
  text-overflow: ellipsis;
}

#study-root .study-speak-action-btn.is-busy-keep {
  max-height: 2.05rem;
}

#study-root .study-speech-btn.is-busy-keep {
  max-height: 2.4rem;
}

#study-root .level-btn.is-busy-keep {
  max-height: 1.85rem;
}

#study-root .study-icon-btn.is-busy-keep,
#study-root .study-icon-btn.is-meaning-loading {
  width: 2.2rem;
  height: 2.2rem;
  min-width: 2.2rem;
  min-height: 2.2rem;
  max-width: 2.2rem;
  max-height: 2.2rem;
  flex: 0 0 2.2rem;
}

.mv-btn-primary {
  background: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep));
  color: var(--mv-on-accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--mv-accent) 28%, transparent);
}

.mv-btn-primary:hover {
  filter: brightness(1.04);
}

.mv-btn-ghost {
  background: var(--mv-surface-solid);
  border-color: var(--mv-border-strong);
  color: var(--mv-text-soft);
}

.mv-btn-ghost:hover {
  border-color: color-mix(in srgb, var(--mv-accent) 40%, var(--mv-border-strong));
  color: var(--mv-text);
  background: var(--mv-surface-2);
}

html[data-theme="dark"] .mv-btn-ghost {
  background: var(--mv-surface-2);
  border-color: var(--mv-border);
}

.mv-btn-danger {
  background: var(--mv-danger-soft);
  color: var(--mv-danger);
  border-color: color-mix(in srgb, var(--mv-danger) 25%, transparent);
}

.mv-chip-scroller {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.mv-chip-row {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 0.5rem;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 0.2rem 0.35rem;
  padding-inline: 0.15rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscromv-behavior-x: contain;
  scromv-behavior: smooth;
  cursor: grab;
}

.mv-chip-row.is-dragging {
  cursor: grabbing;
  scromv-behavior: auto;
  user-select: none;
}

.mv-chip-row::-webkit-scrollbar {
  display: none;
  height: 0;
  width: 0;
}

.mv-chip-arrow {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 999px;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-solid);
  color: var(--mv-text-soft);
  box-shadow: var(--mv-shadow);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mv-chip-arrow:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--mv-accent) 45%, var(--mv-border));
  color: var(--mv-accent);
}

.mv-chip-arrow:active:not(:disabled) {
  transform: scale(0.96);
}

.mv-chip-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  color: var(--mv-muted);
  box-shadow: none;
}

.mv-chip-arrow[hidden] {
  display: none;
}

html[dir="rtl"] .mv-chip-arrow.is-start svg,
html[dir="rtl"] .mv-chip-arrow.is-end svg {
  transform: scaleX(-1);
}

.mv-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 2.2rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  color: var(--mv-text-soft);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 650;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.mv-chip:active {
  transform: scale(0.97);
}

.mv-chip.is-active {
  background: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep));
  border-color: transparent;
  color: var(--mv-on-accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--mv-accent) 24%, transparent);
}

.mv-search {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.mv-search-field {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: stretch;
}

.mv-search-field input[type="search"] {
  width: 100%;
  padding-inline-end: 3rem;
}

.mv-search-submit {
  position: absolute;
  inset-inline-end: 0.35rem;
  top: 50%;
  display: inline-flex;
  width: 2.25rem;
  height: 2.25rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.85rem;
  background: color-mix(in srgb, var(--mv-accent) 16%, transparent);
  color: var(--mv-accent);
  transform: translateY(-50%);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mv-search-submit:hover {
  background: color-mix(in srgb, var(--mv-accent) 28%, transparent);
  color: color-mix(in srgb, var(--mv-accent) 85%, white);
}

.mv-search-submit:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--mv-accent) 55%, transparent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .mv-page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .mv-course-thumb {
    width: 5.25rem;
  }

  .mv-course-row-body {
    padding: 0.4rem 0.5rem;
  }

  .mv-brand-sub {
    display: none;
  }

  .mv-chip-scroller {
    margin-inline: -0.35rem;
  }

  .mv-chip-arrow {
    width: 1.95rem;
    height: 1.95rem;
  }
}

.mv-search input[type="search"],
.mv-field,
input.mv-field,
textarea.mv-field,
select.mv-field {
  width: 100%;
  min-height: 2.85rem;
  border-radius: 1rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-solid);
  color: var(--mv-text);
  padding: 0.75rem 0.95rem;
  outline: none;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mv-search input[type="search"]:focus,
.mv-field:focus,
input.mv-field:focus,
textarea.mv-field:focus,
select.mv-field:focus {
  border-color: color-mix(in srgb, var(--mv-accent) 55%, var(--mv-border));
  box-shadow: 0 0 0 3px var(--mv-accent-soft);
}

.mv-empty {
  text-align: center;
  padding: 3rem 1.25rem;
  border: 1px dashed var(--mv-border-strong);
  border-radius: var(--mv-radius);
  background: color-mix(in srgb, var(--mv-surface) 70%, transparent);
}

.mv-empty h2 {
  margin: 0;
  font-size: 1.15rem;
}

.mv-empty p {
  margin: 0.55rem 0 0;
  color: var(--mv-muted);
  font-size: 0.92rem;
}

.mv-course-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--mv-radius);
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.mv-course-row:hover {
  border-color: color-mix(in srgb, var(--mv-accent) 35%, var(--mv-border));
}

.mv-course-row-clickable {
  cursor: pointer;
}

.mv-course-row-stretch {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
}

.mv-course-row-nested {
  position: relative;
  z-index: 2;
}

.mv-course-row-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 0.08rem;
  padding: 0.4rem 0.55rem;
}

.mv-course-row-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  padding: 0;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 0.95rem;
  color: #fff;
}

.mv-course-row-author {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.65rem;
  line-height: 0.85rem;
  color: #94a3b8;
}

.mv-course-row-stars {
  margin: 0;
  min-height: 0.85rem;
  font-size: 0.65rem;
  line-height: 0.85rem;
}

.mv-course-row-stars.is-empty {
  color: #64748b;
  font-weight: 600;
}

.mv-course-row-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  min-height: 1.7rem;
  font-size: 0.65rem;
  line-height: 0.85rem;
  color: #64748b;
}

.mv-course-row-footer {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.45rem;
  min-height: 1.1rem;
}

.mv-course-row-footer .mv-meta {
  font-size: 0.65rem;
}

.mv-course-row-badges {
  display: flex;
  margin-left: auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.mv-course-row-badges > span {
  white-space: nowrap;
  padding: 0.05rem 0.35rem;
  font-size: 0.55rem;
}

@media (min-width: 640px) {
  .mv-course-row-title {
    font-size: 0.88rem;
    line-height: 1rem;
  }

  .mv-course-row-desc {
    min-height: 2rem;
    font-size: 0.75rem;
    line-height: 1rem;
  }
}

/* Shared media fill — image always crops to the frame */
.mv-media {
  position: relative;
  display: block;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, var(--mv-accent-soft), transparent 55%),
    linear-gradient(160deg, var(--mv-media-from), var(--mv-media-to));
  isolation: isolate;
}

.mv-media > img,
.mv-media-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 0;
  transition: transform 0.3s ease;
}

.mv-media > .mv-media-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.5rem;
  text-align: center;
  color: var(--mv-muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.mv-course-thumb {
  width: clamp(5.5rem, 28vw, 6.75rem);
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 0;
  align-self: center;
  flex-shrink: 0;
  border-radius: 0;
}

@media (min-width: 640px) {
  .mv-course-thumb {
    width: 7rem;
  }
}

.mv-course-row:hover .mv-course-thumb > img {
  transform: scale(1.04);
}

/* Card / grid covers */
.mv-course-cover {
  aspect-ratio: 4 / 3;
  width: 100%;
  border-radius: 0;
}

.mv-course-cover-square {
  aspect-ratio: 1 / 1;
  width: 100%;
}

.mv-course-cover-square:hover > img {
  transform: scale(1.04);
}

.mv-course-tile {
  overflow: hidden;
  border-radius: var(--mv-radius);
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
}

.mv-course-tile:hover .mv-course-cover > img {
  transform: scale(1.03);
}

.mv-avatar {
  position: relative;
  display: block;
  width: 5rem;
  height: 5rem;
  flex-shrink: 0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mv-accent) 30%, transparent);
}

@media (min-width: 640px) {
  .mv-avatar {
    width: 6rem;
    height: 6rem;
  }
}

.mv-meta {
  color: var(--mv-muted);
  font-size: 0.75rem;
}

.mv-stars {
  color: var(--mv-warn);
  font-weight: 700;
  font-size: 0.78rem;
}

.mv-hero-course {
  display: grid;
  overflow: hidden;
  border-radius: calc(var(--mv-radius) + 0.15rem);
  border: 1px solid var(--mv-border);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
}

.mv-hero-course-media {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, var(--mv-accent-soft), transparent 55%),
    linear-gradient(160deg, var(--mv-media-from), var(--mv-media-to));
}

.mv-hero-course-media img,
.mv-hero-course-media .mv-media-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mv-hero-course-media img {
  object-fit: cover;
  object-position: center;
  display: block;
  min-height: 0;
  max-height: none;
}

.mv-hero-course-media .mv-media-fallback {
  display: grid;
  place-items: center;
  color: var(--mv-muted);
  font-size: 0.85rem;
}

@media (min-width: 768px) {
  .mv-hero-course {
    grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr);
    align-items: stretch;
  }

  .mv-hero-course-media {
    aspect-ratio: auto;
    height: 100%;
    min-height: 14rem;
  }
}

.mv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mv-actions .mv-btn {
  flex: 1 1 auto;
}

@media (min-width: 480px) {
  .mv-actions .mv-btn {
    flex: 0 0 auto;
  }
}

.mv-section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

/* Account / profile edit */
.mv-account {
  width: min(100%, 42rem);
  margin-inline: auto;
  display: grid;
  gap: 0.85rem;
}

.mv-account-hero {
  margin-bottom: 0;
}

.mv-account-hero .mv-title {
  font-size: 1.35rem;
  line-height: 1.2;
}

.mv-account-hero .mv-lead {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.mv-account-identity {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
  background:
    linear-gradient(
      135deg,
      color-mix(in srgb, var(--mv-accent) 12%, transparent),
      transparent 55%
    ),
    var(--mv-surface);
}

@media (min-width: 640px) {
  .mv-account {
    gap: 1rem;
  }

  .mv-account-hero .mv-title {
    font-size: 1.6rem;
  }

  .mv-account-identity {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1rem;
    padding: 1rem 1.1rem;
  }
}

.mv-account-kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mv-muted);
}

.mv-account-email {
  margin: 0.15rem 0 0;
  font-size: 0.98rem;
  font-weight: 650;
  color: var(--mv-text);
  word-break: break-word;
}

.mv-account-identity-link {
  width: 100%;
  min-height: 2.35rem;
  justify-content: center;
  padding-inline: 0.9rem;
}

@media (min-width: 640px) {
  .mv-account-identity-link {
    width: auto;
  }
}

.mv-account-form {
  display: grid;
  gap: 0.85rem;
}

.mv-account-panel {
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
  padding: 0.95rem 1rem 1.1rem;
}

@media (min-width: 640px) {
  .mv-account-form {
    gap: 1rem;
  }

  .mv-account-panel {
    padding: 1.1rem 1.15rem 1.25rem;
  }
}

.mv-account-panel-head {
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid color-mix(in srgb, var(--mv-border) 85%, transparent);
}

.mv-account-panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mv-text) 78%, var(--mv-muted));
}

.mv-account-profile-grid {
  display: grid;
  grid-template-columns: 6.75rem minmax(0, 1fr);
  gap: 0.75rem 0.85rem;
  align-items: start;
}

.mv-account-photo {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  gap: 0.45rem;
  justify-items: stretch;
  min-width: 0;
}

.mv-account-name-wrap {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  min-width: 0;
}

.mv-account-bio-wrap {
  grid-column: 1 / -1;
  min-width: 0;
}

@media (min-width: 640px) {
  .mv-account-profile-grid {
    grid-template-columns: 9.5rem minmax(0, 1fr);
    gap: 1.15rem 1.35rem;
  }

  .mv-account-photo {
    grid-row: 1 / span 2;
    justify-items: start;
  }

  .mv-account-name-wrap {
    align-self: start;
  }

  .mv-account-bio-wrap {
    grid-column: 2;
  }
}

.mv-account-photo-field {
  width: 100%;
}

.mv-account-photo .mv-crop-field {
  justify-items: stretch;
  gap: 0.45rem;
}

.mv-account-photo .mv-crop-preview.is-round {
  width: 6.5rem;
  height: 6.5rem;
  justify-self: center;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mv-accent) 28%, transparent);
}

.mv-account-photo .mv-crop-pick {
  width: 100%;
  min-height: 2.1rem;
  justify-content: center;
  padding-inline: 0.5rem;
  font-size: 0.75rem;
}

@media (min-width: 640px) {
  .mv-account-photo .mv-crop-field {
    justify-items: start;
  }

  .mv-account-photo .mv-crop-preview.is-round {
    width: 8rem;
    height: 8rem;
    justify-self: start;
  }

  .mv-account-photo .mv-crop-pick {
    width: auto;
    min-height: 2.2rem;
    padding-inline: 0.75rem;
    font-size: 0.8rem;
  }
}

.mv-account-prefs-grid {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .mv-account-prefs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .mv-account-prefs-grid .mv-account-field:last-child {
    grid-column: 1 / -1;
  }
}

.mv-account-field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.mv-account-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 650;
  color: color-mix(in srgb, var(--mv-text) 88%, var(--mv-muted));
}

.mv-account-help {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--mv-muted);
}

.mv-account-error {
  margin: 0;
  font-size: 0.8rem;
  color: #fda4af;
}

.mv-account-alert {
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  font-size: 0.88rem;
}

.mv-account-alert.is-error {
  border: 1px solid color-mix(in srgb, #fb7185 35%, transparent);
  background: color-mix(in srgb, #fb7185 12%, transparent);
  color: #fecdd3;
}

.mv-account-note {
  margin: 0.85rem 0 0;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--mv-warn) 28%, transparent);
  background: color-mix(in srgb, var(--mv-warn) 10%, transparent);
  color: color-mix(in srgb, var(--mv-warn) 70%, white);
  font-size: 0.74rem;
  line-height: 1.45;
}

.mv-account-form input,
.mv-account-form textarea,
.mv-account-form select {
  font-size: 1rem;
}

.mv-account-save {
  display: grid;
  gap: 0.5rem;
  position: sticky;
  bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  padding: 0.7rem;
  border: 1px solid var(--mv-border);
  border-radius: var(--mv-radius);
  background: color-mix(in srgb, var(--mv-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--mv-shadow);
}

.mv-account-save .mv-btn {
  width: 100%;
  justify-content: center;
}

@media (min-width: 640px) {
  .mv-account-save {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    padding: 0.75rem;
  }

  .mv-account-save .mv-btn {
    width: auto;
    flex: 0 0 auto;
  }
}

.mv-account-danger {
  margin-top: 0.15rem;
  padding-top: 0.85rem;
  border-top: 1px dashed color-mix(in srgb, var(--mv-border) 90%, transparent);
}

.mv-account-danger .mv-btn {
  width: 100%;
  justify-content: center;
}

@media (min-width: 640px) {
  .mv-account-danger .mv-btn {
    width: auto;
  }
}

/* Public profile */
.mv-profile-public {
  width: min(100%, 56rem);
  margin-inline: auto;
}

.mv-profile-banner {
  margin-bottom: 1.25rem;
  border: 1px solid var(--mv-border);
  border-radius: calc(var(--mv-radius) + 0.15rem);
  background:
    radial-gradient(
      120% 80% at 0% 0%,
      color-mix(in srgb, var(--mv-accent) 16%, transparent),
      transparent 55%
    ),
    var(--mv-surface);
  box-shadow: var(--mv-shadow);
  overflow: hidden;
}

.mv-profile-banner-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  padding: 1.15rem 1.15rem 1.25rem;
}

.mv-profile-avatar {
  width: 5.5rem;
  height: 5.5rem;
}

@media (min-width: 640px) {
  .mv-profile-avatar {
    width: 6.5rem;
    height: 6.5rem;
  }
}

.mv-profile-banner-copy {
  flex: 1 1 16rem;
  min-width: 0;
}

.mv-profile-banner-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.mv-profile-name {
  font-size: clamp(1.35rem, 4vw, 1.85rem);
}

.mv-profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.95rem;
}

.mv-profile-stat {
  display: grid;
  gap: 0.15rem;
  min-width: 7.5rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--mv-border) 88%, transparent);
  background: color-mix(in srgb, var(--mv-surface-2, var(--mv-surface)) 80%, transparent);
}

.mv-profile-stat-value {
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--mv-text);
}

.mv-profile-stat-label {
  font-size: 0.74rem;
  color: var(--mv-muted);
}

.mv-profile-bio {
  margin: 0.95rem 0 0;
  max-width: 40rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: color-mix(in srgb, var(--mv-text) 82%, var(--mv-muted));
}

.mv-profile-courses-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--mv-border);
}

.mv-profile-courses-head h2 {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--mv-text) 78%, var(--mv-muted));
}

.mv-fade-in {
  animation: mv-rise 0.4s ease both;
}

@keyframes mv-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Bridge Tailwind dark-palette utilities into theme tokens */
html[data-theme="light"] body.mv-body,
html[data-theme="dark"] body.mv-body {
  color: var(--mv-text);
}

html[data-theme="light"] body.mv-body {
  background-color: var(--mv-bg) !important;
}

/* ——— Light: text ——— */
html[data-theme="light"] .text-white,
html[data-theme="light"] .text-slate-50,
html[data-theme="light"] .text-slate-100,
html[data-theme="light"] h1.text-white,
html[data-theme="light"] h2.text-white,
html[data-theme="light"] h3.text-white {
  color: var(--mv-text) !important;
}

html[data-theme="light"] .text-slate-200,
html[data-theme="light"] .text-slate-300 {
  color: var(--mv-text-soft) !important;
}

html[data-theme="light"] .text-slate-400,
html[data-theme="light"] .text-slate-500,
html[data-theme="light"] .text-slate-600 {
  color: var(--mv-muted) !important;
}

html[data-theme="light"] .text-emerald-100,
html[data-theme="light"] .text-emerald-200,
html[data-theme="light"] .text-emerald-300,
html[data-theme="light"] .text-emerald-400,
html[data-theme="light"] .text-emerald-500,
html[data-theme="light"] .hover\:text-emerald-200:hover,
html[data-theme="light"] .hover\:text-emerald-300:hover,
html[data-theme="light"] .hover\:text-emerald-400:hover {
  color: var(--mv-accent) !important;
}

html[data-theme="light"] .text-sky-200,
html[data-theme="light"] .text-sky-300,
html[data-theme="light"] .text-sky-400,
html[data-theme="light"] .text-cyan-300,
html[data-theme="light"] .text-cyan-400 {
  color: var(--mv-info) !important;
}

html[data-theme="light"] .text-violet-200,
html[data-theme="light"] .text-violet-300,
html[data-theme="light"] .text-violet-400,
html[data-theme="light"] .text-purple-300 {
  color: var(--mv-violet) !important;
}

html[data-theme="light"] .text-amber-100,
html[data-theme="light"] .text-amber-200,
html[data-theme="light"] .text-amber-300,
html[data-theme="light"] .text-amber-400,
html[data-theme="light"] .text-yellow-200,
html[data-theme="light"] .text-yellow-300 {
  color: var(--mv-warn) !important;
}

html[data-theme="light"] .text-rose-200,
html[data-theme="light"] .text-rose-300,
html[data-theme="light"] .text-rose-400,
html[data-theme="light"] .text-red-300,
html[data-theme="light"] .text-red-400 {
  color: var(--mv-danger) !important;
}

/* ——— Light: surfaces ——— */
html[data-theme="light"] .bg-slate-950,
html[data-theme="light"] .bg-slate-950\/40,
html[data-theme="light"] .bg-slate-950\/50,
html[data-theme="light"] .bg-slate-950\/60,
html[data-theme="light"] .bg-slate-950\/70,
html[data-theme="light"] .bg-slate-950\/80,
html[data-theme="light"] .bg-slate-950\/85,
html[data-theme="light"] .bg-slate-900,
html[data-theme="light"] .bg-slate-900\/40,
html[data-theme="light"] .bg-slate-900\/50,
html[data-theme="light"] .bg-slate-900\/60,
html[data-theme="light"] .bg-slate-900\/70,
html[data-theme="light"] .bg-slate-900\/80 {
  background-color: var(--mv-surface-solid) !important;
}

html[data-theme="light"] .bg-slate-800,
html[data-theme="light"] .bg-slate-800\/50,
html[data-theme="light"] .bg-slate-800\/80,
html[data-theme="light"] .bg-slate-700 {
  background-color: var(--mv-surface-2) !important;
}

html[data-theme="light"] .hover\:bg-slate-700:hover,
html[data-theme="light"] .hover\:bg-slate-800:hover,
html[data-theme="light"] .hover\:bg-slate-900:hover {
  background-color: color-mix(in srgb, var(--mv-surface-2) 70%, var(--mv-accent-soft)) !important;
}

html[data-theme="light"] .border-slate-800,
html[data-theme="light"] .border-slate-800\/80,
html[data-theme="light"] .border-slate-700,
html[data-theme="light"] .border-slate-700\/80,
html[data-theme="light"] .border-slate-600 {
  border-color: var(--mv-border-strong) !important;
}

html[data-theme="light"] .border-dashed.border-slate-700,
html[data-theme="light"] .border-dashed.border-slate-800 {
  border-color: var(--mv-border-strong) !important;
}

html[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  background-color: var(--mv-surface-solid) !important;
  color: var(--mv-text) !important;
  border-color: var(--mv-border-strong) !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: var(--mv-muted) !important;
  opacity: 0.85;
}

/* ——— Light: accent / status fills ——— */
html[data-theme="light"] .bg-emerald-500,
html[data-theme="light"] .bg-emerald-400,
html[data-theme="light"] .hover\:bg-emerald-400:hover,
html[data-theme="light"] .hover\:bg-emerald-500:hover {
  background-color: var(--mv-accent) !important;
  color: var(--mv-on-accent) !important;
}

html[data-theme="light"] .bg-emerald-500\/10,
html[data-theme="light"] .bg-emerald-500\/15,
html[data-theme="light"] .bg-emerald-500\/20,
html[data-theme="light"] .bg-emerald-500\/30,
html[data-theme="light"] .hover\:bg-emerald-500\/30:hover,
html[data-theme="light"] .bg-emerald-400\/10 {
  background-color: var(--mv-accent-soft) !important;
}

html[data-theme="light"] .text-rose-100,
html[data-theme="light"] .text-emerald-100 {
  color: var(--mv-text) !important;
}

html[data-theme="light"] .ring-emerald-500\/30,
html[data-theme="light"] .focus\:ring-emerald-500\/30:focus {
  --tw-ring-color: color-mix(in srgb, var(--mv-accent) 35%, transparent) !important;
}

html[data-theme="light"] .focus\:border-emerald-500:focus,
html[data-theme="light"] .hover\:border-emerald-500\/50:hover {
  border-color: color-mix(in srgb, var(--mv-accent) 55%, var(--mv-border)) !important;
}

html[data-theme="light"] .border-emerald-500\/20,
html[data-theme="light"] .border-emerald-500\/30,
html[data-theme="light"] .border-emerald-500\/40 {
  border-color: color-mix(in srgb, var(--mv-accent) 40%, transparent) !important;
}

html[data-theme="light"] .bg-amber-500\/10,
html[data-theme="light"] .bg-amber-500\/15,
html[data-theme="light"] .bg-amber-500\/20 {
  background-color: var(--mv-warn-soft) !important;
}

html[data-theme="light"] .border-amber-500\/20,
html[data-theme="light"] .border-amber-500\/30,
html[data-theme="light"] .hover\:border-amber-400\/40:hover {
  border-color: color-mix(in srgb, var(--mv-warn) 40%, transparent) !important;
}

html[data-theme="light"] .hover\:bg-amber-500\/15:hover {
  background-color: color-mix(in srgb, var(--mv-warn) 16%, transparent) !important;
}

html[data-theme="light"] .bg-rose-500\/10,
html[data-theme="light"] .bg-rose-500\/15,
html[data-theme="light"] .bg-rose-500\/20,
html[data-theme="light"] .hover\:bg-rose-500\/25:hover {
  background-color: var(--mv-danger-soft) !important;
}

html[data-theme="light"] .border-rose-500\/30,
html[data-theme="light"] .border-rose-500\/40 {
  border-color: color-mix(in srgb, var(--mv-danger) 35%, transparent) !important;
}

html[data-theme="light"] .bg-sky-500\/10,
html[data-theme="light"] .bg-sky-500\/15 {
  background-color: var(--mv-info-soft) !important;
}

html[data-theme="light"] .bg-violet-500\/10,
html[data-theme="light"] .bg-violet-500\/15 {
  background-color: var(--mv-violet-soft) !important;
}

/* Primary CTAs that pair emerald fill with dark ink text */
html[data-theme="light"] .bg-emerald-500.text-slate-950,
html[data-theme="light"] a.bg-emerald-500,
html[data-theme="light"] button.bg-emerald-500 {
  color: var(--mv-on-accent) !important;
}

html[data-theme="light"] .mv-desk-cta,
html[data-theme="dark"] .mv-desk-cta {
  background: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep));
  color: var(--mv-on-accent) !important;
}

/* Modal overlays stay readable in both themes */
html[data-theme="light"] .bg-slate-950\/85,
html[data-theme="light"] .fixed.bg-slate-950\/85 {
  background-color: var(--mv-overlay) !important;
}

/* Lesson rows: keep actions usable on narrow phones */
@media (max-width: 640px) {
  .lesson-item {
    align-items: stretch !important;
  }

  .lesson-item .mv-actions {
    width: 100%;
  }

  .section-item {
    padding: 1rem !important;
  }
}

/* Shared confirm / dialog shell */
.mv-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .mv-confirm-modal {
    align-items: center;
    padding: 1.25rem;
  }
}

.mv-confirm-modal.hidden,
.mv-confirm-modal[hidden] {
  display: none !important;
}

.mv-confirm-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: var(--mv-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.mv-confirm-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 24rem);
  margin: 0;
  overflow: hidden;
  border-radius: 1.25rem 1.25rem 0 0;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-solid);
  box-shadow: var(--mv-shadow);
  padding: 1.15rem 1.15rem calc(1.15rem + var(--mv-safe-b));
}

@media (min-width: 640px) {
  .mv-confirm-panel {
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px color-mix(in srgb, #000 28%, transparent);
    padding: 1.25rem;
  }
}

html[data-theme="light"] .mv-confirm-panel {
  box-shadow: 0 -8px 32px rgba(15, 28, 46, 0.12);
}

@media (min-width: 640px) {
  html[data-theme="light"] .mv-confirm-panel {
    box-shadow: 0 20px 48px rgba(15, 28, 46, 0.14);
  }
}

.mv-confirm-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--mv-text);
}

.mv-confirm-message {
  margin: 0.55rem 0 0;
  color: var(--mv-muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.mv-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

body.mv-modal-open {
  overflow: hidden;
}

.mv-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .mv-modal {
    align-items: center;
    padding: 1.25rem;
  }
}

.mv-modal.hidden,
.mv-modal[hidden] {
  display: none !important;
}

.mv-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.mv-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 34rem;
  max-height: min(88dvh, 44rem);
  overflow: hidden;
  border-radius: 1.35rem 1.35rem 0 0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: color-mix(in srgb, #0c1220 94%, transparent);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

@media (min-width: 640px) {
  .mv-modal-panel {
    border-radius: 1.35rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  }
}

.mv-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.mv-modal-body {
  overflow-y: auto;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

/* Course create / edit form */
.mv-course-form-page {
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
}

.mv-course-form-card {
  padding: 1rem;
}

@media (min-width: 640px) {
  .mv-course-form-card {
    padding: 1.35rem 1.5rem 1.5rem;
  }
}

.mv-course-form-head {
  margin-bottom: 1rem;
}

.mv-course-form-head .mv-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

@media (min-width: 640px) {
  .mv-course-form-head .mv-title {
    font-size: 1.35rem;
  }
}

.mv-course-form {
  display: grid;
  gap: 1rem;
}

.mv-course-form-top {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 0.75rem 0.85rem;
  align-items: start;
}

.mv-course-form-cover {
  grid-column: 1;
  grid-row: 1;
}

.mv-course-form-title-wrap {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  min-width: 0;
}

.mv-course-form-desc-wrap {
  grid-column: 1 / -1;
  min-width: 0;
}

@media (min-width: 640px) {
  .mv-course-form-top {
    grid-template-columns: 8.75rem minmax(0, 1fr);
    gap: 1rem 1.15rem;
  }

  .mv-course-form-cover {
    grid-row: 1 / span 2;
  }

  .mv-course-form-title-wrap {
    align-self: start;
  }

  .mv-course-form-desc-wrap {
    grid-column: 2;
  }
}

.mv-course-form-cover .mv-crop-field {
  gap: 0.45rem;
  justify-items: stretch;
}

.mv-course-form-cover .mv-crop-preview {
  width: 6.5rem;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.85rem;
}

.mv-course-form-cover .mv-crop-preview-empty {
  font-size: 0.68rem;
  padding: 0.4rem;
  line-height: 1.25;
}

.mv-course-form-cover .mv-crop-pick {
  width: 100%;
  min-height: 2.1rem;
  justify-content: center;
  padding-inline: 0.5rem;
  font-size: 0.75rem;
}

@media (min-width: 640px) {
  .mv-course-form-cover .mv-crop-field {
    justify-items: start;
  }

  .mv-course-form-cover .mv-crop-preview {
    width: 8.75rem;
  }

  .mv-course-form-cover .mv-crop-pick {
    width: auto;
    min-height: 2.2rem;
    padding-inline: 0.75rem;
    font-size: 0.8rem;
  }
}

.mv-course-form-meta {
  display: grid;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .mv-course-form-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}

.mv-course-form-field {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.mv-course-form-label {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
}

.mv-course-form-help {
  margin: 0;
  color: var(--mv-muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.mv-course-form-error {
  margin: 0;
  color: #fda4af;
  font-size: 0.8rem;
}

.mv-course-form-desc {
  min-height: 4.75rem !important;
}

.mv-course-form input,
.mv-course-form textarea,
.mv-course-form select {
  font-size: 1rem;
}

@media (min-width: 640px) {
  .mv-course-form-desc {
    min-height: 5.5rem !important;
  }
}

.mv-course-form-actions {
  display: flex;
  padding-top: 0.15rem;
}

.mv-course-form-actions .mv-btn {
  width: 100%;
}

@media (min-width: 640px) {
  .mv-course-form-actions {
    justify-content: flex-end;
  }

  .mv-course-form-actions .mv-btn {
    width: auto;
    min-width: 9.5rem;
  }
}

/* Image crop / compress */
.mv-crop-field {
  display: grid;
  gap: 0.75rem;
}

.mv-crop-file-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.mv-crop-preview {
  width: 100%;
  max-width: 10.5rem;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.85rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-2);
  display: grid;
  place-items: center;
}

.mv-crop-preview.is-round {
  width: 7.5rem;
  height: 7.5rem;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
}

.mv-crop-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mv-crop-preview-empty {
  color: var(--mv-muted);
  font-size: 0.82rem;
  padding: 0.75rem;
  text-align: center;
}

.mv-crop-pick {
  justify-self: start;
}

.mv-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .mv-crop-modal {
    align-items: center;
    padding: 1.25rem;
  }
}

.mv-crop-modal.hidden,
.mv-crop-modal[hidden] {
  display: none !important;
}

.mv-crop-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: var(--mv-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

.mv-crop-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 34rem);
  max-height: min(92dvh, 44rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 1.35rem 1.35rem 0 0;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-solid);
  box-shadow: var(--mv-shadow);
}

@media (min-width: 640px) {
  .mv-crop-panel {
    border-radius: 1.35rem;
  }
}

.mv-crop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--mv-border);
}

.mv-crop-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

.mv-crop-hint {
  margin: 0.35rem 0 0;
  color: var(--mv-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.mv-crop-stage {
  flex: 1;
  min-height: 16rem;
  max-height: 55dvh;
  background: #0b1220;
  overflow: hidden;
}

.mv-crop-stage img {
  display: block;
  max-width: 100%;
}

.mv-crop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding: 0.9rem 1rem calc(0.9rem + var(--mv-safe-b));
  border-top: 1px solid var(--mv-border);
}

/* Annotation color spans — theme-aware for study + chunk edit */
.mv-c-red { color: var(--mv-c-red) !important; }
.mv-c-rose { color: var(--mv-c-rose) !important; }
.mv-c-orange { color: var(--mv-c-orange) !important; }
.mv-c-amber { color: var(--mv-c-amber) !important; }
.mv-c-yellow { color: var(--mv-c-yellow) !important; }
.mv-c-lime { color: var(--mv-c-lime) !important; }
.mv-c-emerald { color: var(--mv-c-emerald) !important; }
.mv-c-teal { color: var(--mv-c-teal) !important; }
.mv-c-cyan { color: var(--mv-c-cyan) !important; }
.mv-c-sky { color: var(--mv-c-sky) !important; }
.mv-c-blue { color: var(--mv-c-blue) !important; }
.mv-c-indigo { color: var(--mv-c-indigo) !important; }
.mv-c-violet { color: var(--mv-c-violet) !important; }
.mv-c-purple { color: var(--mv-c-purple) !important; }
.mv-c-pink { color: var(--mv-c-pink) !important; }
.mv-c-slate { color: var(--mv-c-slate) !important; }
.mv-c-gray { color: var(--mv-c-gray) !important; }
.mv-c-white { color: var(--mv-c-white) !important; }

/* ——— Study mode ——— */
body.mv-studying .mv-main {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

body.mv-studying .mv-bottom-nav {
  display: none !important;
}

#study-root.is-studying {
  max-width: 42rem;
}

@media (min-width: 768px) {
  #study-root.is-studying {
    max-width: 48rem;
  }
}

@media (min-width: 1024px) {
  #study-root.is-studying {
    max-width: 54rem;
  }
}

#study-root.is-studying .study-topbar {
  margin-bottom: 0.35rem;
}

#study-root.is-studying .study-lesson-title {
  font-size: clamp(0.95rem, 3.6vw, 1.15rem);
}

#study-root .study-card-panel {
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
  color: var(--mv-text);
  border-radius: 1rem;
  padding: 0.7rem 0.75rem 0.55rem;
}

.mv-lesson-study-progress {
  margin-top: 0.45rem;
  max-width: 16rem;
}

.mv-lesson-study-progress__bar {
  height: 0.32rem;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--mv-surface-2, #1e293b) 88%, #0f172a);
}

.mv-lesson-study-progress__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #10b981);
  transition: width 0.25s ease;
}

.mv-lesson-study-progress__meta {
  margin-top: 0.28rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--mv-muted, #94a3b8);
}

.mv-lesson-study-progress__meta .is-done {
  color: #6ee7b7;
}

.mv-lesson-study-progress__meta .is-sep {
  margin-inline: 0.3rem;
  opacity: 0.55;
}

.study-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
  font-size: 0.75rem;
  color: var(--mv-muted);
}

.study-progress-track {
  flex: 1;
  max-width: 12rem;
  height: 0.35rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--mv-surface-2);
}

.study-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--mv-accent);
  transition: width 0.25s ease;
}

.study-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.study-icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--mv-border) 90%, transparent);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--mv-surface-2) 88%, transparent);
  color: var(--mv-text-soft);
  cursor: pointer;
}

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

.study-card-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.study-timer-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  padding: 0.5rem 0.65rem 0.55rem;
  border-radius: 0.75rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-2);
}

.study-timer-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
}

.study-timer-clock {
  min-width: 0;
}

.study-timer-label {
  margin: 0;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mv-muted);
}

.study-timer-value {
  margin: 0.05rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--mv-accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.study-timer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  text-align: start;
}

.study-timer-meta p,
.study-timer-best,
.study-timer-status {
  margin: 0;
}

.study-timer-best,
.study-timer-status {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 1.55rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--mv-border, #334155) 90%, transparent);
  background: color-mix(in srgb, var(--mv-surface-solid, #0f172a) 55%, transparent);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--mv-text-soft, #cbd5e1);
}

.study-timer-best {
  color: color-mix(in srgb, var(--mv-accent, #10b981) 82%, #fff);
  border-color: color-mix(in srgb, var(--mv-accent, #10b981) 28%, transparent);
  background: color-mix(in srgb, var(--mv-accent, #10b981) 12%, transparent);
}

.study-timer-status {
  color: var(--mv-muted, #94a3b8);
}

#study-card-text {
  --study-line-height: 1.55;
  --study-text-pad-b: 1.6rem;
  color: var(--mv-text) !important;
  font-size: 0.98rem;
  line-height: var(--study-line-height) !important;
  min-height: calc((2 * 1em * var(--study-line-height)) + var(--study-text-pad-b));
  max-height: 22vh;
  overflow: auto;
  padding-bottom: var(--study-text-pad-b);
}

@media (min-width: 768px) {
  #study-root .study-card-panel {
    padding: 1.15rem 1.35rem 1rem;
    border-radius: 1.35rem;
  }

  .study-progress-row {
    margin-bottom: 0.7rem;
    font-size: 0.88rem;
  }

  .study-progress-track {
    max-width: 16rem;
    height: 0.45rem;
  }

  .study-timer-row {
    margin-bottom: 0.75rem;
    padding: 0.75rem 0.95rem 0.8rem;
    border-radius: 1rem;
    gap: 0.55rem;
  }

  .study-timer-label {
    font-size: 0.72rem;
  }

  .study-timer-value {
    font-size: 1.55rem;
  }

  .study-timer-best,
  .study-timer-status {
    min-height: 1.7rem;
    padding: 0.28rem 0.7rem;
    font-size: 0.78rem;
  }

  #study-card-text {
    --study-line-height: 1.85;
    --study-text-pad-b: 2.6rem;
    font-size: 1.45rem;
    max-height: none;
    min-height: calc((2.4 * 1em * var(--study-line-height)) + var(--study-text-pad-b));
  }

  .study-media-actions {
    gap: 0.55rem;
    margin-top: 0.75rem;
  }

  .study-btn {
    min-height: 2.55rem;
    border-radius: 0.85rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
  }

  .study-type-block {
    margin-top: 0.85rem;
  }

  .study-type-label {
    font-size: 0.9rem;
  }

  .study-speech-btn {
    min-height: 2.2rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 0.75rem;
  }

  .study-type-input {
    min-height: 4.4rem;
    border-radius: 1rem;
    padding: 0.7rem 0.9rem;
    font-size: 1.05rem;
    line-height: 1.5;
  }

  .study-type-hint {
    margin-top: 0.4rem;
    font-size: 0.78rem;
    -webkit-line-clamp: 2;
  }

  .study-level-block {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    gap: 0.45rem;
  }

  .study-level-title {
    font-size: 0.86rem;
  }

  .study-level-status {
    font-size: 0.8rem;
  }

  .study-levels {
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 0.95rem;
  }

  .study-levels .level-btn {
    min-height: 2.35rem;
    border-radius: 0.7rem;
    font-size: 0.95rem;
  }

  .study-nav-actions {
    gap: 0.65rem;
    margin-top: 0.9rem;
  }
}

@media (min-width: 1024px) {
  #study-root .study-card-panel {
    padding: 1.35rem 1.6rem 1.2rem;
  }

  #study-card-text {
    font-size: 1.6rem;
    --study-line-height: 1.95;
    --study-text-pad-b: 3rem;
  }

  .study-timer-value {
    font-size: 1.75rem;
  }

  .study-btn {
    min-height: 2.7rem;
    font-size: 0.95rem;
  }

  .study-type-input {
    min-height: 5rem;
    font-size: 1.1rem;
  }
}

.study-media-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.study-media-actions.has-reload {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.study-media-actions .study-btn-reload[hidden] {
  display: none !important;
}

.study-btn {
  appearance: none;
  position: relative;
  box-sizing: border-box;
  min-height: 2.15rem;
  max-height: 2.15rem;
  margin: 0;
  border: 0;
  border-radius: 0.7rem;
  padding: 0.4rem 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.study-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* Playing state: spinner overlay, same box as idle Play */
.study-btn.is-media-playing {
  pointer-events: none;
  cursor: wait;
  color: transparent !important;
}

.study-btn.is-media-playing::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 0.9rem;
  height: 0.9rem;
  margin: -0.45rem 0 0 -0.45rem;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--mv-on-accent) 28%, transparent);
  border-top-color: var(--mv-on-accent);
  animation: mv-busy-spin 0.7s linear infinite;
  pointer-events: none;
}

.study-btn-play,
.study-btn-next {
  background: var(--mv-accent);
  color: var(--mv-on-accent);
}

.study-btn-pause {
  background: color-mix(in srgb, var(--mv-warn, #f59e0b) 18%, transparent);
  color: var(--mv-warn, #fbbf24);
}

.study-btn-stop {
  background: color-mix(in srgb, var(--mv-danger, #f43f5e) 16%, transparent);
  color: color-mix(in srgb, var(--mv-danger, #fb7185) 90%, #fff);
}

.study-btn-ghost {
  background: var(--mv-surface-2);
  color: var(--mv-text-soft);
}

.study-type-block {
  margin-top: 0.5rem;
}

.study-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
  padding: 0.22rem;
  border-radius: 0.85rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-2);
}

.study-mode-tabs--top {
  margin-top: 0;
  margin-bottom: 0.65rem;
}

.study-mode-tab {
  appearance: none;
  min-height: 2.05rem;
  margin: 0;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--mv-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.study-mode-tab.is-active {
  background: color-mix(in srgb, var(--mv-accent) 16%, var(--mv-surface-solid, var(--mv-surface)));
  color: var(--mv-accent);
}

.study-type-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.study-type-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mv-text-soft);
}

.study-speech-row {
  display: none;
  margin-bottom: 0.4rem;
}

.study-type-block[data-study-mode="speaking"] .study-speech-row {
  display: flex;
}

.study-type-block[data-study-mode="speaking"] .study-writing-pane {
  display: none;
}

.study-type-block[data-study-mode="writing"] .study-speak-result {
  display: none !important;
}

.study-speech-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 2.45rem;
  border-radius: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--mv-accent, #10b981) 45%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-accent, #10b981) 18%, transparent);
  color: color-mix(in srgb, var(--mv-accent, #10b981) 70%, #fff);
  padding: 0.4rem 0.85rem;
  font-size: 0.84rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.study-speech-btn:hover {
  background: color-mix(in srgb, var(--mv-accent, #10b981) 28%, transparent);
}

.study-speech-btn.is-again {
  border-color: color-mix(in srgb, #38bdf8 42%, var(--mv-border-strong));
  background: color-mix(in srgb, #38bdf8 16%, transparent);
  color: color-mix(in srgb, #7dd3fc 75%, #fff);
}

.study-speech-btn.is-again:hover {
  background: color-mix(in srgb, #38bdf8 26%, transparent);
}

.study-speech-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
}

.study-speech-ico__again {
  display: none;
}

.study-speech-btn.is-again .study-speech-ico__start {
  display: none;
}

.study-speech-btn.is-again .study-speech-ico__again {
  display: block;
}

.study-speech-dot {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: currentColor;
}

.study-type-input {
  width: 100%;
  min-height: 3.1rem;
  border-radius: 0.8rem;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-2);
  color: var(--mv-text);
  padding: 0.45rem 0.65rem;
  font-size: 0.92rem;
  line-height: 1.4;
  outline: none;
  resize: none;
}

.study-type-input:focus {
  border-color: color-mix(in srgb, var(--mv-accent) 55%, var(--mv-border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mv-accent) 22%, transparent);
}

.study-type-hint {
  margin: 0.25rem 0 0;
  font-size: 0.65rem;
  line-height: 1.3;
  color: var(--mv-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.study-nav-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

#study-card-text .study-line {
  display: block;
  margin: 0;
  padding: 0;
}

#study-card-text .study-line + .study-line {
  margin-top: 0.15em;
}

#study-card-text .study-hl-wrap {
  position: relative;
  display: inline;
  margin: 0 0.04rem;
}

#study-card-text mark.study-mark {
  border-radius: 0.3rem;
  /* Horizontal pad only — vertical pad on inline paints without growing the line box */
  padding: 0 0.28rem;
  cursor: pointer;
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  /* Reserve underline space so open/select never shifts line height */
  border-bottom: 2px solid transparent;
  transition: background 0.15s ease, border-bottom-color 0.15s ease;
}

#study-card-text mark.study-mark .study-word-text {
  display: inline;
  white-space: pre-wrap;
}

#study-card-text mark.study-mark.is-hidden {
  background: var(--mv-study-hidden-bg);
  border-bottom: 2px solid var(--mv-study-hidden-line);
  user-select: none;
}

#study-card-text mark.study-mark.is-hidden .study-word-text {
  color: transparent;
  text-shadow: none;
}

#study-card-text mark.study-mark.is-revealed {
  background: var(--mv-study-reveal-bg);
}

#study-card-text mark.study-mark.is-revealed .study-word-text {
  color: var(--mv-study-reveal);
}

#study-card-text mark.study-mark.is-typed {
  background: var(--mv-study-typed-bg);
  border-bottom-color: var(--mv-study-typed-line);
}

#study-card-text mark.study-mark.is-typed .study-word-text {
  color: var(--mv-study-typed);
}

#study-card-text .study-typed-ok {
  color: var(--mv-study-typed);
}

#study-card-text .study-hl-wrap.is-open mark.study-mark {
  outline: none;
  box-shadow: none;
  border-bottom-color: var(--mv-study-open-outline);
}

#study-card-text mark.study-mark:hover {
  filter: brightness(1.04);
}

#study-card-text .study-hl-pop {
  /* Fixed so it is never clipped by the scrollable text box */
  position: fixed;
  left: 0;
  top: 0;
  z-index: 95;
  display: none;
  width: max-content;
  max-width: min(18rem, calc(100vw - 2rem));
  transform: none;
  border-radius: 0.9rem;
  border: 1px solid var(--mv-study-pop-border);
  background: var(--mv-study-pop-bg);
  padding: 0.55rem 0.65rem;
  box-shadow: var(--mv-shadow);
  color: var(--mv-text);
  pointer-events: auto;
}

#study-card-text .study-hl-wrap.is-open .study-hl-pop {
  display: block;
}

#study-card-text .study-hl-pop::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -5px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  border-left: 1px solid var(--mv-study-pop-border);
  border-top: 1px solid var(--mv-study-pop-border);
  background: var(--mv-study-pop-bg);
}

#study-card-text .study-hl-pop.is-above::before {
  top: auto;
  bottom: -5px;
  border-left: 0;
  border-top: 0;
  border-right: 1px solid var(--mv-study-pop-border);
  border-bottom: 1px solid var(--mv-study-pop-border);
}

#study-card-text .study-hl-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
}

#study-card-text .study-hl-actions button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  border-radius: 0.6rem;
  border: 1px solid color-mix(in srgb, var(--mv-border) 85%, transparent);
  background: var(--mv-study-pop-action-bg);
  color: var(--mv-study-pop-action-text);
  padding: 0;
  cursor: pointer;
}

#study-card-text .study-hl-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

#study-card-text .study-hl-meaning {
  position: relative;
  margin-top: 0.45rem;
  border-top: 1px solid var(--mv-border);
  padding-top: 0.4rem;
  min-height: 1.35em;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--mv-study-pop-meaning);
}

#study-card-text .study-hl-meaning.is-empty {
  color: var(--mv-muted);
}

#study-card-text .study-hl-meaning.is-error {
  color: color-mix(in srgb, #fb7185 80%, var(--mv-muted));
}

#study-card-text .study-hl-meaning.is-loading {
  color: var(--mv-muted);
}

#study-card-text .study-hl-meaning.is-loading .study-hl-meaning__text {
  opacity: 0.55;
}

#study-card-text .study-hl-meaning__spin {
  position: absolute;
  inset-inline-end: 0;
  top: 0.45rem;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid color-mix(in srgb, var(--mv-muted) 35%, transparent);
  border-top-color: var(--mv-accent);
  border-radius: 50%;
  animation: mv-busy-spin 0.7s linear infinite;
  pointer-events: none;
}

#study-toggle-meaning.is-meaning-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: wait;
}

#study-toggle-meaning.is-meaning-loading > * {
  opacity: 0;
}

#study-toggle-meaning.is-meaning-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.85rem;
  height: 0.85rem;
  margin: -0.425rem 0 0 -0.425rem;
  border: 2px solid color-mix(in srgb, var(--mv-muted) 35%, transparent);
  border-top-color: var(--mv-accent);
  border-radius: 50%;
  animation: mv-busy-spin 0.7s linear infinite;
  pointer-events: none;
}

.study-level-block {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--mv-border);
}

.study-level-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.study-level-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mv-text-soft);
}

.study-level-status {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--mv-accent);
  text-align: end;
}

.study-levels {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.15rem;
  padding: 0.15rem;
  border-radius: 0.75rem;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-2);
}

.study-levels .level-btn {
  appearance: none;
  min-height: 1.85rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--mv-text-soft);
  font-size: 0.78rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.study-levels .level-btn:hover {
  background: color-mix(in srgb, var(--mv-accent) 12%, transparent);
  color: var(--mv-text);
}

.study-levels .level-btn:active {
  transform: scale(0.96);
}

.study-levels .level-btn.is-active {
  background: var(--mv-accent);
  color: var(--mv-on-accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--mv-accent) 28%, transparent);
}

.study-levels .level-btn.is-suggested:not(.is-active) {
  color: var(--mv-warn);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--mv-warn) 70%, transparent);
  background: var(--mv-warn-soft);
}

.study-level-ends {
  display: none;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--mv-muted);
}

@media (min-width: 640px) {
  .study-level-ends {
    display: flex;
  }
}

#study-speech-btn.is-listening {
  border-color: color-mix(in srgb, var(--mv-danger) 55%, transparent);
  color: var(--mv-danger);
  background: var(--mv-danger-soft);
}

#study-speech-btn.is-listening #study-speech-icon {
  border-radius: 999px;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--mv-danger) 55%, transparent);
  animation: study-mic-pulse 1.2s ease-out infinite;
}

@keyframes study-mic-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mv-danger) 55%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.study-speak-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.study-speak-overlay.is-open,
.study-speak-overlay:not([hidden]) {
  display: flex;
}

.study-speak-overlay[hidden] {
  display: none !important;
}

.study-speak-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--mv-bg) 55%, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.study-speak-overlay__panel {
  position: relative;
  z-index: 1;
  width: min(22rem, 100%);
  text-align: center;
  padding: 1.5rem 1.2rem;
}

.study-speak-overlay__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.study-speak-phase {
  display: none;
}

.study-speak-phase.is-active {
  display: grid;
  gap: 0.85rem;
  justify-items: center;
}

.study-speak-countdown,
.study-speak-go {
  margin: 0;
  font-size: clamp(3rem, 16vw, 4.5rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--mv-accent);
  line-height: 1;
}

.study-speak-phase-hint {
  margin: 0;
  color: var(--mv-text-soft);
  font-size: 0.95rem;
}

.study-speak-ring {
  position: relative;
  width: 7.5rem;
  height: 7.5rem;
  display: grid;
  place-items: center;
}

.study-speak-ring__pulse,
.study-speak-ring__core {
  position: absolute;
  border-radius: 999px;
}

.study-speak-ring__pulse {
  inset: 0;
  border: 2px solid color-mix(in srgb, var(--mv-danger) 55%, transparent);
  animation: study-speak-pulse 1.4s ease-out infinite;
}

.study-speak-ring__core {
  width: 3.4rem;
  height: 3.4rem;
  background: var(--mv-danger);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--mv-danger) 18%, transparent);
}

@keyframes study-speak-pulse {
  0% { transform: scale(0.72); opacity: 0.9; }
  100% { transform: scale(1.15); opacity: 0; }
}

.study-speak-end-btn {
  appearance: none;
  min-height: 2.7rem;
  min-width: 8rem;
  border: 0;
  border-radius: 999px;
  background: var(--mv-accent);
  color: var(--mv-on-accent);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.study-speak-spinner {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 3px solid color-mix(in srgb, var(--mv-accent) 25%, transparent);
  border-top-color: var(--mv-accent);
  animation: study-speak-spin 0.8s linear infinite;
}

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

.study-speak-error {
  margin: 0.45rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--mv-danger) 40%, var(--mv-border));
  background: color-mix(in srgb, var(--mv-danger) 12%, transparent);
  color: color-mix(in srgb, var(--mv-danger) 85%, #fff);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.study-speak-result {
  margin-top: 0.4rem;
  border: 1px solid var(--mv-border);
  border-radius: 0.8rem;
  background: var(--mv-surface-2);
  padding: 0.4rem 0.45rem 0.45rem;
}

.study-speak-result__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}

.study-speak-result__title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--mv-text-soft);
}

.study-speak-help-btn {
  appearance: none;
  width: 1.3rem;
  height: 1.3rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-solid, var(--mv-surface));
  color: var(--mv-muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.study-speak-help-btn:hover,
.study-speak-help-btn:focus-visible {
  color: var(--mv-accent);
  border-color: color-mix(in srgb, var(--mv-accent) 45%, var(--mv-border-strong));
}

.study-speak-help-panel {
  max-width: min(28rem, calc(100vw - 1.5rem));
}

.study-speak-help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.study-speak-help-list li {
  display: grid;
  grid-template-columns: minmax(4.5rem, auto) 1fr;
  gap: 0.65rem;
  align-items: start;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--mv-text-soft);
}

.study-speak-help-sample {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  border-radius: 0.4rem;
  padding: 0.05rem 0.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.study-speak-help-sample.is-ok {
  color: #34d399;
  border-bottom: 2px solid color-mix(in srgb, #34d399 80%, transparent);
}

.study-speak-help-sample.is-near {
  color: #fbbf24;
  border-bottom: 2px solid color-mix(in srgb, #fbbf24 80%, transparent);
}

.study-speak-help-sample.is-bad {
  color: #fb7185;
  border-bottom: 2px solid color-mix(in srgb, #fb7185 80%, transparent);
}

.study-speak-help-sample.is-missing {
  color: #fb7185;
  border-bottom: 2px dashed color-mix(in srgb, #fb7185 85%, transparent);
}

.study-speak-help-sample.is-tap {
  color: var(--mv-text);
  outline: 1px solid color-mix(in srgb, var(--mv-accent) 55%, transparent);
  background: color-mix(in srgb, var(--mv-accent) 10%, transparent);
}

.study-speak-help-sample.is-action {
  border: 1px solid var(--mv-border-strong);
  border-radius: 0.55rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  color: var(--mv-text-soft);
}

.study-speak-help-sample.is-score {
  color: var(--mv-accent);
  font-weight: 800;
}

.study-speak-result__score {
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--mv-accent);
  white-space: nowrap;
}

.study-speak-result__lead {
  display: none;
}

#study-card-text.is-speak-review {
  max-height: min(26vh, 9.5rem);
  overflow: auto;
  overscroll-behavior: contain;
}

@media (min-width: 768px) {
  #study-card-text.is-speak-review {
    max-height: min(34vh, 14rem);
  }
}

.study-speak-inline {
  appearance: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.12rem;
  margin: 0 0.04em;
  padding: 0.02em 0.12em;
  border: 0;
  border-radius: 0.28rem;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  vertical-align: baseline;
  cursor: default;
}

button.study-speak-inline {
  cursor: pointer;
}

.study-speak-inline.is-ok {
  color: #34d399;
  border-bottom-color: color-mix(in srgb, #34d399 80%, transparent);
}

.study-speak-inline.is-near {
  color: #fbbf24;
  border-bottom-color: color-mix(in srgb, #fbbf24 80%, transparent);
  background: color-mix(in srgb, #fbbf24 10%, transparent);
}

.study-speak-inline.is-bad,
.study-speak-inline.is-missing {
  color: #fb7185;
  border-bottom-color: color-mix(in srgb, #fb7185 85%, transparent);
  background: color-mix(in srgb, #fb7185 10%, transparent);
}

.study-speak-inline.is-missing {
  border-bottom-style: dashed;
}

.study-speak-inline.is-selected {
  outline: none;
  border-bottom-color: var(--mv-study-open-outline);
}

.study-speak-inline__mark {
  font-size: 0.68em;
  opacity: 0.9;
  font-weight: 700;
}

#study-card-text.is-speak-review .study-mark.is-speak-review {
  display: inline;
  padding-inline: 0.05em;
}

#study-card-text.is-speak-review .study-mark.is-speak-review .study-speak-inline {
  margin: 0;
}

#study-card-text .study-hl-wrap.is-plain-word .study-word-hit {
  appearance: none;
  display: inline;
  margin: 0;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  padding: 0 0.04em;
  cursor: pointer;
  /* Always 2px so select/hover only recolor — no vertical jump */
  border-bottom: 2px solid transparent;
}

#study-card-text .study-hl-wrap.is-plain-word .study-word-hit:hover {
  border-bottom-color: color-mix(in srgb, var(--mv-muted) 60%, transparent);
  background: transparent;
}

#study-card-text .study-hl-wrap.is-plain-word.is-open .study-word-hit {
  outline: none;
  background: transparent;
  border-bottom-color: var(--mv-study-open-outline);
}

#study-card-text .study-hl-wrap.is-plain-word .study-word-hit--speak {
  display: inline;
}

.study-speak-heard {
  display: block;
  margin: 0 0 0.35rem;
  padding: 0.3rem 0.4rem;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--mv-surface-2) 80%, transparent);
  border: 1px solid var(--mv-border);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--mv-text-soft);
  white-space: normal;
}

#study-card-text .study-hl-pop .study-speak-heard + .study-hl-actions {
  margin-top: 0.15rem;
}

.study-speak-result__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.study-speak-action-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  min-width: 0;
  min-height: 2.05rem;
  border-radius: 0.65rem;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-2);
  color: var(--mv-text-soft);
  padding: 0.28rem 0.4rem;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.study-speak-action-ico {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.4rem;
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.study-speak-action-title {
  min-width: 0;
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1.15;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-speak-action-hint {
  display: none;
}

/* Model card = main reference */
.study-speak-action-btn.is-play-card {
  border-color: color-mix(in srgb, var(--mv-accent) 45%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-accent) 16%, transparent);
  color: color-mix(in srgb, var(--mv-accent-bright, #5eead4) 55%, #fff);
}

.study-speak-action-btn.is-play-card .study-speak-action-ico {
  background: color-mix(in srgb, var(--mv-accent) 22%, transparent);
  color: var(--mv-accent-bright, #5eead4);
}

/* Slow practice = careful listen */
.study-speak-action-btn.is-play-slow {
  border-color: color-mix(in srgb, var(--mv-warn) 42%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-warn) 12%, var(--mv-surface-2));
  color: color-mix(in srgb, var(--mv-warn) 72%, #fff);
}

.study-speak-action-btn.is-play-slow .study-speak-action-ico {
  background: var(--mv-warn-soft);
  color: var(--mv-warn);
}

/* Own voice = personal compare */
.study-speak-action-btn.is-play-mine {
  border-color: color-mix(in srgb, #38bdf8 40%, var(--mv-border-strong));
  background: color-mix(in srgb, #38bdf8 12%, var(--mv-surface-2));
  color: color-mix(in srgb, #7dd3fc 78%, #fff);
}

.study-speak-action-btn.is-play-mine .study-speak-action-ico {
  background: color-mix(in srgb, #38bdf8 16%, transparent);
  color: #7dd3fc;
}

/* Affirm word = success action */
.study-speak-action-btn.is-mark-right {
  border-color: color-mix(in srgb, #34d399 48%, var(--mv-border-strong));
  background: color-mix(in srgb, #34d399 14%, var(--mv-surface-2));
  color: color-mix(in srgb, #6ee7b7 80%, #fff);
}

.study-speak-action-btn.is-mark-right .study-speak-action-ico {
  background: color-mix(in srgb, #34d399 18%, transparent);
  color: #6ee7b7;
}

.study-speak-action-btn.is-mark-right:not(:disabled) {
  background: color-mix(in srgb, #34d399 22%, transparent);
}

.study-speak-action-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

html[data-theme="light"] .study-speak-action-btn.is-play-card {
  color: var(--mv-accent-deep, #0f766e);
}

html[data-theme="light"] .study-speak-action-btn.is-play-slow {
  color: var(--mv-warn, #b45309);
}

html[data-theme="light"] .study-speak-action-btn.is-play-mine {
  color: #0369a1;
}

html[data-theme="light"] .study-speak-action-btn.is-play-mine .study-speak-action-ico {
  color: #0284c7;
}

html[data-theme="light"] .study-speak-action-btn.is-mark-right {
  color: #047857;
}

html[data-theme="light"] .study-speak-action-btn.is-mark-right .study-speak-action-ico {
  color: #059669;
}

@media (min-width: 768px) {
  .study-speak-result {
    padding: 0.55rem 0.65rem 0.6rem;
  }

  .study-speak-result__actions {
    gap: 0.4rem;
    margin-top: 0.45rem;
  }

  .study-speak-action-btn {
    min-height: 2.35rem;
    padding: 0.35rem 0.55rem;
  }

  .study-speak-action-title {
    font-size: 0.74rem;
  }

  .study-speak-word-detail {
    font-size: 0.74rem;
  }
}

.study-speak-shadow {
  margin-top: 0.55rem;
  padding: 0.55rem 0.6rem;
  border-radius: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--mv-warn) 35%, var(--mv-border));
  background: color-mix(in srgb, var(--mv-warn) 10%, transparent);
}

.study-speak-shadow__text {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--mv-text-soft);
  line-height: 1.4;
}

.study-speak-retry {
  margin-top: 0.45rem;
}

@media (max-width: 767px) {
  .study-speak-overlay__backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: color-mix(in srgb, var(--mv-bg) 88%, #000);
  }
}

.study-setup {
  padding: 0.85rem 0.85rem 5.75rem;
}

@media (min-width: 768px) {
  .study-setup {
    padding: 1.35rem 1.5rem 1.5rem;
  }
}

.study-setup-title {
  font-size: 1.15rem !important;
}

.study-setup-lead {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--mv-muted);
}

.study-setup-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.study-setup-stat {
  border-radius: 0.85rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-2);
  padding: 0.55rem 0.7rem;
}

.study-setup-stat-label {
  margin: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mv-muted);
}

.study-setup-stat-value {
  margin: 0.15rem 0 0;
  font-size: 1.45rem;
  font-weight: 750;
  color: var(--mv-text);
  line-height: 1.1;
}

.study-setup-stat-value.is-accent {
  color: var(--mv-accent);
}

.study-setup-levels {
  margin-top: 0.8rem;
}

.study-setup-levels-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.study-setup-section-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--mv-text-soft);
}

.study-setup-level-tools {
  display: flex;
  gap: 0.3rem;
}

.study-setup-mini-btn {
  appearance: none;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-2);
  color: var(--mv-text-soft);
  border-radius: 0.65rem;
  min-height: 1.85rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 650;
  cursor: pointer;
}

.study-setup-mini-btn.is-save {
  border-color: color-mix(in srgb, var(--mv-accent) 35%, var(--mv-border));
}

.study-setup-settings {
  margin-top: 0.75rem;
  border-radius: 0.9rem;
  border: 1px solid var(--mv-border);
  background: var(--mv-surface-2);
  overflow: hidden;
}

.study-setup-settings-summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 2.1rem 0.7rem 0.8rem;
  user-select: none;
}

.study-setup-settings-summary::-webkit-details-marker {
  display: none;
}

.study-setup-settings-summary > span:first-child {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--mv-text);
}

.study-setup-settings-hint {
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--mv-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.study-setup-settings-summary::after {
  content: "+";
  position: absolute;
  top: 0.7rem;
  inset-inline-end: 0.85rem;
  color: var(--mv-muted);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.study-setup-settings[open] .study-setup-settings-summary::after {
  content: "–";
}

.study-setup-settings-body {
  display: grid;
  gap: 0.45rem;
  padding: 0 0.7rem 0.75rem;
  border-top: 1px solid var(--mv-border);
  padding-top: 0.65rem;
}

.study-setup-setting-card {
  display: block;
  border-radius: 0.75rem;
  border: 1px solid var(--mv-border);
  background: color-mix(in srgb, var(--mv-surface) 70%, transparent);
  padding: 0.55rem 0.65rem;
}

.study-setup-speed-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.4rem;
}

.study-setup-speed-label {
  width: 2.8rem;
  text-align: end;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--mv-accent);
}

.study-setup-autoplay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.study-setup-autoplay-help {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--mv-text-soft);
}

.study-setup-settings-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.study-setup-settings-status {
  margin: 0;
  font-size: 0.68rem;
  color: var(--mv-muted);
}

.study-setup-actions {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--mv-study-sticky-border);
  background: var(--mv-study-sticky-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.study-setup-start-btn {
  appearance: none;
  border: 0;
  border-radius: 0.85rem;
  min-height: 2.7rem;
  padding: 0.55rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
}

.study-setup-start-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.study-setup-start-btn.is-primary {
  background: var(--mv-accent);
  color: var(--mv-on-accent);
}

.study-setup-start-btn.is-secondary {
  background: color-mix(in srgb, var(--mv-accent) 16%, transparent);
  color: var(--mv-accent);
  border: 1px solid color-mix(in srgb, var(--mv-accent) 40%, transparent);
}

@media (min-width: 768px) {
  .study-setup-actions {
    position: static;
    inset: auto;
    margin-top: 1rem;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: flex;
    flex-wrap: wrap;
  }

  .study-setup-start-btn {
    min-width: 11rem;
    font-size: 0.88rem;
    padding-inline: 1rem;
  }

  .study-setup-settings-hint {
    -webkit-line-clamp: 2;
  }
}

.setup-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

@media (min-width: 640px) {
  .setup-level-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.45rem;
  }
}

.setup-level-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-height: 3.1rem;
  margin: 0;
  padding: 0.4rem 0.25rem;
  border-radius: 0.8rem;
  border: 1px solid var(--mv-border-strong);
  background: var(--mv-surface-2);
  color: var(--mv-text-soft);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.setup-level-chip .setup-level-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.setup-level-chip-label {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.setup-level-chip-count {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--mv-muted);
  font-variant-numeric: tabular-nums;
}

.setup-level-chip.is-checked {
  border-color: color-mix(in srgb, var(--mv-accent) 55%, var(--mv-border));
  background: color-mix(in srgb, var(--mv-accent) 16%, transparent);
  color: var(--mv-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mv-accent) 18%, transparent);
}

.setup-level-chip.is-checked .setup-level-chip-count {
  color: color-mix(in srgb, var(--mv-accent) 80%, var(--mv-text));
}

.setup-level-chip.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.setup-level-chip:not(.is-disabled):hover {
  border-color: color-mix(in srgb, var(--mv-accent) 35%, var(--mv-border));
}

.setup-level-row.is-disabled {
  opacity: 0.45;
}

.study-lesson-title {
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  line-height: 1.25;
}

.study-exit-btn {
  min-height: 2.4rem;
  padding-inline: 0.85rem;
  white-space: nowrap;
}

.study-result-toast,
.study-meaning-toast {
  position: fixed;
  inset-inline: 0.85rem;
  top: calc(var(--mv-header-h) + var(--mv-safe-t) + 0.65rem);
  z-index: 70;
  width: auto;
  max-width: min(28rem, calc(100vw - 1.7rem));
  margin-inline: auto;
  pointer-events: auto;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--mv-accent) 40%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-surface-solid) 92%, var(--mv-accent-soft));
  color: var(--mv-text);
  box-shadow: var(--mv-shadow);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  transform: translateY(-0.5rem);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.study-result-toast.is-visible,
.study-meaning-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.study-result-toast.hidden,
.study-meaning-toast.hidden {
  display: none !important;
}

.study-meaning-toast {
  z-index: 71;
  max-height: min(40vh, 16rem);
  overflow-y: auto;
  white-space: pre-wrap;
}

#study-result-compare {
  color: var(--mv-text-soft) !important;
}

.study-level-gate-levels {
  margin-top: 0.9rem;
}

.study-level-gate-ends {
  margin-top: 0.35rem;
}

.study-level-gate-actions {
  margin-top: 1rem;
}

@media (max-width: 767px) {
  #study-card-text .study-hl-actions button {
    width: 1.9rem;
    height: 1.9rem;
  }

  #study-root {
    max-width: 100%;
  }

  body.mv-studying .mv-header {
    min-height: 0;
  }

  body.mv-studying .mv-brand-sub {
    display: none;
  }

  @media (max-height: 760px) {
    #study-card-text {
      max-height: 18vh;
      --study-text-pad-b: 1.25rem;
      font-size: 0.92rem;
    }

    .study-type-hint {
      display: none;
    }

    .study-timer-row {
      padding: 0.35rem 0.55rem;
    }

    .study-type-input {
      min-height: 2.6rem;
      font-size: 16px;
    }
  }
}

/* Floating study video window (PiP-style) */
.study-video-dock {
  --dock-w: min(92vw, 22rem);
  --dock-h: 12.5rem;
  position: fixed;
  /* Default: physical bottom-right before JS places it */
  right: 12px;
  bottom: 18px;
  left: auto;
  top: auto;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: var(--dock-w);
  contain: layout paint;
  transform: translateZ(0);
  height: var(--dock-h);
  min-width: 9.5rem;
  min-height: 6.5rem;
  max-width: min(96vw, 40rem);
  max-height: min(70vh, 28rem);
  border-radius: 0.95rem;
  border: 1px solid color-mix(in srgb, var(--mv-accent) 28%, var(--mv-border-strong));
  background: color-mix(in srgb, var(--mv-surface-solid, #0f172a) 94%, #000);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.study-video-dock.is-hidden,
.study-video-dock[hidden] {
  display: none !important;
}

.study-video-dock.is-minimized {
  height: auto !important;
  min-height: 0;
  max-height: none;
}

.study-video-dock.is-minimized .study-video-dock__body,
.study-video-dock.is-minimized .study-video-dock__resize,
.study-video-dock.is-minimized .study-video-dock__hint {
  display: none;
}

.study-video-dock__chrome {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.15rem;
  padding: 0.3rem 0.4rem 0.3rem 0.55rem;
  cursor: grab;
  background: color-mix(in srgb, var(--mv-surface-2, #1e293b) 88%, transparent);
  border-bottom: 1px solid var(--mv-border, rgba(148, 163, 184, 0.2));
}

.study-video-dock.is-dragging .study-video-dock__chrome {
  cursor: grabbing;
}

.study-video-dock__grab {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0.2rem;
  background:
    radial-gradient(circle, var(--mv-muted, #94a3b8) 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.study-video-dock__title {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--mv-text-soft, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-video-dock__tools {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.study-video-dock__btn {
  appearance: none;
  min-width: 1.7rem;
  min-height: 1.7rem;
  margin: 0;
  padding: 0 0.35rem;
  border: 0;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--mv-accent) 14%, transparent);
  color: var(--mv-text, #e2e8f0);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.study-video-dock__btn:hover {
  background: color-mix(in srgb, var(--mv-accent) 28%, transparent);
}

.study-video-dock__btn.is-active {
  background: var(--mv-accent);
  color: var(--mv-on-accent, #041016);
}

.study-video-dock__body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  cursor: pointer;
}

.study-video-dock__player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  pointer-events: none;
}

.study-settings-panel {
  max-width: 28rem;
}

.study-settings-modal .study-setup-settings-body {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 0;
}

.study-video-dock__resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1.15rem;
  height: 1.15rem;
  cursor: nwse-resize;
  background:
    linear-gradient(
      135deg,
      transparent 46%,
      color-mix(in srgb, var(--mv-accent) 70%, #fff) 48%,
      transparent 52%,
      transparent 62%,
      color-mix(in srgb, var(--mv-accent) 70%, #fff) 64%,
      transparent 68%
    );
  opacity: 0.85;
}

[dir="rtl"] .study-video-dock__resize {
  right: auto;
  left: 0;
  cursor: nesw-resize;
  transform: scaleX(-1);
}

.study-video-dock__hint {
  margin: 0;
  padding: 0.2rem 0.55rem 0.35rem;
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--mv-muted, #94a3b8);
  background: color-mix(in srgb, var(--mv-surface-2, #1e293b) 90%, transparent);
}

@media (max-width: 639px) {
  .study-video-dock {
    --dock-w: min(88vw, 18rem);
    --dock-h: 10.5rem;
    min-width: 8.5rem;
    min-height: 5.75rem;
  }

  .study-video-dock__hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
