/* ------------------------------- app shell -------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .28s var(--ease); }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border); padding: 18px 14px 16px; gap: 4px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; background: var(--accent-grad); display: grid; place-items: center; box-shadow: 0 6px 20px -8px var(--accent); }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 650; letter-spacing: -.02em; font-size: 1.05rem; }
.brand-name span { color: var(--muted); font-weight: 400; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 14px 10px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--text-dim); font-size: .89rem; font-weight: 500; position: relative;
  transition: background .15s, color .15s; white-space: nowrap;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item.active svg { color: var(--accent); opacity: 1; }
.nav-item .nav-badge { margin-left: auto; font-size: .7rem; background: var(--accent); color: var(--on-accent); font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav-item .nav-badge.ghost { background: var(--surface-3); color: var(--text-dim); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 14px; }
.collapse-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-size: .8rem; }
.collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.collapse-btn svg { width: 16px; height: 16px; }
.upgrade-card { background: linear-gradient(150deg, var(--accent-soft), transparent); border: 1px solid var(--border); border-radius: 14px; padding: 12px 12px 13px; }
.upgrade-card p { font-size: .78rem; color: var(--text-dim); margin: 4px 0 9px; line-height: 1.45; }
.app.collapsed .brand-name, .app.collapsed .nav-label, .app.collapsed .nav-item span, .app.collapsed .nav-badge,
.app.collapsed .collapse-btn span, .app.collapsed .upgrade-card, .app.collapsed .sidebar-wallet { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 11px 8px; }
.app.collapsed .brand { justify-content: center; padding: 6px 0 18px; }
.sidebar-wallet { display: flex; gap: 8px; padding: 8px 6px 0; }
.wallet-pill { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; }
.wallet-pill b { display: block; font-size: .86rem; }
.wallet-pill span { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 0 26px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.searchbox { position: relative; flex: 1; max-width: 440px; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.searchbox input { width: 100%; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px 9px 36px; font-size: .86rem; }
.searchbox input::placeholder { color: var(--muted); }
.searchbox input:focus { outline: none; border-color: var(--accent); }
.search-results { position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 60vh; overflow: auto; z-index: 50; }
.search-result { display: flex; gap: 10px; padding: 9px 10px; border-radius: 9px; align-items: center; width: 100%; text-align: left; }
.search-result:hover { background: var(--surface-2); }
.search-result .sr-type { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: .8rem; font-weight: 500; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.streak svg { color: var(--warn); }
.chip.tokens svg { color: var(--accent); }
.chip.credits svg { color: var(--info); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); position: relative; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.dot-badge { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 99px; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 650; font-size: .85rem; background: var(--accent-grad); color: var(--on-accent); overflow: hidden; flex: 0 0 auto; }
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.4rem; }
.avatar.sm { width: 26px; height: 26px; border-radius: 8px; font-size: .68rem; }
.avatar[data-frame="frame-gilded"] { box-shadow: 0 0 0 2px var(--metal-1) inset, 0 0 0 1px var(--metal-1); }
.avatar[data-frame="frame-nebula"] { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 65%, transparent) inset; }
.avatar[data-frame="frame-circuit"] { box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 65%, transparent) inset; }
.avatar[data-frame="frame-ascendant"] { box-shadow: 0 0 0 2px var(--metal-2) inset, 0 4px 18px -8px var(--metal-2); }

/* --------------------------------- view ----------------------------------- */
.view { padding: 26px 32px 72px; max-width: 1380px; width: 100%; margin: 0 auto; animation: fadeUp .35s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.72rem; }
.page-head p { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.card.fill { display: flex; flex-direction: column; }
.card.fill .readiness-factors { margin-top: auto; }
.card.fill .disclaimer { margin-top: 10px; }
.readiness-factors { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.readiness-factors span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.readiness-factors b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.card.tight { padding: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { font-size: .98rem; font-weight: 600; }
.card-title-sm { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.card-link { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.card-link:hover { color: var(--accent); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 10px; padding: 9px 14px; font-size: .85rem; font-weight: 550; border: 1px solid transparent; transition: transform .12s var(--ease), background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-grad); color: var(--on-accent); box-shadow: 0 8px 24px -12px var(--accent); font-weight: 650; }
.btn-primary:hover { filter: brightness(1.07); }
[data-theme="light"] .btn-primary { color: #fff; }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-3); }
.btn-subtle { background: transparent; color: var(--text-dim); padding: 6px 8px; }
.btn-subtle:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--bad) 16%, transparent); }
.btn-sm { padding: 6px 10px; font-size: .78rem; border-radius: 8px; }
.btn-lg { padding: 12px 20px; font-size: .95rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .78rem; color: var(--text-dim); font-weight: 550; letter-spacing: .01em; }
.input, .select, .textarea {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .88rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d839b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: .74rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-dim); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* pills, badges, progress */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-dim); letter-spacing: .01em; }
.pill.mastered { background: var(--good-soft); color: var(--good); }
.pill.progressing { background: var(--info-soft); color: var(--info); }
.pill.revision { background: var(--warn-soft); color: var(--warn); }
.pill.weak { background: var(--bad-soft); color: var(--bad); }
.pill.unstarted { background: var(--surface-3); color: var(--muted); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.outline { background: transparent; border: 1px solid var(--border-strong); }

.progress { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; position: relative; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--accent-grad); transition: width .6s var(--ease); }
.progress.thin { height: 5px; }
.progress.mastered > i { background: linear-gradient(90deg, #2bbf87, #3ddc97); }
.progress.revision > i { background: linear-gradient(90deg, #d98a13, #f5a524); }
.progress.weak > i { background: linear-gradient(90deg, #d94864, #f4607a); }
.progress.progressing > i { background: linear-gradient(90deg, #3f74f5, #5b8cff); }

/* stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 15px 16px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat .stat-label { font-size: .73rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stat .stat-value { font-size: 1.62rem; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .stat-value small { font-size: .8rem; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat .stat-foot { font-size: .76rem; color: var(--muted); }
.stat .stat-icon { position: absolute; right: 14px; top: 14px; color: var(--muted); opacity: .5; }
.stat .stat-icon svg { width: 17px; height: 17px; }
.delta { font-size: .76rem; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* rank emblem */
.rank { display: flex; align-items: center; gap: 10px; }
.rank-emblem { width: 38px; height: 38px; position: relative; display: grid; place-items: center; }
.rank-emblem svg { width: 100%; height: 100%; }
.rank-meta b { font-size: .88rem; display: block; }
.rank-meta span { font-size: .72rem; color: var(--muted); }
[data-rank="Bronze"] .r1 { fill: #8a5a33; } [data-rank="Bronze"] .r2 { fill: #c98a52; }
[data-rank="Silver"] .r1 { fill: #8b93a3; } [data-rank="Silver"] .r2 { fill: #d7dce6; }
[data-rank="Gold"] .r1 { fill: #b8862f; } [data-rank="Gold"] .r2 { fill: #f0ce7a; }
[data-rank="Platinum"] .r1 { fill: #6f8b98; } [data-rank="Platinum"] .r2 { fill: #c8e4ee; }
[data-rank="Diamond"] .r1 { fill: #4b7fd1; } [data-rank="Diamond"] .r2 { fill: #9fd4ff; }
[data-rank="Master"] .r1 { fill: #7a4bd1; } [data-rank="Master"] .r2 { fill: #c9a6ff; }
[data-rank="Ascendant"] .r1 { fill: #c9a06a; } [data-rank="Ascendant"] .r2 { fill: #f6e6c2; }

/* heatmap */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.hm-cell { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-3); }
.hm-cell.l1 { background: color-mix(in srgb, var(--accent) 26%, var(--surface-3)); }
.hm-cell.l2 { background: color-mix(in srgb, var(--accent) 46%, var(--surface-3)); }
.hm-cell.l3 { background: color-mix(in srgb, var(--accent) 70%, var(--surface-3)); }
.hm-cell.l4 { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--muted); }

/* tabs & segmented */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; width: fit-content; max-width: 100%; overflow: auto; }
.tab { padding: 7px 13px; border-radius: 8px; font-size: .82rem; color: var(--muted); font-weight: 550; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow); }

/* table */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* empty state */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .empty-icon { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); }
.empty .empty-icon svg { width: 22px; height: 22px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: .98rem; }
.empty p { font-size: .85rem; max-width: 380px; margin: 0 auto 14px; }

/* toast + modal */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 260px; max-width: 380px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: toastIn .3s var(--ease); font-size: .85rem; }
.toast.out { animation: toastOut .25s var(--ease) forwards; }
.toast .t-icon { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; flex: 0 0 22px; background: var(--accent-soft); color: var(--accent); }
.toast .t-icon svg { width: 13px; height: 13px; }
.toast.success .t-icon { background: var(--good-soft); color: var(--good); }
.toast.error .t-icon { background: var(--bad-soft); color: var(--bad); }
.toast b { display: block; font-size: .84rem; }
.toast span { color: var(--muted); font-size: .78rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(6px); z-index: 150; display: grid; place-items: center; padding: 20px; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; width: min(560px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); animation: modalIn .25s var(--ease); }
.modal.wide { width: min(820px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 20px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h2 { font-size: 1.12rem; }
.modal-head p { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* dashboard bits */
.hero { position: relative; border-radius: var(--radius-xl); border: 1px solid var(--border); background:
  radial-gradient(120% 160% at 0% 0%, var(--hero-glow-1), transparent 55%),
  radial-gradient(100% 140% at 100% 0%, var(--hero-glow-2), transparent 60%), var(--surface);
  padding: 20px 22px; overflow: hidden; }
.hero-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hero-id h1 { font-size: 1.3rem; letter-spacing: -.02em; }
.hero-id p { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.hero-level { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.xp-wrap { min-width: 190px; }
.xp-wrap .between { font-size: .74rem; color: var(--muted); margin-bottom: 5px; }
.hero-stats { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.hero-stat { background: color-mix(in srgb, var(--bg) 45%, transparent); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; min-width: 96px; }
.hero-stat span { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; }
.hero-stat b { font-size: 1.02rem; }

.readiness-ring { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 118px; height: 118px; flex: 0 0 118px; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: url(#ringGrad); transition: stroke-dashoffset 1s var(--ease); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-label b { font-size: 1.5rem; letter-spacing: -.03em; display: block; line-height: 1; }
.ring-label span { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.readiness-copy h3 { font-size: .95rem; margin-bottom: 4px; }
.readiness-copy p { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.disclaimer { font-size: .72rem; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 9px; padding: 7px 10px; margin-top: 12px; display: flex; gap: 7px; align-items: flex-start; }
.disclaimer svg { width: 13px; height: 13px; flex: 0 0 13px; margin-top: 2px; }

.topic-list { display: flex; flex-direction: column; }
.topic-item { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.topic-item:last-child { border-bottom: 0; }
.topic-name { font-size: .85rem; font-weight: 500; }
.topic-bar { width: 110px; flex: 0 0 110px; }
.topic-pct { font-size: .76rem; color: var(--muted); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.topic-item .play { opacity: 0; transition: opacity .15s; }
.topic-item:hover .play { opacity: 1; }

.quest { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); align-items: flex-start; }
.quest.done { border-color: color-mix(in srgb, var(--good) 30%, transparent); background: color-mix(in srgb, var(--good) 6%, transparent); }
.quest-icon { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.quest-icon svg { width: 16px; height: 16px; }
.quest.done .quest-icon { background: var(--good-soft); color: var(--good); }
.quest-body { flex: 1; min-width: 0; }
.quest-body b { font-size: .83rem; font-weight: 550; display: block; margin-bottom: 7px; line-height: 1.4; }
.quest-xp { font-size: .72rem; color: var(--accent); font-weight: 600; }
.quest-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.quest-bar .progress { flex: 1; }

.rec-item { display: flex; gap: 11px; padding: 11px; border-radius: 12px; border: 1px solid var(--border); align-items: center; background: var(--surface-2); }
.rec-item:hover { border-color: var(--border-strong); }
.rec-rank { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: .68rem; font-weight: 700; background: var(--surface-3); color: var(--muted); flex: 0 0 22px; }
.rec-item b { font-size: .84rem; display: block; }
.rec-item p { font-size: .73rem; color: var(--muted); }

/* study */
.study-shell { max-width: 860px; margin: 0 auto; }
.study-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.study-top .progress { flex: 1; min-width: 120px; }
.flashcard { perspective: 1600px; height: min(52vh, 420px); cursor: pointer; user-select: none; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .55s var(--ease); }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow); padding: 34px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; overflow: auto; }
.fc-face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--surface-2), var(--surface)); }
.fc-side { position: absolute; top: 16px; left: 20px; font-size: .65rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.fc-content { font-size: clamp(1.05rem, 2.4vw, 1.5rem); font-weight: 500; line-height: 1.55; max-width: 620px; white-space: pre-wrap; }
.fc-content img { max-height: 200px; border-radius: 10px; margin: 8px auto; }
.fc-hint { position: absolute; bottom: 14px; font-size: .7rem; color: var(--muted); display: flex; gap: 12px; }
.rating-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.rating { padding: 12px 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); text-align: center; transition: all .15s; }
.rating b { display: block; font-size: .85rem; }
.rating span { font-size: .7rem; color: var(--muted); }
.rating:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.rating[data-r="again"]:hover { border-color: var(--bad); color: var(--bad); }
.rating[data-r="hard"]:hover { border-color: var(--warn); color: var(--warn); }
.rating[data-r="good"]:hover { border-color: var(--info); color: var(--info); }
.rating[data-r="easy"]:hover { border-color: var(--good); color: var(--good); }
.kbd { font-family: var(--mono); font-size: .68rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); background: var(--surface-2); }

/* quiz */
.question { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface); }
.question + .question { margin-top: 12px; }
.q-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; align-items: center; }
.q-prompt { font-size: .95rem; font-weight: 550; line-height: 1.5; margin-bottom: 12px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all .15s; background: var(--bg-elev); }
.opt + .opt { margin-top: 7px; }
.opt:hover { border-color: var(--border-strong); }
.opt input { margin-top: 3px; accent-color: var(--accent); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.correct { border-color: color-mix(in srgb, var(--good) 50%, transparent); background: color-mix(in srgb, var(--good) 7%, transparent); }
.opt.wrong { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 7%, transparent); }
.opt .opt-key { width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: .7rem; flex: 0 0 20px; color: var(--muted); }

/* exam / countdown */
.countdown { font-variant-numeric: tabular-nums; }
.countdown b { font-size: 1.4rem; letter-spacing: -.03em; }
.exam-row { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); }
.exam-date { width: 54px; flex: 0 0 54px; text-align: center; border-radius: 11px; background: var(--surface-3); padding: 6px 4px; }
.exam-date b { display: block; font-size: 1.15rem; line-height: 1.1; }
.exam-date span { font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* skill tree */
.tree-canvas { position: relative; min-height: 420px; border-radius: 14px; border: 1px solid var(--border); background:
  radial-gradient(circle at 20% 20%, var(--accent-soft), transparent 50%),
  linear-gradient(var(--surface) 1px, transparent 1px) 0 0 / 100% 40px,
  linear-gradient(90deg, var(--surface) 1px, transparent 1px) 0 0 / 40px 100%, var(--bg-elev);
  overflow: auto; }
.tree-node { position: absolute; transform: translate(-50%, -50%); width: 150px; padding: 9px 10px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface); text-align: left; font-size: .76rem; }
.tree-node:hover { border-color: var(--accent); }
.tree-node.mastered { border-color: color-mix(in srgb, var(--good) 45%, transparent); box-shadow: 0 0 0 3px var(--good-soft); }
.tree-node.progressing { border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.tree-node.revision { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.tree-node.weak { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.tree-node b { display: block; font-size: .78rem; margin-bottom: 2px; }
.tree-node span { color: var(--muted); font-size: .68rem; }
.tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* misc */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-main b { font-size: .87rem; font-weight: 550; display: block; }
.list-row .lr-main span { font-size: .76rem; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.scroll-x { overflow-x: auto; }
.kpi-row { display: flex; gap: 18px; flex-wrap: wrap; }
.kpi-row > div { min-width: 90px; }
.kpi-row b { font-size: 1.15rem; display: block; }
.kpi-row span { font-size: .72rem; color: var(--muted); }
.credit-meter { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: .8rem; }
.sim-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 13px; border-radius: 11px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 24%, transparent); font-size: .78rem; color: var(--warn); }
.sim-banner svg { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 2px; }
.ai-result { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.ai-result h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.ai-result ul li { font-size: .85rem; padding: 5px 0 5px 16px; position: relative; color: var(--text-dim); }
.ai-result ul li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }
.achievement { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-2); align-items: center; }
.achievement.locked { opacity: .45; }
.ach-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent); flex: 0 0 40px; color: var(--accent); }
.ach-badge svg { width: 19px; height: 19px; }
.achievement.locked .ach-badge { background: var(--surface-3); border-color: var(--border); color: var(--muted); }
.shop-item { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; min-height: 224px; }
.shop-item p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shop-preview { height: 82px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); position: relative; overflow: hidden; }
.shop-item.equipped { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 0 0 3px var(--accent-soft); }
.shop-price { font-size: .78rem; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.preview-title { font-size: 1.05rem; font-weight: 650; letter-spacing: -.01em; }
.preview-accent { width: 46px; height: 46px; border-radius: 50%; background: var(--accent-grad); }
.preview-avatar { width: 46px; height: 46px; border-radius: 13px; background: var(--accent-grad); display:grid; place-items:center; color:var(--on-accent); font-weight:700; }

/* responsive */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-102%); transition: transform .28s var(--ease); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.collapsed { grid-template-columns: 1fr; }
  .app.collapsed .sidebar { width: 280px; }
  .app.collapsed .brand-name, .app.collapsed .nav-label, .app.collapsed .nav-item span, .app.collapsed .nav-badge,
  .app.collapsed .collapse-btn span, .app.collapsed .upgrade-card, .app.collapsed .sidebar-wallet { display: revert; }
  .app.collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .menu-btn { display: grid; }
  .view { padding: 20px 18px 80px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .searchbox { max-width: none; }
  .g3 { grid-template-columns: 1fr; }
  .nav-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 35; }
}
@media (max-width: 720px) {
  .g2, .form-grid { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero-level { flex-wrap: wrap; gap: 10px; }
  .rank-meta span { white-space: nowrap; }
  .hero-id h1 { font-size: 1.15rem; }
  .xp-wrap { min-width: 140px; }
  .hero { padding: 16px; }
  .hero-top { gap: 12px; }
  .hero-top .avatar.lg { width: 48px; height: 48px; border-radius: 14px; }
  .hero-stats { gap: 8px; margin-top: 14px; }
  .hero-stat { flex: 1 1 42%; min-width: 0; padding: 7px 10px; }
  .hero-stats > div:last-child { margin-left: 0 !important; width: 100%; }
  .hero-stats > div:last-child .btn { flex: 1; }
  .page-head h1 { font-size: 1.42rem; }
  .hero-level { margin-left: 0; width: 100%; }
  .xp-wrap { flex: 1; }
  .stat .stat-value { font-size: 1.4rem; }
  .stat .stat-icon { display: none; }
  .stat .stat-label { padding-right: 0; }
  .rating-row { grid-template-columns: repeat(2, 1fr); }
  .topbar .chip.tokens, .topbar .chip.credits { display: none; }
  .flashcard { height: 56vh; }
  .hide-sm { display: none !important; }
}

/* Narrow screens: topic rows must never squeeze the label into a column of single words. */
@media (max-width: 640px) {
  .card { padding: 16px; }
  .topic-item {
    display: grid; align-items: center; gap: 6px 8px;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "name state pct" "bar bar bar";
  }
  .topic-item > .grow { grid-area: name; }
  .topic-item > .pill { grid-area: state; justify-self: end; }
  .topic-item > .topic-pct { grid-area: pct; width: auto; }
  .topic-item > .topic-bar { grid-area: bar; width: 100%; flex: none; margin-top: 2px; }
  .topic-item > .play { display: none; }
  .topic-name { display: block; }
  .readiness-ring { gap: 14px; }
  .ring { width: 96px; height: 96px; flex-basis: 96px; }
  .ring svg { width: 96px; height: 96px; }
  .exam-row { gap: 10px; padding: 12px; }
}

/* distraction-free focus mode */
.app.focus-mode { grid-template-columns: 0 minmax(0,1fr); }
.app.focus-mode .sidebar, .app.focus-mode .topbar { display: none; }
.app.focus-mode .main { min-height: 100vh; }
.app.focus-mode .view { padding-top: 56px; }

/* --------------------------- upgrade additions ---------------------------- */
.brand-mark svg { stroke: var(--on-accent); }
.avatar svg { width: 100%; height: 100%; display: block; border-radius: inherit; }
.avatar { padding: 0; }

.chip.shop { gap: 5px; cursor: pointer; }
.chip.shop svg { color: var(--accent); }
.chip.shop:hover { border-color: var(--border-strong); background: var(--surface-2); }

.nav-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--accent); margin-left: auto; box-shadow: 0 0 0 3px var(--accent-soft); }

.lock-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .64rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.lock-badge svg { width: 11px; height: 11px; }
.provider-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .68rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); }
.provider-badge.live { border-color: color-mix(in srgb, var(--good) 35%, transparent); background: var(--good-soft); color: var(--good); }
.provider-badge.sim { border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); color: var(--warn); }
.provider-badge svg { width: 12px; height: 12px; }

/* theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.theme-card { border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: var(--surface); text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.theme-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card .theme-name { display: flex; align-items: center; justify-content: space-between; font-size: .78rem; font-weight: 600; margin-top: 7px; }
.theme-card .theme-name svg { width: 13px; height: 13px; color: var(--accent); }
.theme-swatch { height: 54px; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; gap: 4px; padding: 7px; }
.theme-swatch .sw-row { display: flex; gap: 4px; align-items: center; }
.theme-swatch .sw-dot { width: 10px; height: 10px; border-radius: 3px; }
.theme-swatch .sw-line { height: 4px; border-radius: 99px; flex: 1; }
.theme-swatch .sw-card { height: 14px; border-radius: 4px; flex: 1; }
.accent-row { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-dot { width: 30px; height: 30px; border-radius: 9px; border: 2px solid transparent; position: relative; }
.accent-dot.active { border-color: var(--text); }

/* katex */
.katex { font-size: 1.04em; }
.katex-display { margin: 0.55em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.fc-content .katex-display { text-align: center; }

/* document upload */
.dropzone { border: 1px dashed var(--border-strong); border-radius: 11px; padding: 14px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 20px; height: 20px; color: var(--muted); margin-bottom: 4px; }
.doc-meta { display: flex; gap: 10px; align-items: center; font-size: .76rem; color: var(--muted); }
.upload-track { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.upload-track i { display: block; height: 100%; background: var(--accent-grad); width: 0; transition: width .2s; }
.premium-lock { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); background: var(--accent-soft); }
.premium-lock .pl-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--surface); display: grid; place-items: center; color: var(--accent); flex: 0 0 34px; }
.premium-lock h4 { margin: 0 0 3px; font-size: .9rem; }
.premium-lock p { font-size: .8rem; color: var(--text-dim); }

.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
@media (max-width: 900px) { .plan-grid, .theme-grid.g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .plan-grid { grid-template-columns: 1fr; } .theme-grid { grid-template-columns: 1fr 1fr; } }

/* -------------------------- AI tools list (v2.2.1) ------------------------- */
/* The tool list reused .nav-item, whose white-space:nowrap made long
   descriptions run under the neighbouring panel and pushed the Premium badge
   over the text. Describe the layout explicitly instead. */
.tool-item {
  display: flex; align-items: flex-start; gap: 11px;
  white-space: normal; overflow: hidden; padding: 11px 10px;
  text-align: left; width: 100%;
}
.tool-item > svg { margin-top: 1px; flex: 0 0 18px; }
.tool-item .grow { min-width: 0; }
.tool-item b { display: block; white-space: normal; line-height: 1.35; }
.tool-item .tiny {
  display: block; white-space: normal; line-height: 1.45;
  overflow-wrap: anywhere; hyphens: auto; margin-top: 2px;
}
.tool-item .lock-badge,
.tool-item > .tiny:last-child { flex: 0 0 auto; margin-left: 6px; align-self: flex-start; white-space: nowrap; }
.lock-badge { flex: 0 0 auto; }

/* Free-generation explainer */
.allowance-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.allowance-card { border: 1px solid var(--border); border-radius: 11px; padding: 11px 12px; background: var(--surface-2); }
.allowance-card b { display: block; font-size: .82rem; margin-bottom: 3px; }
.allowance-card span { font-size: .76rem; color: var(--muted); line-height: 1.45; display: block; }
@media (max-width: 640px) {
  .allowance-grid { grid-template-columns: 1fr; }
  .tool-item .lock-badge { font-size: .58rem; padding: 2px 6px; }
}
