/* ============================================================
   CAE Practice — design system
   Modern, clean, content-first. Loads after app.css/bootstrap.
   ============================================================ */

:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --ink: #171e30;
    --muted: #67718c;
    --primary: #4a55e2;
    --primary-strong: #3641c9;
    --primary-soft: #eef0ff;
    --accent: #0e9f6e;
    --accent-soft: #e3f6ee;
    --danger: #d6455d;
    --danger-soft: #fdeaee;
    --warn: #b7791f;
    --warn-soft: #fdf3df;
    --line: #e4e7f2;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(23, 30, 48, .05), 0 8px 24px -12px rgba(23, 30, 48, .18);
    --shadow-lg: 0 2px 6px rgba(23, 30, 48, .06), 0 20px 44px -16px rgba(23, 30, 48, .25);
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { letter-spacing: -.015em; }
h1:focus { outline: none; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

/* ---------- app shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topnav {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.topnav-inner {
    max-width: 1080px; margin: 0 auto;
    display: flex; align-items: center; gap: 1.4rem;
    padding: .65rem 1.25rem;
}
.brand {
    display: flex; align-items: center; gap: .55rem;
    font-weight: 800; font-size: 1.08rem; color: var(--ink);
    text-decoration: none; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7b5cf0);
    color: #fff; font-size: .78rem; font-weight: 800; letter-spacing: .02em;
    box-shadow: 0 6px 14px -6px rgba(74, 85, 226, .55);
}
.brand-name b { color: var(--primary); font-weight: 800; }

.topnav-links { display: flex; gap: .2rem; flex: 1; }
.topnav-link {
    padding: .45rem .85rem; border-radius: 999px;
    color: var(--muted); font-weight: 600; font-size: .95rem;
    text-decoration: none; transition: all .12s ease;
}
.topnav-link:hover { color: var(--ink); background: #eef0f8; text-decoration: none; }
.topnav-link.active { color: var(--primary-strong); background: var(--primary-soft); }

.topnav-auth { display: flex; align-items: center; gap: .55rem; }
.user-chip {
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: var(--primary-soft); color: var(--primary-strong);
    padding: .35rem .8rem; border-radius: 999px;
    font-size: .87rem; font-weight: 700;
}
.inline-form { display: inline; }

.app-main { flex: 1; }
.app-footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    margin-top: 3rem;
}
.app-footer-inner {
    max-width: 1080px; margin: 0 auto; padding: 1.1rem 1.25rem;
    display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; justify-content: space-between;
    color: var(--muted); font-size: .85rem;
}

/* ---------- buttons ---------- */
.btn {
    --btn-bg: var(--surface);
    display: inline-flex; align-items: center; gap: .4rem;
    border-radius: 10px; border: 1px solid var(--line);
    background: var(--btn-bg); color: var(--ink);
    padding: .48rem .95rem; font-size: .93rem; font-weight: 600;
    cursor: pointer; text-decoration: none;
    transition: all .12s ease;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary, .btn-primary:hover { color: #fff; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6259ec);
    border-color: transparent;
    box-shadow: 0 6px 16px -8px rgba(74, 85, 226, .7);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-strong), #5348e0); }
.btn-accent { background: var(--accent); border-color: transparent; color: #fff; }
.btn-accent:hover { background: #0c8a5f; color: #fff; }
.btn-soft { background: #eef0f8; border-color: transparent; color: var(--ink); }
.btn-soft:hover { background: #e4e7f3; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef0f8; color: var(--ink); }
.btn .btn-sm, .btn.btn-sm { padding: .32rem .7rem; font-size: .86rem; }

/* ---------- page & home ---------- */
.page-shell {
    max-width: 1020px; margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.hero {
    position: relative;
    background: linear-gradient(120deg, #1c2560 0%, #4a55e2 55%, #7b5cf0 100%);
    border-radius: 20px;
    color: #fff;
    padding: 2.3rem 2.4rem 2.1rem;
    margin-bottom: 2.2rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.hero::after {
    content: ""; position: absolute; right: -60px; top: -80px;
    width: 320px; height: 320px; border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.hero h1 { font-weight: 800; font-size: 2.1rem; margin: 0 0 .55rem; }
.hero-flag {
    display: inline-block; vertical-align: middle;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .35);
    color: #fff; border-radius: 999px;
    font-size: .5em; font-weight: 700;
    padding: .3em .8em; margin-left: .4em; letter-spacing: .06em;
}
.hero p { max-width: 640px; color: #e3e6ff; margin: 0 0 .4rem; font-size: 1.02rem; line-height: 1.55; }
.hero p strong { color: #fff; }
.hero-stats {
    display: inline-flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center;
    margin-top: 1rem; padding: .55rem .95rem;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 12px; font-size: .92rem; color: #eef0ff;
}
.hero-stats strong { color: #fff; }
.hero-stats a { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.group-title {
    margin: 1.9rem 0 .9rem; font-size: 1.18rem; font-weight: 800;
    display: flex; align-items: center; gap: .6rem;
}
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.task-card {
    display: flex; flex-direction: column; gap: .4rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.15rem 1.2rem; background: var(--surface);
    color: inherit; text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.task-card:hover {
    text-decoration: none;
    transform: translateY(-3px);
    border-color: #c9cdf5;
    box-shadow: var(--shadow-lg);
}
.task-card-head { display: flex; align-items: flex-start; gap: .7rem; }
.task-card-head h3 { font-size: 1rem; margin: 0; font-weight: 700; line-height: 1.3; }
.task-emoji {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--primary-soft); font-size: 1.3rem;
}
.task-sub { color: var(--primary-strong); font-weight: 700; font-size: .85rem; margin: 0; }
.task-desc { color: var(--muted); font-size: .89rem; margin: 0; flex: 1; line-height: 1.45; }
.task-card-foot {
    display: flex; align-items: center; gap: .5rem; justify-content: space-between;
    margin-top: .6rem; padding-top: .7rem; border-top: 1px dashed var(--line);
}
.badge-exam { background: var(--primary); }
.badge-drill { background: #8b5cf6; }
.task-card-foot .muted { font-size: .82rem; }
.home-note { margin-top: 2.2rem; font-size: .88rem; color: var(--muted); text-align: center; }

/* ---------- practice page ---------- */
.practice-head {
    display: flex; flex-wrap: wrap; gap: 1rem;
    justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.1rem;
}
.practice-head h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: .2rem; }
.practice-sub { margin: 0; font-size: .92rem; color: var(--muted); }
.practice-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.badge {
    display: inline-block; border-radius: 999px;
    padding: .18rem .65rem; font-size: .74rem; font-weight: 700;
    color: #fff; letter-spacing: .02em;
}

.cloze-text {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1.09rem; line-height: 2.05;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.6rem 1.8rem; margin-bottom: 1.3rem;
    box-shadow: var(--shadow);
}
.gap-marker {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.65em; height: 1.65em; padding: 0 .2em;
    background: var(--primary); color: #fff;
    border-radius: 999px; font-size: .72rem; font-weight: 700;
    vertical-align: middle; margin: 0 .18rem;
    font-family: var(--font);
    box-shadow: 0 3px 8px -3px rgba(74, 85, 226, .8);
}

.gap-list { display: flex; flex-direction: column; gap: .65rem; margin-top: 1.1rem; }
.gap-row {
    display: flex; gap: .85rem;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .9rem 1rem; background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .15s ease, background .15s ease;
}
.gap-row.row-ok { border-color: #b5e3cf; background: #f3fbf6; }
.gap-row.row-bad { border-color: #f3c1cb; background: #fef5f7; }
.gap-num {
    flex: 0 0 auto; width: 1.95em; height: 1.95em; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary-strong);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .88rem;
}
.gap-body { flex: 1; min-width: 0; }
.gap-lead { margin: 0 0 .45rem; font-style: italic; color: #4a5578; }
.gap-answerline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.gap-marker-static {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.5em; height: 1.5em;
    color: var(--muted); background: #eef0f8; border-radius: 7px;
    font-size: .78rem; font-weight: 800; padding: 0 .3em;
}
.base-badge {
    background: var(--warn-soft); border: 1px solid #f3ddb0; color: var(--warn);
    font-weight: 800; letter-spacing: .07em;
    border-radius: 8px; padding: .14em .5em; font-size: .84rem;
}
.sentence { font-size: 1rem; }
.option-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.opt-pill {
    border: 1.5px solid var(--line); background: #fff;
    border-radius: 999px; padding: .3rem .9rem;
    font-size: .94rem; font-weight: 600; color: var(--ink);
    cursor: pointer; transition: all .1s ease;
}
.opt-pill:hover { border-color: var(--primary); color: var(--primary-strong); }
.opt-pill.opt-selected {
    border-color: var(--primary); background: var(--primary-soft);
    color: var(--primary-strong); font-weight: 700;
    box-shadow: 0 3px 10px -5px rgba(74, 85, 226, .6);
}
.opt-pill.opt-correct {
    border-color: var(--accent); background: var(--accent-soft); color: #0a6b4a; font-weight: 700;
}
.opt-pill.opt-wrong {
    border-color: var(--danger); background: var(--danger-soft); color: #97293d; font-weight: 700;
}
.gap-input {
    border: none; border-bottom: 2px dashed #aab4d0;
    background: #fbfbff; padding: .28rem .45rem;
    font-size: 1rem; width: 130px; outline: none;
    font-family: var(--font); color: var(--ink);
    transition: border-color .12s ease;
}
.gap-input:focus { border-bottom-color: var(--primary); border-bottom-style: solid; background: #fff; }
.gap-input-wide { width: 230px; }
.hint-btn {
    border: none; background: transparent; font-size: 1.02rem;
    cursor: pointer; opacity: .7; padding: .12rem .35rem; border-radius: 8px;
}
.hint-btn:hover { opacity: 1; background: var(--warn-soft); }
.hint-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.hint-text { margin: .45rem 0 0; font-size: .9rem; color: var(--warn); font-style: italic; }
.feedback-text { margin: .5rem 0 0; font-size: .93rem; font-weight: 600; }
.fb-ok { color: var(--accent); }
.fb-bad { color: var(--danger); }
.explanation {
    margin: .35rem 0 0; font-size: .9rem; color: #4d4a3b; font-weight: 400;
    background: var(--warn-soft); border-left: 3px solid #e3c65b;
    padding: .5rem .7rem; border-radius: 0 10px 10px 0; line-height: 1.5;
}

.score-banner {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    border-radius: var(--radius); padding: .95rem 1.15rem; margin-bottom: 1.15rem;
    font-size: 1.05rem; box-shadow: var(--shadow);
}
.score-banner strong { font-size: 1.15rem; }
.score-perfect { background: linear-gradient(120deg, #e3f6ee, #f2fcf7); border: 1px solid #a9dfc6; color: #0a5c40; }
.score-good { background: linear-gradient(120deg, #fdf3df, #fefaf1); border: 1px solid #ecd9ac; color: #6d5312; }
.score-weak { background: linear-gradient(120deg, #fdeaee, #fef5f7); border: 1px solid #f3c1cb; color: #8e2740; }
.score-banner .btn { margin-left: auto; }

.practice-foot {
    margin-top: 1.8rem; display: flex; gap: 1.2rem; align-items: center;
    color: var(--muted); font-size: .9rem;
}

/* ---------- progress page ---------- */
.stat-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem; margin: 1.1rem 0 1.6rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1rem 1.1rem;
    box-shadow: var(--shadow);
}
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--primary-strong); line-height: 1.15; }
.stat-label { color: var(--muted); font-size: .84rem; font-weight: 600; margin-top: .15rem; }

h2 { font-size: 1.15rem; font-weight: 800; margin: 1.7rem 0 .8rem; }

.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem 1.25rem;
    margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
.chart-controls { display: flex; gap: 1.3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.chart-controls label { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .9rem; font-weight: 600; }
.chart-controls select {
    padding: .34rem .6rem; border-radius: 9px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); font-family: var(--font); font-size: .9rem;
}
.line-chart { width: 100%; height: auto; }
.ch-grid { stroke: #e9ecf5; stroke-width: 1; }
.ch-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { fill: #fff; stroke: var(--primary); stroke-width: 2; }
.ch-label { font-size: 11px; fill: #99a1b8; }
.chart-empty { margin: 1rem 0; }

.table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.stats-table th {
    text-align: left; color: var(--muted); font-weight: 700;
    font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
    padding: .5rem .55rem; border-bottom: 2px solid var(--line);
}
.stats-table td { padding: .6rem .55rem; border-bottom: 1px solid #eef0f7; }
.stats-table tbody tr:hover { background: #f8f9fe; }
.acc-cell { display: flex; align-items: center; gap: .55rem; min-width: 140px; }
.acc-bar { flex: 1; height: 8px; background: #eef0f7; border-radius: 999px; overflow: hidden; }
.acc-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #22b8a0); }

.mistake-list { margin: 0; padding-left: 1.15rem; }
.mistake-list li { margin-bottom: .4rem; }
.mistake-list code {
    background: var(--danger-soft); color: #97293d;
    padding: .12em .45em; border-radius: 7px; font-size: .88em; font-weight: 700;
}

/* ---------- identity pages (bootstrap forms) ---------- */
.card, .form-control { border-radius: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
    .topnav-inner { flex-wrap: wrap; gap: .5rem .9rem; padding: .6rem .9rem; }
    .topnav-links { order: 3; flex-basis: 100%; }
    .practice-head { flex-direction: column; }
    .hero { padding: 1.7rem 1.4rem; }
    .hero h1 { font-size: 1.65rem; }
    .cloze-text { padding: 1.1rem 1.15rem; font-size: 1.02rem; }
}

/* ---------- blazor error UI ---------- */
#blazor-error-ui {
    color-scheme: light only;
    bottom: 0; display: none; width: 100%;
    background: #fff3cd; border-top: 1px solid #ffe69c;
    padding: .6rem 1rem; z-index: 100;
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
#blazor-error-ui .dismiss { cursor: pointer; margin-left: auto; }

/* ---------- FAQ ---------- */
.faq-page h1 { font-size: 1.7rem; font-weight: 800; margin-bottom: .3rem; }
.faq-intro { margin-bottom: 1.5rem; }
.faq-list { display: flex; flex-direction: column; gap: .7rem; }
.faq-item {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.faq-item summary {
    list-style: none; cursor: pointer;
    padding: 1rem 1.25rem; font-weight: 700; font-size: 1rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: "+"; font-size: 1.25rem; color: var(--primary);
    font-weight: 800; line-height: 1; transition: transform .15s ease;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item[open] summary { color: var(--primary-strong); }
.faq-body { padding: 0 1.25rem 1.1rem; color: #3c455f; line-height: 1.6; }
.faq-body p { margin: 0; }
.faq-body code {
    background: #eef0f8; color: var(--primary-strong);
    padding: .1em .4em; border-radius: 6px; font-size: .88em;
}

.typed-answer {
    display: inline-block;
    border-bottom: 2px solid var(--primary);
    background: var(--primary-soft);
    color: var(--primary-strong);
    padding: .18rem .5rem;
    border-radius: 7px;
    font-weight: 700;
    font-size: .95rem;
}

/* ---------- account / identity pages ---------- */
.account-shell {
    max-width: 520px;
    margin: 2.5rem auto 3rem;
    padding: 0 1rem;
}
.account-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem 1.9rem 2rem;
}
.account-card h1, .account-card h2 {
    font-size: 1.35rem; font-weight: 800; margin-bottom: 1.1rem;
}
.account-card .form-floating, .account-card .mb-3 { margin-bottom: 1rem; }
.account-card .btn { margin-top: .4rem; }
.account-card .text-danger { font-size: .85rem; }

/* progress header + reset */
.progress-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem;
}
.progress-head h1 { margin: 0; }
.reset-confirm {
    display: inline-flex; align-items: center; gap: .55rem;
    background: var(--danger-soft); border: 1px solid #f3c1cb;
    color: #97293d; border-radius: 10px; padding: .4rem .7rem;
    font-size: .9rem; font-weight: 600;
}
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #bb3a50; color: #fff; }
