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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #dbeafe;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── NAV ── */
nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.nav-logo {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--blue);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover { background: #f1f5f9; color: var(--text); }
.nav-links a.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

@media (max-width: 600px) {
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 8px; font-size: 0.8rem; }
}

/* ── HEADER ── */
header {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #3b82f6 100%);
  color: white;
  padding: 44px 0 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 50%, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

header h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.tagline {
  margin-top: 10px;
  font-size: 1.05rem;
  opacity: 0.85;
}

/* ── LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  padding-top: 28px;
  padding-bottom: 48px;
  align-items: start;
}

.calc-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.07), 0 8px 24px rgba(0,0,0,0.06);
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--blue);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── FORM ── */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="number"] {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 1rem;
  color: var(--text);
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

input[type="number"]:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.13);
}

button#calcBtn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: 9px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  transition: box-shadow 0.15s, transform 0.1s, background 0.15s;
}

button#calcBtn:hover {
  box-shadow: 0 6px 20px rgba(37,99,235,0.45);
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

button#calcBtn:active { transform: scale(0.98); box-shadow: none; }

/* ── RESULT ── */
.result {
  margin-top: 20px;
  padding: 24px 20px;
  border-radius: 12px;
  text-align: center;
  font-size: 1rem;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result.good  { background: #f0fdf4; border: 1.5px solid #86efac; color: var(--green); }
.result.warn  { background: #fff7ed; border: 1.5px solid #fdba74; color: var(--orange); }
.result.hard  { background: #fef2f2; border: 1.5px solid #fca5a5; color: var(--red); }
.result.error { background: #fef2f2; border: 1.5px solid #fca5a5; color: var(--red); }

.result .score {
  font-size: 3.5rem;
  font-weight: 900;
  display: block;
  line-height: 1.05;
  letter-spacing: -1px;
}

.result .label {
  font-size: 0.95rem;
  margin-top: 6px;
  opacity: 0.85;
  display: block;
}

.intro-blurb { border-left: 4px solid var(--blue); background: var(--blue-light); }
.intro-blurb p { font-size: 0.95rem; color: #1e3a8a; line-height: 1.7; }
.intro-blurb p strong { color: var(--blue-dark); }

.hidden { display: none !important; }

/* ── FORMULA ── */
.formula {
  background: #f1f5f9;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  margin: 12px 0;
  color: var(--text);
}

.explainer p { font-size: 0.93rem; color: var(--muted); margin-bottom: 6px; }
.explainer p:last-child { margin-bottom: 0; }

/* ── GRADE TABLE ── */
.grade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.grade-table th {
  background: #f1f5f9;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.grade-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.grade-table tr:last-child td { border-bottom: none; }
.grade-table tr:hover td { background: #f8fafc; }

/* ── FAQ ── */
.faq details {
  border-bottom: 1px solid var(--border);
  padding: 13px 0;
}

.faq details:last-child { border-bottom: none; }

.faq summary {
  font-weight: 600;
  cursor: pointer;
  font-size: 0.93rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq summary::after {
  content: '+';
  font-size: 1.3rem;
  color: var(--blue);
  flex-shrink: 0;
  margin-left: 12px;
  line-height: 1;
}

.faq details[open] summary::after { content: '−'; }

.faq details p {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ── ADS ── */
.ad-banner {
  width: 100%;
  text-align: center;
}

.ad-placeholder {
  background: #e8edf2;
  color: #94a3b8;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.ad-top .ad-placeholder    { height: 90px; }
.ad-bottom .ad-placeholder { height: 90px; }
.ad-inline .ad-placeholder { height: 100px; margin-top: 20px; }
.ad-sidebar .ad-placeholder { height: 250px; }

.ad-top    { padding: 8px 0; background: #fff; border-bottom: 1px solid var(--border); }
.ad-bottom { padding: 8px 0; background: #fff; border-top: 1px solid var(--border); }

.sticky-ad { position: sticky; top: 20px; }

/* ── SIDEBAR ── */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

/* ── MULTI-ROW CALCULATORS ── */
.course-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

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

.course-inputs {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr;
  gap: 10px;
  flex: 1;
}

.course-inputs .form-group { margin-bottom: 0; }

.remove-btn {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 0;
}

.remove-btn:hover { background: #fca5a5; }

.add-course-btn {
  width: 100%;
  padding: 10px;
  background: #f1f5f9;
  color: var(--blue);
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.15s;
}

.add-course-btn:hover { background: var(--blue-light); }

@media (max-width: 600px) {
  .course-inputs { grid-template-columns: 1fr 1fr; }
  .course-inputs .form-group:first-child { grid-column: 1 / -1; }
}

/* ── PROSE (about/privacy pages) ── */
.prose h2 {
  margin-top: 28px;
  margin-bottom: 10px;
}

.prose h2:first-child { margin-top: 0; }

.prose p, .prose li {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.75;
  margin-bottom: 10px;
}

.prose ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.prose a { color: var(--blue); text-decoration: underline; }

/* ── CONTACT FORM ── */
.contact-form textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #f8fafc;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.contact-form textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.13);
}

.contact-form select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: #f8fafc;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* ── FOOTER ── */
footer {
  background: #0f172a;
  color: #64748b;
  text-align: center;
  padding: 22px 0;
  font-size: 0.83rem;
}

footer a { color: #94a3b8; text-decoration: none; }
footer a:hover { color: #fff; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .card { padding: 20px; }
  .result .score { font-size: 2.8rem; }
}
