:root {
  --bg: #fafaf7;
  --bg-alt: #f1efe9;
  --ink: #1a1a1a;
  --ink-soft: #3f3f3f;
  --muted: #7a7a72;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --line: #e5e3dc;
  --line-soft: #efede6;
  --radius: 14px;
  --maxw: 880px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

a:hover { border-bottom-color: var(--accent); }

/* ============ NAV ============ */
.nav {
  position: sticky;
  top: 0;
  background: rgba(250, 250, 247, 0.88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--ink);
  border: none;
  user-select: none;
}

.nav-links {
  display: flex;
  gap: 22px;
  font-size: 14px;
  align-items: center;
}

.nav-links a {
  color: var(--ink-soft);
  border: none;
}

.nav-links a:hover { color: var(--accent); }

.nav-links a.active {
  color: var(--ink);
  font-weight: 600;
}

#nav-writing {
  background: var(--ink);
  color: var(--bg) !important;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 13px;
}

#nav-writing:hover { background: var(--accent); }

/* ============ HERO ============ */
.hero {
  padding: 96px 24px 64px;
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  max-width: var(--maxw);
  margin: 0 auto;
}

.eyebrow, .mono-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 500;
}

.mono-label a { color: var(--muted); border: none; }
.mono-label a:hover { color: var(--accent); }

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(46px, 8vw, 84px);
  font-weight: 600;
  line-height: 1.05;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
}

.intro, .tagline {
  font-family: var(--font-serif);
  font-size: clamp(20px, 2.4vw, 25px);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 0 0 32px;
  font-weight: 400;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-tags span {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}

/* ============ SECTIONS (home) ============ */
.section {
  padding: 72px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.section.split { padding-top: 56px; padding-bottom: 24px; }

.split-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

.split-item p { margin: 0; font-size: 17px; color: var(--ink-soft); }
.split-item .mono-label { margin-bottom: 8px; }

.section-head { margin-bottom: 28px; }

.section-head h2 {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.section-lead {
  color: var(--muted);
  margin: 0;
  font-size: 15.5px;
}

/* ============ TOUR CARDS (home) ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.tour-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tour-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tour-card h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
}

.tour-card p {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: 15px;
}

.mono-hint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.4px;
  margin: 0 !important;
  text-transform: uppercase;
}

/* ============ SUB-PAGES ============ */
.page-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.page-head { margin-bottom: 48px; }

.page-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 600;
  line-height: 1.1;
  margin: 12px 0 16px;
  letter-spacing: -0.02em;
}

.page-lead {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--ink-soft);
  margin: 0;
  max-width: 640px;
  line-height: 1.5;
}

.page-section {
  margin-bottom: 56px;
}

.page-section > h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
}

.page-section > h2.mono-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 14px;
  font-weight: 500;
}

.page-section > p {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0 0 14px;
  line-height: 1.65;
}

.muted { color: var(--muted) !important; font-size: 15px !important; font-style: italic; }

/* ============ LINE LIST (math achievements) ============ */
.line-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.line-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15.5px;
  color: var(--ink-soft);
}

.line-list li:last-child { border-bottom: none; }

/* ============ PROJECTS ============ */
.project {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 24px;
  margin-bottom: 36px;
}

.project h3 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.project p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 16px;
}

.project-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}

/* ============ BEYOND MATH CARDS ============ */
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.card p {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
}

/* ============ RECOMMENDATIONS ============ */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.rec {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.rec-cat {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 500;
}

.rec-stars {
  color: #d97706;
  font-size: 14px;
  letter-spacing: 1.5px;
  white-space: nowrap;
}

.rec-title, .rec-title-link {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  margin: 2px 0 0;
  line-height: 1.25;
  color: var(--ink);
  border: none;
}

.rec-title-link:hover { color: var(--accent); }

.rec-note {
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ============ SESSIONS (application form) ============ */
.rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules-list li {
  padding: 10px 0 10px 28px;
  position: relative;
  font-size: 16px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.rules-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-family: var(--font-mono);
}

.rules-list li:last-child { border-bottom: none; }

.apply-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: none;
  padding: 0;
  margin: 0;
}

.form-field label,
.form-field legend {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--muted);
  font-weight: 500;
  padding: 0;
}

.form-field .muted { font-style: normal; font-size: 11.5px !important; }

.form-field input[type="email"],
.form-field input[type="text"],
.form-field textarea {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font-sans);
  background: var(--bg);
  width: 100%;
}

.form-field textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-field input:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.radio-stack { display: flex; flex-direction: column; gap: 4px; }

.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--ink-soft);
  text-transform: none;
  font-family: var(--font-sans);
  letter-spacing: 0;
  font-weight: 400;
}

.radio-row:hover { background: var(--bg-alt); color: var(--ink); }

.radio-row input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  display: inline-block;
  text-align: center;
}

.btn:hover { background: #1d4ed8; }

.btn.big { padding: 14px 28px; font-size: 15px; }

.btn.secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.btn.secondary:hover { background: var(--bg-alt); color: var(--ink); }

.btn.danger {
  background: transparent;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn.danger:hover { background: #fee2e2; }

.form-hint { font-size: 13px; color: #b91c1c; min-height: 18px; margin: 0; }

.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 28px;
}

.success h2 {
  font-family: var(--font-serif);
  margin: 0 0 8px;
  font-size: 24px;
  color: #065f46;
}

.success p { margin: 0 0 14px; color: #047857; }

/* ============ FOOTER ============ */
footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

footer a { color: var(--muted); }

/* ============ RESPONSIVE ============ */
@media (max-width: 700px) {
  .split-inner { grid-template-columns: 1fr; gap: 24px; }
  .nav-links { gap: 14px; font-size: 13px; }
  .nav { padding: 12px 18px; }
  .hero { padding: 64px 20px 48px; }
  .page-main { padding: 40px 20px 64px; }
}

/* ============ ADMIN ============ */
.admin-body {
  background: var(--bg-alt);
  min-height: 100vh;
}

.gate {
  max-width: 380px;
  margin: 14vh auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
}

.gate h2 { margin-top: 0; font-family: var(--font-serif); }

.gate input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font-sans);
  margin: 12px 0 14px;
}

.err {
  color: #b91c1c;
  font-size: 14px;
  min-height: 18px;
  margin-top: 8px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

.admin-side {
  position: sticky;
  top: 24px;
  align-self: start;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.admin-side .side-head {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  color: var(--ink);
}

.admin-side a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink-soft);
  border: none;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.admin-side a:hover { background: var(--bg-alt); color: var(--ink); }
.admin-side a.active { background: var(--ink); color: var(--bg); }

.admin-side .side-foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-main { min-width: 0; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 20px;
  position: sticky;
  top: 24px;
  z-index: 4;
}

.admin-toolbar .spacer { flex: 1; }
.admin-toolbar .status { font-size: 13px; color: var(--muted); }
.admin-toolbar .status.saved { color: #15803d; }

.editor-section {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
  scroll-margin-top: 90px;
}

.editor-section h3 {
  font-family: var(--font-serif);
  margin: 0 0 16px;
  font-size: 22px;
}

.editor-section .editor-hint {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 14px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > label:first-child {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--bg);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row .toggle-label {
  font-size: 15px;
  font-weight: 500;
}

.toggle-row .toggle-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch.on { background: var(--accent); }
.toggle-switch.on::after { transform: translateX(20px); }

.repeat-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-alt);
}

.repeat-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.add-row { display: flex; gap: 8px; margin-top: 8px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.applicant-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg);
  font-size: 14px;
}

.applicant-row .meta { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.applicant-row .topic { color: var(--ink-soft); margin-top: 6px; white-space: pre-wrap; }

@media (max-width: 800px) {
  .admin-layout { grid-template-columns: 1fr; padding: 16px; }
  .admin-side { position: static; }
}
