/* ---------- shared bits ---------- */
.demo-banner { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; justify-content: center; padding: 8px 14px; background: var(--gold); color: var(--gold-ink); font-size: 13px; font-weight: 500; text-align: center; }
.link-btn { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; min-height: 32px; }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 18px; }
.stack-y { display: grid; gap: 14px; }
.page { padding: 0 18px 110px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px 8px; }
.page-head h1 { font-size: 24px; font-weight: 600; line-height: 1.4; }
.tools { display: flex; align-items: center; }
.empty-note { text-align: center; color: var(--ink-2); font-size: 14px; padding: 28px 12px; }
.sub-note { color: var(--ink-2); font-size: 14px; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 500; font-size: 14px; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: 400 16px/1.5 var(--font);
}
.input:focus { border-color: var(--p2); }
select.input { appearance: auto; }
.area { min-height: 110px; resize: vertical; line-height: 1.6; }
.mono { font-family: var(--mono); font-size: 14px; direction: ltr; text-align: left; }
.hint-text { font-size: 13px; color: var(--ink-2); }
.err { color: var(--bad); font-size: 14px; min-height: 22px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 24px; height: 24px; accent-color: var(--go); }

/* ---------- login ---------- */
.login { padding: 40px 22px 60px; }
.login .logo { width: 72px; height: 72px; border-radius: 22px; background: var(--go); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 0 var(--go-d); margin: 0 auto 22px; }
.login .logo .ic { width: 38px; height: 38px; }
.login h1 { text-align: center; font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.login .sub-note { text-align: center; margin-bottom: 24px; }
.demo-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; align-items: center; font-size: 14px; color: var(--ink-2); }
.demo-chips button { border: 2px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; min-height: 40px; }

/* ---------- bottom tab bar ---------- */
.tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 5; background: var(--surface); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar ul { list-style: none; margin: 0 auto; padding: 0; max-width: 520px; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; font-size: 12px; color: var(--ink-2); text-decoration: none; position: relative; }
.tabbar a[aria-current="page"] { color: var(--go); font-weight: 600; }
.tabbar .count { position: absolute; top: 6px; inset-inline-start: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }

/* ---------- toast and dialog ---------- */
.toast { position: fixed; inset-inline: 16px; bottom: 84px; max-width: 440px; margin: 0 auto; z-index: 50; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-size: 15px; animation: rise .25s var(--ease); }
.toast.bad { background: var(--bad); color: #fff; }
.dlg { border: 0; border-radius: 22px; padding: 20px; width: min(92vw, 440px); background: var(--surface); color: var(--ink); }
.dlg::backdrop { background: rgba(0, 0, 0, .5); }
.dlg.wide { width: min(94vw, 760px); max-height: 90vh; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dlg-head h2 { font-size: 18px; font-weight: 600; }
.dlg-text { font-size: 16px; line-height: 1.6; }
.dlg-actions { display: flex; gap: 10px; margin-top: 18px; }
.dlg-actions .btn { flex: 1; }

/* ---------- home extras ---------- */
.goal { margin-top: 14px; }
.goal .bar { height: 10px; background: var(--brand-d); }
.goal .bar > i { background: var(--mint); }
.goal small { display: block; margin-top: 6px; font-size: 13px; color: var(--mint); }
.announce { margin: 16px 18px 0; display: grid; gap: 8px; }
.announce article { background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.announce article.pin { border-color: var(--gold); }
.announce h3 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.announce p { font-size: 14px; color: var(--ink-2); white-space: pre-wrap; }
.review-cta { margin: 16px 18px 0; display: flex; align-items: center; gap: 12px; background: var(--bad-t); border: 2px solid var(--bad); border-radius: 16px; padding: 12px 14px; }
.review-cta p { flex: 1; font-weight: 500; color: var(--bad-ink); }
.review-cta .btn { width: auto; min-height: 44px; padding: 0 18px; }
.module-title { text-align: center; font-weight: 600; font-size: 15px; color: var(--ink-2); margin: 26px 0 6px; }
.path .node.off1 { position: relative; inset-inline-start: 56px; }
.path .node.off3 { position: relative; inset-inline-start: -56px; }
.node .tile .ic { width: 38px; height: 38px; }
.node.boss .tile { width: 96px; height: 96px; border-radius: 30px; background: var(--brand); color: var(--gold); box-shadow: 0 7px 0 var(--brand-d); }
.node.boss.done .tile { background: var(--gold); color: var(--gold-ink); box-shadow: 0 7px 0 var(--gold-d); }
.node.boss.locked .tile { background: var(--line); color: var(--ink-3); box-shadow: 0 7px 0 var(--line); }
.node .score { font-size: 12px; color: var(--ink-2); margin-top: -4px; }
.node { background: none; border: 0; cursor: pointer; font: inherit; }
.node.locked { pointer-events: auto; cursor: not-allowed; }
.node:focus-visible .tile { outline: 3px solid var(--p2); outline-offset: 3px; }

/* ---------- lesson reader and markdown ---------- */
.reader { padding: 8px 22px 130px; }
.reader h1 { font-size: 26px; font-weight: 600; line-height: 1.4; margin: 6px 0 14px; }
.md { font-size: 17px; line-height: 1.85; }
.md > * { margin: 0 0 14px; }
.md h2, .md h3, .md h4, .md h5 { font-weight: 600; line-height: 1.4; margin-top: 24px; }
.md h2 { font-size: 22px; } .md h3 { font-size: 19px; } .md h4, .md h5 { font-size: 17px; }
.md ul, .md ol { padding-inline-start: 24px; }
.md li { margin-bottom: 4px; }
.md code { font: 500 .9em var(--mono); background: var(--line); padding: 1px 6px; border-radius: 6px; direction: ltr; unicode-bidi: embed; }
.md pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: 14px; overflow: auto; font: 400 14px/1.7 var(--mono); text-align: left; }
.md pre code { background: none; padding: 0; color: inherit; }
.md blockquote { margin-inline: 0; padding: 4px 16px; border-inline-start: 4px solid var(--go); background: var(--go-t); border-radius: 0 12px 12px 0; }
.md a { color: var(--p2); }
.md hr { border: 0; border-top: 2px solid var(--line); }

/* ---------- league ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.rank-row.me { border-color: var(--go); background: var(--go-t); }
.rank-row .pos { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-weight: 600; flex: none; }
.rank-row:nth-child(1) .pos { background: var(--gold); color: var(--gold-ink); }
.rank-row .who { flex: 1; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.rank-row .pts { font-weight: 600; color: var(--gold-d); direction: ltr; }

/* ---------- profile ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 12px; text-align: center; }
.badge .medal-s { width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px; display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); }
.badge.off { opacity: .55; }
.badge.off .medal-s { background: var(--line); color: var(--ink-3); }
.badge b { display: block; font-size: 14px; }
.badge span { font-size: 12px; color: var(--ink-2); }
.sec-title { font-size: 17px; font-weight: 600; margin: 24px 0 10px; }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.chips-row .chip { background: var(--gold); color: var(--gold-ink); }

/* ---------- library ---------- */
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.file-list a { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 14px; color: inherit; text-decoration: none; min-height: 60px; }
.file-list a:hover { border-color: var(--go); }
.file-list b { display: block; font-weight: 500; }
.file-list span { font-size: 13px; color: var(--ink-2); }
