:root {
  --bg-deep: #0d0a1a;
  --bg-card: #16122a;
  --bg-elevated: #1e1835;
  --accent-gold: #f5b942;
  --accent-gold-dim: #c9942a;
  --accent-emerald: #1db87a;
  --accent-coral: #e85d4c;
  --text-primary: #f4f0ff;
  --text-muted: #a89ec4;
  --border: rgba(245, 185, 66, 0.15);
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --header-h: 64px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 1rem;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }

a { color: var(--accent-gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-emerald); }

.container {
  width: min(1140px, 92vw);
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13, 10, 26, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-coral));
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.logo span { color: var(--accent-gold); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-header {
  min-width: unset;
  padding: 0.55rem 1.15rem;
  font-size: 0.88rem;
  min-height: 40px;
}

/* Table of contents */
.toc-wrap {
  position: relative;
  z-index: 2;
  padding: 1.5rem 0 0;
}

.toc-block {
  margin: 0 0 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toc-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  text-align: left;
}

.toc-toggle-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.toc-toggle-icon span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--accent-gold);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

.toc-block.open .toc-toggle-icon span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.toc-block.open .toc-toggle-icon span:nth-child(2) { opacity: 0; }
.toc-block.open .toc-toggle-icon span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.toc-nav {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.toc-block.open .toc-nav {
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

.toc-nav ul {
  list-style: none;
  padding: 0.5rem 0;
}

.toc-nav li { border-top: 1px solid var(--border); }

.toc-nav a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.toc-nav a:hover { color: var(--accent-gold); background: rgba(245, 185, 66, 0.05); }

/* Hero */
.hero {
  position: relative;
  padding: 3rem 0 4rem;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13,10,26,0.3) 0%, var(--bg-deep) 100%);
}

.hero .container { position: relative; z-index: 1; }

.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 720px;
  margin-bottom: 2rem;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 2rem 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-align: center;
  min-height: 48px;
  min-width: 200px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dim));
  color: var(--bg-deep);
  box-shadow: 0 4px 20px rgba(245, 185, 66, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px rgba(245, 185, 66, 0.5);
  color: var(--bg-deep);
}

.btn-secondary {
  background: transparent;
  color: var(--accent-gold);
  border: 2px solid var(--accent-gold);
}

.btn-secondary:hover {
  background: rgba(245, 185, 66, 0.1);
  color: var(--accent-gold);
}

/* Sections */
.section {
  padding: 3.5rem 0;
}

.section-alt { background: var(--bg-card); }

.section h2 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.section h3 {
  font-size: 1.2rem;
  margin: 2rem 0 0.75rem;
  color: var(--accent-gold);
}

.section p, .section li {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.section ul, .section ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.content-article h2 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  margin: 2.5rem 0 1rem;
  padding-top: 0.5rem;
  color: var(--text-primary);
}

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

.content-article h3 {
  font-size: 1.2rem;
  margin: 1.75rem 0 0.75rem;
  color: var(--accent-gold);
}

.content-article p,
.content-article li {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.content-article ul,
.content-article ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.content-article h2,
.section h2[id],
.content-article h2[id] {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

/* Slot cards */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.slot-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.slot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.slot-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.slot-card-body { padding: 1.25rem; }

.slot-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.slot-card p {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.slot-card .btn {
  width: 100%;
  min-width: unset;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-elevated);
  color: var(--accent-gold);
  font-weight: 600;
}

td { color: var(--text-muted); }

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

/* FAQ */
.faq-list { margin: 2rem 0; }

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
  background: var(--bg-elevated);
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
}

.faq-question::after {
  content: "+";
  font-size: 1.4rem;
  color: var(--accent-gold);
  flex-shrink: 0;
  transition: transform 0.3s;
}

.faq-item.open .faq-question::after { transform: rotate(45deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.faq-answer-inner {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
}

/* Info boxes */
.info-box {
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent-emerald);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
}

.info-box p { margin-bottom: 0; }

/* Author card in footer */
.author-footer {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}

.author-footer img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-footer h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
  color: var(--accent-gold);
}

.author-footer p {
  font-size: 0.88rem;
  margin: 0;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2rem;
  margin-top: 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  margin-bottom: 1rem;
}

.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 0.5rem; }
.footer-col a { color: var(--text-muted); font-size: 0.9rem; }
.footer-col a:hover { color: var(--accent-gold); }

.footer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.footer-badges a {
  display: block;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.footer-badges a:hover { opacity: 1; }

.footer-badges img {
  max-height: 56px;
  width: auto;
}

.footer-badges img.badge-round {
  height: 56px;
  width: 56px;
  border-radius: 50%;
}

.footer-copy {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-copy p { margin-bottom: 0.35rem; }

.age-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--accent-coral);
  color: var(--text-primary);
  font-weight: 800;
  font-size: 0.85rem;
}

/* Page templates */
.page-hero {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}

.page-hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: 0.75rem;
}

.page-hero p { color: var(--text-muted); max-width: 640px; }

.content-page .section { padding: 2.5rem 0; }
.content-page h2 { margin-top: 2rem; }

.author-profile {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.author-profile img {
  border-radius: var(--radius);
  width: 100%;
}

@media (max-width: 768px) {
  :root {
    --header-h: 56px;
  }

  .container {
    width: min(1140px, 94vw);
  }

  .site-header {
    height: auto;
    min-height: var(--header-h);
    padding: 0.5rem 0;
  }

  .header-inner {
    height: auto;
    min-height: calc(var(--header-h) - 1rem);
    gap: 0.75rem;
  }

  .logo {
    font-size: 1.05rem;
    min-width: 0;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .header-actions {
    gap: 0.45rem;
    flex-shrink: 0;
  }

  .btn-header {
    padding: 0.45rem 0.7rem;
    font-size: 0.75rem;
    min-height: 36px;
    white-space: nowrap;
  }

  .hero {
    padding: 1.75rem 0 2rem;
  }

  .hero h1 {
    font-size: clamp(1.35rem, 6vw, 1.75rem);
  }

  .hero-lead {
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 1.25rem;
  }

  .btn-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin: 1.25rem 0;
  }

  .btn {
    min-width: unset;
    width: 100%;
    padding: 0.8rem 1.25rem;
    font-size: 0.92rem;
    white-space: normal;
  }

  .toc-wrap {
    padding: 1rem 0 0;
  }

  .toc-block {
    margin-bottom: 1.5rem;
  }

  .toc-toggle {
    font-size: 0.92rem;
    padding: 0.85rem 1rem;
    gap: 0.65rem;
  }

  .toc-nav a {
    font-size: 0.85rem;
    padding: 0.65rem 1rem;
    line-height: 1.4;
  }

  .section {
    padding: 2rem 0;
  }

  .content-article h2,
  .section h2 {
    font-size: 1.2rem;
    margin-top: 1.75rem;
    overflow-wrap: anywhere;
    scroll-margin-top: 5.5rem;
  }

  .content-article h3,
  .section h3 {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
  }

  .content-article p,
  .content-article li,
  .section p,
  .section li {
    font-size: 0.95rem;
  }

  .slots-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
  }

  .table-wrap {
    margin: 1rem -0.25rem;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 0.78rem;
    min-width: 520px;
  }

  th, td {
    padding: 0.55rem 0.6rem;
    vertical-align: top;
  }

  .faq-question {
    font-size: 0.9rem;
    padding: 0.9rem 1rem;
    gap: 0.75rem;
  }

  .faq-answer-inner {
    font-size: 0.9rem;
    padding: 0 1rem 1rem;
  }

  .info-box {
    padding: 1rem 1.1rem;
  }

  .author-profile {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .author-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.25rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    text-align: center;
  }

  .footer-badges {
    gap: 0.85rem 1.25rem;
    padding: 1.25rem 0;
  }

  .footer-badges img {
    max-height: 38px;
  }

  .footer-badges img.badge-round {
    max-height: 38px;
    height: 38px;
    width: 38px;
  }

  .site-footer {
    padding: 2rem 0 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }

  .page-hero {
    padding: 1.5rem 0;
  }

  .page-hero h1 {
    font-size: clamp(1.3rem, 5.5vw, 1.65rem);
  }

  .content-page .section {
    padding: 1.75rem 0;
  }
}

@media (max-width: 400px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .header-actions {
    width: 100%;
  }

  .btn-header {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
  }

  .logo {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
