:root {
  --brand-green: #22c55e;
  --brand-green-dark: #16a34a;
  --text: #111827;
  --text-muted: #4b5563;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--brand-green-dark); }
a:hover { color: var(--brand-green); }

/* --- Header --- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.site-title {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
}

.lang-switcher {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  background: var(--card);
}

.lang-switcher:hover {
  border-color: var(--brand-green);
  color: var(--brand-green-dark);
}

/* --- Layout --- */

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-tutorial .layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  align-items: start;
}

.page-landing .layout {
  max-width: 720px;
}

/* --- Content --- */

.content { min-width: 0; }

.content h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin: 0 0 1rem;
}

.content h2 {
  font-size: 1.4rem;
  margin: 2.2rem 0 0.8rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.content h3 {
  font-size: 1.15rem;
  margin: 1.6rem 0 0.6rem;
}

.content p { margin: 0.8rem 0; }

.content blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--brand-green);
  background: #f0fdf4;
  color: var(--text-muted);
}

.content img {
  display: block;
  width: 100%;
  max-width: 408px;
  height: auto;
  margin: 1.2rem auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #f3f4f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.content pre {
  background: #f3f4f6;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
}

.content pre code { background: transparent; padding: 0; }

/* --- Landing cards --- */

.tutorial-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 1.5rem;
}

@media (min-width: 720px) {
  .tutorial-grid { grid-template-columns: 1fr 1fr; }
}

.tutorial-card {
  display: block;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.tutorial-card:hover {
  border-color: var(--brand-green);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.tutorial-card h2 {
  font-size: 1.15rem;
  margin: 0 0 0.4rem;
  border: none;
  padding: 0;
  color: var(--brand-green-dark);
}

.tutorial-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* --- TOC --- */

.toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.92rem;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}

.toc-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li { margin: 2px 0; }

.toc-list a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}

.toc-list a:hover {
  background: var(--bg);
  color: var(--brand-green-dark);
  border-left-color: var(--brand-green);
}

.toc-h3 a { padding-left: 22px; font-size: 0.86rem; }

/* Hamburger button — lives in the header, hidden on wide screens */

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toc-button {
  display: none;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.toc-button:hover {
  border-color: var(--brand-green);
  color: var(--brand-green-dark);
}

.toc-icon {
  display: inline-block;
  width: 14px;
  height: 10px;
  background:
    linear-gradient(currentColor, currentColor) top/100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) center/100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) bottom/100% 2px no-repeat;
}

/* --- Narrow screens: hamburger in header replaces sidebar --- */

@media (max-width: 768px) {
  .page-tutorial .layout {
    display: block;
  }
  .toc-button {
    display: inline-flex;
  }
  .toc {
    display: none;
  }
  .toc-checkbox:checked ~ .toc {
    display: block;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 9;
    margin: 0;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  }
}
