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

:root {
  --color-bg: #fafaf8;
  --color-surface: #ffffff;
  --color-text: #2d2d2d;
  --color-text-muted: #6b7280;
  --color-primary: #3b7a57;
  --color-primary-light: #e8f5e9;
  --color-accent: #d4a843;
  --color-border: #e5e7eb;
  --color-code-bg: #f3f4f6;
  --font-sans: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Source Code Pro", monospace;
  --max-width: 960px;
  --sidebar-width: 200px;
}

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Header === */
.site-header {
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-primary);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}
.site-title:hover { text-decoration: none; }
.site-nav { display: flex; gap: 1.25rem; font-size: 0.9rem; }
.site-nav a { color: var(--color-text-muted); font-weight: 500; }
.site-nav a.active { color: var(--color-primary); border-bottom: 2px solid var(--color-primary); }
.site-nav a:hover { color: var(--color-primary); text-decoration: none; }
.github-link::after { content: " \2197"; }

/* === Layout === */
.page-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  gap: 2.5rem;
  flex: 1;
  width: 100%;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 4.5rem;
  align-self: flex-start;
}
.sidebar h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 0.25rem; }
.sidebar a {
  display: block;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--color-text);
}
.sidebar a:hover { background: var(--color-primary-light); text-decoration: none; }
.sidebar a.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

/* === Content === */
.content { flex: 1; min-width: 0; }
.content-full { max-width: 720px; margin: 0 auto; }

.content h1 { font-size: 1.75rem; margin-bottom: 1rem; color: var(--color-primary); }
.content h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--color-border); }
.content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.content h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; color: var(--color-text-muted); }
.content p { margin-bottom: 1rem; }
.content ul, .content ol { margin: 0 0 1rem 1.5rem; }
.content li { margin-bottom: 0.25rem; }

/* === Code === */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}
pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
}
th { background: var(--color-code-bg); font-weight: 600; }

/* === Endpoint blocks === */
.endpoint {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.endpoint .method {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  margin-right: 0.5rem;
}
.method-get { background: #dbeafe; color: #1d4ed8; }
.method-post { background: #dcfce7; color: #15803d; }
.method-delete { background: #fee2e2; color: #b91c1c; }
.endpoint .path { font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600; }
.endpoint .scope { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* === Hero (top page) === */
.hero { text-align: center; padding: 2rem 0 2.5rem; }
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero .tagline { font-size: 1.1rem; color: var(--color-text-muted); margin-bottom: 1.5rem; }
.hero-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.hero-links a {
  display: inline-block;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
}
.btn-primary { background: var(--color-primary); color: #fff !important; }
.btn-primary:hover { background: #2d6043; text-decoration: none; }
.btn-outline {
  border: 2px solid var(--color-primary);
  color: var(--color-primary) !important;
}
.btn-outline:hover { background: var(--color-primary-light); text-decoration: none; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.feature {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
}
.feature h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.feature p { margin: 0; font-size: 0.9rem; color: var(--color-text-muted); }

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.25rem 1.5rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: auto;
}

/* === Mobile === */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 0.5rem; }
  .page-wrapper { flex-direction: column; padding: 1.25rem 1rem; }
  .sidebar {
    position: static;
    width: 100%;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
  }
  .sidebar h3 { margin: 0; }
  .sidebar ul { display: flex; gap: 0.25rem; flex-wrap: wrap; }
  .features { grid-template-columns: 1fr; }
}
