/* ================================================
   Python学習サイト - メインスタイルシート
   ================================================ */

/* リセット & ベース */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3776ab;
  --primary-dark: #2c5f8a;
  --primary-light: #5a9fd4;
  --accent: #ffd43b;
  --accent-dark: #e6be00;
  --text: #1a1a2e;
  --text-light: #4a4a6a;
  --text-muted: #7a7a9a;
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --bg-code: #1e1e3f;
  --border: #e0e4ef;
  --shadow: 0 2px 12px rgba(55,118,171,0.10);
  --shadow-hover: 0 8px 32px rgba(55,118,171,0.18);
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --font-body: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  --font-code: 'Source Code Pro', 'Fira Code', 'Consolas', monospace;
  --transition: 0.22s ease;
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; }
ul, ol { padding-left: 1.5rem; }

/* ================================================
   ヘッダー
   ================================================ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo:hover { color: var(--accent); text-decoration: none; }
.header-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  color: var(--primary-dark);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.1rem;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 2rem;
  flex: 1;
}
.header-nav a {
  color: rgba(255,255,255,0.88);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.header-nav a:hover, .header-nav a.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  text-decoration: none;
}

.header-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-search input {
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.88rem;
  width: 200px;
  transition: all var(--transition);
  outline: none;
}
.header-search input::placeholder { color: rgba(255,255,255,0.6); }
.header-search input:focus {
  background: rgba(255,255,255,0.3);
  width: 260px;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  margin-left: auto;
}
.menu-btn:hover { background: rgba(255,255,255,0.18); }

/* ================================================
   サイドバー
   ================================================ */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem 0;
  z-index: 500;
  transition: transform var(--transition);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section { margin-bottom: 1.5rem; }
.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 1.2rem 0.4rem;
}
.sidebar-nav { list-style: none; padding: 0; }
.sidebar-nav li { }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
  color: var(--text-light);
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  color: var(--primary);
  background: rgba(55,118,171,0.07);
  border-left-color: var(--primary);
  text-decoration: none;
}
.sidebar-nav .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.badge-beginner { background: #22c55e; }
.badge-intermediate { background: #f59e0b; }

/* ================================================
   メインコンテンツ
   ================================================ */
.layout {
  display: flex;
  padding-top: var(--header-h);
}
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 2.5rem 2rem 4rem;
  max-width: 960px;
}
.main-content.full-width {
  margin-left: var(--sidebar-w);
  max-width: none;
  padding: 2.5rem 2rem 4rem;
}

/* ================================================
   パンくずリスト
   ================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); text-decoration: none; }
.breadcrumb .sep { color: var(--border); }
/* パンくずがpage-heroの直前にある場合、navをヒーロー背景に統合して白い隙間をなくす */
nav:has(+ .page-hero) {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  margin: -2.5rem -2rem 0;
  padding: 2.5rem 2rem 0;
}
.page-hero .breadcrumb,
nav:has(+ .page-hero) .breadcrumb { color: rgba(255,255,255,0.85); }
.page-hero .breadcrumb a,
nav:has(+ .page-hero) .breadcrumb a { color: rgba(255,255,255,0.85); }
.page-hero .breadcrumb a:hover,
nav:has(+ .page-hero) .breadcrumb a:hover { color: #fff; text-decoration: underline; }
.page-hero .breadcrumb .sep,
nav:has(+ .page-hero) .breadcrumb .sep { color: rgba(255,255,255,0.5); }

/* ================================================
   ページヘッダー
   ================================================ */
.page-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 3rem 2rem;
  margin: -2.5rem -2rem 2.5rem;
}
.page-hero .hero-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.page-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}
.page-hero .hero-desc {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.95);
  max-width: 640px;
  line-height: 1.7;
}
.page-hero .hero-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}
.page-hero .hero-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  opacity: 0.8;
}

/* ================================================
   セクション & 見出し
   ================================================ */
.section { margin-bottom: 3rem; }
h1 { font-size: 2rem; font-weight: 800; color: var(--text); margin-bottom: 1rem; }
h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.4em;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}
h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 1.8rem 0 0.75rem; }
h4 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 1.2rem 0 0.5rem; }
p { margin-bottom: 1rem; color: var(--text-light); }
strong { color: var(--text); }

/* ================================================
   コードブロック
   ================================================ */
pre {
  background: var(--bg-code);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  position: relative;
  border: 1px solid #2a2a5a;
}
pre code {
  font-family: var(--font-code);
  font-size: 0.88rem;
  line-height: 1.7;
  color: #cdd6f4;
  background: none;
  padding: 0;
  border-radius: 0;
}
code {
  font-family: var(--font-code);
  font-size: 0.88em;
  background: #eef2ff;
  color: var(--primary-dark);
  padding: 0.15em 0.45em;
  border-radius: 4px;
}

/* シンタックスカラー */
.kw { color: #c084fc; }
.st { color: #a3e635; }
.cm { color: #6b7280; font-style: italic; }
.nm { color: #fbbf24; }
.bi { color: #f9a8d4; }
.fn { color: #60a5fa; }
.nu { color: #fb923c; }
.op { color: #94a3b8; }
.de { color: #34d399; }

/* コピーボタン */
.code-block-wrapper { position: relative; }
.copy-btn {
  position: absolute;
  top: 0.75rem; right: 0.75rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.copy-btn.copied { background: #22c55e; border-color: #22c55e; color: #fff; }

/* ファイル名ラベル */
.code-filename {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.2rem 0.75rem;
  border-radius: 6px 6px 0 0;
  font-family: var(--font-code);
  margin-bottom: -1px;
}

/* ================================================
   カード
   ================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}
.app-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
  border-color: var(--primary-light);
  text-decoration: none;
  color: inherit;
}
.app-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.app-card-icon {
  font-size: 1.8rem;
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.icon-bg-blue { background: #dbeafe; }
.icon-bg-green { background: #dcfce7; }
.icon-bg-yellow { background: #fef9c3; }
.icon-bg-purple { background: #f3e8ff; }
.icon-bg-red { background: #fee2e2; }
.icon-bg-orange { background: #ffedd5; }
.icon-bg-teal { background: #ccfbf1; }
.icon-bg-pink { background: #fce7f3; }

.app-card-num {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}
.app-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}
.app-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}
.app-card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.18rem 0.55rem;
  border-radius: 20px;
  font-weight: 600;
  background: #eef2ff;
  color: var(--primary);
}
.tag-green { background: #dcfce7; color: #16a34a; }
.tag-yellow { background: #fef9c3; color: #a16207; }
.tag-purple { background: #f3e8ff; color: #7c3aed; }
.arrow-link { margin-left: auto; color: var(--primary); font-size: 1rem; }

/* ================================================
   情報ボックス（Note, Tip, Warning, Info）
   ================================================ */
.box {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  border-left: 4px solid;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.box-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }
.box-body { flex: 1; }
.box-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.25rem; }
.box p:last-child { margin-bottom: 0; }

.box-info { background: #eff6ff; border-color: #3b82f6; }
.box-info .box-title { color: #1d4ed8; }
.box-tip { background: #f0fdf4; border-color: #22c55e; }
.box-tip .box-title { color: #15803d; }
.box-warning { background: #fffbeb; border-color: #f59e0b; }
.box-warning .box-title { color: #b45309; }
.box-danger { background: #fef2f2; border-color: #ef4444; }
.box-danger .box-title { color: #b91c1c; }

/* ================================================
   ステップガイド
   ================================================ */
.steps { list-style: none; padding: 0; margin: 1.25rem 0; }
.steps li {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}
.step-num {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.step-body { flex: 1; }
.step-body strong { display: block; font-size: 1rem; margin-bottom: 0.35rem; }

/* ================================================
   テーブル
   ================================================ */
.table-wrapper { overflow-x: auto; margin: 1.25rem 0; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--primary); color: #fff; }
th { padding: 0.75rem 1rem; font-size: 0.88rem; font-weight: 600; text-align: left; }
td { padding: 0.7rem 1rem; font-size: 0.9rem; border-bottom: 1px solid var(--border); color: var(--text-light); }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: #fafbff; }
tr:hover td { background: #f0f4ff; }

/* ================================================
   目次 (TOC)
   ================================================ */
.toc {
  background: #f8f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0 2rem;
}
.toc-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.toc-list { list-style: none; padding: 0; }
.toc-list li { padding: 0.2rem 0; }
.toc-list a { font-size: 0.9rem; color: var(--text-light); }
.toc-list a:hover { color: var(--primary); text-decoration: none; }
.toc-list .toc-sub { padding-left: 1rem; }
.toc-list .toc-sub a { font-size: 0.85rem; }

/* ================================================
   フッター
   ================================================ */
.site-footer {
  background: #1a1a2e;
  color: rgba(255,255,255,0.85);
  padding: 3rem 2rem 2rem;
  margin-left: var(--sidebar-w);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto 2rem;
}
.footer-brand .footer-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.footer-brand p { font-size: 0.88rem; line-height: 1.65; color: #d0d8e8; }
.footer-heading { font-size: 0.85rem; font-weight: 700; color: #fff; margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.footer-links { list-style: none; padding: 0; }
.footer-links li { margin-bottom: 0.4rem; }
.footer-links a { color: rgba(255,255,255,0.8); font-size: 0.88rem; transition: color var(--transition); }
.footer-links a:hover { color: var(--accent); text-decoration: none; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  color: #c8d0e0;
  max-width: 1100px;
  margin: 0 auto;
}

/* ================================================
   ヒーロー（トップページ）
   ================================================ */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: #fff;
  padding: 5rem 2rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin: -2.5rem -2rem 3rem;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 500px; height: 500px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 400px; height: 400px;
  background: rgba(255,212,59,0.08);
  border-radius: 50%;
}
.hero-content { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.hero-tag {
  display: inline-block;
  background: var(--accent);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.2;
  color: #fff;
}
.hero .hero-sub {
  font-size: 1.15rem;
  opacity: 0.88;
  line-height: 1.7;
  margin-bottom: 2.5rem;
}
.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary {
  background: var(--accent);
  color: var(--primary-dark);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--primary-dark); }
.btn-outline-white {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.6);
}
.btn-outline-white:hover { background: rgba(255,255,255,0.12); border-color: #fff; color: #fff; }
.btn-blue { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-blue:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

/* ================================================
   フィーチャーグリッド
   ================================================ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}
.feature-card h3 { font-size: 1rem; margin: 0 0 0.4rem; }
.feature-card p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* ================================================
   プログレスバー
   ================================================ */
.progress-bar {
  background: var(--border);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin: 0.35rem 0;
}
.progress-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.8s ease;
}

/* ================================================
   タブ
   ================================================ */
.tabs {
  border-bottom: 2px solid var(--border);
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: 0.7rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: -2px;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ================================================
   検索結果
   ================================================ */
.search-overlay {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 800;
}
.search-box {
  background: #fff;
  max-width: 640px;
  margin: 2rem auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.search-box input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  border: none;
  outline: none;
  border-bottom: 1px solid var(--border);
}
.search-results { padding: 0.75rem; max-height: 400px; overflow-y: auto; }
.search-result-item {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg); }
.search-result-title { font-weight: 600; font-size: 0.9rem; }
.search-result-desc { font-size: 0.82rem; color: var(--text-muted); }

/* ================================================
   検索ドロップダウン
   ================================================ */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  z-index: 1100;
  overflow: hidden;
}
.search-dd-item {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-dd-item:hover { background: var(--bg); }
.search-dd-badge {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  height: fit-content;
}
.badge-beginner     { background: #d1fae5; color: #065f46; }
.badge-intermediate { background: #fef3c7; color: #92400e; }
.badge-page         { background: #dbeafe; color: #1e40af; }
.search-dd-title {
  font-weight: 600;
  font-size: 0.87rem;
  line-height: 1.3;
}
.search-dd-desc {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-dd-item mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.search-dd-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.search-dd-more {
  display: block;
  padding: 0.6rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--primary);
  text-decoration: none;
  background: var(--bg);
  font-weight: 600;
  transition: background var(--transition);
}
.search-dd-more:hover { background: var(--border); }

/* ================================================
   ページTOPボタン
   ================================================ */
.back-to-top {
  position: fixed;
  bottom: 2rem; right: 2rem;
  width: 44px; height: 44px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 16px rgba(55,118,171,0.4);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  z-index: 600;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--primary-dark); transform: translateY(-3px); }

/* ================================================
   統計カード
   ================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.stat-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}
.stat-card.green { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-card.amber { background: linear-gradient(135deg, #f59e0b, #b45309); }
.stat-card.purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.stat-num { font-size: 2.2rem; font-weight: 800; line-height: 1; margin-bottom: 0.35rem; }
.stat-label { font-size: 0.85rem; opacity: 0.85; }

/* ================================================
   難易度バッジ
   ================================================ */
.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}
.difficulty-1 { background: #dcfce7; color: #15803d; }
.difficulty-2 { background: #fef9c3; color: #a16207; }
.difficulty-3 { background: #fee2e2; color: #b91c1c; }

/* ================================================
   レスポンシブ
   ================================================ */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-260px);
    width: 260px;
    z-index: 900;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; padding: 1.5rem 1rem 3rem; }
  .site-footer { margin-left: 0; }
  .menu-btn { display: flex; }
  .header-nav { display: none; }
  .header-search { display: none; }
  .hero h1 { font-size: 2rem; }
  .page-hero h1 { font-size: 1.6rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-hero { padding: 2rem 1rem; margin: -1.5rem -1rem 2rem; }
}

@media (max-width: 480px) {
  .hero { padding: 3rem 1rem 2.5rem; }
  .hero h1 { font-size: 1.7rem; }
  .hero-cta { flex-direction: column; align-items: center; }
  .btn { width: 100%; justify-content: center; max-width: 280px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ================================================
   プリント
   ================================================ */
@media print {
  .site-header, .sidebar, .site-footer, .back-to-top, .copy-btn { display: none; }
  .main-content { margin-left: 0; }
  pre { background: #f8f9fc; border: 1px solid #ccc; }
  pre code { color: #1a1a2e; }
}

/* ================================================
   アニメーション
   ================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeIn 0.5s ease forwards; }
