/* =========================================================================
   Topik Master — "OMR sheet" design system
   Ink-navy text on cool paper, OMR-red printed rules, oval answer bubbles.
   ========================================================================= */

:root {
    /* Original Topik Master palette: bright slate canvas, indigo brand. */
    --canvas: #f8fafc;
    --paper: #ffffff;
    --paper-2: #f1f5f9;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --rule: #e2e8f0;
    --rule-strong: #cbd5e1;
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-tint: #eef2ff;
    --brand-line: #c7d2fe;
    /* "omr" tokens drive the answer-sheet accents; they follow the brand colour. */
    --omr: #4f46e5;
    --omr-ink: #4338ca;
    --omr-tint: #eef2ff;
    --omr-line: #c7d2fe;
    --bad: #dc2626;
    --bad-tint: #fee2e2;
    --bad-line: #fecaca;
    --go: #047857;
    --go-tint: #d1fae5;
    --warn: #b45309;
    --warn-tint: #fffbeb;
    --focus: #4f46e5;

    /* Type */
    --font-display: "Inter", "Noto Sans KR", system-ui, sans-serif;
    --font-body: "Inter", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-kr: "Noto Sans KR", "Inter", sans-serif;

    /* Spacing (4/8 scale) */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

    --radius: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --container: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink);
    background: linear-gradient(rgba(248, 250, 252, 0.92), rgba(248, 250, 252, 0.92)),
                url("https://images.unsplash.com/photo-1524178232363-1fb2b075b655?auto=format&fit=crop&w=1920&q=70") center / cover fixed no-repeat,
                var(--canvas);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
.kr { font-family: var(--font-kr); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.icon { flex-shrink: 0; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s4); }
@media (min-width: 768px) { .wrap { padding: 0 var(--s6); } }
main.page { flex: 1; padding: var(--s6) 0 var(--s8); }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 70px; gap: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; }
.tm-logo { display: inline-flex; align-items: center; gap: 10px; }
.tm-logo-mark { filter: drop-shadow(0 4px 8px rgba(79, 70, 229, 0.25)); }
.tm-logo-text { font-size: 20px; letter-spacing: -0.03em; color: var(--ink); white-space: nowrap; }
.tm-logo-text b { font-weight: 800; }
.tm-logo-text span { font-weight: 600; color: var(--brand); margin-left: 4px; }
@media (max-width: 420px) { .tm-logo-text { display: none; } }
.nav { display: flex; align-items: center; gap: var(--s2); }
.nav-user { color: var(--muted); font-size: 14px; margin-right: var(--s2); display: none; }
.nav-link.is-active { color: var(--brand); background: var(--brand-tint); }
@media (max-width: 640px) { .nav-link span { display: none; } .nav-link:not(:has(svg)) { display: none; } }
@media (min-width: 768px) { .nav-user { display: inline; } }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    min-height: 44px; padding: 0 var(--s4);
    border-radius: var(--radius); border: 1px solid transparent;
    font-weight: 600; font-size: 15px; line-height: 1; text-decoration: none; cursor: pointer;
    transition: background-color 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease);
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-ink { background: var(--brand); color: #fff; }
.btn-ink:hover { background: var(--brand-hover); }
.btn-omr { background: var(--brand); color: #fff; }
.btn-omr:hover { background: var(--brand-hover); }
.btn-line { background: var(--paper); border-color: var(--rule-strong); color: var(--ink); }
.btn-line:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font-size: 14px; }
.btn-block { width: 100%; }
@media (pointer: coarse) { .btn-sm { min-height: 44px; } }

/* ---------- Type ---------- */
.display {
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(40px, 7vw, 72px); line-height: 1.05; letter-spacing: -0.035em;
}
.h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 4.5vw, 48px); line-height: 1.1; letter-spacing: -0.03em; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; letter-spacing: -0.02em; }
.h3 { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.3; letter-spacing: -0.01em; }
.lead { font-size: 18px; color: var(--ink-2); max-width: 60ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Alerts ---------- */
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid; font-size: 15px; }
.notice .icon { margin-top: 3px; }
.notice-error { background: var(--bad-tint); border-color: var(--bad-line); color: var(--bad); }
.notice-ok { background: var(--go-tint); border-color: #b8dfca; color: var(--go); }
.notice-warn { background: var(--warn-tint); border-color: #f0d7a0; color: var(--warn); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input {
    min-height: 48px; width: 100%; padding: 0 var(--s4);
    background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius);
    transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.input:hover { border-color: var(--ink-2); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- Panel ---------- */
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

/* ---------- OMR bubble (signature element) ---------- */
.bubble {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    border: 1.5px solid var(--omr);
    color: var(--omr-ink); font-size: 14px; font-weight: 600;
    background: var(--paper);
    transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease), transform 150ms var(--ease);
    user-select: none;
}
.bubble.is-filled { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Footer ---------- */
.footer { background: #0f172a; color: #94a3b8; }
.footer .wrap { color: #94a3b8 !important; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); justify-content: space-between; padding-top: var(--s5); padding-bottom: var(--s5); font-size: 14px; color: var(--muted); }

/* ---------- Dialog ---------- */
.dialog { margin: auto; border: 0; padding: 0; background: transparent; max-width: min(720px, calc(100vw - 32px)); width: 100%; }
.dialog::backdrop { background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); }
.dialog-card { background: var(--paper); border-radius: var(--radius-lg); border: 1px solid var(--rule); box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.25); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--rule); }
.dialog-body { padding: var(--s5); overflow-y: auto; line-height: 1.7; }
.dialog-foot { padding: var(--s4) var(--s5); border-top: 1px solid var(--rule); display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; }
.dialog[open] .dialog-card { animation: dialog-in 220ms var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius); border: 0; background: transparent; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }

/* ---------- Skeleton / spinner ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* =========================================================================
   Auth screens: copy + form on the left, the OMR card on the right
   ========================================================================= */
.auth { display: grid; gap: var(--s6); align-items: start; }
@media (min-width: 960px) {
    .auth { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: var(--s8); align-items: center; padding-top: var(--s5); }
}
.auth-copy { display: flex; flex-direction: column; gap: var(--s4); max-width: 520px; }
.auth-copy .display { margin-bottom: var(--s1); }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); margin-top: var(--s4); }
.auth-form .row-2 { display: grid; gap: var(--s4); }
@media (min-width: 600px) { .auth-form .row-2 { grid-template-columns: 1fr 1fr; } }
.auth-switch { font-size: 15px; color: var(--muted); }
.auth-switch a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.auth-facts { list-style: none; padding: 0; display: grid; gap: var(--s2); font-size: 15px; color: var(--ink-2); }
.auth-facts li { display: flex; gap: var(--s2); align-items: baseline; }
.auth-facts li::before { content: ""; width: 10px; height: 13px; border-radius: 50%; border: 1.5px solid var(--omr); flex-shrink: 0; transform: translateY(1px); }

.omr-card {
    background: var(--paper);
    border: 1.5px solid var(--omr-line);
    border-radius: var(--radius-lg);
    padding: var(--s5);
    transform: rotate(-1.5deg);
}
.omr-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--omr-ink); font-weight: 700; padding-bottom: var(--s3); border-bottom: 1.5px solid var(--omr-line); margin-bottom: var(--s3); }
.omr-head .kr { font-size: 20px; letter-spacing: 0.3em; }
.omr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.omr-col { list-style: none; padding: 0; display: grid; }
.omr-col li { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--omr-tint); }
.omr-col li:last-child { border-bottom: 0; }
.omr-q { width: 24px; font-size: 13px; font-weight: 600; color: var(--omr-ink); text-align: right; margin-right: 4px; }
.omr-card .bubble { width: 26px; height: 26px; font-size: 12px; }
.omr-card .bubble.is-filled { animation: ink-in 420ms var(--ease) both; animation-delay: calc(var(--i) * 70ms + 200ms); }
@keyframes ink-in { from { background: var(--paper); color: var(--omr-ink); border-color: var(--omr); transform: scale(0.85); } }
@media (max-width: 959px) {
    .auth-visual { order: -1; }
    .omr-card { transform: none; padding: var(--s4); }
    .omr-col li:nth-child(n+3) { display: none; }
}
