:root {
    color-scheme: dark;
    --bg: #0a0a0a;
    --panel: #141414;
    --panel-2: #1b1b1b;
    --line: #2a2a2a;
    --line-2: #3a3a3a;
    --text: #eaeaea;
    --muted: #9a9a9a;
    --accent: #6ea8fe;
    --accent-2: #2563eb;
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    padding: .8rem 1.25rem; border-bottom: 1px solid var(--line);
    background: #0d0d0d; position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
    color: var(--muted); text-decoration: none; padding: .3rem .6rem;
    border-radius: 8px; font-size: .92rem;
}
.topbar nav a:hover { color: var(--text); background: var(--panel-2); }
.topbar nav a.on { color: var(--text); background: var(--panel-2); }

.wrap { max-width: 760px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

h1 { font-size: 1.7rem; margin: .2rem 0 .4rem; }
h2 { font-size: 1.2rem; margin: 1.8rem 0 .6rem; }
.lead { color: var(--muted); margin: 0 0 1.4rem; }

a { color: var(--accent); }

/* Cards / tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } }
.tile {
    display: block; text-decoration: none; color: var(--text);
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    padding: 1.2rem 1.25rem; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--line-2); transform: translateY(-2px); }
.tile .ico { font-size: 1.8rem; }
.tile h3 { margin: .5rem 0 .3rem; font-size: 1.1rem; }
.tile p { margin: 0; color: var(--muted); font-size: .92rem; }

.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 14px; padding: 1.4rem 1.5rem; margin: 1rem 0;
}

/* Buttons */
.btn {
    appearance: none; font: inherit; cursor: pointer;
    background: var(--accent-2); color: white; border: 0;
    padding: .6rem 1.1rem; border-radius: 9px; font-weight: 600;
}
.btn:hover { background: #1d4fd8; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

/* Segmented control */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button {
    appearance: none; font: inherit; cursor: pointer; background: transparent;
    color: var(--muted); border: 0; padding: .45rem .9rem;
}
.seg button.on { background: var(--accent-2); color: #fff; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.2rem; flex-wrap: wrap; }
.tabs button {
    appearance: none; font: inherit; cursor: pointer; background: transparent;
    color: var(--muted); border: 0; border-bottom: 2px solid transparent;
    padding: .55rem .8rem; margin-bottom: -1px;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* Word / item lists */
.wordlist { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .5rem; }
.wordlist li {
    display: flex; align-items: center; gap: .8rem;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
    padding: .65rem .9rem; font-size: 1.1rem;
}
.wordlist .num {
    flex: 0 0 auto; width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
    background: #000; border: 1px solid var(--line-2); border-radius: 8px;
    font-size: .9rem; color: var(--muted);
}
.wordlist .shape { font-size: 1.4rem; }

/* Recall input rows */
.recall-row { display: flex; align-items: center; gap: .6rem; margin: .4rem 0; }
.recall-row .num {
    flex: 0 0 auto; width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
    background: #000; border: 1px solid var(--line-2); border-radius: 8px; font-size: .9rem; color: var(--muted);
}
input[type=text], input[type=number] {
    flex: 1; background: #000; border: 1px solid var(--line-2); border-radius: 8px;
    color: var(--text); padding: .55rem .7rem; font: inherit;
}
input[type=text]:focus, input[type=number]:focus { outline: none; border-color: var(--accent); }
.recall-row.ok input { border-color: var(--good); }
.recall-row.no input { border-color: var(--bad); }
.recall-row .mark { width: 1.5rem; text-align: center; }
.recall-row .answer { color: var(--muted); font-size: .85rem; }

/* Big display (study / drill) */
.bigword {
    font-size: clamp(2.2rem, 9vw, 4rem); font-weight: 700; text-align: center;
    padding: 2rem 1rem; margin: 1rem 0;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
}
.bigword small { display: block; font-size: 1rem; font-weight: 400; color: var(--muted); margin-top: .6rem; }

.timer { text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin: .6rem 0; }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .25s linear; }

.stat { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; margin-top: 1rem; }
.stat b { color: var(--text); font-size: 1.05rem; }

.tip { background: #11203a; border: 1px solid #1e3a5f; color: #cfe0ff; border-radius: 10px; padding: .8rem 1rem; font-size: .92rem; margin: 1rem 0; }
.score { font-size: 2.4rem; font-weight: 700; text-align: center; margin: .5rem 0; }
.score.good { color: var(--good); }
.score.mid { color: var(--warn); }
.score.bad { color: var(--bad); }

table.ref { width: 100%; border-collapse: collapse; margin: 1rem 0; }
table.ref th, table.ref td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ref th { color: var(--muted); font-weight: 600; }
table.ref td.big { font-size: 1.4rem; font-weight: 700; }
table.ref code { background: var(--panel-2); padding: .1em .4em; border-radius: 5px; }

.foot { text-align: center; color: #666; font-size: .82rem; padding: 1.5rem 1rem 2.5rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
