:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef4fb;
  --text: #172033;
  --muted: #5f6b7a;
  --primary: #1f6feb;
  --primary-dark: #174ea6;
  --accent: #13a389;
  --border: #d8e0ea;
  --shadow: 0 18px 45px rgba(25, 43, 68, 0.12);
  --radius: 22px;
}

[data-theme="dark"] {
  --bg: #0e1422;
  --surface: #151d2e;
  --surface-2: #101827;
  --text: #e9eef8;
  --muted: #a8b3c4;
  --primary: #6ea8fe;
  --primary-dark: #9ec5fe;
  --accent: #4dd4bc;
  --border: #2a3549;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
}

.site-header {
  padding: 76px 0 56px;
  background:
    radial-gradient(circle at 18% 20%, rgba(31, 111, 235, 0.22), transparent 32%),
    radial-gradient(circle at 85% 12%, rgba(19, 163, 137, 0.18), transparent 28%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
  border-bottom: 1px solid var(--border);
}

.header-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 34px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 {
  line-height: 1.2;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  letter-spacing: -0.05em;
}

.lead {
  max-width: 720px;
  margin: 22px 0 0;
  font-size: 1.14rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 800;
  background: var(--surface);
  color: var(--text);
  transition: transform 0.18s ease, background 0.18s ease, border 0.18s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn.ghost {
  background: transparent;
}

.hero-card, .module-card, .quiz-box, .case-card, .notice, .term-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
}

.hero-card h2 {
  margin-top: 0;
}

.hero-card ul {
  padding-left: 20px;
  color: var(--muted);
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface), transparent 6%);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 22px;
  overflow-x: auto;
}

.nav-inner a {
  white-space: nowrap;
  font-weight: 800;
  color: var(--muted);
}

.nav-inner a:hover {
  color: var(--primary);
}

.theme-toggle {
  margin-left: auto;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.section {
  padding: 72px 0;
}

.section.alt {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-heading {
  margin-bottom: 30px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.04em;
}

.section-heading p:not(.eyebrow) {
  max-width: 760px;
  color: var(--muted);
}

.module-grid, .case-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.module-card, .case-card {
  padding: 26px;
}

.module-card .tag {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

.module-card p, .case-summary {
  color: var(--muted);
}

.module-card ul {
  padding-left: 18px;
}

.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.search-box input {
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.term-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.term-card {
  padding: 18px;
}

.term-card h3 {
  margin: 0 0 6px;
}

.term-card .meta {
  color: var(--primary);
  font-weight: 900;
}

.term-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.flashcard-wrap {
  display: grid;
  place-items: center;
}

.flashcard {
  width: min(620px, 100%);
  min-height: 300px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  cursor: pointer;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  backface-visibility: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flashcard-face.back {
  transform: rotateY(180deg);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary), transparent 85%), var(--surface));
}

.small-label {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.12em;
}

.card-controls {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.quiz-box {
  padding: 28px;
}

.quiz-status {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 900;
}

.choices {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.choice {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}

.choice.correct {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), transparent 84%);
}

.choice.wrong {
  border-color: #d14;
  background: color-mix(in srgb, #d14, transparent 88%);
}

.feedback {
  min-height: 28px;
  font-weight: 800;
}

.case-card details {
  margin-top: 16px;
}

.case-card summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--primary);
}

.notice {
  padding: 28px;
}

.notice code {
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.site-footer {
  padding: 30px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .header-grid,
  .module-grid,
  .case-grid,
  .term-list {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding-top: 48px;
  }

  .nav-inner {
    gap: 16px;
  }

  .theme-toggle {
    margin-left: 0;
  }
}
