:root {
  --bg: #f6f3ec; --card: #ffffff; --ink: #1c2230; --muted: #5d6676; --line: #e2ddd0;
  --brand: #1f3a5f; --brand-ink: #ffffff; --accent: #e8a317; --ok: #1d7f4e; --ok-bg: #e4f4ea;
  --bad: #b3261e; --bad-bg: #fbe9e7; --code-bg: #14202e; --code-ink: #e8eef6; --soft: #eef1f6;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1621; --card: #172131; --ink: #e8edf5; --muted: #9aa6b8; --line: #263349;
    --brand: #6ea0e8; --brand-ink: #0b1220; --accent: #f2b632; --ok: #5fd08f; --ok-bg: #12301f;
    --bad: #ff8a80; --bad-bg: #3a1b19; --code-bg: #0a1018; --code-ink: #e8eef6; --soft: #1d2a3f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
#app { max-width: 760px; margin: 0 auto; padding: 16px 16px 24px; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: .2em 0 .3em; }
h2 { font-size: 1.15rem; margin: 1.4em 0 .4em; }
h3 { font-size: 1.02rem; margin: 1.2em 0 .3em; }
p { margin: .5em 0; }
a { color: var(--brand); }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; background: var(--soft); padding: .08em .35em; border-radius: 5px; }
pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9rem; background: var(--code-bg); color: var(--code-ink); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: .6em 0; white-space: pre-wrap; word-break: break-word; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.crumb { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.crumb a { text-decoration: none; font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.grid { display: grid; gap: 12px; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar.ok > i { background: var(--ok); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; padding: 11px 16px; border-radius: 12px; min-height: 46px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn:disabled { opacity: .5; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.level { display: block; text-decoration: none; color: inherit; }
.level h3 { margin: 0 0 2px; font-size: 1.1rem; }
.level.soon { opacity: .85; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips span { font-size: .8rem; background: var(--soft); border-radius: 99px; padding: 3px 10px; color: var(--muted); }
.lessonrow { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; padding: 12px 14px; }
.num { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--soft); color: var(--brand); }
.num.done { background: var(--ok); color: #fff; }
.grow { flex: 1; min-width: 0; }
.grow b { display: block; }
.exlist a { display: flex; align-items: center; gap: 10px; padding: 12px 4px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.exlist a:first-child { border-top: 0; }
.dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .75rem; color: #fff; }
.dot.done { background: var(--ok); border-color: var(--ok); }
.editor { position: relative; margin: 8px 0; }
.editor textarea { width: 100%; min-height: 150px; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; line-height: 1.5; background: var(--code-bg); color: var(--code-ink); border: 2px solid transparent; border-radius: 10px; padding: 12px; tab-size: 4; white-space: pre; overflow: auto; outline: none; -webkit-appearance: none; }
.editor textarea:focus { border-color: var(--brand); }
.editor.mini textarea { min-height: 0; }
.symbols { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 2px; scrollbar-width: none; }
.symbols::-webkit-scrollbar { display: none; }
.symbols button { flex: none; font: 600 15px ui-monospace, Menlo, monospace; min-width: 40px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.out { margin: 8px 0; }
.out pre { margin: 0; }
.out .err { color: #ffb4a9; }
.out .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 3px; }
.banner { border-radius: 12px; padding: 12px 14px; font-weight: 600; margin: 12px 0 8px; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.res { border-top: 1px solid var(--line); padding: 9px 0; display: flex; gap: 10px; }
.res:first-of-type { border-top: 0; }
.res .mark { flex: none; font-weight: 800; width: 20px; }
.res.ok .mark { color: var(--ok); }
.res.bad .mark { color: var(--bad); }
.res .body { min-width: 0; flex: 1; }
.res pre { margin: 4px 0 0; font-size: .85rem; padding: 8px 10px; }
.hint { background: var(--soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 9px 12px; margin: 8px 0; }
.examples { font-size: .92rem; }
.examples li { margin: 4px 0; }
.section-code { margin: 10px 0 18px; }
.login { max-width: 360px; margin: 14vh auto 0; text-align: center; }
.login input { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); margin: 14px 0 10px; }
.login .logo { width: 64px; height: 64px; }
.err-msg { color: var(--bad); font-weight: 600; min-height: 1.4em; }
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#tabbar[hidden] { display: none; }
#tabbar a { flex: 1; text-align: center; padding: 8px 0 10px; text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; }
#tabbar a span { display: block; font-size: 1.3rem; line-height: 1.1; }
#tabbar a.on { color: var(--brand); }
.cellhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cellhead .idx { font: 600 .8rem ui-monospace, Menlo, monospace; color: var(--muted); }
.stdin { width: 100%; font: 14px ui-monospace, Menlo, monospace; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 44px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.96); opacity: .4; } 100% { transform: none; opacity: 1; } }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
