:root {
  --ink: #162a46;
  --ink-soft: #40516a;
  --blue: #235fce;
  --blue-dark: #1749a3;
  --sky: #eaf2ff;
  --accent: #ffcc58;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --line: #dce4ef;
  --success: #238b63;
  --danger: #d54b53;
  --shadow: 0 18px 55px rgba(22, 42, 70, .10);
  --radius: 22px;
}

html { min-height: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
main { flex: 1; }
a { color: var(--blue); }
.py-lg-6 { padding-top: 5.5rem !important; padding-bottom: 5.5rem !important; }
.page-narrow { max-width: 880px; }
.eyebrow {
  margin-bottom: .55rem;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.text-primary { color: var(--blue) !important; }
.btn { border-radius: 12px; font-weight: 750; padding: .72rem 1.15rem; }
.btn-lg { padding: .92rem 1.35rem; }
.btn-primary { background: var(--blue); border-color: var(--blue); }
.btn-primary:hover, .btn-primary:focus { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { background: #ffbf2f; border-color: #ffbf2f; color: var(--ink); }
.form-control {
  border: 1px solid #cbd7e6;
  border-radius: 12px;
  min-height: 48px;
  color: var(--ink);
  box-shadow: none !important;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(35, 95, 206, .12) !important; }
.errorlist { color: var(--danger); margin-top: .4rem; padding-left: 1.2rem; }

.site-nav {
  position: relative;
  z-index: 50;
  min-height: 76px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid rgba(22,42,70,.08);
  box-shadow: 0 4px 22px rgba(22,42,70,.04);
}
.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: white;
  background: linear-gradient(145deg, var(--blue), #6b8ff5);
  font-size: 1.22rem;
  font-weight: 900;
  box-shadow: 0 7px 18px rgba(35,95,206,.28);
}
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: .25rem; color: #7d8999; font-size: .68rem; font-weight: 650; letter-spacing: .05em; }
.site-nav .nav-link { color: var(--ink-soft); font-weight: 700; border-radius: 9px; padding: .55rem .75rem !important; }
.site-nav .nav-link:hover { color: var(--blue); background: var(--sky); }
.logout-link { border: 0; background: transparent; }

.site-footer { background: var(--ink); color: #b9c6d7; padding: 1.4rem 0; font-size: .83rem; }

.login-page { background: white; }
.login-page .site-footer { display: none; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.login-visual {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 4rem;
  color: white;
  background:
    radial-gradient(circle at 20% 15%, rgba(95,139,255,.55), transparent 26%),
    radial-gradient(circle at 82% 72%, rgba(44,196,171,.23), transparent 28%),
    linear-gradient(145deg, #11223d 0%, #174a9a 100%);
}
.login-visual::before, .login-visual::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
}
.login-visual::before { width: 620px; height: 620px; right: -250px; top: -210px; }
.login-visual::after { width: 420px; height: 420px; left: -220px; bottom: -210px; }
.login-visual-inner { position: relative; z-index: 2; width: min(680px, 100%); }
.brand-light { color: white; }
.brand-light:hover { color: white; }
.brand-light small { color: rgba(255,255,255,.68); }
.login-visual h1 { font-size: clamp(2.8rem, 5vw, 5.4rem); line-height: .98; letter-spacing: -.055em; font-weight: 850; }
.login-visual h1 span { color: var(--accent); }
.login-visual .lead { max-width: 630px; margin-top: 1.6rem; color: #d6e4fa; line-height: 1.65; }
.code-orbit {
  margin-top: 3.5rem;
  width: 118px;
  height: 118px;
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  box-shadow: 0 0 0 15px rgba(255,255,255,.04), 0 0 0 31px rgba(255,255,255,.025);
}
.code-orbit span { font-size: 2rem; font-weight: 850; }
.code-orbit small { color: #c8d7ee; }
.login-panel { display: grid; place-items: center; padding: 3rem; }
.login-card { width: min(440px, 100%); }
.login-card h2 { font-size: 2rem; font-weight: 820; letter-spacing: -.03em; }
.login-help { margin-top: 2rem; color: #8490a0; font-size: .86rem; text-align: center; }

.hero-section { color: white; background: linear-gradient(130deg, #142944 0%, #174a9b 100%); }
.hero-section h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); font-weight: 850; letter-spacing: -.055em; }
.hero-copy { max-width: 730px; margin: 1.25rem 0 2rem; color: #d7e5f8; font-size: 1.12rem; line-height: 1.65; }
.hero-signal {
  width: 230px;
  height: 230px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 18px rgba(255,255,255,.035), 0 0 0 38px rgba(255,255,255,.018);
}
.hero-signal span { color: var(--accent); font-size: .8rem; font-weight: 850; letter-spacing: .2em; }
.hero-signal strong { font-size: 3.7rem; line-height: 1.1; }
.hero-signal small { color: #bfcee3; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.section-heading h1, .section-heading h2 { margin-bottom: .35rem; font-weight: 820; letter-spacing: -.035em; }
.section-heading p:last-child { margin-bottom: 0; color: #65738a; max-width: 750px; }
.metric-card, .content-card, .diagnostic-card {
  background: var(--paper);
  border: 1px solid rgba(22,42,70,.08);
  border-radius: var(--radius);
  box-shadow: 0 7px 28px rgba(22,42,70,.055);
}
.metric-card { min-height: 150px; display: flex; flex-direction: column; justify-content: center; padding: 1.5rem; }
.metric-card span { color: #738096; font-size: .82rem; font-weight: 750; }
.metric-card strong { margin: .15rem 0; font-size: 2.5rem; line-height: 1.1; letter-spacing: -.04em; }
.metric-card small { color: #8b97a8; }
.content-card { overflow: hidden; padding: 1.6rem; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card-heading h2, .card-heading p { margin-bottom: 0; }
.card-heading a { font-weight: 750; text-decoration: none; }
.result-list { margin: 0 -1.6rem -1.6rem; }
.result-list a { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.05rem 1.6rem; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.result-list a:hover { background: #f8faff; }
.result-list span { display: flex; flex-direction: column; }
.result-list small { color: #8793a5; margin-top: .2rem; }
.result-list b { color: var(--blue); white-space: nowrap; }
.empty-state { min-height: 160px; display: grid; place-content: center; justify-items: center; color: #8390a2; text-align: center; padding: 2rem; }
.empty-state > span { font-size: 2rem; }
.next-card { display: flex; flex-direction: column; }
.next-card > p:not(.eyebrow) { color: #66758a; line-height: 1.6; }
.next-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1.5rem; }
.next-meta span, .diagnostic-meta span { padding: .42rem .7rem; border-radius: 999px; background: var(--sky); color: var(--blue-dark); font-size: .76rem; font-weight: 750; }

.profile-list { margin: 2rem 0; }
.profile-list div { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.profile-list dt { color: #7c899b; font-weight: 650; }
.profile-list dd { margin: 0; font-weight: 750; }
.stacked-form input { display: block; width: 100%; border: 1px solid #cbd7e6; border-radius: 12px; min-height: 48px; padding: .65rem .8rem; }
.stacked-form ul { margin: .4rem 0; color: #7b8798; font-size: .82rem; }
.success-icon { width: 70px; height: 70px; display: grid; place-items: center; margin: 0 auto 1rem; border-radius: 50%; color: white; background: var(--success); font-size: 2rem; }

.active-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.35rem; border-radius: 18px; color: white; background: linear-gradient(120deg, #174a9b, #2468dc); box-shadow: var(--shadow); }
.active-banner > div { display: flex; align-items: center; gap: .8rem; }
.active-banner strong, .active-banner small { display: block; }
.active-banner small { color: #d7e5fa; margin-top: .15rem; }
.pulse-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px rgba(255,204,88,.18); }
.diagnostic-card { position: relative; overflow: hidden; min-height: 360px; padding: 2rem; }
.diagnostic-card h2 { max-width: 520px; font-weight: 820; }
.diagnostic-card > p:not(.eyebrow) { max-width: 520px; color: #65738a; line-height: 1.6; }
.diagnostic-number { position: absolute; right: -12px; top: -34px; color: rgba(35,95,206,.055); font-size: 8rem; font-weight: 900; letter-spacing: -.08em; }
.diagnostic-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0; }
.history-table { margin-bottom: 0; }
.history-table th { color: #7e8b9c; font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.history-table td { padding-top: 1rem; padding-bottom: 1rem; }
.start-card h1 { font-weight: 820; letter-spacing: -.035em; }
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 2rem 0; }
.start-grid div { padding: 1.3rem; border-radius: 16px; background: var(--sky); text-align: center; }
.start-grid strong, .start-grid span { display: block; }
.start-grid strong { font-size: 2rem; color: var(--blue); }
.start-grid span { color: #65738a; font-size: .82rem; }
.rules-box { padding: 1.3rem 1.5rem; margin-bottom: 1.5rem; border-left: 4px solid var(--accent); border-radius: 0 15px 15px 0; background: #fffaf0; }
.rules-box li { margin: .45rem 0; color: #596779; }
.back-link { display: block; margin-top: 1.25rem; text-align: center; text-decoration: none; font-weight: 700; }

.exam-page { background: #eef3f9; }
.exam-topbar { position: sticky; top: 0; z-index: 40; color: white; background: var(--ink); box-shadow: 0 8px 22px rgba(15,31,52,.18); }
.exam-topbar-inner { min-height: 80px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2rem; }
.exam-topbar-inner > div:first-child strong, .timer small, .timer strong, .exam-progress small, .exam-progress strong { display: block; }
.exam-topbar-inner > div:first-child strong { margin-top: .2rem; font-size: .83rem; color: #b8c6d8; }
.exam-status { font-size: .76rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.exam-status i { display: inline-block; width: 8px; height: 8px; margin-right: .35rem; border-radius: 50%; background: #59d49f; }
.timer { text-align: center; }
.timer small, .exam-progress small { color: #aebed2; font-size: .7rem; }
.timer strong { color: var(--accent); font-size: 1.55rem; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.timer.urgent strong { color: #ff858c; }
.exam-progress { text-align: right; }
.exam-progress strong { font-size: 1.1rem; }
.palette-card { top: 110px; padding: 1.25rem; border-radius: 18px; background: white; border: 1px solid rgba(22,42,70,.08); }
.palette-heading { display: flex; align-items: end; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.palette-heading span { color: #8390a1; font-size: .67rem; }
.answered-key { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.task-palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: .45rem; }
.palette-item, .finish-palette a { aspect-ratio: 1; display: grid; place-items: center; border: 1px solid #d9e2ed; border-radius: 9px; background: white; color: #536174; font-size: .78rem; font-weight: 800; text-decoration: none; }
.palette-item.answered, .finish-palette a.answered { color: var(--success); border-color: #b8e3d2; background: #ecfaf4; }
.palette-item.current { color: white; border-color: var(--blue); background: var(--blue); box-shadow: 0 5px 14px rgba(35,95,206,.25); }
.task-card { overflow: hidden; border: 1px solid rgba(22,42,70,.08); border-radius: 22px; background: white; box-shadow: 0 12px 38px rgba(22,42,70,.07); }
.task-heading { display: flex; justify-content: space-between; gap: 1rem; padding: 1.7rem 2rem; border-bottom: 1px solid var(--line); }
.task-heading h1 { margin: 0; font-size: 1.65rem; font-weight: 820; }
.task-heading p:last-child { margin: .35rem 0 0; color: #6e7c90; }
.points-badge { align-self: start; padding: .45rem .7rem; border-radius: 999px; color: var(--blue-dark); background: var(--sky); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.task-statement { padding: 1.5rem 2rem 0; line-height: 1.65; }
.task-page { margin: 1.6rem 2rem; }
.task-page img { display: block; width: 100%; height: auto; border: 1px solid #dce3ec; border-radius: 12px; background: #fafafa; }
.task-page figcaption { margin-top: .5rem; color: #8a96a7; font-size: .72rem; text-align: right; }
.attachments { margin: 1.6rem 2rem; padding: 1rem; border-radius: 14px; background: #f6f9fd; }
.attachments h2 { color: #67758a; }
.attachments a { display: flex; align-items: center; gap: .8rem; padding: .8rem; border-radius: 10px; color: var(--ink); text-decoration: none; }
.attachments a:hover { background: white; }
.attachments a > span:first-child { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--blue); font-size: 1.2rem; }
.attachments a strong, .attachments a small { display: block; }
.attachments a small { color: #8490a1; }
.answer-box { margin-top: 2rem; padding: 1.6rem 2rem 1.8rem; background: #f6f9fd; border-top: 1px solid var(--line); }
.answer-box label { display: block; margin-bottom: .2rem; font-size: 1rem; font-weight: 820; }
.answer-box p { color: #718095; font-size: .82rem; }
.answer-input { width: 100%; min-height: 92px; resize: vertical; padding: .85rem 1rem; border: 2px solid #cbd7e6; border-radius: 13px; background: white; color: var(--ink); font-size: 1.05rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.answer-input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(35,95,206,.12); }
.save-indicator { display: block; min-height: 1rem; margin-top: .5rem; color: #8793a3; }
.save-indicator.saved { color: var(--success); }
.exam-actions { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem 0 0; }
.finish-summary { display: flex; align-items: baseline; gap: .8rem; margin: 2rem 0; }
.finish-summary strong { font-size: 3rem; letter-spacing: -.05em; }
.finish-summary span { color: #758296; }
.finish-palette { display: grid; grid-template-columns: repeat(9, 1fr); gap: .5rem; }

.result-hero { color: white; text-align: center; background: linear-gradient(125deg, #142944, #1d58bb); }
.result-hero h1 { font-weight: 820; }
.score-orb { width: 154px; height: 154px; display: grid; place-content: center; margin: 1.5rem auto; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; background: rgba(255,255,255,.08); box-shadow: 0 0 0 14px rgba(255,255,255,.035); }
.score-orb strong, .score-orb span { display: block; }
.score-orb strong { color: var(--accent); font-size: 3.8rem; line-height: 1; }
.score-orb span { color: #c5d4e8; }
.result-grid { margin: 0 -1.6rem -1.6rem; }
.result-item { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 1rem; padding: 1rem 1.6rem; border-top: 1px solid var(--line); }
.result-task-number { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: #edf2f8; font-weight: 850; }
.result-item.correct .result-task-number { color: var(--success); background: #e8f7f1; }
.result-item.wrong .result-task-number { color: var(--danger); background: #fff0f1; }
.result-item > div:nth-child(2) { min-width: 0; }
.result-item > div:nth-child(2) strong, .result-item > div:nth-child(2) span, .result-item > div:nth-child(2) small { display: block; }
.result-item > div:nth-child(2) span { overflow: hidden; color: #607086; text-overflow: ellipsis; white-space: nowrap; }
.result-item > div:nth-child(2) small { color: #8a96a7; }
.result-points { font-weight: 850; }

@media (max-width: 991.98px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 420px; padding: 3rem 1.5rem; }
  .login-panel { padding: 3rem 1.5rem; }
  .hero-signal { margin: 2rem auto 0; }
  .exam-topbar { position: relative; }
  .palette-card { position: static !important; }
  .task-palette { grid-template-columns: repeat(9, 1fr); }
}

@media (max-width: 575.98px) {
  .login-visual { min-height: 350px; }
  .login-visual h1 { font-size: 2.65rem; }
  .code-orbit { display: none; }
  .hero-section { text-align: center; }
  .hero-signal { width: 180px; height: 180px; }
  .profile-list div { grid-template-columns: 1fr; gap: .2rem; }
  .start-grid { grid-template-columns: 1fr; }
  .active-banner { align-items: stretch; flex-direction: column; }
  .exam-topbar-inner { min-height: 92px; grid-template-columns: 1fr 1fr; gap: .6rem; }
  .exam-topbar-inner > div:first-child { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 1rem; }
  .exam-progress { text-align: right; }
  .task-heading, .answer-box { padding-left: 1.15rem; padding-right: 1.15rem; }
  .task-page, .attachments { margin-left: .65rem; margin-right: .65rem; }
  .task-palette, .finish-palette { grid-template-columns: repeat(6, 1fr); }
  .result-item { grid-template-columns: 38px 1fr; }
  .result-points { grid-column: 2; }
}
