/* NihongoKu — Japanese Pocket Textbook + Hinomaru Stamp
   Mobile-first (360-430px) & Desktop Adaptive App Shell (>=900px) */

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --soft: #f1f5f9;
  --ink: #0f172a;
  --mut: #475569;
  --line: #e2e8f0;
  --ai: #1e3a8a;
  --ai-hover: #1e40af;
  --ai-soft: rgba(37, 99, 235, 0.1);
  --red: #2563eb;
  --red-hover: #1d4ed8;
  --red-soft: rgba(37, 99, 235, 0.1);
  --cyan: #0891b2;
  --cyan-soft: rgba(6, 182, 212, 0.12);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, 0.1);
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --tabbar-h: 64px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --soft: #1e293b;
  --ink: #f1f5f9;
  --mut: #94a3b8;
  --line: #273449;
  --ai: #1e3a8a;
  --ai-hover: #2563eb;
  --ai-soft: rgba(96, 165, 250, 0.16);
  --red: #3b82f6;
  --red-hover: #2563eb;
  --red-soft: rgba(59, 130, 246, 0.18);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.16);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, 0.16);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }

*, *::before, *::after { box-sizing: border-box; min-width: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  overflow-x: clip;
}

.jp { font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif; }
body.hide-furigana .furi, body.hide-furigana rt { opacity: 0; visibility: hidden; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

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

/* Shell Layout: Mobile-first */
.app-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* Mobile Top Header (Light-First Selective Glassmorphism) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  color: var(--ink);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 8px;
}
:root[data-theme="dark"] .topbar {
  background: rgba(17, 24, 39, 0.78);
  border-bottom-color: rgba(39, 52, 73, 0.85);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 800 18px/1 "M PLUS Rounded 1c", sans-serif;
  white-space: nowrap;
}
.sun-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px #fff;
  flex: none;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 700;
}
.icon-btn:hover { background: var(--line); }
.card-hero .icon-btn, .motion-stage .icon-btn, .lp-hero .icon-btn {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.card-hero .icon-btn:hover, .motion-stage .icon-btn:hover, .lp-hero .icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--ai-soft);
  color: var(--ai);
  white-space: nowrap;
}
:root[data-theme="dark"] .badge { color: #a9ccf5; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.inv { background: rgba(255, 255, 255, 0.18); color: #fff; }
.badge.inv-red { background: var(--red); color: #fff; }

/* Desktop Left Sidebar (hidden on mobile) */
.sidebar { display: none; }

/* Main Content Area */
.main-area {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 14px calc(var(--tabbar-h) + 28px);
}

/* Mobile Bottom Tab Bar (Selective Glassmorphism) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: var(--tabbar-h);
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom, 0);
}
:root[data-theme="dark"] .tabbar {
  background: rgba(17, 24, 39, 0.82);
  border-top-color: rgba(39, 52, 73, 0.85);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--mut);
  min-height: 48px;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--red); }

/* Desktop Adaptive Shell (>= 900px) & Collapsible Sidebar (>= 1024px, P1.3) */
@media (min-width: 900px) {
  .topbar { display: none; }
  .tabbar { display: none; }
  .app-shell {
    flex-direction: row;
    align-items: stretch;
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100svh;
    padding: 18px 14px;
    gap: 14px;
    overflow-y: auto;
    transition: width 0.2s ease, padding 0.2s ease;
  }
  .sidebar-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .sidebar-toggle {
    display: none;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--soft);
    color: var(--ink);
    align-items: center;
    justify-content: center;
    flex: none;
  }
  .sidebar-toggle:hover { background: var(--line); }
  .sidebar-logo-icon { display: none; width: 32px; height: 32px; border-radius: 8px; }
  .sidebar-brand {
    display: flex;
    align-items: center;
    padding: 4px 2px;
  }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    font-weight: 600;
    color: var(--mut);
    min-height: 44px;
    white-space: nowrap;
  }
  .sidebar-nav a svg { width: 20px; height: 20px; flex: none; }
  .sidebar-nav a:hover { background: var(--soft); color: var(--ink); }
  .sidebar-nav a[aria-current="page"] {
    background: var(--red-soft);
    color: var(--red);
  }
  .sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .main-area {
    padding: 28px 32px 48px;
    flex: 1;
    max-width: 1120px;
  }
}

@media (min-width: 1024px) {
  .sidebar-toggle { display: inline-flex; }
  html.sidebar-collapsed .sidebar {
    width: 72px;
    padding: 18px 10px;
    align-items: center;
  }
  html.sidebar-collapsed .sidebar-top-row { flex-direction: column; gap: 10px; }
  html.sidebar-collapsed .sidebar-logo-full,
  html.sidebar-collapsed .sb-text,
  html.sidebar-collapsed .sidebar-user-meta,
  html.sidebar-collapsed .sidebar-footer-links { display: none !important; }
  html.sidebar-collapsed .sidebar-logo-icon { display: block; }
  html.sidebar-collapsed .sidebar-nav { width: 100%; align-items: center; }
  html.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px;
    width: 46px;
  }
  html.sidebar-collapsed .sidebar-footer { width: 100%; align-items: center; }
  html.sidebar-collapsed .sidebar-footer .flex-gap { flex-direction: column; width: 100%; align-items: center; }
  html.sidebar-collapsed .sidebar-footer .btn { width: 44px; padding: 0; min-height: 40px; }
}

/* Typography & Layout Utilities */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.h1 { font: 800 clamp(24px, 3vw, 32px)/1.18 "M PLUS Rounded 1c", sans-serif; margin: 0; }
.h2 { font: 800 19px/1.25 "M PLUS Rounded 1c", sans-serif; margin: 0 0 6px; }
.h3 { font: 700 16px/1.3 "M PLUS Rounded 1c", sans-serif; margin: 0 0 4px; }
.mut { color: var(--mut); font-size: 14px; }
.small { font-size: 13px; color: var(--mut); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-hero {
  background: var(--ai);
  color: #fff;
  border: 0;
  position: relative;
  overflow: hidden;
}
.card-hero .mut { color: #cddbf0; }
.card-hero .bg-kanji {
  position: absolute;
  right: -4px;
  bottom: -24px;
  font: 800 128px/1 "M PLUS Rounded 1c", sans-serif;
  color: rgba(255, 255, 255, 0.08);
  pointer-events: none;
  user-select: none;
}
.card-hero > *:not(.bg-kanji) { position: relative; z-index: 1; }

/* Buttons & Inputs (min 44px touch target, 16px input font) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 0;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}
.btn:hover { background: var(--red-hover); }
.btn.block { width: 100%; }
.btn.ai { background: var(--ai); color: #fff; }
.btn.ai:hover { background: var(--ai-hover); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.sec {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.sec:hover { background: var(--soft); }
.btn.partner {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1.5px solid rgba(245, 158, 11, 0.48);
}
.btn.partner:hover { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .btn.partner {
  background: rgba(245, 158, 11, 0.16);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.45);
}
.btn.partner-hero {
  background: rgba(251, 191, 36, 0.18);
  color: #fef3c7;
  border: 1.5px solid rgba(251, 191, 36, 0.58);
}
.btn.partner-hero:hover { background: rgba(251, 191, 36, 0.28); }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.inp, .sel, .txt {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.txt { min-height: 92px; resize: vertical; }

/* Alerts & Banners */
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert.err { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.alert.info { background: var(--ai-soft); color: var(--ink); border-color: var(--line); }

/* Track Switcher Pills */
.track-pills {
  display: inline-flex;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  flex-wrap: wrap;
}
.track-pills button, .track-pills a {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--mut);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.track-pills .active {
  background: var(--surface);
  color: var(--ai);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
:root[data-theme="dark"] .track-pills .active { color: #fff; }

/* Stats Strip */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.stat-box {
  background: var(--soft);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.stat-box b { display: block; font: 800 22px/1.15 "M PLUS Rounded 1c", sans-serif; }
.stat-box span { font-size: 12px; color: var(--mut); }

/* Module List Row */
.mod-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.mod-row:first-child { border-top: 0; padding-top: 4px; }
.mod-ic {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font: 800 22px "M PLUS Rounded 1c", sans-serif;
  background: var(--ai-soft);
  color: var(--ai);
}
:root[data-theme="dark"] .mod-ic { color: #a9ccf5; }

/* Progress Bar */
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ai); border-radius: 99px; transition: width 0.25s; }
:root[data-theme="dark"] .bar > i { background: #6da5ea; }

/* Kana Interactive Grid */
.kana-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.kana-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 4px;
  text-align: center;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.kana-cell:hover { border-color: var(--red); background: var(--red-soft); }
.kana-cell .ch { font: 800 26px/1.1 "M PLUS Rounded 1c", sans-serif; }
.kana-cell .rm { font-size: 12px; color: var(--mut); font-weight: 600; }
.kana-cell.empty { visibility: hidden; pointer-events: none; }

/* Quiz & Test Prompt */
.q-prompt {
  font: 800 clamp(40px, 10vw, 64px)/1.15 "M PLUS Rounded 1c", sans-serif;
  text-align: center;
  margin: 14px 0 8px;
}
.opts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.opt-btn {
  min-height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  padding: 10px;
}
.opt-btn:hover:not(:disabled) { border-color: var(--ai); background: var(--ai-soft); }
.opt-btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt-btn.no { background: #dc2626; color: #fff; border-color: #dc2626; }

/* Hanko Stamp Animation (one meaningful animation) */
@keyframes hankoStamp {
  0% { opacity: 0; transform: scale(1.6) rotate(-14deg); }
  100% { opacity: 1; transform: scale(1) rotate(-8deg); }
}
.hanko {
  display: inline-grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 4px solid var(--red);
  color: var(--red);
  font: 800 22px/1 "M PLUS Rounded 1c", sans-serif;
  letter-spacing: 0.04em;
  transform: rotate(-8deg);
  animation: hankoStamp 0.35s ease-out both;
}

/* Flashcard */
.flashcard {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 28px 18px;
  text-align: center;
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.flashcard:hover { border-color: var(--ai); }

/* Tables (Responsive scroll wrapper for Admin) */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--mut); background: var(--soft); }

/* Toast (High-contrast opaque in dark & light mode, P3.1) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%) translateY(14px);
  background: rgba(15, 23, 42, 0.96);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}
:root[data-theme="dark"] .toast {
  background: rgba(30, 41, 59, 0.97);
  border-color: rgba(148, 163, 184, 0.35);
}
@media (min-width: 768px) {
  .track-map-wrap {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
  }
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Horizontal Scroll Tabs (Kanji Batches, SSW Fields, Mensetsu, Admin) */
.admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 8px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}
.admin-tabs a {
  flex: none;
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  color: var(--mut);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.admin-tabs a.active {
  background: var(--ai);
  color: #fff;
  border-color: var(--ai);
}

/* Speak Button (min 44x44 touch target, P3.8) */
.spk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.spk-btn:hover { border-color: var(--ai); background: var(--ai-soft); }
.page-head a.small, .card a.small {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}

/* Avatar + Premium Crown Ring (Section 2) */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 2px;
  background: var(--line);
  flex: none;
}
.avatar-wrap.is-premium {
  background: linear-gradient(135deg, #f59e0b, #eab308, #2563eb);
  padding: 2.5px;
}
.avatar-img, .avatar-init {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--ai);
  color: #fff;
  font: 800 13px/1 "Plus Jakarta Sans", sans-serif;
  border: 2px solid var(--surface);
}
.avatar-lg .avatar-img, .avatar-lg .avatar-init {
  width: 74px;
  height: 74px;
  font-size: 24px;
}
.avatar-crown {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
}
.avatar-lg .avatar-crown { width: 24px; height: 24px; }
.premium-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  font-size: 12px;
  font-weight: 800;
}
:root[data-theme="dark"] .premium-pill { color: #fcd34d; }

/* Selective Glassmorphism Modal (Validity Popup, Progress Breakdown, Soft Cert Popup) */
.glass-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 42, 0.48);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.glass-backdrop.open { display: flex; }
.glass-modal {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 24px 48px -16px rgba(15, 23, 42, 0.35);
  max-height: 86svh;
  overflow-y: auto;
}
:root[data-theme="dark"] .glass-modal {
  background: rgba(17, 24, 39, 0.9);
  border-color: rgba(255, 255, 255, 0.14);
}

/* Bookmark (☆) & Mastered (✓) Buttons */
.star-btn, .master-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--mut);
  font-size: 13px;
  font-weight: 700;
}
.star-btn.on { color: #d97706; border-color: #f59e0b; background: rgba(245, 158, 11, 0.12); }
.master-btn.on { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }

