/* Mimivo 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 {
  scromv-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}

body.mv-body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  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;
}

/* Avoid iOS zoom-on-focus; keep tap targets comfortable on phones */
@media (max-width: 767px) {
  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }

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

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: 100dvh;
  display: flex;
  flex-direction: column;
}

.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: linear-gradient(145deg, var(--mv-accent-bright), var(--mv-accent-deep));
  color: var(--mv-on-accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--mv-accent) 28%, transparent);
  flex-shrink: 0;
}

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

.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,
  .mv-messages {
    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 {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
}

.mv-toast {
  border: 1px solid color-mix(in srgb, var(--mv-accent) 35%, var(--mv-border));
  background: var(--mv-accent-soft);
  color: var(--mv-text);
  border-radius: var(--mv-radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  animation: mv-rise 0.35s ease both;
}

.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-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;
}

@media (max-width: 480px) {
  .mv-search {
    flex-wrap: wrap;
  }

  .mv-search input[type="search"] {
    flex: 1 1 100%;
    min-width: 0;
  }

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

  .mv-page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .mv-course-thumb {
    width: 4.75rem;
    min-height: 5.5rem;
  }

  .mv-course-row-body {
    padding: 0.7rem 0.75rem;
  }

  .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: space-between;
  gap: 0.65rem;
  padding: 0.8rem 0.85rem;
}

/* 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.25rem, 26vw, 7.25rem);
  min-height: 6.75rem;
  align-self: stretch;
  flex-shrink: 0;
  border-radius: 0;
}

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

.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: 1rem;
}

.mv-account-hero {
  margin-bottom: 0.25rem;
}

.mv-account-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
  padding: 1rem 1.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);
}

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

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

.mv-account-identity-link {
  min-height: 2.35rem;
  padding-inline: 0.9rem;
}

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

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

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

.mv-account-panel-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-account-profile-grid {
  display: grid;
  gap: 1.15rem;
}

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

.mv-account-photo {
  display: grid;
  gap: 0.55rem;
  justify-items: start;
}

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

.mv-account-photo .mv-crop-field {
  justify-items: start;
}

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

.mv-account-fields,
.mv-account-prefs-grid {
  display: grid;
  gap: 1rem;
}

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

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

.mv-account-field {
  display: grid;
  gap: 0.45rem;
}

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

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

.mv-account-error {
  margin: 0;
  font-size: 0.82rem;
  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: 1rem 0 0;
  padding: 0.85rem 1rem;
  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.78rem;
  line-height: 1.5;
}

.mv-account-save {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  position: sticky;
  bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  padding: 0.75rem;
  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 {
  flex: 1 1 auto;
}

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

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

/* 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;
}

/* 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%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 1rem;
  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 ——— */
#study-root .study-card-panel {
  border-color: var(--mv-border-strong);
  background: var(--mv-surface);
  box-shadow: var(--mv-shadow);
  color: var(--mv-text);
}

#study-card-text {
  --study-line-height: 1.95;
  --study-text-pad-b: 3rem;
  color: var(--mv-text) !important;
  font-size: 1.05rem;
  /* Must beat Tailwind text-* line-height; keeps highlight boxes from touching */
  line-height: var(--study-line-height) !important;
  /* Reserve 3 lines so short cards don't collapse the layout / jump scroll */
  min-height: calc((3 * 1em * var(--study-line-height)) + var(--study-text-pad-b));
  padding-bottom: var(--study-text-pad-b);
  overflow: visible;
}

@media (min-width: 640px) {
  #study-card-text {
    --study-line-height: 2.05;
    --study-text-pad-b: 4rem;
    font-size: 1.5rem;
  }
}

#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;
  transition: background 0.15s ease, outline 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: 1px solid var(--mv-study-open-outline);
  background: var(--mv-study-open-bg);
}

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

#study-card-text .study-hl-pop {
  position: absolute;
  left: 50%;
  top: calc(100% + 0.45rem);
  z-index: 30;
  display: none;
  width: max-content;
  max-width: min(18rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  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);
}

#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: -6px;
  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-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#study-card-text .study-hl-actions button {
  border-radius: 0.55rem;
  border: 0;
  background: var(--mv-study-pop-action-bg);
  color: var(--mv-study-pop-action-text);
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

#study-card-text .study-hl-actions button:hover:not(:disabled) {
  filter: brightness(0.96);
}

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

#study-card-text .study-hl-meaning {
  margin-top: 0.45rem;
  border-top: 1px solid var(--mv-border);
  padding-top: 0.4rem;
  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-level-block {
  display: grid;
  gap: 0.55rem;
}

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

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

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

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

.study-levels .level-btn {
  appearance: none;
  min-height: 2.35rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.72rem;
  background: transparent;
  color: var(--mv-text-soft);
  font-size: 0.88rem;
  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: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.68rem;
  line-height: 1.3;
  color: var(--mv-muted);
}

#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 {
  background: var(--mv-danger);
  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; }
}

.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-result-suggest {
  color: var(--mv-warn) !important;
}

@media (max-width: 767px) {
  #study-session .study-nav-actions {
    position: sticky;
    bottom: 0;
    z-index: 25;
    margin-inline: -1rem;
    margin-bottom: -1rem;
    padding: 0.75rem 1rem calc(0.75rem + 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-card-panel {
    padding-bottom: 0.25rem;
  }

  #study-card-text .study-hl-actions button {
    min-height: 2.25rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
  }
}

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