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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Noto Sans JP", sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.7;
}

/* ── ナビゲーション ── */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #1a1a2e;
  z-index: 100;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
nav .nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
nav .nav-title {
  font-weight: 700;
  color: #e94560;
  white-space: nowrap;
  padding: 8px 8px 8px 0;
  font-size: 14px;
}
nav a {
  color: #ccc;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 10px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s;
}
nav a:hover,
nav a.active {
  color: #fff;
  border-bottom-color: #e94560;
}

/* ── メインコンテンツ ── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 90px 20px 60px;
}

h1 {
  text-align: center;
  font-size: 28px;
  margin-bottom: 8px;
  color: #1a1a2e;
}

section {
  margin-bottom: 48px;
}
h2 {
  font-size: 22px;
  color: #1a1a2e;
  border-left: 4px solid #e94560;
  padding-left: 12px;
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}
h3 {
  font-size: 16px;
  color: #555;
  margin: 20px 0 8px;
}

/* ── コードブロック ── */
.code-block {
  position: relative;
  margin-bottom: 16px;
}
.code-block pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 16px 20px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
}
/* ── コード内ハイライト ── */
.cm {
  color: #6c7086;
}
.kw {
  color: #cba6f7;
}
.fn {
  color: #89b4fa;
}
.st {
  color: #a6e3a1;
}
.nb {
  color: #fab387;
}
.op {
  color: #89dceb;
}
.tg {
  color: #f38ba8;
}
.at {
  color: #f9e2af;
}

p {
  margin-bottom: 8px;
  color: #555;
  font-size: 14px;
}
p code,
li code {
  background: #e8e8e8;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
}
ul {
  padding-left: 20px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #555;
}
li {
  margin-bottom: 4px;
}

.note {
  background: #e8f4fd;
  border-left: 4px solid #89b4fa;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 16px;
  font-size: 13px;
  color: #444;
}

/* ── 中級バッジ ── */
.badge-intermediate {
  display: inline-block;
  background: #e94560;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

/* ── ナビ区切り ── */
.nav-divider {
  color: #45475a;
  padding: 0 4px;
  user-select: none;
  font-size: 14px;
}

/* ── 検索ボックス ── */
.nav-search {
  margin-left: auto;
  flex-shrink: 0;
}
.nav-search input {
  background: #16213e;
  border: 1px solid #45475a;
  color: #cdd6f4;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 13px;
  width: 150px;
  outline: none;
  transition:
    border-color 0.2s,
    width 0.2s;
}
.nav-search input:focus {
  border-color: #e94560;
  width: 200px;
}
.nav-search input::placeholder {
  color: #6c7086;
}

/* ── フィルタリング状態 ── */
.code-block.search-hidden,
h3.search-hidden,
p.search-hidden,
ul.search-hidden,
.note.search-hidden {
  display: none;
}
section.search-no-match h2::after {
  content: " — 該当なし";
  font-size: 13px;
  color: #aaa;
  font-weight: normal;
}

/* ── トップに戻るボタン ── */
#backToTop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1a1a2e;
  color: #e94560;
  border: 2px solid #e94560;
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 99;
}
#backToTop.visible {
  opacity: 1;
  pointer-events: auto;
}
#backToTop:hover {
  background: #e94560;
  color: #fff;
}

@media (max-width: 640px) {
  main {
    padding-top: 80px;
  }
  h1 {
    font-size: 22px;
  }
  h2 {
    font-size: 18px;
  }
  .code-block pre {
    font-size: 12px;
    padding: 12px;
  }
  .nav-search input {
    width: 110px;
  }
  .nav-search input:focus {
    width: 140px;
  }
}
