/* ─────────────────────────────
   BASE & VARIABLES
───────────────────────────── */
:root {
  --bg: #f8f8f8;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e0e0e0;
  --border-light: #eee;
  --accent: #2a5a8c;
  --accent-hover: #1a3a5c;
  --nav-bg: #ffffff;
  --nav-border: #e0e0e0;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-card: #1e1e1e;
  --text: #e0e0e0;
  --text-secondary: #aaa;
  --text-muted: #777;
  --border: #333;
  --border-light: #2a2a2a;
  --accent: #6a9ac4;
  --accent-hover: #8ab4dc;
  --nav-bg: #1a1a1a;
  --nav-border: #333;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* ─────────────────────────────
   TOP NAVIGATION
───────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  backdrop-filter: blur(8px);
  gap: 16px;
}

.nav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-breadcrumb a {
  color: var(--text-muted);
}

.nav-breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb-sep {
  margin: 0 6px;
  opacity: 0.5;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 6px 8px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.theme-toggle:hover {
  background: var(--border-light);
  color: var(--text);
}

.icon-moon { display: none; }

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: flex; }

/* ─────────────────────────────
   HOMEPAGE
───────────────────────────── */
.home-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px;
}

.home-hero {
  text-align: center;
  margin-bottom: 40px;
}

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

.home-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

.domain-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.domain-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s, transform 0.15s;
  color: var(--text);
}

.domain-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  color: var(--text);
}

.domain-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.domain-card-title {
  font-size: 20px;
  font-weight: 700;
}

.domain-card-count {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 12px;
}

.domain-card-series {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 6px;
}

.domain-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─────────────────────────────
   DOMAIN PAGE (CHAPTER LIST)
───────────────────────────── */
.domain-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px;
}

.domain-header {
  margin-bottom: 28px;
}

.domain-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.domain-series {
  font-size: 15px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 4px;
}

.domain-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  color: var(--text);
  transition: background 0.15s;
}

.chapter-item:hover {
  background: var(--bg-card);
  box-shadow: var(--card-shadow);
  color: var(--text);
}

.chapter-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.chapter-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chapter-title {
  font-size: 15px;
  font-weight: 500;
}

.chapter-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─────────────────────────────
   UNIT NAVIGATION (PREV/NEXT)
───────────────────────────── */
.unit-nav {
  max-width: 720px;
  margin: 24px auto 48px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.unit-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 48%;
  transition: background 0.15s, border-color 0.15s;
}

.unit-nav-link:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--text);
}

.unit-nav-link.disabled {
  visibility: hidden;
}

.unit-nav-arrow {
  font-size: 16px;
  flex-shrink: 0;
}

.unit-nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-nav-next {
  margin-left: auto;
}

/* ─────────────────────────────
   RESPONSIVE
───────────────────────────── */
@media (max-width: 768px) {
  .top-nav {
    padding: 10px 16px;
  }

  .nav-brand {
    font-size: 14px;
  }

  .nav-breadcrumb {
    font-size: 12px;
  }

  .home-page {
    padding: 32px 16px;
  }

  .home-title {
    font-size: 24px;
  }

  .domain-page {
    padding: 24px 16px;
  }

  .unit-nav {
    padding: 0 16px;
    flex-direction: column;
  }

  .unit-nav-link {
    max-width: 100%;
  }
}
