/* ---------- tokens (dark theme) ---------- */
:root {
    --pico-font-size: 100%;
    --radius: 14px;
    --page: #0d1117;
    --surface: #161b22;
    --surface-soft: #1f2630;
    --border: #2b3340;
    --text: #e6edf3;
    --text-soft: #9aa4b2;
    --accent: #58a6ff;
    --good: #3fb950; --good-bg: rgba(63, 185, 80, .14);
    --bad: #f85149;  --bad-bg: rgba(248, 81, 73, .14);
    --warn: #d29922; --warn-bg: rgba(210, 153, 34, .15);
    --info-bg: rgba(56, 139, 253, .15);
    --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] {
    --pico-background-color: var(--page);
    --pico-card-background-color: var(--surface);
    --pico-card-sectioning-background-color: var(--surface-soft);
    --pico-color: var(--text);
    --pico-muted-border-color: var(--border);
    --pico-table-border-color: var(--border);
    --pico-code-background-color: #232b36;
}
body { background: var(--page); }
main.container { padding-top: 1.25rem; padding-bottom: 2rem; }

/* Smooth page-to-page transitions (Chrome/Edge/Safari 18+; ignored elsewhere) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(13, 17, 23, .82);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; padding-top: 0; padding-bottom: 0; }
.brand { font-weight: 800; font-size: 1.1rem; text-decoration: none; color: var(--text); white-space: nowrap; display: flex; align-items: center; gap: .45rem; }
.brand:hover { color: var(--text); }
.icon { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }

.nav-links { display: flex; gap: .25rem; align-items: center; }
.nav-links a {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .45rem .85rem; border-radius: 999px;
    color: var(--text-soft); text-decoration: none; font-size: .95rem; font-weight: 500;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-links a:hover { background: var(--surface-soft); color: var(--text); }
.nav-links a[aria-current="page"] { background: var(--pico-primary-background); color: #fff; }
.nav-links .nav-logout { margin-left: .25rem; }

/* Dropdown menu (small screens) */
.menu { display: none; position: relative; margin: 0; }
.menu > summary {
    list-style: none; display: flex; align-items: center; justify-content: center;
    width: 2.6rem; height: 2.6rem; padding: 0; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); line-height: 1;
    -webkit-tap-highlight-color: transparent; cursor: pointer;
    transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { display: none !important; }   /* hide Pico's chevron */
.menu[open] > summary { background: var(--surface-soft); border-color: var(--accent); }
.menu > summary .icon { width: 1.35rem; height: 1.35rem; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + .5rem); min-width: 13.5rem;
    display: flex; flex-direction: column; padding: .4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
    transform-origin: top right;
}
.menu[open] .menu-panel { animation: drop .16s var(--ease); }
.menu-panel a {
    display: flex; align-items: center; gap: .75rem; padding: .75rem .85rem; border-radius: 10px;
    color: var(--text); text-decoration: none; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}
.menu-panel a:hover, .menu-panel a:active { background: var(--surface-soft); }
.menu-panel a[aria-current="page"] { color: var(--accent); background: var(--info-bg); }
.menu-panel .menu-logout { margin-top: .3rem; border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; color: var(--text-soft); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }

@media (max-width: 768px) {
    .nav-links { display: none; }
    .menu { display: block; }
}

/* ---------- generic ---------- */
article { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: none; }
.muted { color: var(--pico-muted-color); }
.good { color: var(--good); }
.ok { color: var(--warn); }
.bad { color: var(--bad); }
.big { font-size: 2.2rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.cards article { margin-bottom: 1rem; display: flex; flex-direction: column; justify-content: center; }
.cards .start { width: 100%; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.login { max-width: 420px; margin: 4rem auto; }
.flash { padding: .75rem 1rem; border-radius: 10px; border-left: 4px solid var(--accent); background: var(--info-bg); animation: rise .25s var(--ease); }
.flash-error { border-color: var(--bad); background: var(--bad-bg); }
.flash-notice { border-color: var(--warn); background: var(--warn-bg); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    *, ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; transition: none !important; }
}

/* ---------- question page ---------- */
.quiz-head { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.chip {
    display: inline-flex; align-items: center; padding: .25rem .7rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    font-size: .85rem; color: var(--text-soft); white-space: nowrap;
}
.chip-strong { background: var(--pico-primary-background); border-color: transparent; color: #fff; font-weight: 600; }
.chip-score { margin-left: auto; color: var(--good); font-weight: 600; }
.quiz-progress { height: .4rem; margin-bottom: 1rem; border-radius: 999px; }
.question { animation: rise .25s var(--ease); }
.question h2 { font-size: 1.25rem; line-height: 1.5; margin-bottom: 1.25rem; }
.question pre { border-radius: 10px; }
pre code { white-space: pre; }

.choices { display: flex; flex-direction: column; gap: .65rem; }
.letter {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 1.9rem; height: 1.9rem; border-radius: 50%;
    background: var(--surface-soft); color: var(--text-soft); font-weight: 700; font-size: .9rem;
}
.choices .choice {
    display: flex; gap: .85rem; align-items: center; width: 100%; margin: 0;
    padding: .85rem 1rem; text-align: left; line-height: 1.45;
    background: var(--surface); color: var(--pico-color); font-weight: 400;
    border: 1.5px solid var(--border); border-radius: 12px; box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease);
}
.choices .choice:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 166, 255, .15); }
.choices .choice:hover .letter { background: var(--pico-primary-background); color: #fff; }
.choices .choice:active { transform: scale(.985); }
.choices .choice:focus-visible { outline: 3px solid var(--pico-primary-focus); outline-offset: 2px; }

.verdict { font-size: 1.1rem; font-weight: 700; padding: .7rem 1rem; border-radius: 12px; animation: rise .25s var(--ease); }
.verdict-good { color: var(--good); background: var(--good-bg); }
.verdict-bad { color: var(--bad); background: var(--bad-bg); }
.feedback { list-style: none; padding: 0; margin-bottom: 1.25rem; }
.feedback li {
    list-style: none; border: 1.5px solid var(--border); border-radius: 12px;
    padding: .8rem 1rem; margin-bottom: .6rem; background: var(--surface);
    animation: rise .3s var(--ease) both;
}
.feedback li:nth-child(2) { animation-delay: .04s; }
.feedback li:nth-child(3) { animation-delay: .08s; }
.feedback li:nth-child(4) { animation-delay: .12s; }
.feedback li.is-correct { border-color: var(--good); background: var(--good-bg); }
.feedback li.is-correct .letter { background: var(--good); color: #fff; }
.feedback li.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.feedback li.is-wrong .letter { background: var(--bad); color: #fff; }
.feedback p { margin: 0; }
.feedback .why { margin-top: .45rem; padding-left: 2.75rem; font-size: .93rem; color: var(--text-soft); }
.choice-text { display: flex; gap: .85rem; flex-wrap: wrap; align-items: center; }
.tag { font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; }
.tag.good { background: var(--good); color: #fff; }
.next-btn { min-width: 12rem; }

@media (max-width: 768px) {
    main.container { padding-top: .9rem; }
    .question { padding: 1.1rem; }
    .question h2 { font-size: 1.1rem; }
    .feedback .why { padding-left: 0; }
    .next-btn {
        display: block; width: 100%; text-align: center;
        position: sticky; bottom: calc(env(safe-area-inset-bottom) + .75rem);
        box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    }
    .big { font-size: 1.8rem; }
}

/* ---------- dashboard ---------- */
.rates progress { width: 90px; margin: 0 .4rem 0 0; vertical-align: middle; }
.rate { white-space: nowrap; }
.focus li { margin-bottom: .3rem; }
.weakest-form { margin: 1rem 0 .25rem; }
table.compact td, table.compact th { padding: .3rem .5rem; font-size: .9rem; }
svg.chart { overflow: visible; vertical-align: middle; max-width: 100%; height: auto; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
svg.chart .dot { fill: var(--accent); }
svg.chart .grid { stroke: #30363d; stroke-dasharray: 3 3; }
svg.chart .grid-label { fill: #8b949e; font-size: 10px; }
