/* QEDMint — simple, modern, responsive. Light/dark follow the system setting. */
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --text: #0e1220;
  --muted: #667085;
  --line: #e4e7ef;
  --accent: #10b981;          /* mint */
  --accent-2: #6366f1;        /* indigo */
  --accent-ink: #ffffff;
  --bad: #e5484d;
  --gold: #d99a00;
  --glow: rgba(99, 102, 241, 0.16);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 20px;
  --radius-sm: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0c14;
    --surface: #11141f;
    --surface-2: #171b29;
    --text: #edf0f7;
    --muted: #8a92ab;
    --line: #232838;
    --accent: #34d399;
    --accent-2: #818cf8;
    --accent-ink: #06120d;
    --bad: #ff6b6b;
    --gold: #fbbf24;
    --glow: rgba(129, 140, 248, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(60rem 30rem at 50% -10rem, var(--glow), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, Inter, system-ui, -apple-system, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  line-height: 1.55;
}
#app { max-width: 620px; margin: 0 auto; padding: 0 20px 64px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 -20px 8px; padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.top-right { display: flex; gap: 8px; align-items: center; }
.logo { border: 0; background: none; padding: 0; color: var(--text); font-size: 18px; font-weight: 800; letter-spacing: -0.03em; cursor: pointer; }
.logo span { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.me, .stars {
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); white-space: nowrap;
}
.me { color: var(--accent-2); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.stars { color: var(--gold); }

/* ---------- buttons ---------- */
button {
  font: inherit; cursor: pointer; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 18px; min-height: 46px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line)); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent-2) 45%, transparent); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--text); color: var(--bg); border: 0; font-weight: 700;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--text) 18%, transparent);
}
button.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 28px color-mix(in srgb, var(--text) 24%, transparent); }
button.ghost { background: var(--surface); }
button.small { padding: 5px 11px; min-height: 30px; font-size: 12.5px; border-radius: 999px; font-weight: 600; }
button.link {
  border: 0; background: none; min-height: 0; padding: 6px 2px; color: var(--muted); font-weight: 500;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 40%, transparent); text-underline-offset: 4px;
}
button.link:hover:not(:disabled) { color: var(--text); }

/* ---------- home ---------- */
.hero { text-align: center; margin: 72px 0 32px; }
.eyebrow {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.hero h1 {
  font-size: clamp(44px, 11vw, 68px); line-height: 1; margin: 20px 0 12px; letter-spacing: -0.05em; font-weight: 800;
  background: linear-gradient(180deg, var(--text) 30%, color-mix(in srgb, var(--text) 55%, var(--accent-2)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); font-size: 17px; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.stack .primary { min-height: 54px; font-size: 16px; }
.band-label { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; margin: 28px 0 0; }
.pills {
  display: flex; justify-content: center; gap: 4px; margin: 10px auto 16px; padding: 4px; width: fit-content;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.pill { min-height: 36px; padding: 6px 16px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; }
.pill.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.links { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; }
.sphinx-line {
  text-align: center; color: var(--muted); font-size: 13px; margin: 40px auto 0; padding: 12px 16px;
  border: 1px dashed var(--line); border-radius: var(--radius-sm); max-width: 420px;
}
.note { color: var(--muted); font-size: 13px; text-align: center; }
.guest-note {
  margin: 28px auto 0; max-width: 420px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--muted); font-size: 13px; text-align: center; line-height: 1.6;
}
.guest-note b { color: var(--text); font-weight: 600; }
.account { margin-top: 20px; display: flex; flex-direction: column; align-items: center; }
.account .note { margin: 8px 0 0; }
.center { text-align: center; font-size: 22px; letter-spacing: -0.03em; margin: 48px 0 18px; }
.band-btn { display: flex; justify-content: space-between; align-items: center; min-height: 58px; padding: 14px 18px; border-radius: 16px; font-weight: 600; }
.band-btn small { color: var(--muted); font-weight: 500; }

/* ---------- cards & goal ---------- */
.card, .problem {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin: 16px 0;
}
.card h2 { margin-top: 0; letter-spacing: -0.03em; }
.goal { margin: 0 0 18px; font-size: 13px; }
main > .goal { margin: 8px 0 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.goal-text { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; color: var(--muted); margin-bottom: 8px; }
.goal-text b { color: var(--text); font-weight: 600; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.5s cubic-bezier(.2, .8, .2, 1); }
.clear {
  margin-top: 14px; padding: 16px; text-align: center; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent-2) 14%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent);
  animation: pop 0.35s cubic-bezier(.2, .8, .2, 1);
}
.clear b { font-size: 18px; }
.clear p { margin: 6px 0 0; }

/* ---------- problem ---------- */
.progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 12px 0 0; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.4s ease; }
.problem .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 18px; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); }
.timer .goal-time { color: var(--gold); }
.timer .over { color: var(--muted); text-decoration: line-through; }
.question { font-size: 20px; line-height: 1.75; margin-bottom: 22px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.m { font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', 'Times New Roman', serif; font-size: 1.08em; letter-spacing: 0; }
.question .m { display: inline-block; max-width: 100%; overflow-x: auto; vertical-align: middle; padding: 2px 8px; border-radius: 8px; background: var(--surface-2); }
.answer { display: flex; gap: 8px; }
.answer input {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 12px 16px; min-height: 52px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.answer input:focus { outline: none; border-color: var(--accent-2); background: var(--surface); }
.answer .primary { min-width: 88px; min-height: 52px; }
.feedback { min-height: 22px; margin: 12px 0 0; font-weight: 600; }
.feedback.ok { color: var(--accent); }
.feedback.bad { color: var(--bad); }
.hint {
  color: var(--text); background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 10px 0; line-height: 1.6; font-size: 15px; animation: rise 0.25s ease;
}
.solution { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; line-height: 1.7; }
.solution p { margin: 6px 0; }
.solution .ans { color: var(--accent); font-weight: 700; }
.actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.actions .primary { margin-left: auto; }
.earned { color: var(--gold); font-weight: 800; }
.earned small { font-weight: 600; margin-left: 4px; }

/* ---------- result / locked ---------- */
.result, .locked { text-align: center; }
.result .label { color: var(--muted); margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.result h2 { font-size: 28px; line-height: 1.3; margin: 12px 0 20px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; }
.stats b { display: block; font-size: 28px; letter-spacing: -0.03em; }
.stats small { color: var(--muted); font-weight: 600; }

/* ---------- matrices ---------- */
.mat {
  display: inline-flex; flex-direction: column; vertical-align: middle; margin: 4px; padding: 4px 10px;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor; border-radius: 8px;
  font-family: 'STIX Two Math', 'Cambria Math', 'Times New Roman', serif;
}
.mat span { display: flex; gap: 14px; justify-content: space-between; }
.mat i { font-style: normal; min-width: 1.8em; text-align: center; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- mobile ---------- */
@media (max-width: 520px) {
  #app { padding: 0 14px 48px; }
  .top { margin: 0 -14px 6px; padding: 12px 14px; }
  .hero { margin: 48px 0 24px; }
  .card, .problem { padding: 18px; border-radius: 18px; }
  .question { font-size: 18px; }
  .problem .meta { font-size: 12px; }
  .answer input { font-size: 17px; }            /* >=16px avoids iOS zoom */
  .answer .primary { min-width: 72px; padding: 12px 14px; }
  .actions { gap: 12px; }
  .actions .primary { width: 100%; margin-left: 0; }
  .mat span { gap: 8px; }
  .mat i { min-width: 1.4em; }
  .me { max-width: 38vw; }
  .goal-text { flex-direction: column; }
}
