*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

:root {
  --navy: #0d1f4e;
  --blue: #1a3a8f;
  --accent: #e63946;
  --gold: #f4a623;
  --light: #f4f6fb;
  --white: #ffffff;
  --text: #1a1a2e;
  --muted: #5a6585;
  --border: #dde3f0;
  --sidebar-w: 260px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; color: var(--text); background: var(--light); }

/* NAV */
nav {
  background: var(--navy); padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; position: sticky; top: 0; z-index: 100;
}
.logo { color: #fff; font-size: 1.3rem; font-weight: 700; text-decoration: none; }
.logo span { color: var(--gold); }
.back-link { color: #b0bdd8; text-decoration: none; font-size: 0.9rem; }
.back-link:hover { color: #fff; }

/* LAYOUT */
.page { display: flex; min-height: calc(100vh - 60px); }

/* SIDEBAR */
aside {
  width: var(--sidebar-w); background: var(--white);
  border-right: 1px solid var(--border); padding: 2rem 0;
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-subject {
  padding: 0 1.5rem 1rem; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
}
.sidebar-section { margin-bottom: 0.25rem; }
.sidebar-section-title {
  display: block; padding: 0.5rem 1.5rem; font-size: 0.8rem;
  font-weight: 700; color: var(--navy); text-transform: uppercase;
  letter-spacing: 0.5px; cursor: pointer;
}
.sidebar-link {
  display: block; padding: 0.45rem 1.5rem 0.45rem 2rem;
  text-decoration: none; color: var(--muted); font-size: 0.9rem;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.sidebar-link:hover { color: var(--blue); background: var(--light); border-left-color: var(--blue); }
.sidebar-link.active { color: var(--blue); background: #eef2ff; border-left-color: var(--blue); font-weight: 600; }

/* MAIN */
main { flex: 1; padding: 2.5rem; max-width: 860px; }

.subject-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  color: #fff; border-radius: 14px; padding: 2.5rem; margin-bottom: 2rem;
}
.subject-hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.subject-hero p { color: #b0bdd8; font-size: 1rem; }
.exam-boards { display: flex; gap: 0.5rem; margin-top: 1.2rem; flex-wrap: wrap; }
.eb-tag {
  background: rgba(255,255,255,0.15); color: #fff;
  padding: 0.25rem 0.75rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
}

/* TOPIC CARDS */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.topic-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.4rem; text-decoration: none;
  color: var(--text); transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
}
.topic-card:hover { box-shadow: 0 6px 20px rgba(26,58,143,0.1); transform: translateY(-2px); border-color: var(--blue); }
.topic-card-icon { font-size: 1.6rem; margin-bottom: 0.6rem; }
.topic-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.topic-card p { font-size: 0.82rem; color: var(--muted); }

/* CONTENT */
.content-block { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; margin-bottom: 1.5rem; }
.content-block h2 { font-size: 1.3rem; font-weight: 800; color: var(--navy); margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--light); }
.content-block h3 { font-size: 1rem; font-weight: 700; color: var(--blue); margin: 1.2rem 0 0.5rem; }
.content-block p { font-size: 0.92rem; color: #333; line-height: 1.7; margin-bottom: 0.8rem; }
.content-block ul { padding-left: 1.4rem; margin-bottom: 0.8rem; }
.content-block li { font-size: 0.92rem; line-height: 1.7; margin-bottom: 0.3rem; color: #333; }

.formula-box {
  background: #eef2ff; border: 1px solid #c7d2fe;
  border-radius: 8px; padding: 1rem 1.2rem; margin: 0.8rem 0;
  font-family: 'Courier New', monospace; font-size: 0.92rem; color: var(--navy);
}
.formula-box strong { display: block; margin-bottom: 0.3rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

.tip-box {
  background: #fffbeb; border-left: 4px solid var(--gold);
  border-radius: 0 8px 8px 0; padding: 1rem 1.2rem; margin: 1rem 0;
}
.tip-box strong { color: #92400e; font-size: 0.85rem; }
.tip-box p { margin: 0; font-size: 0.88rem; color: #78350f; }

.key-fact {
  background: #f0fdf4; border-left: 4px solid #22c55e;
  border-radius: 0 8px 8px 0; padding: 1rem 1.2rem; margin: 1rem 0;
}
.key-fact p { margin: 0; font-size: 0.9rem; color: #14532d; }

/* HAMBURGER */
.hamburger {
  display: none; background: none; border: none; color: #b0bdd8;
  font-size: 1.4rem; cursor: pointer; padding: 0.2rem 0.4rem; line-height: 1;
}

/* SIDEBAR TOGGLE (mobile) */
.sidebar-toggle-btn {
  display: none; margin: 1rem 1.2rem 0;
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 0.55rem 1.1rem; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; width: calc(100% - 2.4rem);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links { display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: var(--navy); flex-direction: column; padding: 1rem 1.5rem 1.5rem;
    gap: 0.8rem; z-index: 200; }
  .nav-links.nav-open { display: flex; }
  .nav-links li a { font-size: 1rem; }
  aside { display: none; position: fixed; top: 60px; left: 0; bottom: 0;
    z-index: 150; box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    width: min(280px, 85vw); overflow-y: auto; }
  aside.open { display: block; }
  .sidebar-toggle-btn { display: block; }
  main { padding: 1.2rem; }
  nav { position: relative; }
}
