:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --tech: #0f766e;
  --tech-soft: #f0fdfa;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ローディング */
.boot-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ログイン画面 */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #1e3a8a 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  padding: 36px 30px;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-brand {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: 8px;
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  line-height: 1.35;
}
.login-sub {
  margin: 0 0 24px;
  font-size: 0.86rem;
  color: var(--text-sub);
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.84rem; font-weight: 700; color: var(--text-sub); }
.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}
.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  text-align: center;
}

/* ヘッダー＆2コーナー切替ナビ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.14);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand-title {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.user-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-badge {
  font-size: 0.8rem;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
}
.header-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.25); }
.header-btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.18); color: #cbd5e1; }

.section-nav {
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.section-nav-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
}
.section-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #cbd5e1;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.section-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.section-tab.active {
  color: #fff;
  border-bottom-color: #60a5fa;
  background: rgba(255, 255, 255, 0.06);
}
.section-tab[data-section="tech"].active {
  border-bottom-color: #2dd4bf;
}
.tab-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 800;
}

/* コンテナ＆バナー */
.container {
  max-width: 980px;
  margin: 22px auto 64px;
  padding: 0 16px;
}
.detail-container { max-width: 840px; }

.section-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
}
.section-banner.tech-mode { border-left-color: var(--tech); }
.section-banner h2 { margin: 0 0 4px; font-size: 1.12rem; }
.section-banner p { margin: 0; font-size: 0.86rem; color: var(--text-sub); }

/* 検索・絞り込みツールバー */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.search-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search-input {
  flex: 1 1 240px;
  padding: 10px 14px;
  font-size: 0.94rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.search-input:focus { border-color: var(--primary); }
.sort-select {
  padding: 10px 12px;
  font-size: 0.88rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.status-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: #f1f5f9; }
.chip.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.chip.status-chip.active { background: var(--primary); border-color: var(--primary); }

.list-meta {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 0 4px 12px;
}

/* カードグリッド */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.14s, box-shadow 0.14s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08); }
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.num-badge {
  font-family: Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 6px;
}
.cat-badge {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.cat-badge.tech { background: var(--tech-soft); color: var(--tech); }

.status-pill {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}
.pill-done { background: var(--success-soft); color: var(--success); }
.pill-todo { background: var(--warn-soft); color: var(--warn); }
.pill-read { background: #e0f2fe; color: #0369a1; }

.card h3 {
  margin: 0 0 6px;
  font-size: 1.04rem;
  line-height: 1.45;
  color: var(--text);
}
.card-note {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-sub);
  flex-grow: 1;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 5px;
}
.card-date { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 10px; }
.card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }

/* ボタン */
.btn {
  display: inline-block;
  text-align: center;
  padding: 10px 16px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
}
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-tech { background: var(--tech); color: #fff; }
.btn-tech:hover { background: #115e59; }
.btn-outline { background: #f8fafc; color: #1e3a8a; border: 1.5px solid #bfdbfe; }
.btn-outline:hover { background: var(--primary-soft); }

.empty-state {
  background: var(--surface);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ページネーション */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.page-btn {
  background: #fff;
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.page-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* 記事詳細画面 */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.crumb-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  padding: 0;
  cursor: pointer;
  font-size: 0.84rem;
}
.crumb-btn:hover { text-decoration: underline; }

.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 34px;
  box-shadow: var(--shadow);
}
@media (max-width: 600px) { .article-card { padding: 22px 18px; } }
.article-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toc {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 18px 0 26px;
}
.toc-title { font-size: 0.86rem; font-weight: 800; color: var(--text-sub); margin-bottom: 8px; }
.toc ol { margin: 0; padding-left: 1.3rem; font-size: 0.9rem; }
.toc li { margin-bottom: 4px; }
.toc a { color: var(--primary); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.article-card h1 { font-size: 1.55rem; border-bottom: 3px solid var(--primary); padding-bottom: 10px; margin-top: 0; line-height: 1.35; }
.article-card h2 { font-size: 1.24rem; border-left: 4px solid var(--primary); padding-left: 12px; margin-top: 2rem; scroll-margin-top: 110px; }
.article-card h3 { font-size: 1.05rem; margin-top: 1.3rem; }
.article-card ul, .article-card ol { padding-left: 1.5rem; }
.article-card li { margin-bottom: 6px; }
.article-card table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 0.9rem; display: block; overflow-x: auto; }
.article-card th, .article-card td { border: 1px solid #cbd5e1; padding: 10px 12px; text-align: left; }
.article-card th { background: var(--primary-soft); color: #1e3a8a; font-weight: 700; }
.article-card tr:nth-child(even) td { background: #f8fafc; }
.article-card blockquote { border-left: 4px solid #94a3b8; margin: 16px 0; padding: 10px 16px; color: var(--text-sub); background: #f8fafc; border-radius: 0 8px 8px 0; }
.article-card pre { background: #0f172a; color: #f8fafc; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 0.88rem; }
.article-card code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: Consolas, monospace; font-size: 0.9em; }
.article-card pre code { background: transparent; padding: 0; }

/* 読了ボタン＆テストCTA */
.read-box {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.read-btn {
  background: #0f172a;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.read-btn.done { background: var(--success-soft); color: var(--success); cursor: default; }

.quiz-cta {
  margin-top: 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1.5px solid #93c5fd;
  border-radius: 16px;
  padding: 26px 22px;
  text-align: center;
}
.quiz-cta-badge { display: inline-block; background: var(--primary); color: #fff; font-size: 0.75rem; font-weight: 700; padding: 3px 12px; border-radius: 999px; margin-bottom: 10px; }
.quiz-cta h2 { margin: 0 0 8px; font-size: 1.18rem; color: #1e3a8a; }
.quiz-cta p { margin: 0 0 18px; font-size: 0.88rem; color: #334155; }
.quiz-cta-btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 13px 32px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.96rem;
}
.quiz-cta-btn:hover { background: var(--primary-hover); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } }
.pager-btn {
  display: block; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; text-align: left; cursor: pointer;
}
.pager-btn:hover { border-color: #93c5fd; }
.pager-right .pager-btn { text-align: right; }
.pager-label { display: block; font-size: 0.76rem; color: var(--text-muted); margin-bottom: 4px; }
.pager-title { display: block; font-size: 0.9rem; font-weight: 700; color: #1e3a8a; }

.related { margin-top: 26px; }
.related h3 { font-size: 0.96rem; color: var(--text-sub); margin: 0 0 12px; }
.related-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.related-btn {
  display: block; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; text-align: left; cursor: pointer;
}
.related-btn:hover { border-color: #93c5fd; }
.related-title { display: block; font-size: 0.9rem; font-weight: 700; color: #1e3a8a; }
.related-date { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
