:root {
    --tmg-navy: #172743;
    --tmg-navy-2: #243858;
    --tmg-burgundy: #802f40;
    --tmg-gold: #d7a72f;
    --tmg-gold-dark: #a97908;
    --tmg-paper: #f5f3ee;
    --tmg-surface: #ffffff;
    --tmg-line: #dfe3e8;
    --tmg-ink: #202733;
    --tmg-muted: #657080;
    --bs-primary: #243858;
    --bs-primary-rgb: 36, 56, 88;
}

html { scrollbar-gutter: stable; }
body { min-height: 100vh; background: var(--tmg-paper); color: var(--tmg-ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: #234f82; }
p:last-child { margin-bottom: 0; }
.skip-link { position: fixed; z-index: 2000; top: 8px; left: 8px; padding: .65rem .9rem; background: #fff; color: #111; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.flash-stack { position: fixed; z-index: 1080; top: 1rem; right: 1rem; width: min(420px, calc(100vw - 2rem)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border-radius: 6px; font-weight: 650; }
.btn svg, .nav-link svg, .site-footer svg { width: 18px; height: 18px; flex: 0 0 auto; }
.btn-icon { width: 40px; height: 40px; padding: 0; }
.btn-primary { --bs-btn-bg: var(--tmg-navy-2); --bs-btn-border-color: var(--tmg-navy-2); --bs-btn-hover-bg: #2e4a72; --bs-btn-hover-border-color: #2e4a72; --bs-btn-active-bg: #12223c; --bs-btn-active-border-color: #12223c; }
.btn-outline-primary { --bs-btn-color: var(--tmg-navy-2); --bs-btn-border-color: #708098; --bs-btn-hover-bg: var(--tmg-navy-2); --bs-btn-hover-border-color: var(--tmg-navy-2); }
.btn-warning { --bs-btn-bg: var(--tmg-gold); --bs-btn-border-color: var(--tmg-gold); --bs-btn-hover-bg: #e6b83f; --bs-btn-hover-border-color: #e6b83f; --bs-btn-color: #111827; }
.form-control, .form-select, .input-group-text { border-radius: 6px; border-color: #cfd5dc; }
.form-control:focus, .form-select:focus { border-color: #557ba6; box-shadow: 0 0 0 .2rem rgba(36,56,88,.14); }
.rounded-3, .card { border-radius: 8px !important; }

.topbar { min-height: 64px; background: var(--tmg-navy); border-bottom: 1px solid rgba(255,255,255,.12); }
.navbar-brand { font-size: 1.05rem; font-weight: 700; letter-spacing: 0; }
.topbar .nav-link { color: rgba(255,255,255,.82); }
.topbar .nav-link:hover { color: #fff; }
.brand-mark { width: 40px; height: 40px; border-radius: 6px; display: inline-grid; place-items: center; background: var(--tmg-gold); color: var(--tmg-navy); font-weight: 900; letter-spacing: 0; box-shadow: inset 0 0 0 1px rgba(23,39,67,.2); }

.hero { position: relative; min-height: calc(78vh - 64px); display: grid; align-items: center; isolation: isolate; overflow: hidden; background: url("/images/gniezno-cathedral-hero.webp") center 44% / cover no-repeat; color: #fff; }
.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(17,31,55,.63); }
.hero-copy { max-width: 780px; padding: 5rem 0; }
.hero-kicker { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.2rem; color: #f1ca62; font-size: .9rem; font-weight: 800; text-transform: uppercase; }
.hero-kicker span { display: inline-block; width: 38px; height: 3px; background: var(--tmg-gold); }
.hero h1 { max-width: 760px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 4rem; line-height: 1.03; font-weight: 700; text-wrap: balance; }
.hero-lead { max-width: 730px; margin-top: 1.4rem; font-size: 1.18rem; line-height: 1.7; color: rgba(255,255,255,.9); }
.section-band { padding: 4.5rem 0; }
.section-kicker { margin-bottom: .45rem; color: var(--tmg-burgundy); font-size: .79rem; font-weight: 850; text-transform: uppercase; }
.section-title { max-width: 760px; margin: 0 0 2rem; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; }
.metric { position: relative; padding: 1.5rem; background: var(--tmg-surface); border: 1px solid var(--tmg-line); border-top: 4px solid var(--tmg-gold); border-radius: 8px; box-shadow: 0 8px 24px rgba(31,42,58,.05); }
.metric > svg { width: 28px; height: 28px; margin-bottom: 1rem; color: var(--tmg-burgundy); }
.metric h3 { font-size: 1.05rem; font-weight: 800; }
.metric p { color: var(--tmg-muted); line-height: 1.65; }
.instruction-band { background: var(--tmg-surface); border-top: 1px solid var(--tmg-line); }
.instruction-band h2 { font-family: Georgia, "Times New Roman", serif; font-size: 1.85rem; }
.instruction-list { display: grid; gap: .8rem; margin: 1.4rem 0 0; padding: 0; list-style: none; }
.instruction-list li { display: flex; align-items: center; gap: .85rem; padding: .8rem 0; border-bottom: 1px solid var(--tmg-line); }
.instruction-list span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--tmg-navy); color: #fff; font-size: .82rem; font-weight: 800; }
.site-footer { padding: 1.5rem 0; background: var(--tmg-navy); color: rgba(255,255,255,.75); font-size: .9rem; }
.site-footer a { display: inline-flex; align-items: center; gap: .35rem; color: #f2cb67; font-weight: 700; text-decoration: none; }
.content-page { min-height: calc(100vh - 64px); padding: 4.5rem 0; background: #f5f6f8; }
.content-narrow { max-width: 860px; }
.content-page h1 { margin-bottom: 1.5rem; font-family: Georgia, "Times New Roman", serif; font-size: 2.5rem; }
.document-surface { padding: 2rem; background: #fff; border: 1px solid var(--tmg-line); border-left: 4px solid var(--tmg-gold); border-radius: 8px; line-height: 1.8; white-space: normal; }
.contact-list { display: grid; gap: .8rem; }
.contact-list > div { display: flex; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--tmg-line); }
.contact-list svg { width: 24px; color: var(--tmg-burgundy); }
.contact-list span { display: grid; }
.contact-list small { color: var(--tmg-muted); }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(480px, .95fr); background: #fff; }
.auth-visual { position: relative; display: flex; align-items: flex-end; padding: 3rem; background: url("/images/gniezno-cathedral-hero.webp") center / cover no-repeat; color: #fff; isolation: isolate; }
.auth-visual::before { content: ""; position: absolute; z-index: -1; inset: 0; background: rgba(18,35,61,.55); }
.auth-visual p { margin: .8rem 0 .25rem; color: rgba(255,255,255,.76); font-weight: 700; }
.auth-visual strong { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; }
.auth-main { display: grid; place-items: center; padding: 3rem; }
.auth-card { width: min(440px, 100%); }
.auth-brand { display: none; align-items: center; gap: .65rem; margin-bottom: 3rem; color: var(--tmg-navy); font-weight: 800; text-decoration: none; }
.auth-card h1 { margin: 0 0 .6rem; font-size: 2.15rem; font-weight: 850; }
.password-toggle { min-width: 54px; border-color: #cfd5dc; }
.auth-back { display: inline-flex; align-items: center; gap: .35rem; margin-top: 1.5rem; color: var(--tmg-muted); font-size: .9rem; text-decoration: none; }
.auth-back svg { width: 16px; }

.student-topbar, .attempt-header { background: var(--tmg-navy); color: #fff; }
.student-topbar .container { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.student-topbar a:first-child { display: flex; align-items: center; gap: .65rem; color: #fff; font-weight: 800; text-decoration: none; }
.student-shell { min-height: calc(100vh - 68px); padding: 3.5rem 0; background: #f5f6f8; }
.student-shell > .container { max-width: 980px; }
.student-heading { margin-bottom: 1.8rem; }
.student-heading h1 { max-width: 800px; font-family: Georgia, "Times New Roman", serif; font-size: 2.6rem; }
.student-heading > p:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: var(--tmg-muted); }
.student-heading > p svg { width: 18px; }
.student-heading > p span { width: 4px; height: 4px; border-radius: 50%; background: #9aa3ae; }
.student-status { display: grid; grid-template-columns: 84px 1fr; gap: 1.5rem; padding: 2rem; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; box-shadow: 0 10px 28px rgba(31,42,58,.05); }
.student-status h2 { font-size: 1.55rem; font-weight: 800; }
.student-status p:not(.section-kicker) { max-width: 670px; color: var(--tmg-muted); line-height: 1.65; }
.status-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: #eef1f4; color: var(--tmg-navy); }
.status-icon svg { width: 29px; height: 29px; }
.status-icon-ready { background: #edf5ee; color: #28733d; }
.status-icon-done { background: #edf5ee; color: #28733d; }
.stage-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 1rem; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.stage-facts > div { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem; border-right: 1px solid var(--tmg-line); }
.stage-facts > div:last-child { border-right: 0; }
.stage-facts svg { width: 22px; color: var(--tmg-burgundy); }
.stage-facts span { display: grid; font-weight: 800; }
.stage-facts small { color: var(--tmg-muted); font-weight: 500; }
.start-countdown { width: fit-content; display: grid; margin-top: 1.1rem; padding: .75rem 1rem; background: #f4f6f8; border-left: 3px solid var(--tmg-gold); border-radius: 4px; }
.start-countdown small { color: var(--tmg-muted); font-size: .73rem; font-weight: 700; text-transform: uppercase; }
.start-countdown strong { color: var(--tmg-navy); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.student-information { display: grid; gap: .75rem; margin-top: 1rem; }
.student-information details { background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.student-information summary { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.2rem; cursor: pointer; color: var(--tmg-navy); font-weight: 800; }
.student-information summary svg { width: 19px; color: var(--tmg-burgundy); }
.student-information details > div { padding: 0 1.2rem 1.2rem; color: var(--tmg-muted); line-height: 1.7; }

.attempt-header { position: sticky; z-index: 10; top: 0; box-shadow: 0 3px 14px rgba(20,30,45,.14); }
.attempt-header .container { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.attempt-header .container > div:first-child { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.attempt-header h1 { margin: 0; overflow: hidden; font-size: 1.1rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.attempt-timer { display: grid; flex: 0 0 auto; text-align: right; }
.attempt-timer small { color: rgba(255,255,255,.65); font-size: .72rem; text-transform: uppercase; }
.attempt-timer .timer { color: #f3ca62; font-size: 1.35rem; }
.attempt-shell { min-height: calc(100vh - 72px); padding: 2rem 0 4rem; background: #f5f6f8; }
.attempt-shell > .container { max-width: 900px; }
.save-status { display: flex; align-items: center; gap: .4rem; color: var(--tmg-muted); font-size: .84rem; }
.save-status svg { width: 17px; }
.question-surface { margin-bottom: 1rem; padding: 1.6rem; scroll-margin-top: 92px; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.question-meta { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.question-meta h2 { margin: 0; color: var(--tmg-burgundy); font-size: .82rem; font-weight: 850; text-transform: uppercase; }
.question-meta span { color: var(--tmg-muted); font-size: .82rem; font-weight: 700; }
.question-content { font-size: 1.08rem; font-weight: 650; line-height: 1.6; }
.answer-option { cursor: pointer; transition: border-color .15s, background-color .15s; }
.answer-option:hover { border-color: #7790aa; background: #f8fafc; }
.answer-option:has(input:checked) { border-color: var(--tmg-navy-2); background: #f0f4f8; box-shadow: inset 3px 0 0 var(--tmg-gold); }
.question-navigation { min-height: 44px; display: grid; grid-template-columns: auto minmax(120px, 1fr) auto auto auto; align-items: center; gap: .65rem; }
.question-navigation > strong { text-align: center; color: var(--tmg-muted); font-size: .9rem; }
.attempt-summary { padding: 1.6rem; scroll-margin-top: 92px; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.attempt-summary h2 { font-size: 1.45rem; font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; margin: 1.3rem 0; }
.summary-item { min-height: 72px; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 0 .65rem; padding: .7rem; text-align: left; background: #fff; border: 1px solid #cfd5dc; border-radius: 6px; color: var(--tmg-ink); }
.summary-item:hover { border-color: #7790aa; background: #f8fafc; }
.summary-number { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; background: #eef1f4; border-radius: 50%; font-weight: 800; }
.summary-item small { color: var(--tmg-burgundy); }
.summary-item.is-answered { border-color: #8ab097; background: #f1f7f3; }
.summary-item.is-answered .summary-number { background: #dcecdf; color: #246437; }
.summary-item.is-answered small { color: #246437; }
.finish-form { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding: 1.2rem 1.4rem; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.finish-form > div { display: grid; }
.finish-form small { color: var(--tmg-muted); }
.result-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: #f5f6f8; }
.result-surface { width: min(600px, 100%); padding: 2.5rem; text-align: center; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.result-icon { width: 70px; height: 70px; display: grid; place-items: center; margin: 0 auto 1.2rem; border-radius: 50%; background: #edf5ee; color: #28733d; }
.result-icon svg { width: 34px; height: 34px; }
.result-score { display: grid; margin: 1.5rem 0; }
.result-score strong { color: var(--tmg-burgundy); font-size: 3rem; }
.result-score span { color: var(--tmg-muted); }

.panel-shell { min-height: 100vh; display: grid; grid-template-columns: 256px minmax(0, 1fr); }
.panel-sidebar { width: 256px !important; min-height: 100vh; padding: 1.35rem 1rem; background: var(--tmg-navy) !important; border-right: 1px solid rgba(255,255,255,.08); }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; margin: 0 .35rem 1.6rem; color: #fff; font-weight: 800; text-decoration: none; }
.panel-sidebar .nav-link { display: flex; align-items: center; gap: .7rem; min-height: 42px; padding: .62rem .72rem; color: rgba(255,255,255,.74); border-radius: 6px; font-size: .91rem; font-weight: 600; }
.panel-sidebar .nav-link:hover, .panel-sidebar .nav-link.active { background: rgba(255,255,255,.11); color: #fff; }
.panel-sidebar .nav-link.active { box-shadow: inset 3px 0 0 var(--tmg-gold); }
.sidebar-user { display: grid; margin-top: 2rem; padding: 1rem .7rem 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-user span { font-size: .88rem; font-weight: 700; }
.sidebar-user small { margin-top: .15rem; color: rgba(255,255,255,.52); overflow-wrap: anywhere; }
.panel-main { min-width: 0; background: #f5f6f8; }
.panel-header { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 2rem; background: #fff; border-bottom: 1px solid var(--tmg-line); }
.panel-header h1 { margin: 0; overflow: hidden; font-size: 1.45rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.panel-content { width: min(1480px, 100%); padding: 2rem; }
.school-switcher { width: fit-content; padding: .6rem .8rem; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.school-switcher select { min-width: 260px; }

.card, .bg-white.rounded-3 { border: 1px solid var(--tmg-line); box-shadow: 0 5px 18px rgba(31,42,58,.04); }
.table-responsive { background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.table { margin-bottom: 0; vertical-align: middle; }
.table > :not(caption) > * > * { padding: .8rem .85rem; }
.table thead th { color: #5f6875; background: #f4f6f8; border-bottom-width: 1px; font-size: .75rem; text-transform: uppercase; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .3rem .68rem; font-size: .78rem; font-weight: 700; }
.answer-option { border: 1px solid #d6dbe1; border-radius: 8px; padding: .9rem; background: #fff; }
.timer { color: var(--tmg-burgundy); font-variant-numeric: tabular-nums; font-weight: 800; }
.progress { height: 9px; border-radius: 6px; }
.progress-bar, .distribution-bar { background: var(--tmg-burgundy); }
.distribution { display: grid; gap: .7rem; padding: 1.2rem; background: #fff; border: 1px solid var(--tmg-line); border-radius: 8px; }
.distribution-row { display: grid; grid-template-columns: 70px minmax(80px, 1fr) 32px; align-items: center; gap: .75rem; font-size: .86rem; }
.distribution-track { height: 10px; overflow: hidden; background: #e9edf1; border-radius: 6px; }
.distribution-bar { height: 100%; border-radius: inherit; }
.login-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.login-card { break-inside: avoid; padding: 1.4rem; background: #fff; border: 1px solid #cfd4da; border-top: 4px solid var(--tmg-gold); border-radius: 8px; }
.login-card h2 { margin: 1rem 0 .3rem; font-size: 1.2rem; }
.login-card dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 1rem 0; }
.login-card dd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; }

@media (max-width: 991.98px) {
    .topbar .btn { width: 100%; margin-top: .25rem; }
    .hero h1 { font-size: 3.1rem; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
    .auth-brand { display: flex; }
}

@media (max-width: 767.98px) {
    .panel-shell { display: block; }
    .panel-sidebar { min-height: 100%; padding-top: .5rem; }
    .panel-sidebar .offcanvas-header { padding-inline: .35rem; }
    .panel-header { min-height: 68px; padding: .8rem 1rem; }
    .panel-header h1 { font-size: 1.12rem; }
    .panel-content { padding: 1rem; }
    .section-band { padding: 3.4rem 0; }
    .hero { min-height: calc(78vh - 64px); background-position: 60% 50%; }
    .hero-copy { padding: 3.8rem 0; }
    .hero h1 { font-size: 2.55rem; }
    .hero-lead { font-size: 1.03rem; line-height: 1.55; }
    .school-switcher { width: 100%; align-items: stretch !important; flex-direction: column; }
    .school-switcher select { min-width: 0; width: 100%; }
    .student-shell { padding: 2rem 0; }
    .student-heading h1 { font-size: 2rem; }
    .student-status { grid-template-columns: 1fr; padding: 1.4rem; }
    .stage-facts { grid-template-columns: 1fr; }
    .stage-facts > div { border-right: 0; border-bottom: 1px solid var(--tmg-line); }
    .stage-facts > div:last-child { border-bottom: 0; }
    .finish-form { align-items: stretch; flex-direction: column; }
    .finish-form .btn { width: 100%; }
    .question-navigation { grid-template-columns: 1fr 1fr; }
    .question-navigation > strong { grid-column: 1 / 3; grid-row: 1; }
    .question-navigation #previous-question { grid-column: 1; grid-row: 2; }
    .question-navigation #next-question { grid-column: 2; grid-row: 2; }
    .question-navigation #show-summary { grid-column: 1 / 3; }
    .question-navigation button[type="submit"] { grid-column: 1 / 3; }
}

@media (max-width: 420px) {
    .navbar-brand span:last-child { max-width: 190px; font-size: .92rem; white-space: normal; }
    .hero h1 { font-size: 2.15rem; }
    .hero-kicker { font-size: .72rem; }
    .hero .btn-lg { width: 100%; }
    .distribution-row { grid-template-columns: 56px minmax(60px, 1fr) 24px; gap: .5rem; }
    .auth-main { padding: 1.5rem; }
    .student-topbar .container > a:first-child span:last-child { display: none; }
    .attempt-header .brand-mark { width: 36px; height: 36px; }
    .attempt-header h1 { max-width: 155px; font-size: .88rem; }
    .attempt-timer small { font-size: .62rem; }
    .question-surface { padding: 1.15rem; }
}

@media print {
    .panel-sidebar, .panel-header, .school-switcher, form, .btn { display: none !important; }
    .panel-shell { display: block; }
    .panel-content { padding: 0; }
    .login-card-grid { grid-template-columns: repeat(2, 1fr); }
}
