/* QuickLearn — styles.css */
:root {
  --bg: #0E0F1A;
  --bg2: #151729;
  --card: #1B1E33;
  --card2: #23274A;
  --line: rgba(255,255,255,.08);
  --text: #F4F5FB;
  --muted: #9AA0C3;
  --accent: #FFD23F;      /* lightning yellow */
  --accent-ink: #1A1400;
  --coral: #FF5D73;
  --mint: #3DDC97;
  --sky: #5B8CFF;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 68px;
  --maxw: 720px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior-y: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.center { text-align: center; }
.muted { color: var(--muted); margin: 4px 0 16px; }
.fine { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 16px; }

/* ---------- Shell ---------- */
#app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) 20px 10px;
  background: linear-gradient(var(--bg) 70%, rgba(14,15,26,0));
  max-width: var(--maxw); margin: 0 auto;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.3px; display: flex; gap: 6px; align-items: center; }
.bolt { filter: drop-shadow(0 0 8px rgba(255,210,63,.6)); }
.pro-chip {
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
  background: var(--card2); border: 1px solid var(--line);
}
.pro-chip.is-pro { background: var(--accent); color: var(--accent-ink); }

#view {
  max-width: var(--maxw); margin: 0 auto;
  padding: 6px 20px calc(var(--tabbar-h) + var(--safe-b) + 28px);
  animation: fade .22s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(21,23,41,.92); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; min-width: 56px; }
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.active { color: var(--text); }
.tab.active svg { fill: var(--accent); }
.tab-scan {
  width: 62px; height: 62px; border-radius: 22px; margin-top: -26px;
  background: var(--accent); color: var(--accent-ink) !important; justify-content: center;
  box-shadow: 0 10px 30px rgba(255,210,63,.35), 0 0 0 6px var(--bg);
}
.tab-scan svg { width: 30px; height: 30px; fill: var(--accent-ink) !important; }
.badge { position: absolute; top: -4px; right: 8px; background: var(--coral); color: #fff; font-style: normal; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 999px; }

/* ---------- Type ---------- */
h1 { font-size: 34px; line-height: 1.05; letter-spacing: -1px; margin: 8px 0; font-weight: 850; }
.page-title { font-size: 30px; margin-top: 6px; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 28px 0 12px; }
.eyebrow { color: var(--muted); font-weight: 600; margin: 0; }
.hl { color: var(--accent); }
.pill { display: inline-block; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); }
p.pill.center, .pill.center { display: block; width: fit-content; margin: 12px auto; }

/* ---------- Buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px 18px; margin-top: 10px; border-radius: 16px; font-weight: 700; transition: transform .08s ease; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: var(--card); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--coral); border: 1px solid rgba(255,93,115,.35); margin-top: 28px; }
.btn-xl { padding: 18px; font-size: 18px; border-radius: 20px; }
.btn.small { width: auto; padding: 9px 16px; margin: 0; font-size: 14px; }
.link { display: block; margin: 12px auto 0; color: var(--muted); font-size: 14px; text-decoration: underline; }
.back { color: var(--muted); font-weight: 600; padding: 6px 0; font-size: 16px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(0,0,0,.2); border-top-color: currentColor; animation: spin .7s linear infinite; display: inline-block; }
.spinner.big { width: 36px; height: 36px; border-color: var(--line); border-top-color: var(--accent); margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Home ---------- */
.hero { padding: 10px 0 4px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }

.deck-list { display: grid; gap: 10px; }
@media (min-width: 700px) { .deck-list { grid-template-columns: 1fr 1fr; } }
.deck-tile { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.deck-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--card2); display: grid; place-items: center; font-size: 24px; flex: none; }
.deck-icon.big { width: 64px; height: 64px; font-size: 34px; border-radius: 20px; }
.deck-meta { flex: 1; min-width: 0; }
.deck-meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-meta span { color: var(--muted); font-size: 13px; }
.deck-meta em { color: var(--coral); font-style: normal; font-weight: 700; }
.chev { color: var(--muted); font-size: 24px; }

.empty { text-align: center; padding: 30px 16px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-emoji { font-size: 52px; margin-bottom: 6px; }

/* ---------- Scan ---------- */
.source-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.source { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 8px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.source span { font-size: 34px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 16px 0; }
.thumb { position: relative; aspect-ratio: 3/4; border-radius: 14px; overflow: hidden; background: var(--card); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb i { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); font-style: normal; font-size: 12px; padding: 1px 7px; border-radius: 8px; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 30px; color: var(--muted); border-style: dashed; }
.thumb.add small { font-size: 12px; }
.x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.65); font-size: 18px; line-height: 1; }
.pdf-chip { position: relative; margin: 16px 0; padding: 16px 44px 16px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 600; }
.pdf-chip .x { top: 12px; right: 10px; }
.tips { margin-top: 26px; padding: 16px; background: var(--bg2); border-radius: var(--radius); color: var(--muted); font-size: 14px; }
.tips b { color: var(--text); }
.tips ul { margin: 8px 0 0; padding-left: 18px; }

.field { display: block; margin: 14px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 16px; -webkit-appearance: none; appearance: none; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.preview-list { display: grid; gap: 8px; }
.mini-card { position: relative; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.mini-card b { display: block; margin-bottom: 4px; padding-right: 64px; }
.mini-card span { color: var(--muted); font-size: 14px; }
.tag { position: absolute; top: 12px; right: 12px; font-style: normal; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.tag.new { background: rgba(91,140,255,.18); color: var(--sky); }
.tag.weak { background: rgba(255,93,115,.18); color: var(--coral); }
.tag.good { background: rgba(61,220,151,.18); color: var(--mint); }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 16px; }
.sticky-actions .btn { margin: 0; }

/* ---------- Deck ---------- */
.deck-head { text-align: center; margin: 8px 0 10px; }
.deck-head .deck-icon { margin: 0 auto 6px; }
.progress { height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; flex: 1; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--mint)); border-radius: 99px; transition: width .3s ease; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 4px; }
.action { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.action span { font-size: 30px; }
.action small { color: var(--muted); font-size: 12px; }
.action.hot { background: linear-gradient(160deg, #3A2A6B, #24264A); border-color: rgba(255,210,63,.35); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.seg button { padding: 10px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px; }

/* ---------- Study ---------- */
.study-top { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.study-top .back { font-size: 22px; }
.flip { perspective: 1400px; height: min(56vh, 440px); margin: 12px 0 18px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d; }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; border: 1px solid var(--line); overflow-y: auto; }
.face p { font-size: clamp(20px, 3.2vw, 28px); font-weight: 700; margin: 0; line-height: 1.3; }
.face small { position: absolute; bottom: 18px; color: var(--muted); }
.face.front { background: linear-gradient(160deg, var(--card2), var(--card)); }
.face.back { background: linear-gradient(160deg, #2F2A12, #1D1B10); border-color: rgba(255,210,63,.3); transform: rotateY(180deg); }
.face.back p { font-weight: 600; }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade { padding: 14px 4px; border-radius: 14px; font-weight: 800; display: flex; flex-direction: column; align-items: center; font-size: 15px; }
.grade small { font-size: 11px; font-weight: 600; opacity: .8; }
.grade.again { background: rgba(255,93,115,.16); color: var(--coral); }
.grade.hard { background: rgba(255,170,80,.16); color: #FFAA50; }
.grade.good { background: rgba(61,220,151,.16); color: var(--mint); }
.grade.easy { background: rgba(91,140,255,.16); color: var(--sky); }

.question { font-size: 22px; line-height: 1.3; margin: 10px 0 18px; }
.options { display: grid; gap: 10px; }
@media (min-width: 700px) { .options { grid-template-columns: 1fr 1fr; } }
.option { display: flex; align-items: center; gap: 12px; text-align: left; padding: 16px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); font-weight: 600; transition: background .15s, border-color .15s, opacity .15s; }
.option i { flex: none; width: 30px; height: 30px; border-radius: 10px; background: var(--card2); display: grid; place-items: center; font-style: normal; font-weight: 800; color: var(--muted); }
.option:disabled { opacity: 1; }
.option.picked { border-color: var(--sky); }
.option.correct { background: rgba(61,220,151,.16); border-color: var(--mint); }
.option.correct i { background: var(--mint); color: #062; }
.option.wrong { background: rgba(255,93,115,.14); border-color: var(--coral); }
.option.wrong i { background: var(--coral); color: #fff; }
.option.dim { opacity: .45 !important; }

.done { text-align: center; padding: 30px 0; }
.done h1 { font-size: 36px; }

/* ---------- Review ---------- */
.review-card { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px 8px; text-align: center; margin: 10px 0; }
.review-card.hot { background: linear-gradient(160deg, #3A1F33, #1B1E33); border-color: rgba(255,93,115,.35); }
.review-card span { display: block; color: var(--muted); font-size: 13px; }
.big-num { font-size: 32px; font-weight: 850; }

/* ---------- Battle ---------- */
.battle { position: relative; padding-top: 4px; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.player { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player.opp { justify-content: flex-end; text-align: right; }
.player b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.player small { color: var(--muted); font-size: 11px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; }
.me .avatar { background: var(--accent); color: var(--accent-ink); }
.opp .avatar { background: var(--coral); color: #fff; }
.score { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 56px; }
.me .score { color: var(--accent); margin-left: auto; }
.opp .score { color: var(--coral); margin-right: auto; }
.vs { font-weight: 900; color: var(--muted); font-size: 13px; }
.tug { height: 10px; border-radius: 99px; background: var(--coral); overflow: hidden; margin: 14px 0 10px; }
.tug i { display: block; height: 100%; background: var(--accent); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.round-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 600; }
.opp-status { color: var(--coral); }
.timer { height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; margin: 10px 0 8px; }
.timer i { display: block; height: 100%; width: 100%; background: var(--mint); }
.timer i.low { background: var(--coral); }
#bStage { min-height: 360px; }
.countdown { font-size: 120px; font-weight: 900; text-align: center; color: var(--accent); padding-top: 60px; }
.countdown.pop { animation: pop .8s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: .9; } }
.float-pts { position: absolute; top: 40px; left: 40px; font-size: 26px; font-weight: 900; color: var(--accent); pointer-events: none; animation: floatUp 1.1s ease forwards; }
@keyframes floatUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-50px); opacity: 0; } }
.final { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.final div { background: var(--card); border-radius: var(--radius); padding: 16px; }
.final div:first-child { border: 1px solid rgba(255,210,63,.4); }
.final b { display: block; font-size: 32px; }
.final span { color: var(--muted); font-size: 13px; }

.room-code { display: flex; justify-content: center; gap: 10px; margin: 24px 0 8px; }
.room-code i { font-style: normal; width: 60px; height: 72px; display: grid; place-items: center; font-size: 36px; font-weight: 900; background: var(--card); border: 2px solid var(--accent); border-radius: 16px; }

.leaderboard { display: grid; gap: 6px; }
.lb-row { display: grid; grid-template-columns: 34px 1fr 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.lb-row.mine { border-color: rgba(255,210,63,.5); }
.rank { text-align: center; font-weight: 800; }
.lb-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-bar { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.lb-bar i { display: block; height: 100%; background: var(--accent); }

/* ---------- Me ---------- */
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; margin-top: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-row.soft { background: var(--bg2); }
.card-row b { display: block; }
.card-row span { color: var(--muted); font-size: 13px; }

/* ---------- Modal / paywall ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,6,12,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 28px 28px 0 0; padding: 26px 22px calc(22px + var(--safe-b)); animation: up .28s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 28px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { font-size: 26px; line-height: 1.15; margin: 10px 0; letter-spacing: -.5px; }
.sheet-x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; background: var(--card); font-size: 22px; line-height: 1; }
.pw-badge { display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(255,210,63,.14); color: var(--accent); font-weight: 800; font-size: 13px; }
.perks { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; font-weight: 600; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 4px; }
.plan { position: relative; padding: 18px 12px 14px; border-radius: 18px; background: var(--card); border: 2px solid var(--line); text-align: left; }
.plan b { display: block; font-size: 17px; }
.plan span { color: var(--muted); font-size: 14px; }
.plan.sel { border-color: var(--accent); background: #26233A; }
.save { position: absolute; top: -10px; right: 10px; background: var(--mint); color: #05301D; font-style: normal; font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 999px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 40px); padding: 12px 18px; border-radius: 14px;
  background: #2A2E52; color: var(--text); font-weight: 600; font-size: 14px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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