/* ============================================================
   Velnov - refined, modern theme
   Light & Dark mode via CSS variables on <html data-theme="">
   ============================================================ */

:root {
  /* brand */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-2: #8b5cf6;
  --secondary: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.14), rgba(139,92,246,.14));

  /* surfaces */
  --bg: #f4f5fb;
  --bg-card: #ffffff;
  --bg-muted: #f0f2f9;
  --bg-inset: #f7f8fc;
  --text: #101426;
  --text-muted: #6b7392;
  --border: #e7e9f3;
  --border-strong: #d7dbec;

  /* elevation */
  --shadow-sm: 0 1px 2px rgba(24, 27, 56, 0.05);
  --shadow: 0 6px 20px -6px rgba(24, 27, 56, 0.14), 0 2px 6px -2px rgba(24, 27, 56, 0.08);
  --shadow-lg: 0 24px 48px -18px rgba(60, 45, 120, 0.28);
  --ring: 0 0 0 4px rgba(99, 102, 241, 0.18);

  /* glassmorphism */
  --glass: rgba(255, 255, 255, 0.80);
  --glass-strong: rgba(255, 255, 255, 0.90);
  --glass-brd: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 16px 40px -16px rgba(90, 70, 150, 0.28);

  --code-bg: #0e1222;
  --code-text: #dfe4f4;
  --radius: 16px;

  --font-sans: 'Inter', system-ui, 'Segoe UI', sans-serif;
  --font-display: 'Sora', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, 'Cascadia Code', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* warm → cool gradient wash behind everything */
body {
  background:
    radial-gradient(70rem 55rem at 100% 0%, #fce7c2 0%, rgba(252, 231, 194, 0) 55%),
    radial-gradient(62rem 55rem at 0% 100%, #e0d2fb 0%, rgba(224, 210, 251, 0) 55%),
    radial-gradient(50rem 40rem at 92% 88%, #fbe0b5 0%, rgba(251, 224, 181, 0) 50%),
    linear-gradient(125deg, #f4eefc 0%, #f8f2ec 50%, #fdf6e9 100%);
  background-attachment: fixed;
}
[data-theme='dark'] body {
  background:
    radial-gradient(70rem 55rem at 100% 0%, rgba(180, 130, 60, 0.16) 0%, transparent 55%),
    radial-gradient(62rem 55rem at 0% 100%, rgba(139, 92, 246, 0.20) 0%, transparent 55%),
    linear-gradient(125deg, #090b16 0%, #0b0d1a 55%, #0d0b16 100%);
  background-attachment: fixed;
}

/* ---------- floating 3D-style decor ---------- */
.bg-decor { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; }

/* real 3D image assets (SVG) */
.asset {
  position: absolute; display: block; height: auto;
  filter: drop-shadow(0 18px 26px rgba(70, 50, 120, 0.22));
}
.a-hero     { width: 360px; top: 18px;  right: -30px; }
.a-gold-3   { width: 42px;  top: 20%;   left: 26px; }
.a-purple-1 { width: 66px;  top: 47%;   left: 12px; }
.a-gem-2    { width: 54px;  top: 32%;   left: 74px; }
.a-purple-2 { width: 40px;  top: 120px; right: 348px; }
.a-gem-1    { width: 90px;  bottom: 60px; right: 44px; }

/* big soft blurred bokeh blobs */
.blob { filter: blur(28px); opacity: 0.55; }
.blob-warm { width: 240px; height: 240px; top: -40px; right: 4%;
  background: radial-gradient(circle, #f9d18a, rgba(249, 209, 138, 0)); }
.blob-cool { width: 260px; height: 260px; bottom: -60px; left: -40px;
  background: radial-gradient(circle, #c3aef7, rgba(195, 174, 247, 0)); }
[data-theme='dark'] .blob { opacity: 0.30; }

/* dotted patterns */
.dots {
  background-image: radial-gradient(currentColor 1.7px, transparent 1.8px);
  background-size: 17px 17px;
}
.dots-a { width: 150px; height: 100px; right: 3%; top: 26%; color: rgba(139, 92, 246, 0.28); }
.dots-b { width: 130px; height: 90px; left: 15%; bottom: 8%; color: rgba(180, 130, 40, 0.28); }
[data-theme='dark'] .dots-a { color: rgba(167, 139, 250, 0.22); }
[data-theme='dark'] .dots-b { color: rgba(203, 163, 90, 0.20); }

@media (max-width: 820px) {
  .a-purple-2, .a-gem-2, .dots-a { display: none; }
  .a-hero { width: 200px; top: 8px; right: -30px; opacity: 0.85; }
  .a-gem-1 { width: 60px; }
}
@media (prefers-reduced-motion: no-preference) {
  .a-hero     { animation: float 12s ease-in-out infinite; }
  .a-gold-3   { animation: float 6s ease-in-out infinite; }
  .a-purple-1 { animation: float 11s ease-in-out infinite reverse; }
  .a-purple-2 { animation: float 7s ease-in-out infinite; }
  .a-gem-1    { animation: float 10s ease-in-out infinite reverse; }
  .a-gem-2    { animation: float 8s ease-in-out infinite; }
}
@keyframes float { 50% { transform: translateY(-14px); } }

h1, h2, h3, .brand { font-family: var(--font-display); letter-spacing: -0.02em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); line-height: 1.15; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.08rem; font-weight: 600; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.container { width: min(960px, 100% - 2rem); margin-inline: auto; flex: 1; padding-block: 1.75rem; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg-card) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
    width: 100%;
    padding: 0.85rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.brand { font-size: 1.4rem; font-weight: 800; display: inline-flex; align-items: center; gap: 0.15rem; }
.brand-accent {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.theme-toggle {
  display: grid; place-items: center;
  width: 2.4rem; height: 2.4rem;
  background: var(--bg-muted); border: 1px solid var(--border);
  border-radius: 999px; font-size: 1.05rem;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.theme-toggle:hover { transform: translateY(-2px) rotate(-8deg); box-shadow: var(--shadow); border-color: var(--border-strong); }

/* ---------- Fixed full-height left sidebar ---------- */
.sidebar {
  position: fixed; top: 10px; left: 10px; z-index: 40;
  width: 246px; height: calc(100vh - 20px); min-height: calc(100vh - 20px);
  display: flex; flex-direction: column;
  padding: 1.15rem 0.85rem 0; overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(168, 140, 246, 0.32);
  background: linear-gradient(170deg, #ffffff 0%, #f8f4ff 52%, #eee7fd 100%);
  box-shadow: 0 26px 64px -24px rgba(124, 92, 214, 0.45), 0 0 0 6px rgba(124, 92, 214, 0.05);
}
[data-theme='dark'] .sidebar {
  border-color: rgba(140, 120, 210, 0.28);
  background: linear-gradient(170deg, #171a2b 0%, #141628 52%, #181336 100%);
  box-shadow: 0 26px 64px -24px rgba(0,0,0,0.7), 0 0 0 6px rgba(124,92,214,0.10);
}
.sidebar .brand {
  font-size: 1.35rem; font-weight: 800; padding: 0.35rem 0.55rem; margin-bottom: 1.1rem;
  display: inline-flex; align-items: center; gap: 0.25rem; position: relative; z-index: 2;
}

.side-nav {
  display: flex; flex-direction: column; gap: 0.4rem;
  background: none; border: none; box-shadow: none; padding: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  position: relative; z-index: 2;
}
.side-link {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  padding: 0.78rem 1rem; border-radius: 13px;
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  font-weight: 600; text-align: left; transition: background 0.18s, color 0.18s;
}
.side-link:hover { background: color-mix(in srgb, var(--primary) 9%, transparent); color: var(--text); }
.side-link.active { background: var(--grad); color: #fff; box-shadow: 0 12px 24px -8px var(--primary); }
.side-ico { font-size: 1.2rem; }
a.side-link { text-decoration: none; font-size: inherit; }

.side-divider {
  height: 1px; background: color-mix(in srgb, var(--primary) 16%, transparent);
  margin: 0.85rem 0.5rem 0; position: relative; z-index: 2;
}

/* decorative bottom of the sidebar */
.sb-blob { position: absolute; border-radius: 50%; z-index: 1; pointer-events: none; }
.sb-blob-1 { width: 150px; height: 150px; bottom: -46px; left: -42px;
  background: radial-gradient(circle at 42% 38%, #cdb9f8, #9f82ee); opacity: 0.55; }
.sb-blob-2 { width: 44px; height: 44px; top: 46%; left: -20px;
  background: radial-gradient(circle at 40% 35%, #d9caf9, #ac90f0); opacity: 0.6; }
.sb-dots { position: absolute; bottom: 92px; right: 16px; width: 58px; height: 72px; z-index: 1;
  background-image: radial-gradient(rgba(139,92,246,0.32) 1.6px, transparent 1.7px); background-size: 16px 16px; }
[data-theme='dark'] .sb-dots { background-image: radial-gradient(rgba(167,139,250,0.28) 1.6px, transparent 1.7px); }

/* ---------- Page content (offset by the fixed sidebar) ---------- */
.page { margin-left: 268px; min-height: 100vh; display: flex; flex-direction: column; }
.main-content { flex: 1; min-width: 0; padding: 1.5rem 2rem 0.5rem; }

/* ---------- Top-right corner: track progress + theme toggle ---------- */
.topbar { position: fixed; top: 12px; right: 16px; z-index: 45; display: flex; align-items: center; gap: 0.55rem; }

/* trophy button — collapsed by default, expands to a progress popover on hover/tap */
.track { position: relative; }
.track-fab {
  width: 2.7rem; height: 2.7rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.4rem; line-height: 1;
  background: var(--glass-strong); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow);
  backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%);
  transition: transform 0.16s;
}
.track-fab:hover { transform: translateY(-2px) scale(1.05); }
.track-pop {
  position: absolute; top: calc(100% + 0.5rem); right: 0; width: 212px;
  padding: 0.85rem 0.9rem; border-radius: 16px; text-align: left;
  background: var(--glass-strong); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s;
}
.track:hover .track-pop, .track.open .track-pop { opacity: 1; visibility: visible; transform: translateY(0); }
.track-pop strong { font-family: var(--font-display); font-size: 0.9rem; display: block; }
.track-stats { margin: 0.3rem 0 0.7rem; font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.track-pop .btn { width: 100%; justify-content: center; }

/* ---------- Hamburger + overlay (mobile) ---------- */
.hamburger {
  display: none; position: fixed; top: 12px; left: 14px; z-index: 46;
  width: 2.6rem; height: 2.6rem; border-radius: 12px; font-size: 1.25rem;
  background: var(--glass-strong); border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow);
  backdrop-filter: blur(14px);
}
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 35; background: rgba(20,16,40,0.42); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-118%); transition: transform 0.28s cubic-bezier(.2,.7,.3,1); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .hamburger { display: grid; place-items: center; }
  .page { margin-left: 0; }
  .main-content { padding: 3.7rem 1.1rem 0.5rem; }
  .track-pop { right: -0.5rem; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid transparent; border-radius: 12px;
  padding: 0.65rem 1.3rem; font-weight: 600; font-family: var(--font-sans);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s, background 0.2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 22px -10px var(--primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 14px 28px -10px var(--primary); }
.btn-secondary { background: var(--secondary); color: #04263b; }
[data-theme='dark'] .btn-secondary { color: #04121b; }
.btn-secondary:hover:not(:disabled) { box-shadow: var(--shadow); }
.btn-outline { background: var(--bg-card); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

/* ---------- Hero / search ---------- */
.hero { text-align: center; padding: 0.2rem 0 1rem; }
.hero h1 { max-width: 20ch; margin-inline: auto; font-size: clamp(1.4rem, 3.2vw, 2.05rem); line-height: 1.18; }
.hero p { max-width: 520px; margin: 0.45rem auto 0.9rem; color: var(--text-muted); font-size: 0.98rem; }
.text-gradient {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.search-bar { position: relative; width: min(520px, 100%); margin-inline: auto; }
.search-bar::before {
  content: ''; position: absolute; left: 1.15rem; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; background: var(--text-muted); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.7' y2='16.7'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.7' y2='16.7'/%3E%3C/svg%3E") center/contain no-repeat;
}
.search-bar input {
  width: 100%; height: 58px; padding: 0 1.25rem 0 3rem;
  border: 1px solid var(--border-strong); border-radius: 15px;
  background: var(--bg-card); color: var(--text); font: inherit; font-size: 1rem;
  box-shadow: 0 10px 26px -12px rgba(86, 64, 150, 0.24);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring), 0 10px 26px -12px rgba(86, 64, 150, 0.24); }
.search-bar:focus-within::before { background: var(--primary); }

/* ---------- Cards / grid ---------- */
.section-title { position: relative; display: inline-block; margin: 0.9rem 0 0.9rem; font-weight: 600; }
.section-title::after {
  content: ''; position: absolute; left: 0; bottom: -0.5rem;
  width: 46px; height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, #f7b733, #fc9a3f);
}
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.15rem;
}
@media (max-width: 1200px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px)  { .grid { grid-template-columns: 1fr; } }
.card {
  background: var(--glass); border: 1px solid var(--glass-brd);
  border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--glass-shadow);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}

.subject-card, .formula-topic-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 0.5rem;
  cursor: pointer; text-align: left;
  transition: transform 0.22s cubic-bezier(.2,.7,.3,1), box-shadow 0.22s, border-color 0.22s;
}
.subject-card::after, .formula-topic-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent, var(--primary)); opacity: 0; transition: opacity 0.22s;
}
.subject-card::before, .formula-topic-card::before {
  content: '→'; position: absolute; top: 1.2rem; right: 1.25rem;
  font-size: 1.05rem; font-weight: 700; line-height: 1; color: var(--text-muted);
  opacity: 0.45; transform: translateX(0);
  transition: transform 0.22s, color 0.22s, opacity 0.22s;
}
.subject-card h3, .formula-topic-card h3 { padding-right: 1.5rem; }
.subject-card:hover, .formula-topic-card:hover {
  transform: translateY(-7px);
  border-color: color-mix(in srgb, var(--primary) 55%, var(--glass-brd));
  box-shadow: var(--shadow-lg), 0 18px 42px -16px rgba(124, 92, 214, 0.52);
}
.subject-card:hover::after, .formula-topic-card:hover::after { opacity: 1; }
.subject-card:hover::before, .formula-topic-card:hover::before {
  opacity: 1; transform: translateX(5px); color: var(--primary);
}
.subject-card:hover .subject-icon, .formula-topic-card:hover .subject-icon {
  transform: scale(1.06) rotate(-3deg);
}
.subject-icon { transition: transform 0.22s cubic-bezier(.2,.7,.3,1); }
.subject-icon {
  display: grid; place-items: center;
  width: 3.1rem; height: 3.1rem; border-radius: 14px; font-size: 1.6rem;
  background: color-mix(in srgb, var(--accent, var(--primary)) 15%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent, var(--primary)) 22%, transparent);
}
.card-meta {
  margin-top: auto; padding-top: 0.35rem; font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted);
}

/* ---------- Subject / topic page ---------- */
.page-head { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.5rem; }
.page-head .subject-icon { width: 3.6rem; height: 3.6rem; font-size: 2rem; }
.back-link {
  display: inline-flex; align-items: center; gap: 0.3rem;
  margin-bottom: 1.1rem; color: var(--primary); font-weight: 600; cursor: pointer;
  transition: gap 0.15s;
}
.back-link:hover { gap: 0.55rem; }

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; align-items: center; }
.chip {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 999px; padding: 0.34rem 1rem; font-size: 0.86rem; font-weight: 600;
  transition: all 0.16s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip-active { background: var(--grad); border-color: transparent; color: #fff; }

.topic-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  margin-bottom: 0.9rem; transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.topic-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
@media (max-width: 520px) { .topic-row { flex-direction: column; align-items: flex-start; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 0.2rem 0.7rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em;
  background: var(--bg-muted); border: 1px solid var(--border); color: var(--text-muted);
}
.badge-easy { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.badge-medium { color: var(--warning); background: color-mix(in srgb, var(--warning) 13%, transparent); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.badge-hard { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

/* ---------- Quiz ---------- */
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.progress-track { height: 9px; background: var(--bg-muted); border-radius: 999px; overflow: hidden; margin-bottom: 1.4rem; }
.progress-fill { height: 100%; background: var(--grad); border-radius: 999px; transition: width 0.4s cubic-bezier(.2,.7,.3,1); }

.question-text { font-size: 1.16rem; font-weight: 500; white-space: pre-wrap; margin-bottom: 1.2rem; }

.option {
  display: flex; align-items: center; gap: 0.9rem; width: 100%; text-align: left;
  background: var(--bg-inset); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 13px; padding: 0.85rem 1.05rem; margin-bottom: 0.7rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.option:hover:not(:disabled) { border-color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-sm); }
.option:disabled { cursor: default; }
.option-key {
  flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 9px;
  display: grid; place-items: center; font-weight: 700;
  background: var(--bg-card); border: 1px solid var(--border);
}
.option.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--bg-inset)); }
.option.selected .option-key { background: var(--primary); color: #fff; border-color: transparent; }
.option.correct  { border-color: var(--success); background: color-mix(in srgb, var(--success) 14%, var(--bg-inset)); }
.option.correct .option-key { background: var(--success); color: #fff; border-color: transparent; }
.option.wrong    { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, var(--bg-inset)); animation: shake 0.3s; }
.option.wrong .option-key { background: var(--danger); color: #fff; border-color: transparent; }
.option.faded    { opacity: 0.55; }

.quiz-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 1.1rem; }

/* ---------- Solution panel ---------- */
.solution {
  margin-top: 1.3rem; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  animation: fadeIn 0.35s ease;
}
.solution h4 { margin: 1rem 0 0.3rem; font-family: var(--font-display); font-size: 0.95rem; }
.verdict { font-weight: 700; font-size: 1.05rem; }
.verdict.ok { color: var(--success); }
.verdict.no { color: var(--danger); }
.verdict.neutral { color: var(--text-muted); }
.solution-text { white-space: pre-wrap; }
pre.code {
  background: var(--code-bg); color: var(--code-text);
  padding: 1rem 1.1rem; border-radius: 12px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.55; margin-top: 0.3rem;
}
.notes { padding-left: 1.2rem; }
.tag-row { display: flex; gap: 0.45rem; flex-wrap: wrap; margin-top: 0.3rem; }

/* ---------- Result ---------- */
.result-card { text-align: center; padding: 2.4rem 1.5rem; animation: fadeIn 0.35s ease; }
.result-ring {
  position: relative; width: 140px; height: 140px; border-radius: 50%;
  margin: 1.2rem auto;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--bg-muted) 0);
  display: grid; place-items: center;
}
.result-ring::before {
  content: ''; position: absolute; width: 108px; height: 108px;
  border-radius: 50%; background: var(--bg-card);
}
.result-ring span { position: relative; font-size: 1.8rem; font-weight: 800; font-family: var(--font-display); }
.result-stats { display: flex; justify-content: center; gap: 2.4rem; flex-wrap: wrap; margin-block: 1.2rem; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.5rem; font-family: var(--font-display); }
.good { color: var(--success); }
.bad { color: var(--danger); }
.quiz-actions.center { justify-content: center; }

.review-block { margin-top: 1.5rem; }
.review-block .card { margin-bottom: 1rem; }

/* ---------- Recent scores table ---------- */
.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.history-table th { color: var(--text-muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.history-table tbody tr { transition: background 0.15s; }
.history-table tbody tr:hover { background: var(--bg-muted); }

/* ---------- Formula reference ---------- */
.formula-card { margin-bottom: 1.15rem; }
.formula-card h3 { margin-bottom: 0.6rem; font-weight: 600; }
.formula-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.55rem; }
.formula-tag {
  font-size: 0.74rem; font-weight: 700; padding: 0.16rem 0.65rem; border-radius: 999px;
  background: var(--grad-soft); color: var(--primary);
}
.formula-tag.sub { background: var(--bg-muted); color: var(--text-muted); }
.formula-expr {
  background: linear-gradient(180deg, var(--bg-inset), var(--bg-muted));
  border: 1px solid var(--border); border-radius: 13px;
  padding: 0.9rem 1.1rem; text-align: center; margin-bottom: 1rem;
  font-family: var(--font-mono); font-size: 1.18rem; font-weight: 700; color: var(--text);
  overflow-x: auto; white-space: nowrap;
}
.formula-syms { list-style: none; padding: 0; margin: 0 0 1rem; }
.formula-syms li { display: flex; gap: 0.75rem; padding: 0.18rem 0; font-size: 0.96rem; }
.formula-syms .sym { color: var(--primary); font-family: var(--font-mono); font-weight: 700; min-width: 2.4rem; }
.formula-block { border-top: 1px solid var(--border); padding-top: 0.8rem; margin-bottom: 0.6rem; }
.formula-block .label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.formula-block.use .label { color: var(--secondary); }
.formula-block.layman .label { color: var(--success); }
.formula-eg {
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.65rem 0.95rem; font-size: 0.9rem; margin-top: 0.5rem;
}
.formula-eg .label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.formula-eg code { font-family: var(--font-mono); white-space: pre-wrap; }

/* ---------- Scientific calculator ---------- */
/* two-column calculator view: decorative aside + bigger calculator */
.calc-view { display: flex; gap: 2.2rem; justify-content: center; align-items: flex-start; max-width: 880px; margin: 1rem auto 0; }
.calc-aside {
  flex: 1; max-width: 320px; padding: 1.7rem 1.6rem; border-radius: 24px; text-align: center;
  background: linear-gradient(160deg, #f7f2ff 0%, #ece2fd 100%);
  border: 1px solid var(--glass-brd); box-shadow: var(--glass-shadow);
}
[data-theme='dark'] .calc-aside { background: linear-gradient(160deg, #1b1d33 0%, #191436 100%); border-color: rgba(140,120,210,0.24); }
.calc-3d { width: 118px; height: auto; margin: 0 auto 0.4rem; display: block; filter: drop-shadow(0 16px 22px rgba(124,92,214,0.34)); }
.calc-aside h2 { font-family: var(--font-display); font-size: 1.5rem; margin-bottom: 0.5rem; }
.calc-aside p { font-size: 0.9rem; margin-bottom: 1rem; }
.calc-tips { list-style: none; padding: 0; margin: 0; text-align: left; display: flex; flex-direction: column; gap: 0.55rem; }
.calc-tips li { position: relative; padding-left: 1.4rem; font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.calc-tips li::before { content: '✦'; position: absolute; left: 0; top: 0; color: var(--primary); }
.calc-tips b { color: var(--text); }

.calc { width: 100%; max-width: 420px; margin: 0; }
.calc-display {
  background: #ffffff; color: #0f1424;
  border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 1rem 1.15rem; margin-bottom: 0.9rem; min-height: 92px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 0.2rem;
  box-shadow: var(--shadow-sm);
}
[data-theme='dark'] .calc-display { background: #10131f; color: #f1f4ff; border-color: var(--border); }
.calc-expr { font-family: var(--font-mono); font-size: 0.98rem; color: var(--text-muted); min-height: 1.2rem; word-break: break-all; text-align: right; }
.calc-result { font-family: var(--font-mono); font-size: 2.1rem; font-weight: 700; text-align: right; word-break: break-all; }
.calc-modes { display: flex; gap: 0.4rem; margin-bottom: 0.7rem; align-items: center; }
.calc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.55rem; }
.calc-btn {
  padding: 0.85rem 0; border-radius: 13px; font-size: 1.08rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  transition: transform 0.1s, background 0.14s, box-shadow 0.14s, border-color 0.14s;
}
.calc-btn:hover { background: var(--bg-muted); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.calc-btn:active { transform: scale(0.93); }
.calc-btn.fn { font-size: 0.98rem; color: var(--secondary); }
.calc-btn.op { color: var(--primary); font-weight: 700; }
.calc-btn.eq { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -10px var(--primary); margin-top: 0.5rem !important; font-size: 1.2rem; }
.calc-btn.clear { color: var(--danger); }
@media (max-width: 820px) {
  .calc-view { flex-direction: column; align-items: stretch; gap: 1.2rem; max-width: 460px; }
  .calc-aside { max-width: none; }
  .calc { max-width: none; }
}
@media (max-width: 430px) { .calc-btn { padding: 0.7rem 0; font-size: 1rem; } }

/* ---------- Footer ---------- */
.footer {
  background: color-mix(in srgb, var(--bg-card) 70%, transparent);
  border-top: 1px solid var(--border);
  text-align: center; padding: 1.35rem; color: var(--text-muted); font-size: 0.9rem;
}
.footer a { color: var(--primary); font-weight: 600; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.fade-in { animation: fadeIn 0.4s cubic-bezier(.2,.7,.3,1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
/* ============================================================
   Homepage SEO content
   Compact, readable and visually consistent with Velnov
   ============================================================ */

.seo-intro {
  max-width: 1050px;
  margin: 28px auto 10px;
  padding: 28px 32px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(130, 100, 220, 0.12);
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(80, 60, 150, 0.06);
}

.seo-intro h2 {
  margin: 0 0 10px;
  font-family: 'Sora', sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.seo-intro p {
  margin: 8px 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-muted);
}

.seo-intro ul {
  margin: 14px 0 10px;
  padding-left: 20px;
}

.seo-intro li {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.seo-intro li strong {
  color: var(--text);
}

.seo-intro h3 {
  margin: 18px 0 6px;
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  color: var(--text);
}

.seo-intro a { color: var(--primary-dark); font-weight: 600; }

/* Mobile */
@media (max-width: 700px) {
  .seo-intro {
    margin: 22px 12px 8px;
    padding: 22px 20px;
    border-radius: 18px;
  }

  .seo-intro h2 {
    font-size: 20px;
  }

  .seo-intro p,
  .seo-intro li {
    font-size: 14px;
    line-height: 1.55;
  }
}
