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

/* === Tokens — Notion warm === */
:root {
  --bg: #fbfbfa;
  --text: #37352f;
  --muted: #6b6b67;
  --muted-light: #9b9a97;
  --border: #e9e9e5;
  --surface: #ffffff;
  --radius: 4px;
  --radius-lg: 6px;
  --font-heading: 'Times New Roman', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 708px;
}

/* === Base === */
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #000; }

/* === Nav === */
nav {
  position: sticky; top: 0; z-index: 100;
  height: 44px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.nav-brand {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.nav-links { display: flex; gap: 20px; }
.nav-links a {
  font-size: 14px;
  color: var(--muted-light);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.15s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); }

/* === Main container === */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

/* === Hero (home) === */
.hero {
  text-align: center;
  padding: 88px 16px 64px;
}
.hero h1 {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.hero p {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 40px;
}

/* === Search / Input === */
.search-wrap {
  max-width: 480px;
  margin: 0 auto;
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus {
  border-color: var(--text);
}
.search-wrap button {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s;
}
.search-wrap button:hover { background: #2f2e2c; }
.search-wrap button:disabled { opacity: 0.6; cursor: not-allowed; }

/* === Result box === */
.result-box {
  display: none;
  text-align: left;
  margin-top: 24px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.result-box.error {
  color: #e03e2d;
  border-color: #f5c6cb;
  background: #fff5f5;
}

/* === Section heading === */
.section-heading {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

/* === Topic list (flat, not cards) === */
.topic-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 64px;
}
.topic-item {
  background: var(--surface);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
  text-decoration: none;
}
.topic-item:hover { background: #f7f6f3; }
.topic-item h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}
.topic-item .count {
  font-size: 13px;
  color: var(--muted-light);
}

/* === Lesson list === */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.lesson-list a {
  background: var(--surface);
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}
.lesson-list a:hover { background: #f7f6f3; }

/* === Breadcrumb === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 24px 0 8px;
  font-size: 14px;
  color: var(--muted-light);
}
.breadcrumb a { color: var(--muted-light); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb span { color: var(--text); }
.breadcrumb .sep { color: var(--border); margin: 0 2px; }

/* === Lesson content (rendered Markdown) === */
.lesson-content {
  padding: 16px 0 40px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.lesson-content h1,
.lesson-content h2,
.lesson-content h3 {
  font-family: var(--font-heading);
  color: var(--text);
  margin: 28px 0 8px;
}
.lesson-content h1 { font-size: 28px; }
.lesson-content h2 { font-size: 22px; }
.lesson-content h3 { font-size: 18px; }
.lesson-content p { margin: 8px 0; }
.lesson-content ul, .lesson-content ol { padding-left: 24px; margin: 8px 0; }
.lesson-content li { margin: 4px 0; }
.lesson-content code {
  background: #f1f0ed;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 14px;
  font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #e03e2d;
}
.lesson-content pre {
  background: #f7f6f3;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
}
.lesson-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 14px;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 64px 16px;
  color: var(--muted);
  font-size: 16px;
}

/* === Loading spinner === */
.spinner {
  display: none;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading .spinner { display: inline-block; }
.loading .btn-text { display: none; }

/* === Footer === */
footer {
  text-align: center;
  padding: 40px 16px;
  font-size: 12px;
  color: var(--muted-light);
}

/* === Responsive === */
@media (max-width: 480px) {
  .hero { padding: 48px 16px 40px; }
  .hero h1 { font-size: 36px; }
}
