/* My Education — Editorial Personal Study Studio
 * Warm tactile surfaces, user-selectable accent palettes, custom select popovers,
 * full-bleed responsive Focus Mode, and strict CSP compliance (zero inline styles).
 */
:root {
  --bg: #f7f6f2;
  --bg-2: #efede7;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --sidebar-bg: #f2f1ec;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --line: #e4e2dc;
  --line-strong: #d4d1c8;

  /* Default Theme: Forest (Xanh rêu) */
  --accent: #16654e;
  --accent-d: #114f3d;
  --accent-soft: #e8f3ef;
  --accent-border: #b8dccf;

  --amber: #b45309;
  --amber-soft: #fef5e7;
  --amber-border: #f5d6a7;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --red-border: #fecaca;
  --ok: #15803d;
  --ok-soft: #ecfdf3;

  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 4px 16px rgba(24, 24, 27, 0.05);
  --shadow-lg: 0 16px 40px rgba(24, 24, 27, 0.12);
  --r: 14px;
  --r-sm: 10px;
}

/* User-Selectable Color Palettes (like CT UAV) */
body[data-accent="ocean"] {
  --bg: #f6f8fb;
  --bg-2: #edf1f7;
  --sidebar-bg: #eff3f8;
  --line: #e1e6ef;
  --line-strong: #cbd3e0;
  --accent: #1d4ed8;
  --accent-d: #1e40af;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
}
body[data-accent="terracotta"] {
  --bg: #faf7f4;
  --bg-2: #f1ebe4;
  --sidebar-bg: #f4efe9;
  --line: #e7dfd6;
  --line-strong: #d6cabd;
  --accent: #b45309;
  --accent-d: #92400e;
  --accent-soft: #fef3e6;
  --accent-border: #f4cfa3;
}
body[data-accent="teal"] {
  --bg: #f5f9f9;
  --bg-2: #eaf2f2;
  --sidebar-bg: #edf4f4;
  --line: #dce8e8;
  --line-strong: #c4d8d8;
  --accent: #0f766e;
  --accent-d: #115e59;
  --accent-soft: #e6f6f5;
  --accent-border: #a7dfd9;
}
body[data-accent="graphite"] {
  --bg: #f8f8f8;
  --bg-2: #efefef;
  --sidebar-bg: #f2f2f2;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #27272a;
  --accent-d: #09090b;
  --accent-soft: #f0f0f2;
  --accent-border: #d4d4d8;
}
body[data-accent="crimson"] {
  --bg: #faf7f8;
  --bg-2: #f2ebed;
  --sidebar-bg: #f5eff1;
  --line: #e8dfe2;
  --line-strong: #d8c8cd;
  --accent: #9f1239;
  --accent-d: #881337;
  --accent-soft: #fdf2f5;
  --accent-border: #f3c4d1;
}

/* Dark Mode with Accent Parity */
body.dark {
  --bg: #121315;
  --bg-2: #1a1c20;
  --surface: #181a1e;
  --surface-2: #1f2228;
  --sidebar-bg: #14161a;
  --ink: #f4f4f5;
  --ink-2: #d4d4d8;
  --muted: #9ca3af;
  --line: #272a30;
  --line-strong: #363a42;
  --accent: #34d399;
  --accent-d: #10b981;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --accent-border: rgba(52, 211, 153, 0.3);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.28);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --red-border: rgba(248, 113, 113, 0.28);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, 0.5);
}
body.dark[data-accent="ocean"] { --accent: #60a5fa; --accent-d: #3b82f6; --accent-soft: rgba(96, 165, 250, 0.14); --accent-border: rgba(96, 165, 250, 0.32); }
body.dark[data-accent="terracotta"] { --accent: #f59e0b; --accent-d: #d97706; --accent-soft: rgba(245, 158, 11, 0.14); --accent-border: rgba(245, 158, 11, 0.32); }
body.dark[data-accent="teal"] { --accent: #2dd4bf; --accent-d: #14b8a6; --accent-soft: rgba(45, 212, 191, 0.14); --accent-border: rgba(45, 212, 191, 0.32); }
body.dark[data-accent="graphite"] { --accent: #e4e4e7; --accent-d: #ffffff; --accent-soft: rgba(228, 228, 231, 0.12); --accent-border: rgba(228, 228, 231, 0.28); }
body.dark[data-accent="crimson"] { --accent: #fb7185; --accent-d: #f43f5e; --accent-soft: rgba(251, 113, 133, 0.14); --accent-border: rgba(251, 113, 133, 0.32); }

/* Swatch Dot Colors (CSP-safe) */
.swatch-dot { width: 16px; height: 16px; border-radius: 999px; display: inline-block; flex-shrink: 0; border: 1.5px solid rgba(0, 0, 0, 0.12); }
.swatch-forest { background: #16654e; }
.swatch-ocean { background: #1d4ed8; }
.swatch-terracotta { background: #b45309; }
.swatch-teal { background: #0f766e; }
.swatch-graphite { background: #27272a; }
.swatch-crimson { background: #9f1239; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  font-weight: 550;
  font-size: 13.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.14s, border-color 0.14s, color 0.14s, box-shadow 0.14s;
}
button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.45; cursor: wait; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-d); border-color: var(--accent-d); color: #fff; }
body.dark button.primary { color: #0f1115; }
button.secondary { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
button.secondary:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
button.danger { background: var(--red-soft); border-color: var(--red-border); color: var(--red); }
button.danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
button.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
button.ghost-btn { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost-btn:hover { background: var(--bg-2); color: var(--ink); border-color: transparent; }

a { color: var(--accent); text-underline-offset: 3px; }
input, textarea {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 12px;
  max-width: 100%;
  transition: border-color 0.14s, box-shadow 0.14s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; min-height: 96px; }
input[type=search] { min-width: 220px; flex: 1; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }
p { margin: 0.4em 0 0.9em; }
h1, h2, h3, h4 { line-height: 1.28; color: var(--ink); margin: 0 0 0.5em; letter-spacing: -0.022em; font-weight: 650; }
h1 { font-size: clamp(1.5rem, 2.3vw, 1.95rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
small, .muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.ico { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 22px; height: 22px; }
.skip { position: absolute; top: -100px; padding: 10px; background: var(--surface); z-index: 100; }
.skip:focus { top: 0; }

/* App Shell & Full-Bleed Responsive Focus Mode */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
body.focus-mode .app-shell { grid-template-columns: 0 minmax(0, 1fr); }
body.focus-mode .sidebar { overflow: hidden; padding: 0; opacity: 0; pointer-events: none; border: 0; }

/* Calm Editorial Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: var(--ink-2);
  padding: 18px 13px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 6px 14px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
body.dark .brand-mark { color: #0f1115; }
.brand strong { display: block; font-size: 15px; letter-spacing: -0.02em; color: var(--ink); line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11.5px; display: block; margin-top: 1px; }

.switch-course-btn {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 550;
  justify-content: space-between;
  margin-bottom: 14px;
  box-shadow: var(--shadow-xs);
}
.switch-course-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }

.side-label {
  font-size: 11px;
  color: var(--muted);
  padding: 12px 9px 5px;
  font-weight: 600;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-button {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  width: 100%;
}
.nav-button .nav-left { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.nav-button:hover { background: var(--bg-2); color: var(--ink); border: 0; }
.nav-button.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow-xs), inset 3px 0 0 var(--accent);
}
.tiny-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  font-weight: 650;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 12px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.side-bottom-head { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.side-bottom-title { font-size: 13px; font-weight: 650; color: var(--ink); margin-bottom: 7px; }
.side-bottom-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* Topbar */
.main-area { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px;
  padding: 0 clamp(16px, 2.5vw, 32px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb b { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 7px; position: relative; }
.top-pill {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 550;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
}
.top-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.top-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
body.dark .top-pill.active { color: #0f1115; }

/* Theme Color Picker Popover */
.theme-wrap { position: relative; }
.theme-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 248px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 35;
}
.theme-pop-title { font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 2px 6px 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.theme-opt {
  justify-content: flex-start;
  padding: 7px 10px;
  font-size: 12.5px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.theme-opt:hover { border-color: var(--line-strong); background: var(--bg-2); color: var(--ink); }
.theme-opt.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }

/* Voice & Speed Picker Popover (English workspace) */
.voice-wrap { position: relative; }
.voice-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 35;
}
.voice-pop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.voice-pop-head span { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.voice-list { display: grid; gap: 3px; max-height: 290px; overflow-y: auto; }
.voice-opt {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 7px 9px;
  border-radius: 8px;
  justify-content: space-between;
  text-align: left;
  gap: 8px;
}
.voice-opt:hover { background: var(--bg-2); border-color: transparent; }
.voice-opt.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.voice-opt-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.voice-opt-name { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.voice-opt.active .voice-opt-name { color: var(--accent); }
.voice-opt-accent { font-size: 11px; font-weight: 500; color: var(--muted); }
.voice-opt-desc { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-pop-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Custom Select Dropdown (replaces ugly native OS <select>) */
.cselect { position: relative; min-width: 220px; }
.cselect-btn {
  width: 100%;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  gap: 10px;
}
.cselect-btn:hover { border-color: var(--accent); background: var(--surface); color: var(--ink); }
.cselect-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.cselect-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  min-width: 100%;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  max-height: 330px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 5px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.cselect-opt {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: 8px;
  justify-content: space-between;
  text-align: left;
  font-size: 13.5px;
  font-weight: 450;
}
.cselect-opt:hover { background: var(--bg-2); color: var(--ink); border: 0; }
.cselect-opt.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Main Content Area — Full-Screen Responsive in Focus Mode! */
.main {
  padding: 28px clamp(18px, 3vw, 44px) 64px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  transition: max-width 0.2s ease, padding 0.2s ease;
}
body.focus-mode .main {
  max-width: 100%;
  padding: 28px clamp(20px, 4vw, 68px) 72px;
}

/* Smart Full-Screen Two-Column Lesson Split in Focus Mode */
.lesson { max-width: 960px; }
body.focus-mode .lesson {
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
body.focus-mode .lesson-reading { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
body.focus-mode .lesson-practice-head { margin-top: 0; }
@media (max-width: 1120px) {
  body.focus-mode .lesson { display: block; }
  body.focus-mode .lesson-reading { position: static; max-height: none; overflow: visible; }
}

/* Course Hub */
.hub-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.hub-container { max-width: 820px; width: 100%; }
.hub-head { margin-bottom: 28px; }
.hub-head h1 { font-size: clamp(1.7rem, 3vw, 2.2rem); margin-bottom: 6px; }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.course-button {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.course-button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  color: var(--ink);
}
.course-button.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm); }
.hub-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.hub-enter { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 13.5px; }

/* Editorial Session Hero (Clean Paper Surface — NO generic AI purple gradient!) */
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 550; margin-bottom: 4px; }
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.hero h2 { font-size: 1.3rem; margin-bottom: 6px; }
.hero p { color: var(--ink-2); max-width: 72ch; margin-bottom: 14px; }
.hero-meta-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.hero-trail {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.trail-btn {
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.trail-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.trail-btn.done { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.trail-btn.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); font-weight: 600; }

/* Stats, Grids, Cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat strong { display: block; font-size: 1.4rem; color: var(--ink); line-height: 1.2; font-weight: 650; }
.stat span { font-size: 12px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 14px; }
.card, .os-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-xs); min-width: 0; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chapter-card { display: flex; flex-direction: column; gap: 8px; }
.chapter-card h3 { margin: 0; font-size: 1rem; }
.chapter-card button { align-self: flex-start; margin-top: auto; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 2px 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.error { background: var(--red-soft); color: var(--red); }
.pill.neutral { background: var(--bg-2); color: var(--muted); }

/* Native CSP-Safe Progress Bars */
progress.progress-meter {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
  display: block;
}
progress.progress-meter::-webkit-progress-bar { background: var(--bg-2); border-radius: 999px; }
progress.progress-meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.progress-meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.progress-meter.warn::-webkit-progress-value { background: var(--amber); }
progress.progress-meter.critical::-webkit-progress-value { background: var(--red); }

.sparkline { display: grid; grid-template-columns: repeat(14, 1fr); gap: 5px; align-items: end; height: 48px; padding-top: 8px; }
.spark-bar { background: var(--bg-2); border-radius: 3px; min-height: 5px; }
.spark-bar.active { background: var(--accent); }
.spark-h-0 { height: 12%; }
.spark-h-1 { height: 26%; }
.spark-h-2 { height: 44%; }
.spark-h-3 { height: 62%; }
.spark-h-4 { height: 82%; }
.spark-h-5 { height: 100%; }

.weak-row { display: grid; gap: 5px; padding: 10px 0; border-top: 1px solid var(--line); }
.weak-row:first-child { border-top: 0; padding-top: 0; }
.evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.evidence-box { border: 1px solid var(--line); border-radius: var(--r); padding: 20px; background: var(--surface); }
.evidence-box.verified { border-style: dashed; background: var(--surface-2); }
.rec-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); margin-top: 8px; }
.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; font-size: 12px; }
.metric-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.metric-chip strong { display: block; font-size: 14px; color: var(--ink); }

/* Lesson & Exercises */
.section-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 10px; }
.section-tabs button { white-space: nowrap; font-size: 13px; }
.section-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
body.dark .section-tabs button.active { color: #0f1115; }
.theory { font-size: 15.2px; line-height: 1.82; max-width: 70ch; }
.examples { border-left: 3px solid var(--accent); background: var(--surface-2); padding: 14px 18px; margin: 18px 0; border-radius: 0 10px 10px 0; }
.source-box { margin: 14px 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.section-actions { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 18px 0 0; }
.exercise { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 20px; margin: 12px 0; }
.exercise-head { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.exercise-head code { color: var(--muted); font-size: 11px; opacity: 0.72; overflow-wrap: anywhere; }
.prompt { font-size: 15px; font-weight: 500; margin-bottom: 14px; white-space: pre-wrap; }
.options { display: grid; gap: 8px; margin-bottom: 14px; }
.option { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; cursor: pointer; white-space: pre-wrap; }
.option:hover { border-color: var(--accent); background: var(--surface-2); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 4px; flex-shrink: 0; }
.question-images { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.question-images img { max-width: 100%; height: auto; max-height: 420px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.submit-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.submit-row label { font-size: 13px; color: var(--muted); }
.feedback { border: 1px solid var(--accent-border); background: var(--surface-2); padding: 16px 18px; margin-top: 14px; border-radius: 11px; }
.feedback.incorrect { border-color: var(--amber-border); background: var(--amber-soft); }
.feedback .model { white-space: pre-wrap; font-weight: 550; background: var(--surface); padding: 10px 12px; border-radius: 8px; margin: 8px 0; border: 1px solid var(--line); }
.rating { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; align-items: center; }
.rating button { font-size: 12.5px; }
.empty { padding: 32px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface); }
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.pager-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-controls { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pager-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
}
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pager-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
body.dark .pager-btn.active { color: #0f1115; }
.pager-ellipsis { color: var(--muted); padding: 0 4px; font-size: 13px; user-select: none; }
.plan-session.current { background: var(--accent-soft); margin: 0 -20px; padding: 14px 20px; border-radius: 9px; }

/* Auth & IAM UI */
.auth-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.auth-box { width: 100%; max-width: 440px; }
.auth-head { margin-bottom: 20px; }
.auth-head h1 { font-size: 1.65rem; margin: 4px 0 6px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 18px;
}
.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  padding: 7px 10px;
  border-radius: 7px;
}
.auth-tab:hover { color: var(--ink); background: transparent; border: 0; }
.auth-tab.active { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-xs); }
.field { display: grid; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field input { width: 100%; min-width: 0; }
.auth-err {
  background: var(--red-soft);
  border: 1px solid var(--red-border);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 14px;
}
.code-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
}
.code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}
.iam-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.iam-row:first-child { border-top: 0; padding-top: 0; }
.iam-reset-box {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.user-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 9px;
  margin-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.user-foot-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-text { line-height: 1.85; white-space: pre-wrap; max-width: 72ch; }
.media { width: 100%; max-height: 420px; margin: 14px 0; border-radius: 10px; }
.transcript { white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.lex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 275px), 1fr)); gap: 13px; }
.lex-word { font-size: 1.18rem; font-weight: 680; margin: 0; }
.lex-ipa { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.lex-examples { font-size: 13px; padding-left: 18px; }
.lex-meaning { margin: 8px 0; }
.review-list { display: grid; gap: 10px; }
.review-card { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.review-card p { margin: 4px 0; white-space: pre-wrap; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spaced { justify-content: space-between; }
.plan-session { border-top: 1px solid var(--line); padding: 14px 0; }
.plan-session:first-child { border: 0; }
.source-links { font-size: 12px; overflow-wrap: anywhere; margin-top: 10px; }
.recording-box { padding: 11px 0 0; border-top: 1px dashed var(--line); margin-top: 12px; }
.recording-box audio { max-width: 100%; height: 36px; }
.notice-banner { border-left: 3px solid var(--amber); background: var(--amber-soft); padding: 11px 14px; border-radius: 0 9px 9px 0; margin: 12px 0; font-size: 13px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); font-size: 1.25rem; }
.exam-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.exam-nav button { width: 36px; padding: 5px; font-size: 12.5px; }
.exam-nav button.answered { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }
.today-fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; margin-top: 14px; }
.today-fold summary { cursor: pointer; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.today-fold[open] summary { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.drill-counters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* Quick 5-Minute Active Recall Flashcard & Reflex Drill */
.flashcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow-md);
  max-width: 780px;
  margin: 0 auto;
}
.flash-front { text-align: center; padding: 14px 0 8px; }
.flash-meaning { font-size: clamp(1.3rem, 2.5vw, 1.75rem); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 10px 0 8px; }
.flash-answer {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--line-strong);
}
.flash-word { font-size: clamp(1.45rem, 2.8vw, 2rem); font-weight: 750; letter-spacing: -0.025em; color: var(--accent); margin: 0 0 4px; }
.flash-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.rate-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.rate-btn {
  flex-direction: column;
  gap: 3px;
  padding: 12px 10px;
  border-radius: 10px;
  text-align: center;
}
.rate-btn strong { font-size: 13.5px; }
.rate-btn small { font-size: 11.5px; color: var(--muted); font-weight: 450; }
.rate-btn.rate-again:hover { border-color: var(--red-border); background: var(--red-soft); color: var(--red); }
.rate-btn.rate-hard:hover { border-color: var(--amber-border); background: var(--amber-soft); color: var(--amber); }
.rate-btn.rate-good:hover { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent); }

/* TTS Speed Control & Listening Dictation Diff */
.speed-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.speed-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}
.speed-btn:hover { color: var(--ink); background: transparent; border: 0; }
.speed-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }

.dictation-box {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.diff-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.7;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-top: 10px;
  font-size: 14.5px;
}
.diff-ok { color: var(--accent); font-weight: 600; }
.diff-miss {
  color: var(--amber);
  background: var(--amber-soft);
  padding: 0 5px;
  border-radius: 5px;
  font-weight: 600;
}
.diff-extra {
  color: var(--red);
  text-decoration: line-through;
  opacity: 0.78;
}

/* Three-Pace Daily Study Selector (5m / 15m / 45-60m) */
.pace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.pace-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 6px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.14s, transform 0.12s, box-shadow 0.14s;
}
.pace-card:hover { border-color: var(--accent); background: var(--surface); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pace-card.primary-pace { border-color: var(--accent-border); background: var(--accent-soft); }
.pace-top { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 8px; }
.pace-card strong { font-size: 14.5px; color: var(--ink); font-weight: 680; }
.pace-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.pace-time { font-size: 11.5px; font-weight: 650; color: var(--accent); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.pace-card.primary-pace .pace-time { border-color: var(--accent-border); }

/* Session & Daily Goal Summary Banner */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.summary-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.summary-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.summary-metric { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.summary-metric strong { display: block; font-size: 1.35rem; font-weight: 720; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.summary-metric span { font-size: 12px; color: var(--muted); }
.week-dots { display: flex; gap: 6px; align-items: center; }
.week-dot {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 650;
  color: var(--muted);
}
.week-dot.done { background: var(--accent); border-color: var(--accent); color: #fff; }
body.dark .week-dot.done { color: #0f1115; }

/* Segmented Mode Toggle (Lesson: List vs 1-Question Stepper) */
.mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 10px;
  border-radius: 7px;
}
.mode-btn:hover { color: var(--ink); background: transparent; border: 0; }
.mode-btn.active { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-xs); }

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  line-height: 1.4;
}
.kbd-hint { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 12px; justify-content: center; }

/* CSP-Safe Utility Classes */
.w-full { width: 100%; }
.m-0 { margin: 0; }
.mt-xs { margin-top: 6px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-xs { margin-bottom: 6px; }
.mb-sm { margin-bottom: 10px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 20px; }
.my-md { margin: 14px 0; }
.ml-xs { margin-left: 6px; }
.w-goal { width: 84px; }
.justify-center { justify-content: center; }
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-red { color: var(--red); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hub-title { margin: 2px 0 4px; font-size: 1.2rem; }

#notice {
  position: fixed; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 32px));
  background: var(--ink); color: var(--surface); padding: 0; border-radius: 10px; z-index: 50; box-shadow: var(--shadow-lg);
}
#notice.visible { padding: 11px 16px; }
.loading { padding: 70px; text-align: center; }
.file-input { max-width: 100%; padding: 8px; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 214px minmax(0, 1fr); }
  .stats, .summary-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pace-grid { grid-template-columns: 1fr; }
  .evidence-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { height: auto; position: static; padding: 12px 14px; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 8px; }
  .side-label, .sidebar-bottom { display: none; }
  .nav-list { flex-direction: row; flex-wrap: wrap; gap: 4px; padding-bottom: 4px; }
  .nav-button { white-space: nowrap; width: auto; padding: 6px 9px; font-size: 12.5px; }
  .nav-button.active { box-shadow: var(--shadow-xs); }
  .topbar { padding: 0 14px; height: 52px; }
  .hide-sm { display: none; }
  .main, body.focus-mode .main { padding: 18px 14px 44px; }
  .hub-grid { grid-template-columns: 1fr; }
  .cselect { width: 100%; min-width: 0; }
  .cselect-menu { left: 0; right: 0; width: 100%; }
  .page-head { display: block; }
  .hero { padding: 18px; }
  .review-card { display: block; }
  .review-card button { margin-top: 10px; }
  .pager { justify-content: center; }
  .pager-controls { justify-content: center; }
  .rate-grid { grid-template-columns: 1fr; }
  input, textarea { font-size: 16px; }
}
