@font-face {
  font-family: 'Portal Sans';
  src: local('Segoe UI'), local('Inter'), local('Arial');
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --surface-3: #eef0f5;
  --ink: #050608;
  --soft: #1f232b;
  --muted: #5a6270;
  --border: #d7dbe3;
  --border-strong: #b8bfcb;
  --primary: #0028c9;
  --primary-hover: #001fa8;
  --primary-soft: #e9eeff;
  --success: #0f7a50;
  --success-soft: #e6f5ee;
  --warning: #a96500;
  --warning-soft: #fff6dd;
  --danger: #d93a12;
  --danger-soft: #fdeae6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-md: 0 14px 34px rgba(10, 18, 40, .1);
  --shadow-lg: 0 28px 70px rgba(10, 18, 40, .16);
  --radius: 14px;
  --header: rgba(242, 243, 247, .82);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08090c;
  --surface: #12151a;
  --surface-2: #181c23;
  --surface-3: #20252e;
  --ink: #ffffff;
  --soft: #e3e7ee;
  --muted: #a4adba;
  --border: #2a3140;
  --border-strong: #424c60;
  --primary: #4c70ff;
  --primary-hover: #6a88ff;
  --primary-soft: #18224a;
  --success: #5ee0a0;
  --success-soft: #10241c;
  --warning: #ffc95c;
  --warning-soft: #3a2f16;
  --danger: #ff6a4a;
  --danger-soft: #3a1f1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, .42);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .55);
  --header: rgba(8, 9, 12, .84);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Portal Sans', 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.025em; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .7; }
svg { flex-shrink: 0; }
::selection { background: var(--primary-soft); color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  background: var(--header);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 11px; color: #fff; background: var(--primary);
  box-shadow: 0 5px 16px color-mix(in srgb, var(--primary) 28%, transparent);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 15px; letter-spacing: -.02em; }
.brand-copy small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 13px; }
.header-note {
  padding: 4px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase;
  color: var(--success); background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 24%, transparent);
}
.ghost-link { color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; }
.ghost-link:hover { color: var(--primary); }
.icon-button {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--soft);
}
.icon-button:hover { color: var(--primary); border-color: var(--primary); }
.icon-button svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Hero */
main { width: min(1180px, calc(100% - 2 * clamp(18px, 4vw, 48px))); margin: 0 auto; }
.hero {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(360px, .78fr);
  gap: clamp(32px, 5vw, 76px); align-items: center;
  padding: clamp(46px, 7vw, 92px) 0 clamp(40px, 5vw, 68px);
}
.hero::before {
  content: ""; position: absolute; inset: 0 calc(50% - 50vw); z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 12% 12%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 34%),
    radial-gradient(circle at 92% 6%, color-mix(in srgb, var(--success) 8%, transparent), transparent 28%),
    linear-gradient(color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px);
  background-size: auto, auto, 34px 34px, 34px 34px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 92%);
}
.eyebrow {
  display: inline-block; color: var(--primary); font-size: 11.5px; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
}
.hero h1 {
  margin: 16px 0 18px;
  max-width: 720px;
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 700; line-height: .98; letter-spacing: -.045em;
}
.hero-lede { max-width: 600px; color: var(--muted); font-size: clamp(15px, 1.6vw, 17px); line-height: 1.65; }
.hero-points { display: flex; flex-wrap: wrap; gap: 9px 18px; margin: 25px 0 28px; padding: 0; list-style: none; }
.hero-points li { display: flex; align-items: center; gap: 7px; color: var(--soft); font-size: 13px; font-weight: 600; }
.point-icon { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); }
.point-icon svg { width: 12px; height: 12px; }
.hero-seal { display: inline-flex; align-items: center; gap: 12px; padding-top: 24px; border-top: 1px solid var(--border); }
.seal-mark {
  width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-family: Georgia, serif; font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--muted);
}
.hero-seal > span:last-child { display: flex; flex-direction: column; }
.hero-seal strong { font-size: 13px; }
.hero-seal small { color: var(--muted); font-size: 12px; }

/* Lookup card */
.lookup-card {
  position: relative;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.lookup-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 30%, var(--success)));
}
.lookup-head { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 22px; }
.feature-icon {
  width: 46px; height: 46px; display: grid; place-items: center; flex-shrink: 0;
  border-radius: 12px; color: var(--primary); background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
}
.feature-icon svg { width: 24px; height: 24px; }
.lookup-head h2 { margin: 1px 0 3px; font-size: 22px; }
.lookup-head p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.lookup-form label { display: block; margin-bottom: 7px; color: var(--soft); font-size: 12px; font-weight: 700; }
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input-row input::placeholder { color: var(--muted); opacity: .85; }
.input-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.primary-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 126px; height: 48px; padding: 0 20px;
  border: 1px solid var(--primary); border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 750; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.primary-button:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.button-spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.primary-button.is-loading .button-spinner { display: block; }
.primary-button.is-loading .button-label { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }
.field-error { margin: 9px 0 0; color: var(--danger); font-size: 12.5px; line-height: 1.45; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.scan-button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 14px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--soft);
  transition: border-color .15s, background .15s, transform .15s;
}
.scan-button:hover { border-color: var(--primary); background: var(--primary-soft); }
.scan-button-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--primary); flex-shrink: 0; }
.scan-button-icon svg { width: 21px; height: 21px; }
.scan-button > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.scan-button strong { font-size: 13.5px; }
.scan-button small { color: var(--muted); font-size: 11.5px; }
.scan-button .chevron { width: 18px; height: 18px; color: var(--muted); }
.privacy-note { display: flex; align-items: flex-start; gap: 7px; margin: 17px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.privacy-note svg { width: 15px; height: 15px; margin-top: 1px; color: var(--success); }

/* Scanner */
.scanner-panel { margin-top: 15px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.camera-shell { overflow: hidden; border-radius: 10px; background: #0b0e14; }
.camera-stage { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 400px; }
.qr-reader, .qr-reader > div, .qr-reader video { width: 100% !important; height: 100% !important; }
.qr-reader video { display: block; object-fit: cover; }
.camera-overlay { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.frame-corners { position: absolute; inset: 13%; filter: drop-shadow(0 0 8px rgba(76,112,255,.55)); }
.frame-corners i { position: absolute; width: 38px; height: 38px; border: 3px solid #6f8cff; }
.frame-corners i:nth-child(1) { inset: 0 auto auto 0; border-width: 3px 0 0 3px; border-radius: 12px 0 0 0; }
.frame-corners i:nth-child(2) { inset: 0 0 auto auto; border-width: 3px 3px 0 0; border-radius: 0 12px 0 0; }
.frame-corners i:nth-child(3) { inset: auto auto 0 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 12px; }
.frame-corners i:nth-child(4) { inset: auto 0 0 auto; border-width: 0 3px 3px 0; border-radius: 0 0 12px 0; }
.scan-line { position: absolute; left: 15%; right: 15%; top: 15%; height: 2px; background: linear-gradient(90deg, transparent, #6f8cff, #fff, #6f8cff, transparent); box-shadow: 0 0 16px rgba(111,140,255,.9); animation: sweep 2.4s ease-in-out infinite; }
@keyframes sweep { 0% { top: 15%; opacity: .35; } 50% { top: 84%; opacity: 1; } 100% { top: 15%; opacity: .35; } }
.camera-hint { position: absolute; left: 50%; bottom: 15px; transform: translateX(-50%); padding: 7px 12px; border-radius: 999px; background: rgba(7,9,14,.76); color: #e8edf5; font-size: 11px; white-space: nowrap; backdrop-filter: blur(5px); }
.camera-loading { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; background: rgba(7,9,14,.78); color: #dbe3f0; font-size: 12px; }
.spinner { width: 30px; height: 30px; border: 2.5px solid rgba(255,255,255,.22); border-top-color: #6f8cff; border-radius: 50%; animation: spin .8s linear infinite; }
.scan-status { margin: 11px 1px 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.scanner-actions { display: flex; gap: 8px; margin-top: 11px; }
.secondary-button, .ghost-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px;
  border-radius: 8px; font-size: 12.5px; font-weight: 700;
}
.secondary-button { border: 1px solid var(--border-strong); background: var(--surface); color: var(--soft); }
.secondary-button:hover { border-color: var(--primary); color: var(--primary); }
.ghost-button { border: 1px solid transparent; background: transparent; color: var(--muted); }
.ghost-button:hover { background: var(--surface-3); color: var(--ink); }

/* Results */
.result-section { padding: 12px 0 56px; animation: rise .3s ease both; }
.result-sheet { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: clamp(22px, 4vw, 34px); border-bottom: 1px solid var(--border); background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 70%, var(--surface)), var(--surface) 58%); }
.result-student { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar { width: 66px; height: 66px; display: grid; place-items: center; flex-shrink: 0; border-radius: 16px; color: #fff; background: var(--primary); font-size: 21px; font-weight: 800; letter-spacing: -.03em; }
.result-student h2 { margin: 2px 0 3px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.04em; }
.result-student p { margin: 0; color: var(--muted); font-size: 13px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.result-list { display: flex; flex-direction: column; }
.result-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; padding: clamp(20px, 3vw, 28px) clamp(22px, 4vw, 34px); border-bottom: 1px solid var(--border); }
.result-entry:last-child { border-bottom: 0; }
.entry-exam { min-width: 0; }
.entry-exam h3 { margin: 0 0 6px; font-size: clamp(18px, 2.2vw, 23px); }
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: 11.5px; }
.entry-pill { padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 650; }
.entry-details { margin: 12px 0 0; color: var(--soft); font-size: 13px; white-space: pre-wrap; line-height: 1.6; }
.entry-grade { align-self: start; min-width: 120px; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--success) 28%, var(--border)); border-radius: 12px; background: var(--success-soft); text-align: center; }
.entry-grade span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.entry-grade strong { display: block; margin-top: 3px; color: var(--success); font-size: clamp(22px, 2.6vw, 30px); line-height: 1.1; letter-spacing: -.03em; word-break: break-word; }
.entry-published { margin: 12px 0 0; color: var(--muted); font-size: 11.5px; }
.result-foot { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 16px clamp(22px, 4vw, 34px); border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 11.5px; }

/* Help */
.help-section { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 0 64px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--border); }
.help-section article { padding: clamp(20px, 3vw, 28px); background: var(--surface); }
.help-number { display: inline-block; margin-bottom: 12px; color: var(--primary); font-family: Georgia, serif; font-size: 13px; font-weight: 700; }
.help-section h3 { margin: 0 0 6px; font-size: 16px; }
.help-section p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }

/* Footer */
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 22px; flex-wrap: wrap; padding: 28px clamp(18px, 4vw, 48px); border-top: 1px solid var(--border); background: var(--surface); }
.site-footer > div { display: flex; flex-direction: column; gap: 2px; }
.site-footer strong { font-size: 13px; }
.site-footer span { color: var(--muted); font-size: 11.5px; }
.footer-links { align-items: flex-end; text-align: right; }
.footer-links a { color: var(--primary); font-size: 12px; font-weight: 700; text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* Toast */
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-md); font-size: 12.5px; animation: rise .2s ease both; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast strong { display: block; margin-bottom: 2px; font-size: 12.5px; }
.toast span { color: var(--muted); font-size: 11.5px; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 46px; }
  .hero-copy { max-width: 720px; }
  .lookup-card { max-width: 620px; }
  .help-section { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .site-header { padding: 11px 16px; }
  .header-note, .ghost-link { display: none; }
  .brand-copy small { max-width: 180px; }
  main { width: calc(100% - 32px); }
  .hero h1 { font-size: clamp(38px, 12vw, 52px); }
  .input-row { flex-direction: column; }
  .primary-button { width: 100%; }
  .result-head { flex-direction: column; }
  .result-actions { width: 100%; justify-content: flex-start; }
  .result-entry { grid-template-columns: 1fr; }
  .entry-grade { min-width: 0; text-align: left; }
  .result-student { align-items: flex-start; }
  .avatar { width: 54px; height: 54px; border-radius: 13px; font-size: 18px; }
  .site-footer { align-items: flex-start; flex-direction: column; }
  .footer-links { align-items: flex-start; text-align: left; }
  .toast-region { right: 12px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  body { background: #fff; color: #111827; font-size: 12px; }
  .site-header, .site-footer, .hero, .help-section, .toast-region, .result-actions { display: none !important; }
  main { width: 100%; }
  .result-section { padding: 0; }
  .result-sheet { border: 1px solid #d1d5db; box-shadow: none; }
  .result-head { background: #fff; }
  .result-entry { break-inside: avoid; }
  .avatar { color: #111827; background: #e5e7eb; }
  .entry-grade { border-color: #d1d5db; background: #f9fafb; }
  .entry-grade strong { color: #111827; }
}
