@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

/* ═══════ THEMES ═══════ */
:root {
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --f: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --trans: all .18s ease;
}

[data-theme="dark"], [data-theme="system-dark"] {
  --bg:       #09090B;
  --bg1:      #0F1014;
  --bg2:      #18181B;
  --bg3:      #27272A;
  --bg4:      #3F3F46;
  --border:   #27272A;
  --border2:  #3F3F46;
  --text:     #FAFAFA;
  --text2:    #A1A1AA;
  --text3:    #52525B;
  --accent:   #3B82F6;
  --accent-h: #2563EB;
  --accent-bg:rgba(59,130,246,.1);
  --accent-bd:rgba(59,130,246,.25);
  --ok:       #22C55E;
  --ok-bg:    rgba(34,197,94,.1);
  --ok-bd:    rgba(34,197,94,.25);
  --err:      #EF4444;
  --err-bg:   rgba(239,68,68,.1);
  --err-bd:   rgba(239,68,68,.25);
  --warn:     #F59E0B;
  --gold:     #EAB308;
  --silver:   #94A3B8;
  --bronze:   #B45309;
  --shadow:   0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg:0 4px 24px rgba(0,0,0,.6);
  --glow:     0 0 0 1px var(--accent-bd), 0 4px 20px rgba(59,130,246,.15);
}

[data-theme="light"], [data-theme="system-light"] {
  --bg:       #FFFFFF;
  --bg1:      #FAFAFA;
  --bg2:      #F4F4F5;
  --bg3:      #E4E4E7;
  --bg4:      #D4D4D8;
  --border:   #E4E4E7;
  --border2:  #D4D4D8;
  --text:     #09090B;
  --text2:    #52525B;
  --text3:    #A1A1AA;
  --accent:   #2563EB;
  --accent-h: #1D4ED8;
  --accent-bg:rgba(37,99,235,.08);
  --accent-bd:rgba(37,99,235,.2);
  --ok:       #16A34A;
  --ok-bg:    rgba(22,163,74,.08);
  --ok-bd:    rgba(22,163,74,.2);
  --err:      #DC2626;
  --err-bg:   rgba(220,38,38,.08);
  --err-bd:   rgba(220,38,38,.2);
  --warn:     #D97706;
  --gold:     #CA8A04;
  --silver:   #64748B;
  --bronze:   #92400E;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:0 4px 24px rgba(0,0,0,.12);
  --glow:     0 0 0 1px var(--accent-bd), 0 4px 16px rgba(37,99,235,.12);
}

/* ═══════ RESET ═══════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); height: 100%; }
body {
  font-family: var(--f); background: var(--bg); color: var(--text);
  min-height: 100vh; padding-bottom: 72px;
  max-width: 480px; margin: 0 auto; overflow-x: hidden;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--f); }
input, textarea, select { font-family: var(--f); }

/* ═══════ HEADER ═══════ */
.hdr {
  position: sticky; top: 0; z-index: 200;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  backdrop-filter: blur(12px);
}
[data-theme="dark"] .hdr, [data-theme="system-dark"] .hdr { background: rgba(9,9,11,.9); }
[data-theme="light"] .hdr, [data-theme="system-light"] .hdr { background: rgba(255,255,255,.9); }

.logo { display: flex; align-items: center; gap: .45rem; }
.logo-mark {
  width: 30px; height: 30px;
  background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark svg { width: 16px; height: 16px; stroke: white; }
.logo-name { font-size: .95rem; font-weight: 800; letter-spacing: -.4px; color: var(--text); }
.logo-badge {
  font-size: .52rem; font-weight: 700; letter-spacing: .8px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid var(--accent-bd); border-radius: 4px;
  padding: 2px 5px; text-transform: uppercase;
}
.hdr-right { display: flex; align-items: center; gap: .35rem; }
.hdr-pill {
  display: flex; align-items: center; gap: .2rem;
  padding: 3px 9px; border-radius: 20px;
  font-size: .68rem; font-weight: 600; font-family: var(--mono);
  border: 1px solid var(--border); background: var(--bg2);
  color: var(--text2);
}
.hdr-pill.streak { color: var(--warn); border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.06); }
.hdr-pill.xp     { color: var(--accent); border-color: var(--accent-bd); background: var(--accent-bg); }

/* ═══════ NAV ═══════ */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 300;
  background: var(--bg); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5,1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[data-theme="dark"] .nav, [data-theme="system-dark"] .nav { background: rgba(9,9,11,.95); }
[data-theme="light"] .nav, [data-theme="system-light"] .nav { background: rgba(255,255,255,.95); }
.nav-btn {
  padding: 10px 4px 9px; border: none; background: transparent;
  color: var(--text3); font-size: .55rem; font-weight: 600;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 4px; letter-spacing: .1px;
  transition: color .15s; position: relative;
}
.nav-btn svg { width: 22px; height: 22px; transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.nav-btn.active { color: var(--accent); }
.nav-btn.active svg { transform: scale(1.1) translateY(-1px); }
.nav-btn.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%); width: 16px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}

/* ═══════ SCREENS ═══════ */
.screen { display: none; padding: .9rem 1rem; position: relative; z-index: 1; }
.screen.active { display: block; animation: screenIn .2s ease; }
@keyframes screenIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

/* ═══════ COMPONENTS ═══════ */
.section-label {
  font-size: .62rem; font-weight: 700; color: var(--text3);
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: .5rem;
}

/* Card */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  margin-bottom: .65rem; box-shadow: var(--shadow);
}
.card-accent {
  background: var(--accent-bg); border: 1px solid var(--accent-bd);
  border-radius: var(--radius-lg); padding: 1rem; margin-bottom: .65rem;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; border: none; border-radius: var(--radius);
  font-weight: 600; cursor: pointer; transition: var(--trans);
  font-family: var(--f); white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 1px 8px rgba(59,130,246,.25);
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary {
  background: var(--bg3); color: var(--text2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg4); color: var(--text); }
.btn-secondary:active { transform: scale(.98); }
.btn-danger { background: var(--err-bg); color: var(--err); border: 1px solid var(--err-bd); }
.btn-full { width: 100%; padding: .82rem; font-size: .88rem; }
.btn-sm { padding: .42rem .85rem; font-size: .78rem; }
.btn-icon { padding: .5rem; border-radius: var(--radius-sm); background: var(--bg3); border: 1px solid var(--border); color: var(--text2); }
.btn-icon:hover { color: var(--text); background: var(--bg4); }
.btn-icon:active { transform: scale(.95); }

/* Inputs */
.input-group { margin-bottom: .85rem; }
.input-label { font-size: .78rem; font-weight: 600; color: var(--text2); margin-bottom: .35rem; display: block; }
.input {
  width: 100%; padding: .72rem .9rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .9rem; outline: none; transition: var(--trans);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input::placeholder { color: var(--text3); }
.input-error { border-color: var(--err); }
.input-error:focus { box-shadow: 0 0 0 3px var(--err-bg); }
.field-error { font-size: .72rem; color: var(--err); margin-top: .25rem; }

/* Divider */
.divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.divider span { font-size: .72rem; color: var(--text3); white-space: nowrap; }

/* ═══════ AUTH SCREENS ═══════ */
.auth-wrap { min-height: calc(100vh - 56px); display: flex; flex-direction: column; justify-content: center; padding: 1.5rem 1rem; }
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-logo { width: 48px; height: 48px; background: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin: 0 auto .9rem; }
.auth-logo svg { width: 24px; height: 24px; stroke: white; }
.auth-title { font-size: 1.3rem; font-weight: 800; letter-spacing: -.3px; margin-bottom: .3rem; }
.auth-sub { font-size: .82rem; color: var(--text2); line-height: 1.5; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow-lg); }
.auth-footer { text-align: center; font-size: .78rem; color: var(--text3); margin-top: 1.2rem; }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* Google Button */
.btn-google {
  width: 100%; padding: .78rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  gap: .6rem; font-size: .88rem; font-weight: 600; color: var(--text);
  cursor: pointer; transition: var(--trans);
}
.btn-google:hover { background: var(--bg3); }
.btn-google svg { width: 18px; height: 18px; }

/* ═══════ HOME ═══════ */
.hero-card {
  background: var(--accent);
  border-radius: var(--radius-lg); padding: 1.3rem;
  margin-bottom: .65rem; position: relative; overflow: hidden;
  color: white;
}
.hero-card::before {
  content: ''; position: absolute; top: -30px; right: -30px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,.08); border-radius: 50%;
}
.hero-card::after {
  content: ''; position: absolute; bottom: -20px; right: 20px;
  width: 80px; height: 80px;
  background: rgba(255,255,255,.06); border-radius: 50%;
}
.hero-eyebrow { font-size: .62rem; font-weight: 700; opacity: .8; letter-spacing: 1px; text-transform: uppercase; margin-bottom: .4rem; }
.hero-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -.3px; margin-bottom: .25rem; }
.hero-sub { font-size: .8rem; opacity: .85; line-height: 1.5; margin-bottom: .9rem; }
.hero-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  color: white; border-radius: var(--radius-sm);
  padding: .52rem 1rem; font-size: .82rem; font-weight: 700;
  cursor: pointer; transition: var(--trans); backdrop-filter: blur(8px);
}
.hero-btn:hover { background: rgba(255,255,255,.25); }
.hero-btn:active { transform: scale(.97); }

.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: .5rem; margin-bottom: .65rem; }
.stat-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: .78rem .5rem; text-align: center; box-shadow: var(--shadow); }
.stat-val { font-size: 1.3rem; font-weight: 800; font-family: var(--mono); }
.stat-lbl { font-size: .58rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }

.badge-row { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: none; }
.badge-row::-webkit-scrollbar { display: none; }
.badge-item { flex-shrink: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .6rem; text-align: center; min-width: 62px; transition: var(--trans); }
.badge-item.earned { border-color: var(--accent-bd); background: var(--accent-bg); }
.badge-item.locked { opacity: .3; filter: grayscale(1); }
.badge-icon { width: 20px; height: 20px; margin: 0 auto 3px; }
.badge-name { font-size: .56rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .2px; }
.badge-item.earned .badge-name { color: var(--accent); }

/* ═══════ SCAN ═══════ */
.scan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin-bottom: .65rem; }
.scan-zone {
  background: var(--bg2); border: 1.5px dashed var(--border2);
  border-radius: var(--radius-lg); padding: 1.4rem .75rem;
  text-align: center; cursor: pointer; transition: var(--trans);
  box-shadow: var(--shadow);
}
.scan-zone:hover, .scan-zone:active { border-color: var(--accent); background: var(--accent-bg); }
.scan-zone.gallery { border-color: rgba(34,197,94,.3); }
.scan-zone.gallery:hover { border-color: var(--ok); background: var(--ok-bg); }
.scan-zone-icon { width: 30px; height: 30px; margin: 0 auto .45rem; color: var(--text3); }
.scan-zone:hover .scan-zone-icon { color: var(--accent); }
.scan-zone.gallery:hover .scan-zone-icon { color: var(--ok); }
.scan-zone-title { font-size: .84rem; font-weight: 700; color: var(--text); }
.scan-zone-sub { font-size: .66rem; color: var(--text3); margin-top: 2px; }

#img-preview-wrap { display: none; margin-bottom: .65rem; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); position: relative; }
#img-preview { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.preview-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: .5rem .65rem; background: linear-gradient(to top,rgba(0,0,0,.65),transparent); display: flex; align-items: center; justify-content: space-between; }
.preview-label { font-size: .68rem; font-weight: 600; color: rgba(255,255,255,.8); display: flex; align-items: center; gap: .22rem; }
.preview-remove { background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.15); border-radius: 6px; width: 26px; height: 26px; color: rgba(255,255,255,.7); cursor: pointer; display: flex; align-items: center; justify-content: center; }

.privacy-note { display: flex; align-items: flex-start; gap: .4rem; font-size: .72rem; color: var(--text3); line-height: 1.6; padding: .7rem .9rem; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.privacy-note svg { flex-shrink: 0; margin-top: 1px; }
.privacy-note strong { color: var(--text2); }

/* ═══════ LOADING ═══════ */
.loading-wrap { text-align: center; padding: 4rem 1rem; }
.spinner { position: relative; width: 52px; height: 52px; margin: 0 auto 1.3rem; }
.spin-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; animation: spin .75s linear infinite; }
.spin-ring:nth-child(1) { border-top-color: var(--accent); }
.spin-ring:nth-child(2) { inset: 7px; border-top-color: var(--text3); animation-direction: reverse; animation-duration: 1s; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: .95rem; font-weight: 700; margin-bottom: .85rem; }
.load-step { font-size: .78rem; color: var(--text3); line-height: 2.1; display: flex; align-items: center; justify-content: center; gap: .38rem; transition: color .25s; }
.load-step .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text3); flex-shrink: 0; transition: all .25s; }
.load-step.active { color: var(--accent); }
.load-step.active .dot { background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.load-step.done { color: var(--ok); }
.load-step.done .dot { background: var(--ok); }

/* ═══════ TASK LIST ═══════ */
.tl-header { background: var(--accent); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: .65rem; color: white; position: relative; overflow: hidden; }
.tl-header::before { content: ''; position: absolute; top: -20px; right: -20px; width: 100px; height: 100px; background: rgba(255,255,255,.08); border-radius: 50%; }
.tl-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .45rem; }
.tl-subject { font-size: .6rem; font-weight: 700; opacity: .8; letter-spacing: 1px; text-transform: uppercase; }
.tl-count { font-size: .6rem; font-weight: 600; opacity: .75; font-family: var(--mono); }
.tl-topic { font-size: 1.05rem; font-weight: 700; letter-spacing: -.2px; }
.tl-diff { font-size: .7rem; opacity: .7; margin-top: .1rem; }
.tl-progress-bg { background: rgba(255,255,255,.2); border-radius: 4px; height: 4px; margin-top: .7rem; overflow: hidden; }
.tl-progress { height: 100%; background: white; border-radius: 4px; transition: width .4s cubic-bezier(.4,0,.2,1); }

.tl-actions { display: flex; gap: .4rem; margin-bottom: .65rem; }
.tl-action { flex: 1; padding: .62rem .4rem; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text3); font-size: .74rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .28rem; transition: var(--trans); min-height: 44px; }
.tl-action:hover { background: var(--bg3); color: var(--text2); }
.fav-btn { background: transparent; border: none; cursor: pointer; padding: 3px; display: flex; align-items: center; justify-content: center; transition: transform .12s; }
.fav-btn:active { transform: scale(.82); }
.fav-btn.active svg { stroke: var(--err); fill: var(--err); }

.task-list { display: flex; flex-direction: column; gap: .38rem; margin-bottom: .65rem; }
.task-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .82rem .95rem;
  display: flex; align-items: center; gap: .8rem;
  cursor: pointer; transition: var(--trans);
  position: relative; overflow: hidden; min-height: 62px;
  box-shadow: var(--shadow);
}
.task-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px; border-radius: 0 2px 2px 0; }
.task-card:hover { border-color: var(--border2); }
.task-card:active { transform: scale(.99); }
.task-card.completed { border-color: var(--ok-bd); }
.task-card.completed::before { background: var(--ok); }
.task-card.open::before { background: var(--accent); }
.task-card.locked { opacity: .6; cursor: default; }
.task-card.locked:hover { border-color: var(--border); }
.task-card.unavailable { opacity: .38; cursor: default; filter: grayscale(.6); }
.task-card.unavailable:hover { border-color: var(--border); transform: none; }

.add-types-btn {
  width: 100%; padding: .72rem; margin-top: .2rem;
  background: var(--bg2); border: 1.5px dashed var(--accent-bd);
  border-radius: var(--radius-lg); color: var(--accent);
  font-size: .82rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  gap: .4rem; transition: var(--trans);
}
.add-types-btn:hover { background: var(--accent-bg); border-color: var(--accent); }
.task-icon-wrap { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.task-icon-wrap svg { width: 18px; height: 18px; }
.task-text { flex: 1; min-width: 0; }
.task-name { font-size: .88rem; font-weight: 700; color: var(--text); }
.task-desc { font-size: .66rem; color: var(--text3); margin-top: 1px; }
.task-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.task-stars { display: flex; gap: 2px; }
.task-stars svg { width: 14px; height: 14px; }
.task-xp { font-size: .58rem; color: var(--text3); font-family: var(--mono); }
.lock-badge { display: flex; align-items: center; gap: .2rem; font-size: .58rem; font-weight: 700; color: var(--text3); background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; padding: 2px 7px; }
.lock-badge svg { width: 9px; height: 9px; }

/* Login prompt */
.login-prompt { background: var(--accent-bg); border: 1px solid var(--accent-bd); border-radius: var(--radius-lg); padding: 1rem; text-align: center; margin-bottom: .65rem; }
.login-prompt-title { font-size: .9rem; font-weight: 700; color: var(--text); margin-bottom: .3rem; }
.login-prompt-sub { font-size: .76rem; color: var(--text2); margin-bottom: .8rem; line-height: 1.45; }

/* Done panel */
.done-panel { background: var(--ok-bg); border: 1px solid var(--ok-bd); border-radius: var(--radius-lg); padding: 1.25rem; text-align: center; margin-bottom: .65rem; }
.done-icon { width: 44px; height: 44px; margin: 0 auto .65rem; color: var(--ok); }
.done-score { font-size: 1.9rem; font-weight: 800; color: var(--ok); font-family: var(--mono); }
.done-label { font-size: .74rem; color: var(--text2); margin: .15rem 0 .8rem; }
.done-chips { display: flex; justify-content: center; gap: .38rem; margin-bottom: .85rem; flex-wrap: wrap; }
.done-chip { background: var(--bg2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 11px; font-size: .7rem; font-weight: 600; color: var(--text2); font-family: var(--mono); }

/* ═══════ EXERCISE ═══════ */
.ex-header { display: flex; align-items: center; gap: .65rem; margin-bottom: .72rem; }
.back-btn { width: 38px; height: 38px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: var(--trans); box-shadow: var(--shadow); }
.back-btn:hover { background: var(--bg3); }
.ex-title { font-size: .92rem; font-weight: 700; }
.ex-sub { font-size: .68rem; color: var(--text3); }
.ex-progress { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.ex-progress-bar { flex: 1; background: var(--bg3); border-radius: 4px; height: 5px; overflow: hidden; }
.ex-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #6366F1); border-radius: 4px; transition: width .3s; }
.ex-progress-txt { font-size: .62rem; color: var(--text3); font-family: var(--mono); flex-shrink: 0; min-width: 28px; text-align: right; }

.q-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem; box-shadow: var(--shadow-lg); animation: cardIn .22s ease; }
@keyframes cardIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.q-pill { display: inline-flex; align-items: center; gap: .28rem; padding: 3px 9px; border-radius: 20px; font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: .8rem; }
.q-step { font-size: .62rem; color: var(--text3); font-family: var(--mono); margin-bottom: .55rem; }
.q-text { font-size: .96rem; font-weight: 600; line-height: 1.55; margin-bottom: .92rem; color: var(--text); }

/* MC */
.mc-option { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .38rem; cursor: pointer; font-size: .88rem; display: flex; align-items: center; gap: .6rem; transition: var(--trans); color: var(--text); min-height: 50px; }
.mc-option:hover { border-color: var(--border2); }
.mc-option.selected { border-color: var(--accent); background: var(--accent-bg); }
.mc-option.correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.mc-option.wrong { border-color: var(--err); background: var(--err-bg); color: var(--err); }
.mc-letter { width: 26px; height: 26px; border-radius: 50%; background: var(--bg4); display: flex; align-items: center; justify-content: center; font-size: .65rem; font-weight: 800; flex-shrink: 0; color: var(--text3); font-family: var(--mono); transition: var(--trans); }
.mc-option.selected .mc-letter { background: var(--accent); color: white; }
.mc-option.correct .mc-letter { background: var(--ok); color: white; }
.mc-option.wrong .mc-letter { background: var(--err); color: white; }

/* Gap */
.gap-sentence { font-size: .93rem; line-height: 2.7; color: var(--text); }
.gap-input { background: transparent; border: none; border-bottom: 2px solid var(--accent); color: var(--text); font-size: .93rem; padding: 0 5px; width: 120px; outline: none; text-align: center; font-weight: 600; transition: var(--trans); }
.gap-input:focus { border-color: var(--accent); }
.gap-input.correct { border-color: var(--ok); color: var(--ok); }
.gap-input.wrong { border-color: var(--err); color: var(--err); }

/* TF */
.tf-statement { font-size: .88rem; padding: .62rem .78rem; background: var(--bg3); border-radius: var(--radius-sm); line-height: 1.45; margin-bottom: .4rem; border: 1px solid var(--border); color: var(--text); }
.tf-buttons { display: flex; gap: .35rem; }
.tf-btn { flex: 1; padding: .55rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg3); color: var(--text3); font-size: .8rem; font-weight: 700; cursor: pointer; transition: var(--trans); display: flex; align-items: center; justify-content: center; gap: .25rem; min-height: 46px; }
.tf-btn:hover { border-color: var(--border2); color: var(--text2); }
.tf-btn.sel-true  { border-color: var(--ok);  background: var(--ok-bg);  color: var(--ok);  }
.tf-btn.sel-false { border-color: var(--err); background: var(--err-bg); color: var(--err); }
.tf-btn.mark-correct { border-color: var(--ok);  background: var(--ok-bg);  }
.tf-btn.mark-wrong   { border-color: var(--err); background: var(--err-bg); }

/* Sort */
.sort-list { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.sort-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .88rem; font-size: .86rem; display: flex; align-items: center; gap: .5rem; color: var(--text); transition: var(--trans); min-height: 50px; }
.sort-item.correct-order { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.sort-item.wrong-order { border-color: var(--err); background: var(--err-bg); color: var(--err); }
.sort-num { width: 22px; height: 22px; background: var(--bg4); border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: .63rem; font-weight: 800; color: var(--text3); flex-shrink: 0; font-family: var(--mono); }
.sort-text { flex: 1; }
.sort-arrows { display: flex; flex-direction: column; gap: 1px; flex-shrink: 0; }
.sort-arrow { background: var(--bg4); border: none; border-radius: 4px; width: 26px; height: 22px; color: var(--text3); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--trans); }
.sort-arrow:hover { background: var(--accent); color: white; }
.sort-arrow:active { transform: scale(.92); }
.sort-arrow:disabled { opacity: .2; cursor: not-allowed; }

/* Map */
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .48rem; margin-bottom: .75rem; }
.map-col-header { font-size: .6rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .32rem; text-align: center; }
.map-item { background: var(--bg3); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .45rem; font-size: .8rem; text-align: center; cursor: pointer; transition: var(--trans); min-height: 50px; display: flex; align-items: center; justify-content: center; font-weight: 500; margin-bottom: .3rem; }
.map-item:hover { border-color: var(--border2); }
.map-item.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.map-item.matched { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); cursor: default; }
.map-item.wrong-match { border-color: var(--err); background: var(--err-bg); animation: shake .3s ease; }
.map-item.used { opacity: .4; cursor: default; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.map-progress { font-size: .72rem; color: var(--text3); text-align: center; margin-bottom: .48rem; font-family: var(--mono); }

/* Explain */
.explain-textarea { width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: .88rem; padding: .8rem; min-height: 100px; resize: vertical; outline: none; line-height: 1.5; transition: var(--trans); }
.explain-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.ai-feedback { background: var(--accent-bg); border: 1px solid var(--accent-bd); border-radius: var(--radius); padding: .72rem; font-size: .82rem; line-height: 1.5; margin-top: .6rem; color: var(--text); display: none; }

/* Feedback */
.feedback { border-radius: var(--radius); padding: .72rem .9rem; font-size: .83rem; line-height: 1.5; margin-top: .7rem; display: none; animation: fbIn .2s ease; }
@keyframes fbIn { from{opacity:0;transform:translateY(3px)} to{opacity:1;transform:translateY(0)} }
.feedback.correct { background: var(--ok-bg); border: 1px solid var(--ok-bd); color: var(--ok); }
.feedback.wrong   { background: var(--err-bg); border: 1px solid var(--err-bd); color: var(--err); }
.feedback-label { display: flex; align-items: center; gap: .28rem; font-weight: 700; margin-bottom: .2rem; }
.feedback-label svg { width: 13px; height: 13px; }

.check-btn { width: 100%; padding: .8rem; background: var(--accent); border: none; border-radius: var(--radius); color: white; font-size: .88rem; font-weight: 700; cursor: pointer; margin-top: .8rem; display: flex; align-items: center; justify-content: center; gap: .38rem; transition: var(--trans); }
.check-btn:hover { background: var(--accent-h); }
.check-btn:active { transform: scale(.98); }
.next-btn { width: 100%; padding: .8rem; background: var(--accent); border: none; border-radius: var(--radius); color: white; font-size: .88rem; font-weight: 700; cursor: pointer; margin-top: .45rem; display: none; align-items: center; justify-content: center; gap: .38rem; transition: var(--trans); }
.next-btn.show { display: flex; }
.next-btn:hover { background: var(--accent-h); }

/* ═══════ RESULT ═══════ */
.result-wrap { text-align: center; padding: 1rem 0; }
.result-award-row { display: flex; justify-content: center; margin-bottom: .65rem; }
.result-trophy { width: 56px; height: 56px; }
.result-stars-row { display: flex; justify-content: center; gap: .38rem; margin: .45rem 0 .82rem; }
.result-title { font-size: 1.2rem; font-weight: 800; margin-bottom: .22rem; }
.result-sub { font-size: .84rem; color: var(--text2); margin-bottom: .95rem; }
.result-score { display: inline-flex; align-items: center; gap: .35rem; background: var(--ok-bg); border: 1px solid var(--ok-bd); border-radius: 20px; padding: 5px 16px; font-size: .86rem; font-weight: 700; color: var(--ok); font-family: var(--mono); margin-bottom: 1.1rem; }
.result-actions { display: flex; gap: .42rem; }

/* ═══════ PROGRESS ═══════ */
.level-card { background: var(--accent); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: .65rem; color: white; }
.level-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .45rem; }
.level-label { font-size: .6rem; font-weight: 700; opacity: .8; letter-spacing: 1px; text-transform: uppercase; }
.level-num { font-size: 1.6rem; font-weight: 800; font-family: var(--mono); }
.level-bar-bg { background: rgba(255,255,255,.2); border-radius: 4px; height: 6px; overflow: hidden; }
.level-bar { height: 100%; background: white; border-radius: 4px; transition: width .5s; }
.level-next { font-size: .68rem; opacity: .7; margin-top: .28rem; text-align: right; font-family: var(--mono); }

.stats-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-bottom: .65rem; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .85rem; text-align: center; box-shadow: var(--shadow); }
.stat-card-val { font-size: 1.5rem; font-weight: 800; color: var(--accent); font-family: var(--mono); }
.stat-card-lbl { font-size: .6rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }

.history-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .8rem; margin-bottom: .38rem; display: flex; align-items: center; gap: .72rem; cursor: pointer; transition: var(--trans); min-height: 58px; box-shadow: var(--shadow); }
.history-item:hover { background: var(--bg3); border-color: var(--border2); }
.history-icon { width: 36px; height: 36px; background: var(--accent-bg); border: 1px solid var(--accent-bd); border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.history-icon svg { width: 16px; height: 16px; color: var(--accent); }
.history-body { flex: 1; min-width: 0; }
.history-topic { font-size: .86rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.history-meta { font-size: .63rem; color: var(--text3); margin-top: 2px; display: flex; align-items: center; gap: .3rem; }

.badges-grid { display: flex; flex-wrap: wrap; gap: .38rem; }

/* ═══════ LEADERBOARD ═══════ */
/* ── LEADERBOARD ── */
.lb-tabs { display: flex; gap: .35rem; margin-bottom: .75rem; }
.lb-tab {
  flex: 1; padding: .55rem .35rem;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text3);
  font-size: .73rem; font-weight: 600; cursor: pointer;
  text-align: center; transition: var(--trans);
}
.lb-tab.active { background: var(--accent-bg); border-color: var(--accent-bd); color: var(--accent); }

/* Podium top 3 */
.lb-row { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .8rem .9rem; margin-bottom: .38rem; display: flex; align-items: center; gap: .72rem; min-height: 58px; box-shadow: var(--shadow); transition: all .15s; }
.lb-row:active { transform: scale(.99); }
.lb-row.me { border-color: var(--accent-bd); background: var(--accent-bg); }
.lb-row.top-1 { background: linear-gradient(135deg, rgba(245,158,11,.12) 0%, rgba(251,191,36,.06) 100%); border-color: rgba(245,158,11,.35); }
.lb-row.top-2 { background: linear-gradient(135deg, rgba(148,163,184,.1) 0%, rgba(203,213,225,.05) 100%); border-color: rgba(148,163,184,.3); }
.lb-row.top-3 { background: linear-gradient(135deg, rgba(180,107,54,.1) 0%, rgba(217,158,108,.05) 100%); border-color: rgba(180,107,54,.3); }

.lb-rank { font-size: 1.1rem; flex-shrink: 0; min-width: 28px; text-align: center; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.lb-avatar-placeholder {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #1D4ED8);
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 800; color: white; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(59,130,246,.25);
}
.lb-row.top-1 .lb-avatar-placeholder { background: linear-gradient(135deg, #F59E0B, #D97706); box-shadow: 0 2px 8px rgba(245,158,11,.35); }
.lb-row.top-2 .lb-avatar-placeholder { background: linear-gradient(135deg, #94A3B8, #64748B); box-shadow: 0 2px 6px rgba(148,163,184,.3); }
.lb-row.top-3 .lb-avatar-placeholder { background: linear-gradient(135deg, #B47036, #92520A); box-shadow: 0 2px 6px rgba(180,107,54,.3); }
.lb-row.me   .lb-avatar-placeholder { background: linear-gradient(135deg, var(--accent), #7C3AED); }

/* Leaderboard Avatar Wrapper + Bild + Gold-Rahmen */
.lb-av-wrap {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #1D4ED8);
  position: relative; overflow: hidden;
  box-shadow: 0 2px 6px rgba(59,130,246,.25);
}
.lb-av-init {
  font-size: .82rem; font-weight: 800; color: white; line-height: 1;
  position: relative; z-index: 1; pointer-events: none;
}
.lb-avatar-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; z-index: 2;
}
.lb-av-wrap.lb-frame-gold {
  box-shadow: 0 0 0 2.5px #F59E0B, 0 2px 10px rgba(245,158,11,.45);
}
.lb-row.top-1 .lb-av-wrap { background: linear-gradient(135deg, #F59E0B, #D97706); box-shadow: 0 2px 8px rgba(245,158,11,.35); }
.lb-row.top-1 .lb-av-wrap.lb-frame-gold { box-shadow: 0 0 0 2.5px #F59E0B, 0 2px 12px rgba(245,158,11,.55); }
.lb-row.top-2 .lb-av-wrap { background: linear-gradient(135deg, #94A3B8, #64748B); box-shadow: 0 2px 6px rgba(148,163,184,.3); }
.lb-row.top-3 .lb-av-wrap { background: linear-gradient(135deg, #B47036, #92520A); box-shadow: 0 2px 6px rgba(180,107,54,.3); }
.lb-row.me    .lb-av-wrap { background: linear-gradient(135deg, var(--accent), #7C3AED); }
.lb-fire-badge { font-size: .85rem; vertical-align: middle; margin-left: .2rem; }

.lb-info { flex: 1; min-width: 0; }
.lb-name { font-size: .86rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sub { font-size: .62rem; color: var(--text3); margin-top: 2px; }
.lb-you { background: var(--accent); color: white; border-radius: 6px; padding: 1px 5px; font-size: .52rem; font-weight: 700; vertical-align: middle; margin-left: .25rem; }
.lb-score { flex-shrink: 0; text-align: right; }
.lb-value { display: block; font-size: 1rem; font-weight: 800; font-family: var(--mono); }
.lb-key { font-size: .57rem; color: var(--text3); font-weight: 600; letter-spacing: .3px; }
.lb-empty, .lb-loading { text-align: center; padding: 2.5rem 1rem; color: var(--text3); font-size: .82rem; }

/* ═══════ SAVED ═══════ */
.saved-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .8rem; margin-bottom: .38rem; display: flex; align-items: center; gap: .72rem; cursor: pointer; transition: var(--trans); min-height: 58px; box-shadow: var(--shadow); }
.saved-item:hover { background: var(--bg3); border-color: var(--border2); }
.saved-icon { width: 36px; height: 36px; background: var(--err-bg); border: 1px solid var(--err-bd); border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.saved-icon svg { width: 16px; height: 16px; color: var(--err); }

/* ═══════ PROFILE ═══════ */
.profile-hero { background: var(--accent); border-radius: var(--radius-lg); padding: 1.4rem; text-align: center; margin-bottom: .65rem; color: white; position: relative; overflow: hidden; }
.profile-avatar-wrap { position: relative; width: 64px; height: 64px; margin: 0 auto .75rem; }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255,255,255,.3); }
.profile-avatar-placeholder { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.2); border: 3px solid rgba(255,255,255,.3); display: flex; align-items: center; justify-content: center; }
.profile-avatar-placeholder svg { width: 30px; height: 30px; stroke: white; }

/* ── NEW PROFILE HERO ── */
.prof-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, #1D4ED8 100%);
  border-radius: var(--radius-lg); padding: 1.5rem 1.25rem 1.2rem;
  text-align: center; margin-bottom: .65rem; color: white;
  box-shadow: 0 4px 20px rgba(59,130,246,.3);
}
.prof-hero-bg {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 80% 20%, rgba(255,255,255,.1) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(255,255,255,.06) 0%, transparent 50%);
}
.profile-avatar-placeholder {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 3px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}
.profile-avatar-placeholder svg { width: 30px; height: 30px; stroke: white; }
.profile-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  object-fit: cover; border: 3px solid rgba(255,255,255,.35);
  display: block; margin: 0 auto;
}
.prof-hero-name { font-size: 1.15rem; font-weight: 800; margin-top: .65rem; letter-spacing: -.01em; }
.prof-hero-email { font-size: .73rem; opacity: .72; margin-top: .18rem; word-break: break-all; }
.prof-hero-row { display: flex; align-items: center; justify-content: center; gap: .55rem; margin-top: .5rem; flex-wrap: wrap; }
.prof-hero-level { font-size: .72rem; opacity: .85; font-family: var(--mono); }

/* ── PROFILE STATS ROW ── */
.prof-stats-row {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .85rem .5rem;
  display: flex; align-items: center; justify-content: space-around;
  margin-bottom: .65rem; gap: .25rem;
}
.prof-stat { text-align: center; flex: 1; }
.prof-stat-val { font-size: 1.15rem; font-weight: 800; font-family: var(--mono); line-height: 1.1; }
.prof-stat-lbl { font-size: .62rem; color: var(--text3); margin-top: .18rem; white-space: nowrap; }
.prof-stat-divider { width: 1px; height: 30px; background: var(--border); flex-shrink: 0; }

/* ── SETTING BUTTON ROWS ── */
.setting-btn { width: 100%; text-align: left; cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
.setting-right { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.prof-guest-section { }
.profile-name { font-size: 1.1rem; font-weight: 800; }
.profile-email { font-size: .75rem; opacity: .8; margin-top: .2rem; }
.profile-provider { display: inline-flex; align-items: center; gap: .25rem; font-size: .62rem; font-weight: 600; background: rgba(255,255,255,.15); border-radius: 20px; padding: 3px 9px; margin-top: .4rem; }

.settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: .65rem; box-shadow: var(--shadow); }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid var(--border); transition: var(--trans); }
.setting-row:last-child { border: none; }
.setting-row:hover { background: var(--bg3); }
.setting-left { display: flex; align-items: center; gap: .45rem; font-size: .86rem; font-weight: 500; color: var(--text); }
.setting-left svg { width: 16px; height: 16px; color: var(--text2); flex-shrink: 0; }
.setting-value { font-size: .72rem; color: var(--text3); font-family: var(--mono); }

/* Theme toggle */
.theme-toggle { display: flex; gap: .28rem; background: var(--bg3); border-radius: var(--radius-sm); padding: 3px; }
.theme-opt { padding: 4px 9px; border-radius: 5px; font-size: .68rem; font-weight: 600; cursor: pointer; color: var(--text3); transition: var(--trans); border: none; background: transparent; }
.theme-opt.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }

/* Sync badge */
.sync-badge { display: inline-flex; align-items: center; gap: .22rem; font-size: .65rem; font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.sync-badge.synced { background: var(--ok-bg); color: var(--ok); }
.sync-badge.local { background: var(--bg3); color: var(--text3); }

/* ═══════ INSTALL BANNER ═══════ */
.install-banner {
  display: none; position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: white; border-radius: var(--radius-lg);
  padding: .9rem 1.1rem; z-index: 998;
  width: calc(100% - 2rem); max-width: 440px;
  box-shadow: 0 4px 20px rgba(59,130,246,.4);
  flex-direction: column; gap: .42rem;
}
.install-banner.show { display: flex; animation: slideUp .25s ease; }
@keyframes slideUp { from{opacity:0;transform:translateX(-50%) translateY(12px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }
.install-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.install-title { font-size: .88rem; font-weight: 800; margin-bottom: 2px; }
.install-sub { font-size: .72rem; opacity: .85; }
.install-action-btn { background: white; color: var(--accent); border: none; border-radius: var(--radius-sm); padding: .5rem 1rem; font-size: .8rem; font-weight: 800; cursor: pointer; flex-shrink: 0; }
.install-close { background: transparent; border: none; color: rgba(255,255,255,.7); cursor: pointer; font-size: 1.1rem; padding: 3px; }

/* ═══════ TOAST & XP POP ═══════ */
.toast { position: fixed; bottom: 82px; left: 50%; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--border2); color: var(--text); padding: .6rem 1.1rem; border-radius: var(--radius); font-size: .8rem; font-weight: 500; display: none; z-index: 999; max-width: 92%; text-align: center; box-shadow: var(--shadow-lg); }
.toast.show { display: block; animation: toastIn .2s ease; }
.toast.error { background: var(--err-bg); border-color: var(--err-bd); color: var(--err); }
@keyframes toastIn { from{opacity:0;transform:translateX(-50%) translateY(6px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }
.xp-popup { position: fixed; top: 64px; right: 14px; background: var(--accent); color: white; padding: 4px 12px; border-radius: 20px; font-size: .74rem; font-weight: 700; z-index: 999; pointer-events: none; font-family: var(--mono); animation: xpPop .75s ease forwards; box-shadow: 0 2px 10px rgba(59,130,246,.35); }
@keyframes xpPop { 0%{opacity:0;transform:translateY(5px)} 25%{opacity:1;transform:translateY(0)} 75%{opacity:1} 100%{opacity:0;transform:translateY(-20px)} }

/* ═══════ EMPTY STATE ═══════ */
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto .7rem; display: block; color: var(--text3); opacity: .5; }
.empty-state-title { font-size: .9rem; font-weight: 700; color: var(--text2); margin-bottom: .3rem; }
.empty-state-sub { font-size: .78rem; color: var(--text3); line-height: 1.5; }

/* ═══════ FLASHCARD SYSTEM ═══════ */

/* Nav with 6 items */
.nav-6 { grid-template-columns: repeat(6,1fr) !important; }
.nav-6 .nav-btn { font-size: .5rem; gap: 3px; padding: 10px 2px 9px; }
.nav-6 .nav-btn svg { width: 20px; height: 20px; }

/* Deck List Screen */
.fc-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.fc-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -.3px; }
.fc-actions { display: flex; gap: .4rem; }

.deck-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  margin-bottom: .6rem; cursor: pointer;
  transition: var(--trans); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: .85rem;
}
.deck-card:hover { border-color: var(--border2); background: var(--bg3); }
.deck-card:active { transform: scale(.99); }

.deck-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 1.4rem;
  background: var(--accent-bg); border: 1px solid var(--accent-bd);
}
.deck-body { flex: 1; min-width: 0; }
.deck-name { font-size: .9rem; font-weight: 700; margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-meta { font-size: .7rem; color: var(--text3); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.deck-due { color: var(--accent); font-weight: 600; }
.deck-due-warn { color: var(--warn); font-weight: 600; }
.deck-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex-shrink: 0; }
.deck-count { font-size: .75rem; font-weight: 700; color: var(--text2); }

.deck-progress { height: 4px; border-radius: 2px; background: var(--bg4); overflow: hidden; min-width: 50px; }
.deck-progress-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .3s; }

/* Empty state */
.fc-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text3);
}
.fc-empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.fc-empty-title { font-size: .95rem; font-weight: 700; color: var(--text2); margin-bottom: .35rem; }
.fc-empty-sub { font-size: .78rem; line-height: 1.5; margin-bottom: 1.25rem; }

/* Import/Export action buttons */
.fc-action-row {
  display: flex; gap: .5rem; margin-bottom: 1rem;
}
.fc-action-btn {
  flex: 1; padding: .6rem; border-radius: var(--radius);
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text2); font-size: .75rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  cursor: pointer; transition: var(--trans);
}
.fc-action-btn:hover { background: var(--bg3); color: var(--text); }
.fc-action-btn:active { transform: scale(.98); }
.fc-action-btn.accent { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-bd); }
.fc-action-btn.accent:hover { background: var(--accent); color: white; }

/* STUDY SCREEN */
.study-screen {
  min-height: calc(100vh - 56px - 72px);
  display: flex; flex-direction: column;
  padding: .75rem 1rem 1.5rem;
}
.study-header {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: .85rem;
}
.study-back {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--trans); flex-shrink: 0;
}
.study-back:hover { background: var(--bg3); }
.study-header-text { flex: 1; min-width: 0; }
.study-deck-name { font-size: .88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-progress-text { font-size: .68rem; color: var(--text3); }

.study-prog-bar { height: 4px; border-radius: 2px; background: var(--bg3); margin-bottom: 1rem; overflow: hidden; }
.study-prog-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .35s; }

/* THE FLIP CARD */
.fc-flip-wrap {
  perspective: 1200px;
  flex: 1; display: flex; flex-direction: column;
  min-height: 0;
}
.fc-flip {
  position: relative;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
  border-radius: var(--radius-lg);
  min-height: 280px; flex: 1;
  max-height: 380px;
}
.fc-flip.flipped { transform: rotateY(180deg); }

.fc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1.5rem; text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  cursor: pointer;
}
.fc-front {
  background: var(--bg2);
}
.fc-back {
  background: var(--bg3);
  transform: rotateY(180deg);
}

.fc-face-label {
  font-size: .6rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text3); margin-bottom: 1rem;
  display: flex; align-items: center; gap: .3rem;
}
.fc-face-word {
  font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px;
  color: var(--text); line-height: 1.2; margin-bottom: .5rem;
  word-break: break-word;
}
.fc-face-sub {
  font-size: .82rem; color: var(--text2); line-height: 1.5;
  max-width: 280px; word-break: break-word;
}
.fc-face-example {
  margin-top: .75rem; font-size: .72rem; color: var(--text3);
  font-style: italic; line-height: 1.4;
  background: var(--bg2); border-radius: 8px; padding: .5rem .75rem;
  border: 1px solid var(--border);
}
.fc-tap-hint {
  position: absolute; bottom: .9rem;
  font-size: .62rem; color: var(--text3);
  display: flex; align-items: center; gap: .25rem;
}

/* Rating buttons */
.fc-rating-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: .45rem; margin-top: .9rem;
}
.fc-rate-btn {
  padding: .65rem .3rem; border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .68rem; font-weight: 700;
  cursor: pointer; transition: var(--trans);
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  line-height: 1.1;
}
.fc-rate-btn:active { transform: scale(.97); }
.fc-rate-btn.again { background: var(--err-bg); color: var(--err); border-color: var(--err-bd); }
.fc-rate-btn.hard  { background: rgba(245,158,11,.1); color: var(--warn); border-color: rgba(245,158,11,.25); }
.fc-rate-btn.good  { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bd); }
.fc-rate-btn.easy  { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-bd); }
.fc-rate-btn .rate-interval { font-size: .58rem; font-weight: 500; opacity: .8; }

/* Flip hint when not yet flipped */
.fc-show-btn {
  width: 100%; padding: .78rem; margin-top: .9rem;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  font-size: .88rem; font-weight: 700;
  cursor: pointer; transition: var(--trans);
  display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.fc-show-btn:hover { background: var(--accent-h); }
.fc-show-btn:active { transform: scale(.98); }

/* Session result */
.study-result {
  text-align: center; padding: 2rem 1rem;
}
.study-result-icon { font-size: 3.5rem; margin-bottom: .75rem; }
.study-result-title { font-size: 1.2rem; font-weight: 800; margin-bottom: .35rem; }
.study-result-sub { font-size: .82rem; color: var(--text2); margin-bottom: 1.5rem; line-height: 1.5; }
.study-result-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: .5rem; margin-bottom: 1.5rem;
}
.srs-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem .4rem; text-align: center;
}
.srs-stat-val { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.srs-stat-lbl { font-size: .6rem; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-top: .2rem; }

/* Deck edit modal */
.deck-edit-header {
  display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem;
}
.deck-card-edit-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem; margin-bottom: .4rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.deck-card-inputs { flex: 1; display: flex; flex-direction: column; gap: .35rem; }
.deck-card-inputs input {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .6rem;
  color: var(--text); font-size: .82rem; outline: none;
  transition: border-color .15s;
}
.deck-card-inputs input:focus { border-color: var(--accent); }
.deck-card-inputs input::placeholder { color: var(--text3); }
.add-card-btn {
  width: 100%; padding: .65rem; margin-top: .4rem;
  background: var(--bg3); border: 1px dashed var(--border2);
  border-radius: var(--radius); color: var(--text3);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  transition: var(--trans);
}
.add-card-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* Scan → Deck badge */
.scan-deck-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem .9rem; margin: .4rem 0;
  background: var(--accent-bg); border: 1px solid var(--accent-bd);
  border-radius: var(--radius); color: var(--accent);
  font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: var(--trans); width: 100%;
}
.scan-deck-btn:hover { background: var(--accent); color: white; }
.scan-deck-btn:active { transform: scale(.99); }

/* Section badges in deck list */
.fc-section { font-size: .6rem; font-weight: 700; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; margin: .9rem 0 .4rem; }


/* ═══════ AVATAR UPLOAD ═══════ */
#prof-avatar-wrap {
  position: relative;
  display: inline-block;
}
.avatar-frame-wrap {
  border-radius: 50%;
  overflow: hidden;
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
}
.avatar-frame-wrap.frame-gold {
  outline: 3px solid #EAB308;
  box-shadow: 0 0 12px rgba(234,179,8,.5);
  border-radius: 50%;
}
.avatar-edit-badge {
  position: absolute;
  bottom: 0; right: 0;
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  pointer-events: none;
}

/* ═══════ GEM SHOP BUTTON ═══════ */
.shop-open-btn {
  display: flex; align-items: center; justify-content: center;
  gap: .5rem;
  background: linear-gradient(135deg, #7C3AED, #3B82F6);
  color: white; border: none;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-weight: 700; font-size: .95rem;
  cursor: pointer;
  transition: var(--trans);
}
.shop-open-btn:active { transform: scale(.98); opacity: .9; }
.shop-gems-badge {
  margin-left: auto;
  background: rgba(255,255,255,.25);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 800;
}

/* ═══════ SHOP OVERLAY ═══════ */
.shop-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.shop-overlay.open {
  opacity: 1; pointer-events: all;
}
.shop-sheet {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.25rem 1rem 2rem;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.22,1,.36,1);
  max-height: 85vh;
  overflow-y: auto;
}
.shop-overlay.open .shop-sheet {
  transform: translateY(0);
}
.shop-header {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .25rem;
}
.shop-title {
  font-size: 1.1rem; font-weight: 800; flex: 1;
}
.shop-balance {
  display: flex; align-items: center; gap: .35rem;
  font-size: .82rem; color: var(--text2);
}
.shop-gems-val {
  font-weight: 800; color: #A855F7; font-size: .95rem;
}
.shop-close-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg3); border: none; color: var(--text2);
  font-size: .9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--trans);
}
.shop-close-btn:hover { background: var(--bg4); color: var(--text); }
.shop-sub {
  font-size: .78rem; color: var(--text2);
  margin-bottom: 1rem;
}
.shop-grid {
  display: flex; flex-direction: column; gap: .6rem;
}
.shop-card {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem;
  transition: var(--trans);
}
.shop-card.maxed {
  opacity: .6;
}
.shop-card.cant-afford {
  opacity: .75;
}
.shop-icon-big {
  font-size: 1.6rem;
  width: 36px; text-align: center;
  flex-shrink: 0;
}
.shop-info {
  flex: 1; min-width: 0;
}
.shop-name {
  font-size: .9rem; font-weight: 700;
  margin-bottom: .1rem;
}
.shop-desc {
  font-size: .74rem; color: var(--text2);
  line-height: 1.35;
}
.shop-owned {
  display: inline-block;
  margin-top: .25rem;
  font-size: .7rem; font-weight: 700;
  color: var(--ok);
}
.shop-buy-btn {
  flex-shrink: 0;
  background: linear-gradient(135deg, #7C3AED, #3B82F6);
  color: white; border: none;
  padding: .45rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--trans);
}
.shop-buy-btn:active { transform: scale(.95); }
.shop-buy-btn.owned, .shop-buy-btn:disabled {
  background: var(--bg4); color: var(--text3);
  cursor: default; transform: none;
}

/* ═══════ PROGRESS CHARTS ═══════ */
.prog-chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .9rem 1rem .7rem;
  margin-bottom: .65rem;
  overflow: hidden;
}
.prog-chart-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .6rem;
}
.prog-chart-title {
  font-size: .73rem;
  font-weight: 700;
  color: var(--text);
}
.prog-chart-badge {
  font-size: .68rem;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--mono);
  background: var(--accent-bg);
  border: 1px solid var(--accent-bd);
  border-radius: 20px;
  padding: 2px 8px;
}
.prog-chart-legend {
  display: flex;
  gap: .75rem;
  margin-top: .55rem;
  font-size: .64rem;
  color: var(--text3);
  flex-wrap: wrap;
}
.prog-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 3px;
  vertical-align: middle;
}

/* Progress Detail Cards */
.prog-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .65rem;
}
.prog-detail-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .85rem;
}
.prog-detail-label {
  font-size: .58rem;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: .28rem;
}
.prog-detail-val {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prog-detail-sub {
  font-size: .63rem;
  color: var(--text3);
  margin-top: .18rem;
}
