:root {
  --bg: #151716;
  --surface: #202321;
  --surface-2: #292c2a;
  --surface-3: #343735;
  --text: #f6f5f0;
  --muted: #969b96;
  --line: rgba(255,255,255,.075);
  --accent: #56f28b;
  --accent-rgb: 86, 242, 139;
  --danger: #ff647c;
  --warning: #ffb454;
  --radius: 26px;
  color-scheme: dark;
}

html[data-accent="orange"] { --accent: #ff8a35; --accent-rgb: 255, 138, 53; }
html[data-accent="purple"] { --accent: #a970ff; --accent-rgb: 169, 112, 255; }
html[data-accent="blue"] { --accent: #45a4ff; --accent-rgb: 69, 164, 255; }
html[data-accent="magenta"] { --accent: #ff4fc8; --accent-rgb: 255, 79, 200; }

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell, .learn-shell, .profile-screen { width: min(100%, 720px); margin: 0 auto; min-height: 100vh; }
.app-shell { position: relative; padding: max(24px, env(safe-area-inset-top)) 20px 112px; }
.app-shell.narrow { max-width: 620px; }
.topbar { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 12px; }
.topbar-label { color: var(--muted); font-size: .82rem; }
.avatar { display: grid; place-items: center; border-radius: 50%; color: #111; font-weight: 800; background: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .12); }
.avatar-small { width: 38px; height: 38px; font-size: .85rem; }
.avatar-large { width: 86px; height: 86px; font-size: 1.8rem; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); display: grid; place-items: center; font-size: 1.1rem; }
.welcome { padding: 34px 2px 26px; }
.eyebrow, .overline { margin: 0 0 7px; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.welcome h1, .page-heading h1 { margin: 0; font-size: clamp(2rem, 7vw, 3rem); letter-spacing: -.055em; line-height: 1.05; }
.welcome h1 span { color: var(--accent); }
.muted { color: var(--muted); line-height: 1.65; }
.welcome .muted { margin: 10px 0 0; font-size: .9rem; }

.hero-panel { min-height: 192px; padding: 28px; border-radius: var(--radius); background: linear-gradient(145deg, rgba(var(--accent-rgb), .18), transparent 58%), var(--surface); border: 1px solid rgba(var(--accent-rgb), .2); display: flex; justify-content: space-between; align-items: center; gap: 22px; overflow: hidden; position: relative; }
.hero-panel::after { content: ''; position: absolute; width: 180px; height: 180px; border: 1px solid rgba(var(--accent-rgb), .12); border-radius: 50%; right: -80px; top: -90px; }
.hero-copy { position: relative; z-index: 1; }
.hero-copy h2 { max-width: 320px; margin: 7px 0; font-size: clamp(1.3rem, 5vw, 2rem); letter-spacing: -.035em; }
.hero-copy p { margin: 0; color: var(--muted); font-size: .82rem; }
.progress-ring { --progress: 0; flex: 0 0 94px; width: 94px; height: 94px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--surface-3) 0); position: relative; z-index: 1; }
.progress-ring::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.progress-ring span { z-index: 1; font-size: 1.25rem; font-weight: 800; }
.progress-ring small { font-size: .65rem; color: var(--muted); }

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 28px 2px 14px; }
.section-title h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.02em; }
.section-title > span { color: var(--muted); font-size: .7rem; max-width: 50%; text-align: right; }
.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.action-card { min-height: 166px; border-radius: 22px; background: var(--surface); padding: 20px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line); }
.action-card.featured { background: var(--accent); color: #111; border-color: transparent; }
.action-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); }
.featured .action-icon { background: rgba(0,0,0,.15); }
.action-card div { display: flex; flex-direction: column; }
.action-card strong { font-size: 1.8rem; line-height: 1; letter-spacing: -.04em; }
.action-card div span { margin-top: 6px; color: var(--muted); font-size: .72rem; }
.featured div span { color: rgba(0,0,0,.65); }
.action-card > a, .action-card form button, .action-card > i { align-self: flex-end; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; border: 0; background: var(--surface-3); font-style: normal; cursor: pointer; }
.featured > a, .featured > i { background: #111; color: white; }
.action-card form { align-self: flex-end; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 16px; }
.panel > h2 { margin: 0 0 18px; font-size: 1rem; }
.stats-panel { margin-top: 14px; }
.stats-panel .section-title { margin: 0 0 24px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-row div { display: flex; flex-direction: column; gap: 5px; }
.stat-row strong { font-size: 1.25rem; }
.stat-row span { color: var(--muted); font-size: .64rem; }
.linear-progress, .session-progress { height: 6px; border-radius: 10px; background: var(--surface-3); overflow: hidden; }
.linear-progress { margin-top: 22px; }
.linear-progress span, .session-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }

.bottom-nav { position: fixed; z-index: 5; bottom: 14px; left: 50%; transform: translateX(-50%); width: min(calc(100% - 28px), 680px); height: 72px; padding: 8px; display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(34,37,35,.92); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 18px 50px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: .62rem; border-radius: 15px; }
.bottom-nav a span { font-size: 1.12rem; }
.bottom-nav a.active { color: var(--accent); background: rgba(var(--accent-rgb), .09); }

.profiles-body { background: radial-gradient(circle at 50% 20%, rgba(255,255,255,.045), transparent 35%), var(--bg); }
.profile-screen { padding: max(72px, env(safe-area-inset-top)) 22px 50px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.brand-mark { width: 52px; height: 52px; margin-bottom: 44px; display: grid; place-items: center; border-radius: 17px; color: #111; background: var(--accent); font-weight: 900; font-size: 1.3rem; }
.profile-screen h1 { margin: 0; font-size: clamp(2rem, 8vw, 3.1rem); letter-spacing: -.055em; }
.profile-screen > .muted { max-width: 470px; margin: 14px auto 38px; }
.profile-grid { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; gap: 14px; }
.profile-card { --card-accent: var(--accent); width: 100%; min-height: 230px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; cursor: pointer; transition: transform .2s ease, border-color .2s ease; }
.profile-card:hover { transform: translateY(-3px); border-color: var(--card-accent); }
.profile-card .avatar { background: var(--card-accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--card-accent) 14%, transparent); }
.profile-card strong { font-size: 1.25rem; }
.profile-card > span:last-child { color: var(--muted); font-size: .7rem; }
.profile-card b { color: var(--card-accent); }
.accent-green { --card-accent: #56f28b; }
.accent-magenta { --card-accent: #ff4fc8; }

.page-heading { padding: 34px 2px 16px; }
.page-heading .muted { margin-bottom: 0; }
.library-list { display: grid; gap: 8px; }
.library-row { width: 100%; padding: 14px; display: grid; grid-template-columns: 42px 1fr 20px; align-items: center; gap: 12px; text-align: left; border: 1px solid transparent; border-radius: 17px; background: var(--surface-2); cursor: pointer; }
.library-row.selected { border-color: rgba(var(--accent-rgb), .45); background: rgba(var(--accent-rgb), .08); }
.library-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--surface-3); color: var(--accent); }
.library-row > span:nth-child(2) { display: flex; flex-direction: column; gap: 4px; }
.library-row strong { font-size: .82rem; }
.library-row small { color: var(--muted); font-size: .65rem; }
.radio-dot { width: 17px; height: 17px; border: 2px solid var(--muted); border-radius: 50%; }
.selected .radio-dot { border: 5px solid var(--accent); }
.accent-picker { display: flex; gap: 13px; flex-wrap: wrap; }
.swatch { width: 42px; height: 42px; border: 3px solid var(--surface); border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.swatch.active { box-shadow: 0 0 0 2px white; transform: scale(.9); }
.swatch-green { background: #56f28b; }.swatch-orange { background: #ff8a35; }.swatch-purple { background: #a970ff; }.swatch-blue { background: #45a4ff; }.swatch-magenta { background: #ff4fc8; }
.setting-description { margin: -7px 0 17px; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.size-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.size-option { min-height: 68px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.size-option strong { font-size: 1.05rem; }
.size-option span { color: var(--muted); font-size: .58rem; }
.size-option.active { color: #111; background: var(--accent); border-color: var(--accent); }
.size-option.active span { color: rgba(0,0,0,.6); }
.setting-note { margin: 14px 0 0; color: var(--muted); font-size: .64rem; line-height: 1.5; }
.logout-form { margin: 18px 0; }

.learn-shell { max-width: 680px; height: 100vh; height: 100dvh; min-height: 560px; padding: max(14px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; overflow: hidden; }
.learn-header { display: grid; grid-template-columns: 42px 1fr 38px; gap: 12px; align-items: center; }
.learn-header > div { display: flex; flex-direction: column; text-align: center; gap: 2px; }
.learn-header span { color: var(--muted); font-size: .65rem; }
.learn-header strong { font-size: .78rem; }
.session-progress { flex: 0 0 auto; margin: 18px 3px 7px; }
.session-count { flex: 0 0 auto; margin: 0 3px 10px; text-align: right; color: var(--muted); font-size: .65rem; }
.flashcard { flex: 1 1 auto; min-height: 0; padding: clamp(20px, 5vw, 38px); border-radius: 30px; background: radial-gradient(circle at 50% 20%, rgba(var(--accent-rgb), .1), transparent 32%), var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.flashcard:not(.is-revealed) { cursor: pointer; }
.flashcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.category { align-self: center; padding: 7px 12px; border-radius: 99px; color: var(--accent); background: rgba(var(--accent-rgb), .1); font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.card-front { margin: auto 0; text-align: center; }
.card-front p { color: var(--muted); font-size: .7rem; }
.card-front h1 { margin: 10px 0; font-size: clamp(2.25rem, 10vw, 5rem); line-height: 1; letter-spacing: -.06em; overflow-wrap: anywhere; }
.card-answer { margin: -12px 0 auto; padding: 24px; text-align: center; border-radius: 21px; background: var(--surface-2); animation: reveal .28s ease both; }
.card-answer span { color: var(--muted); font-size: .64rem; text-transform: uppercase; letter-spacing: .1em; }
.card-answer h2 { margin: 9px 0 5px; color: var(--accent); font-size: clamp(1.55rem, 7vw, 2.6rem); }
.card-answer p { margin: 8px 0 0; color: var(--muted); font-size: .75rem; }
.flashcard.is-revealed .card-front { margin-bottom: 28px; }
.button { min-height: 52px; padding: 0 22px; border: 0; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .78rem; cursor: pointer; }
.button-primary { color: #111; background: var(--accent); box-shadow: 0 10px 30px rgba(var(--accent-rgb), .12); }
.button-ghost { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.reveal-button { width: 100%; margin-top: auto; }
.grade-area { margin-top: auto; }
.grade-area > p { margin: 0 0 12px; text-align: center; color: var(--muted); font-size: .68rem; }
.grade-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade { min-height: 78px; border: 0; border-radius: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; background: var(--surface-2); cursor: pointer; }
.grade b { font-size: 1.22rem; }
.grade span { color: var(--muted); font-size: .58rem; }
.grade-bad b { color: var(--danger); }.grade-mid b { color: var(--warning); }.grade-good { background: var(--accent); color: #111; }.grade-good span { color: rgba(0,0,0,.62); }
.completion-card { margin: auto; width: 100%; padding: 46px 28px; border-radius: 28px; text-align: center; background: var(--surface); border: 1px solid var(--line); }
.completion-icon { width: 72px; height: 72px; margin: 0 auto 24px; display: grid; place-items: center; border-radius: 50%; color: #111; background: var(--accent); font-size: 2rem; }
.completion-card h1 { margin: 7px 0; font-size: 2rem; letter-spacing: -.045em; }
.completion-card .button { width: 100%; margin-top: 10px; }
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.empty-state span { color: var(--muted); font-size: .75rem; }
.empty-state .button { margin-top: 10px; }
code { padding: 2px 6px; color: var(--accent); border-radius: 6px; background: var(--surface-3); }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 420px) {
  .profile-grid { grid-template-columns: 1fr 1fr; }
  .profile-card { min-height: 200px; padding: 18px 10px; }
  .avatar-large { width: 70px; height: 70px; }
  .hero-panel { padding: 22px; }
  .progress-ring { width: 82px; height: 82px; flex-basis: 82px; }
  .learn-header { grid-template-columns: 38px 1fr 34px; }
  .learn-header .icon-button { width: 38px; height: 38px; }
  .learn-header .avatar-small { width: 34px; height: 34px; }
  .flashcard { border-radius: 24px; }
  .grade { min-height: 68px; }
}
@media (max-height: 650px) {
  .learn-shell { min-height: 500px; padding-top: 8px; padding-bottom: 8px; }
  .session-progress { margin-top: 10px; }
  .session-count { margin-bottom: 7px; }
  .flashcard { padding: 17px; }
  .card-front h1 { font-size: clamp(2rem, 9vw, 3.5rem); }
  .card-answer { padding: 16px; }
  .grade { min-height: 62px; }
}
@media (min-width: 760px) {
  .app-shell { padding-left: 0; padding-right: 0; }
  .action-grid { gap: 16px; }
  .action-card { min-height: 190px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
