:root {
  --a1: #8b5cf6; --a2: #22d3ee;
  --bg: #0b0d17; --bg2: #121528; --card: rgba(255,255,255,.055); --card2: rgba(255,255,255,.09);
  --line: rgba(255,255,255,.09); --text: #eef0ff; --muted: #9aa0c3; --good: #3ddc97; --bad: #ff5d73; --warn: #ffb547;
  --r: 18px; --shadow: 0 10px 40px rgba(0,0,0,.35);
  --grad: linear-gradient(135deg, var(--a1), var(--a2));
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
  background-image: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--a1) 22%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, color-mix(in srgb, var(--a2) 16%, transparent), transparent 60%);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--a2); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.7rem; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: .3rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: .6rem; }
.grow { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.hidden { display: none !important; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }

/* ---------- layout ---------- */
#app { min-height: 100%; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 1.2rem .9rem; border-right: 1px solid var(--line);
  background: rgba(10,12,24,.6); backdrop-filter: blur(16px); display: flex; flex-direction: column; gap: .3rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.2rem; padding: .3rem .6rem 1rem; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.nav-btn {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 12px; border: 0; background: none;
  color: var(--muted); cursor: pointer; text-align: left; font-weight: 600; text-decoration: none;
}
.nav-btn .ico { width: 1.4rem; text-align: center; font-size: 1.1rem; }
.nav-btn:hover { background: var(--card); color: var(--text); }
.nav-btn.active { background: var(--card2); color: var(--text); box-shadow: inset 3px 0 0 var(--a1); }
.side .spacer { flex: 1; }
.sync-pill { font-size: .78rem; color: var(--muted); padding: .5rem .8rem; display: flex; gap: .4rem; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.off { background: var(--warn); }
main { padding: 1.6rem 2rem 6rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.tabbar { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: calc(1rem + var(--safe-t)) 1rem calc(6rem + var(--safe-b)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: .4rem .4rem calc(.4rem + var(--safe-b));
    background: rgba(12,14,28,.85); backdrop-filter: blur(18px); border-top: 1px solid var(--line);
  }
  .tabbar button { flex: 1; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; padding: .35rem 0; border-radius: 12px; }
  .tabbar button .ico { font-size: 1.3rem; }
  .tabbar button.active { color: var(--text); background: var(--card); }
  h1 { font-size: 1.45rem; }
}

/* ---------- components ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem;
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.card.glow { border-color: color-mix(in srgb, var(--a1) 45%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--a1) 14%, transparent), var(--card)); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 1.6rem 0 .7rem; }
.section-title h2 { margin: 0; }

.btn {
  border: 0; border-radius: 12px; padding: .65rem 1rem; font-weight: 700; cursor: pointer; background: var(--card2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; transition: transform .08s, filter .15s; text-decoration: none;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 20px color-mix(in srgb, var(--a1) 40%, transparent); }
.btn.good { background: var(--good); color: #062; }
.btn.danger { background: color-mix(in srgb, var(--bad) 25%, transparent); color: #ffd0d6; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { border: 0; background: var(--card); width: 38px; height: 38px; border-radius: 12px; cursor: pointer; font-size: 1.05rem; }

label.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=time], input[type=url], select, textarea {
  background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; color: var(--text); width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--a1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a1) 25%, transparent); }
textarea { min-height: 160px; resize: vertical; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; background: var(--card2); font-size: .8rem; font-weight: 600; }
.chip.on { background: var(--grad); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.toggle { position: relative; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--card2); border-radius: 99px; transition: .2s; cursor: pointer; }
.toggle span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle input:checked + span { background: var(--grad); }
.toggle input:checked + span::after { transform: translateX(20px); }
.daypick { display: flex; gap: .3rem; }
.daypick button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 700; font-size: .8rem; }
.daypick button.on { background: var(--grad); border-color: transparent; color: #fff; }

.bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }

.banner { display: flex; gap: .8rem; align-items: center; padding: .8rem 1rem; border-radius: 14px; margin-bottom: 1rem; background: linear-gradient(90deg, color-mix(in srgb, var(--a1) 30%, transparent), color-mix(in srgb, var(--a2) 20%, transparent)); border: 1px solid var(--line); }
.banner .grow { font-weight: 600; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: auto 1fr auto; gap: 1.2rem; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 2.1rem; background: var(--card2); position: relative; }
.avatar.lg { width: 96px; height: 96px; font-size: 3.2rem; border-radius: 28px; }
.avatar .lvl { position: absolute; bottom: -8px; right: -8px; background: var(--grad); font-size: .72rem; font-weight: 800; padding: .1rem .45rem; border-radius: 99px; border: 2px solid var(--bg); }
.rank-badge { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.rank-badge .em { font-size: 1.8rem; filter: drop-shadow(0 0 10px var(--rc, #fff4)); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-top: 1rem; }
.stat { background: rgba(0,0,0,.2); border-radius: 14px; padding: .7rem; text-align: center; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { font-size: .75rem; color: var(--muted); }
@media (max-width: 600px) {
  .hero { grid-template-columns: auto 1fr; }
  .hero .rank-badge { grid-column: 1 / -1; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: .55rem; }
.tl-item { display: grid; grid-template-columns: 62px 6px 1fr auto; gap: .8rem; align-items: center; padding: .75rem .9rem; border-radius: 16px; background: var(--card); border: 1px solid var(--line); cursor: pointer; transition: .15s; }
.tl-item:hover { background: var(--card2); }
.tl-item .time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9rem; }
.tl-item .time small { display: block; color: var(--muted); font-weight: 500; }
.tl-item .stripe { width: 6px; height: 100%; min-height: 38px; border-radius: 6px; background: var(--c); }
.tl-item .title { font-weight: 700; }
.tl-item.done { opacity: .6; }
.tl-item.done .title { text-decoration: line-through; }
.tl-item.busy { cursor: default; background: transparent; border-style: dashed; opacity: .55; }
.check { width: 40px; height: 40px; border-radius: 13px; border: 2px solid var(--line); background: transparent; cursor: pointer; display: grid; place-items: center; font-size: 1.15rem; transition: .2s; }
.check.on { background: var(--good); border-color: var(--good); color: #052; transform: scale(1.05); }

/* ---------- week grid ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; }
.wday { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .6rem; min-height: 220px; }
.wday.today { border-color: var(--a1); box-shadow: 0 0 0 1px var(--a1), var(--shadow); }
.wday h4 { margin: 0 0 .5rem; font-size: .85rem; display: flex; justify-content: space-between; }
.wblock { border-radius: 10px; padding: .4rem .5rem; margin-bottom: .4rem; font-size: .78rem; background: color-mix(in srgb, var(--c) 22%, transparent); border-left: 3px solid var(--c); cursor: pointer; }
.wblock.done { opacity: .5; text-decoration: line-through; }
.wblock.busy { --c: #667; cursor: default; opacity: .7; }
.wblock b { display: block; font-size: .8rem; }
@media (max-width: 1000px) { .week { grid-template-columns: 1fr; } .wday { min-height: 0; } }

/* ---------- lessons ---------- */
.path { display: flex; flex-direction: column; gap: .4rem; }
.stage-h { margin: 1.2rem 0 .4rem; font-weight: 800; color: var(--muted); text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; }
.lesson-row { display: flex; gap: .8rem; align-items: center; padding: .6rem .8rem; border-radius: 14px; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.lesson-row .num { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--card2); font-weight: 800; font-size: .85rem; flex: none; }
.lesson-row.done .num { background: var(--good); color: #052; }
.lesson-row.current { border-color: var(--a1); background: linear-gradient(90deg, color-mix(in srgb, var(--a1) 18%, transparent), var(--card)); }
.lesson-row.current .num { background: var(--grad); color: #fff; }
.lesson-row.locked { opacity: .5; }
pre.tab { background: #070912; border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; overflow-x: auto; font: 13px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #cfe3ff; }
.chord-grid { display: flex; flex-wrap: wrap; gap: .8rem; }
.chord { background: rgba(0,0,0,.25); border-radius: 14px; padding: .5rem .6rem .3rem; text-align: center; }
.chord b { display: block; font-size: .9rem; margin-bottom: .1rem; }
ol.steps, ul.points { padding-left: 1.2rem; margin: .4rem 0; }
ol.steps li, ul.points li { margin: .35rem 0; }
.practice-item { display: flex; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.practice-item:last-child { border: 0; }
.practice-item input { width: 20px; height: 20px; accent-color: var(--a1); }

/* ---------- exercises ---------- */
.ex { display: grid; grid-template-columns: 1fr auto; gap: .5rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.ex:last-child { border: 0; }
.ex .sets { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; }
.ex .set { min-width: 46px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 700; font-size: .8rem; }
.ex .set.on { background: var(--good); color: #052; border-color: var(--good); }
details { margin-top: .4rem; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

/* ---------- quiz ---------- */
.quiz-q { font-size: 1.15rem; font-weight: 700; margin: .6rem 0 1rem; }
.opt { display: block; width: 100%; text-align: left; padding: .85rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--card); margin-bottom: .5rem; cursor: pointer; font-weight: 600; transition: .15s; }
.opt:hover { background: var(--card2); }
.opt.right { background: color-mix(in srgb, var(--good) 25%, transparent); border-color: var(--good); }
.opt.wrong { background: color-mix(in srgb, var(--bad) 25%, transparent); border-color: var(--bad); }
.explain { padding: .8rem 1rem; border-radius: 14px; background: rgba(0,0,0,.25); margin-top: .5rem; font-size: .92rem; }
.score-ring { width: 140px; height: 140px; margin: 1rem auto; }

/* ---------- ranks & rewards ---------- */
.ladder { display: flex; flex-direction: column; gap: .5rem; }
.rung { display: grid; grid-template-columns: 48px 1fr auto; gap: .8rem; align-items: center; padding: .7rem .9rem; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.rung .em { font-size: 1.9rem; text-align: center; }
.rung.locked { opacity: .45; filter: grayscale(.7); }
.rung.current { border-color: var(--rc); box-shadow: 0 0 0 1px var(--rc); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.ach { padding: .8rem; border-radius: 14px; background: var(--card); text-align: center; border: 1px solid var(--line); }
.ach .em { font-size: 1.9rem; }
.ach.locked { opacity: .35; filter: grayscale(1); }
.pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.pick button { border: 2px solid transparent; background: var(--card2); border-radius: 14px; width: 52px; height: 52px; font-size: 1.6rem; cursor: pointer; }
.pick button.on { border-color: var(--a1); }
.pick button:disabled { opacity: .3; cursor: not-allowed; }
.swatch { width: 52px; height: 52px; border-radius: 14px; border: 2px solid transparent; cursor: pointer; }
.swatch.on { border-color: #fff; }
.swatch:disabled { opacity: .25; cursor: not-allowed; }

/* ---------- friends ---------- */
.friend { display: grid; grid-template-columns: 34px 52px 1fr auto; gap: .8rem; align-items: center; padding: .7rem .9rem; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.friend .pos { font-weight: 800; color: var(--muted); text-align: center; }
.friend.me { border-color: var(--a1); }
.friend .avatar { width: 52px; height: 52px; font-size: 1.7rem; border-radius: 16px; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5,6,14,.7); backdrop-filter: blur(6px); z-index: 100; display: grid; place-items: center; padding: 1rem; animation: fade .2s; }
.modal { width: min(560px, 100%); max-height: 88vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 1.4rem; box-shadow: var(--shadow); }
.toasts { position: fixed; top: calc(1rem + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--bg2); border: 1px solid var(--line); padding: .7rem 1.1rem; border-radius: 14px; box-shadow: var(--shadow); font-weight: 600; animation: pop .25s; }
.xp-pop { position: fixed; z-index: 300; font-weight: 900; font-size: 1.3rem; pointer-events: none; animation: rise 1.1s ease-out forwards; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
@keyframes rise { to { transform: translateY(-70px); opacity: 0; } }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 300; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

.timer-big { font-size: 3.5rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; margin: .5rem 0; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .em { font-size: 2.6rem; }
.onboard { max-width: 560px; margin: 4vh auto; }
.kbd { font-family: ui-monospace, monospace; background: rgba(0,0,0,.35); padding: .1rem .4rem; border-radius: 6px; font-size: .85em; word-break: break-all; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.sparkbars { display: flex; align-items: flex-end; gap: 3px; height: 70px; }
.sparkbars i { flex: 1; border-radius: 3px 3px 0 0; background: var(--grad); min-height: 3px; }
.sparkbars i.neg { background: var(--bad); }
