:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-alt: #f0ebde;
  --text: #2f241d;
  --muted: #6f675f;
  --accent: #a66b3d;
  --border: #dfd2bc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

.app-header {
  background: linear-gradient(135deg, #5f3b1f, #a66b3d);
  color: white;
  padding: 24px 20px 28px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.search-panel {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px 0;
}

.search-box {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

.search-box label {
  font-weight: 700;
  min-width: 98px;
  margin-bottom: 0;
}

.search-box input {
  flex: 1;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: 1rem;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(166, 107, 61, 0.12);
}

.search-results {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.search-result-item {
  width: 100%;
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.search-result-item:hover,
.search-result-item:focus-visible {
  background: #fff2d6;
  transform: translateY(-1px);
}

.search-result-item-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
}

.search-result-item-title small {
  color: var(--muted);
  font-size: 0.9rem;
}

.search-result-snippet {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.search-empty {
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--muted);
}

.search-highlight {
  background: #fff176;
  color: inherit;
  border-radius: 3px;
}

@media (max-width: 768px) {
  .search-panel {
    padding: 12px 14px 0;
  }
  .search-box {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box label {
    width: 100%;
  }
  .search-box input {
    width: 100%;
  }
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.sidebar,
.content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04);
}

.sidebar {
  padding: 18px;
  height: fit-content;
  position: sticky;
  top: 12px;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 1rem;
}

.sidebar nav a {
  display: block;
  padding: 8px 0;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.future-note {
  margin-top: 16px;
  background: var(--surface-alt);
  padding: 12px;
  border-radius: 12px;
  font-size: 0.92rem;
}

.future-note ul {
  padding-left: 18px;
  margin-bottom: 0;
}

.content {
  padding: 20px 24px 32px;
  min-height: 70vh;
}

.status {
  color: var(--muted);
  margin-bottom: 12px;
}

.content h1,
.content h2,
.content h3 {
  color: var(--accent);
  line-height: 1.4;
}

.content img {
  max-width: 100%;
  height: auto;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 0.95rem;
}

.content th,
.content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.content code {
  background: var(--surface-alt);
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
}

#scroll-top-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.4rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  z-index: 20;
}

#scroll-top-button.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.page-navigation {
  margin-top: 32px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  background: rgba(246, 238, 226, 0.95);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.page-navigation .nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: white;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.page-navigation .nav-link:hover,
.page-navigation .nav-link:focus-visible {
  background: #fff5eb;
  border-color: var(--border);
}

.page-navigation .nav-link.button {
  background: var(--accent);
  color: white;
}

@media (max-width: 768px) {
  .page-navigation {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }

  .page-navigation .nav-link {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  #scroll-top-button {
    right: 14px;
    bottom: 14px;
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sidebar {
    position: static;
  }

  .content {
    padding: 16px 16px 24px;
  }
}
