:root {
  --bg: #f6f7f9; --panel: #ffffff; --rail: #eef0f4;
  --text: #1a2233; --muted: #5b6577; --border: #d9dee7;
  --accent: #2f6fed; --accent-soft: #e3ecfd;
  --ok: #1e8e5a; --warn: #b07a1a; --bad: #c0392b;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08);
}
[data-theme="dark"] {
  --bg: #10141c; --panel: #171c26; --rail: #131824;
  --text: #e8ecf4; --muted: #97a1b4; --border: #2a3244;
  --accent: #5b8df6; --accent-soft: #1d2a45;
  --ok: #3dc98a; --warn: #e0a53f; --bad: #e26a5a;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
h1 { font-size: 1.5rem; margin: .2rem 0 .4rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
code { background: var(--rail); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
pre { background: var(--rail); padding: .8em; border-radius: 8px; overflow-x: auto; }

.logo { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.logo span { color: var(--accent); }

/* ---- email gate ---- */
.gate {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; background: var(--bg); z-index: 10;
}
.gate-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 2.2rem; width: min(400px, 90vw); box-shadow: var(--shadow); text-align: center;
}
.gate-sub { color: var(--muted); margin: .4rem 0 1.4rem; }
.gate-card form { display: flex; gap: .5rem; }
.gate-card input {
  flex: 1; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: .95rem;
}
.gate-card button {
  padding: .6rem 1.1rem; border: 0; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer;
}
.gate-card button:disabled { opacity: .6; cursor: wait; }
.gate-error { color: var(--bad); margin: .8rem 0 0; font-size: .9rem; }
.gate-note { color: var(--muted); font-size: .8rem; margin: 1.2rem 0 0; }

/* ---- layout ---- */
.app { display: flex; min-height: 100vh; }
.rail {
  width: 290px; flex-shrink: 0; background: var(--rail);
  border-right: 1px solid var(--border); padding: 1rem;
  overflow-y: auto; height: 100vh; position: sticky; top: 0;
}
.rail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
#theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 1rem; cursor: pointer; padding: .15rem .5rem;
}
.course h4 {
  margin: 1rem 0 .3rem; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); cursor: pointer;
}
.course ul { list-style: none; margin: 0; padding: 0; }
.course li a {
  display: block; padding: .35rem .6rem; border-radius: 7px; color: var(--text);
  text-decoration: none; font-size: .9rem;
}
.course li a:hover { background: var(--accent-soft); }
.course li a.active { background: var(--accent); color: #fff; }

.main { flex: 1; padding: 2rem 2.5rem; max-width: 900px; }
.welcome { margin-top: 15vh; text-align: center; color: var(--muted); }
.welcome h1 { color: var(--text); }
.crumb { color: var(--muted); font-size: .85rem; margin: 0; }
.goal { color: var(--muted); font-style: italic; margin-top: 0; }
.instructions {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.2rem 1.5rem; box-shadow: var(--shadow);
}

/* ---- submission ---- */
.submit-zone { margin-top: 1.5rem; }
.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 2rem;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone p { margin: .2rem 0; }
.hint { color: var(--muted); font-size: .85rem; }

.progress { display: flex; align-items: center; gap: .8rem; padding: 1.2rem 0; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result {
  margin-top: 1rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.2rem 1.5rem; box-shadow: var(--shadow);
}
.score-row { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.score-badge {
  font-size: 1.6rem; font-weight: 800; width: 64px; height: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff;
}
.criteria { list-style: none; padding: 0; margin: .8rem 0 0; }
.criteria li {
  display: flex; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--border);
  font-size: .92rem; align-items: baseline;
}
.status-pill {
  flex-shrink: 0; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  padding: .1rem .5rem; border-radius: 999px; color: #fff; white-space: nowrap;
}
.status-met { background: var(--ok); }
.status-partially { background: var(--warn); }
.status-not { background: var(--bad); }
.crit-note { color: var(--muted); }
.result .error-text { color: var(--bad); }
.retry-btn {
  margin-top: .6rem; padding: .45rem .9rem; border: 1px solid var(--border);
  border-radius: 8px; background: none; color: var(--text); cursor: pointer;
}

.history { margin-top: 1.5rem; color: var(--muted); }
.history ul { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: .2rem 0; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; }
  .main { padding: 1.2rem; }
}
