:root {
  --bg: #121416;
  --panel: #191d21;
  --panel-strong: #232930;
  --text: #eef2f5;
  --muted: #97a2ad;
  --accent: #d96b3b;
  --accent-strong: #f18452;
  --border: #2f3740;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-strong: #e9eff6;
  --text: #18212d;
  --muted: #586678;
  --accent: #c95a2d;
  --accent-strong: #e27245;
  --border: #d4dde7;
  --shadow: 0 20px 60px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 107, 59, 0.14), transparent 28%),
    linear-gradient(160deg, #101214 0%, #171b1f 52%, #111417 100%);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(201, 90, 45, 0.12), transparent 28%),
    linear-gradient(160deg, #f8fbff 0%, #eef3f8 54%, #e7edf4 100%);
}

body::after {
  content: "";
  position: fixed;
  right: 10px;
  bottom: 10px;
  width: clamp(220px, 24vw, 420px);
  height: clamp(220px, 24vw, 420px);
  background: url("/icon-white.svg") no-repeat center center;
  background-size: contain;
  opacity: 0.11;
  pointer-events: none;
  z-index: 0;
}

html[data-theme="light"] body::after {
  opacity: 0.05;
  filter: invert(1);
}

a {
  color: inherit;
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 32px auto 88px;
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.hero,
.panel,
.section-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(217, 107, 59, 0.14), rgba(25, 29, 33, 0.94)),
    var(--panel);
}

html[data-theme="light"] .hero {
  background:
    linear-gradient(135deg, rgba(201, 90, 45, 0.10), rgba(255, 255, 255, 0.96)),
    var(--panel);
}

.hero-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.hero-icon {
  width: clamp(72px, 10vw, 124px);
  height: clamp(72px, 10vw, 124px);
  object-fit: contain;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.22));
}

html[data-theme="light"] .hero-icon {
  filter: invert(1) drop-shadow(0 14px 24px rgba(0, 0, 0, 0.14));
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.98;
  letter-spacing: 0.02em;
  text-transform: none;
}

.hero-copy,
.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1.02rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.secondary {
  background: var(--panel-strong);
  color: var(--text);
}

.hero-button {
  appearance: none;
}

.primary {
  background: var(--accent);
  color: #fff7f1;
}

.primary:hover {
  background: var(--accent-strong);
}

.panel {
  padding: 18px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
}

.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.toc a:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: rgba(217, 107, 59, 0.12);
}

.section-card {
  padding: 22px;
}

.section-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.info-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
}

.info-box {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #12161a;
}

html[data-theme="light"] .info-box {
  background: #ffffff;
}

.info-box h3,
.example h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.info-box ul,
.tips-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.info-box li + li,
.tips-list li + li {
  margin-top: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 18px;
  background: #111418;
}

html[data-theme="light"] .table-wrap {
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel-strong);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

html[data-theme="light"] th {
  background: #eef3f8;
}

tr:last-child td {
  border-bottom: 0;
}

code {
  padding: 0.18rem 0.38rem;
  border-radius: 6px;
  background: rgba(217, 107, 59, 0.12);
  color: var(--text);
  font-family: "Courier New", monospace;
  font-size: 0.94em;
}

pre {
  margin: 0;
  overflow: auto;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #101316;
  color: #edf1f5;
  line-height: 1.55;
  font-family: "Courier New", monospace;
}

html[data-theme="light"] pre {
  background: #ffffff;
  color: #18212d;
}

.example {
  margin-top: 18px;
}

.theme-toggle {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 81;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) scale(1.02);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.94);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 14, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: min(920px, 100%);
  max-height: min(88vh, 960px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4);
  transform: translateY(10px) scale(0.98);
  transition: transform 180ms ease;
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.modal-title {
  margin: 0;
  font-size: 1.2rem;
  text-transform: none;
}

.ghost {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
}

.modal-body {
  overflow: auto;
  padding: 20px;
}

.quiz-body {
  display: grid;
  gap: 18px;
}

.quiz-intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.quiz-form {
  display: grid;
  gap: 14px;
}

.quiz-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #12161a;
}

html[data-theme="light"] .quiz-card {
  background: #ffffff;
}

.quiz-question {
  margin: 0 0 12px;
  font-size: 1rem;
  line-height: 1.45;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

.quiz-option input {
  margin-top: 2px;
}

.quiz-option span {
  line-height: 1.45;
}

.quiz-option.is-correct {
  border-color: rgba(78, 192, 141, 0.6);
  background: rgba(78, 192, 141, 0.12);
}

.quiz-option.is-wrong {
  border-color: rgba(255, 108, 108, 0.7);
  background: rgba(255, 108, 108, 0.12);
}

.quiz-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quiz-actions .secondary,
.quiz-actions .primary {
  min-height: 46px;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}

.quiz-result {
  min-height: 24px;
  color: var(--muted);
  line-height: 1.55;
}

.quiz-result strong {
  color: var(--text);
}

.quiz-feedback {
  margin-top: 10px;
}

.quiz-feedback-list {
  margin: 10px 0 0;
  padding-left: 18px;
}

.quiz-feedback-list li + li {
  margin-top: 10px;
}

html[data-theme="light"] .modal-head {
  background: rgba(255, 255, 255, 0.8);
}

html[data-theme="light"] .ghost {
  background: rgba(255, 255, 255, 0.9);
}

@media (max-width: 860px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100% - 20px, 1100px);
    margin: 20px auto 84px;
  }

  .modal {
    max-height: 92vh;
  }
}

@media (max-width: 540px) {
  .hero,
  .section-card,
  .panel {
    padding: 16px;
  }

  .hero-link,
  .toc a {
    width: 100%;
    justify-content: center;
  }

  .theme-toggle {
    left: 14px;
    bottom: 14px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-head,
  .modal-body {
    padding: 16px;
  }
}
