:root {
  --bg: #f6f7fb;
  --surface: #fff;
  --text: #0f172a;
  --muted: #475569;
  --line: rgba(15, 23, 42, .10);
  --r: 18px;
  --max: 1120px;
  --sidebarW: 280px;
  --accent: #2563eb;
  --accent2: #7c3aed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}

.container {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebarW) 1fr;
  min-height: 100vh;
}

:root {
  /* Light theme */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface2: #f1f3f9;
  --text: #0f172a;
  --muted: #475569;
  --line: rgba(15, 23, 42, .10);
  --shadow: 0 18px 55px rgba(2, 6, 23, .10);

  --accent: #2563eb;
  /* blue */
  --accent2: #7c3aed;
  /* violet */
  --accentSoft: rgba(37, 99, 235, .10);

  --r: 18px;
  --max: 1120px;
  --sidebarW: 280px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  --size-bump: 2pt;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: calc(16px + var(--size-bump));
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(37, 99, 235, .12), transparent 60%),
    radial-gradient(820px 520px at 88% 10%, rgba(124, 58, 237, .10), transparent 62%),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
}

/* Breadcrumbs */
.breadcrumb-nav {
  margin: 12px 0 0;
}
.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 8px;
  font-size: calc(12.5px + var(--size-bump));
  color: var(--muted);
}
.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb-item:not(:last-child)::after {
  content: "/";
  color: rgba(15, 23, 42, .2);
}
.breadcrumb-item a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
.breadcrumb-item a:hover {
  color: var(--accent2);
  text-decoration: underline;
}
.breadcrumb-item span[aria-current="page"] {
  color: var(--text);
  font-weight: 500;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebarW) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(16px);
  overflow: auto;
}

.sb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 6px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 30px rgba(37, 99, 235, .20);
  flex: 0 0 auto;
}

.brand strong {
  display: block;
  letter-spacing: .2px;
  font-size: calc(14px + var(--size-bump));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: calc(12px + var(--size-bump));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iconbtn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(2, 6, 23, .06);
  transition: transform .12s ease, background .12s ease;
}

.iconbtn:hover {
  transform: translateY(-1px);
  background: var(--surface2);
}

.sb-group {
  margin-top: 10px;
  padding: 10px 6px;
}

.sb-title {
  font-size: calc(12px + var(--size-bump));
  color: var(--muted);
  letter-spacing: .2px;
  margin: 10px 0 8px;
  padding: 0 6px;
  text-transform: uppercase;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: #1f2937;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.sb-link:hover {
  background: var(--surface);
  border-color: var(--line);
  transform: translateY(-1px);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(37, 99, 235, .25);
  flex: 0 0 auto;
}

.sb-link.primary .dot {
  background: rgba(37, 99, 235, .55);
  box-shadow: 0 0 0 6px rgba(37, 99, 235, .10);
}

.sb-link.is-disabled {
  color: var(--muted);
  cursor: default;
  background: transparent;
  pointer-events: none;
}

.sb-link.is-disabled:hover {
  border-color: transparent;
  transform: none;
  background: transparent;
}

.sb-link.is-disabled .dot {
  background: rgba(15, 23, 42, .18);
  box-shadow: none;
}

/* Collapsed sidebar */
.app.collapsed {
  grid-template-columns: 78px 1fr;
}

.app.collapsed .brand-text,
.app.collapsed .sb-title,
.app.collapsed .sb-link span {
  display: none;
}

.app.collapsed .sb-link {
  justify-content: center;
  padding: 12px 0;
}

/* Main */
.main {
  padding: 24px 0 60px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246, 247, 251, .75);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(15, 23, 42, .06);
}

.topbar-inner {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /* 幅が足りない場合は折り返す */
  gap: 14px;
  padding: 12px 0;
}

.topbar .title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  gap: 2px;
  min-width: 200px;
  /* 極端に潰れないように最小幅を確保 */
  flex: 1 1 auto;
  padding-left: 20px;
}

.topbar .title strong {
  font-size: calc(14px + var(--size-bump));
  letter-spacing: .2px;
  word-break: break-all;
}

.topbar .title small {
  color: var(--muted);
  font-size: calc(12px + var(--size-bump));
  word-break: break-all;
}

.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-controls-left {
  flex: 0 0 auto;
  justify-content: flex-start;
}

.topbar-controls-right {
  flex: 0 0 auto;
  margin-left: auto;
}

.topbar-controls .btn {
  white-space: nowrap;
}

.topbar-controls .btn.topbar-btn-uniform {
  inline-size: 11em;
  min-block-size: 46px;
  padding: 0 12px;
  justify-content: center;
}

/* 解説ページ共通: 本文外（上部ヘッダー） */
:is(.kaisetsu-page, .siryoshu-page) {
  --kaisetsu-title-primary: #6b7280;
  --kaisetsu-title-secondary: #111827;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar-inner {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding-left: 8px;
  padding-right: 8px;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar-controls-left {
  margin-right: 10px;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar .title {
  margin-left: 0;
  margin-right: 0;
  flex: 1 1 auto;
  min-width: 200px;
  align-items: flex-start;
  text-align: left;
  padding-left: 20px;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar-controls-right {
  margin-left: 12px;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar .title strong {
  color: var(--kaisetsu-title-primary);
  font-size: calc(12px + var(--size-bump));
  font-weight: 700;
}

:is(.kaisetsu-page, .siryoshu-page) .topbar .title :is(small, h1) {
  margin: 0;
  padding: 0;
  color: var(--kaisetsu-title-secondary);
  font-size: calc(14px + var(--size-bump));
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
  box-shadow: 0 10px 22px rgba(2, 6, 23, .06);
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--surface2);
}

.hero {
  margin-top: 18px;
  border-radius: calc(var(--r) + 10px);
  border: 1px solid rgba(15, 23, 42, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .85));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero .inner {
  padding: 26px 26px 22px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.2px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: calc(15px + var(--size-bump));
  line-height: 1.8;
}

.highlight {
  background: linear-gradient(90deg, rgba(37, 99, 235, .15), rgba(124, 58, 237, .12));
  border: 1px solid rgba(37, 99, 235, .18);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

section {
  padding: 22px 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: .2px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: calc(13px + var(--size-bump));
  line-height: 1.7;
}

.card {
  border-radius: var(--r);
  border: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 10px 26px rgba(2, 6, 23, .06);
  padding: 18px;
}

.prose {
  color: #0f172a;
  line-height: 1.95;
  font-size: calc(14px + var(--size-bump));
}

.prose p {
  margin: 0 0 12px;
}

.prose p:last-child {
  margin-bottom: 0;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.item {
  display: flex;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, .08);
  background: rgba(241, 243, 249, .75);
}

.date {
  font-weight: 800;
  font-size: calc(12px + var(--size-bump));
  color: #1d4ed8;
  min-width: 92px;
  white-space: nowrap;
}

.desc {
  color: var(--muted);
  font-size: calc(13px + var(--size-bump));
  line-height: 1.8;
}

.links {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.linkcard {
  grid-column: span 4;
  border-radius: var(--r);
  border: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 10px 26px rgba(2, 6, 23, .06);
  padding: 16px;
  transition: transform .12s ease, background .12s ease;
}

.linkcard:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .95);
}

.linkcard h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.linkcard p {
  margin: 0;
  color: var(--muted);
  font-size: calc(12.5px + var(--size-bump));
  line-height: 1.7;
}

.site-footer {
  margin-top: 32px;
  padding: 24px 0 22px;
  color: var(--muted);
  font-size: calc(12px + var(--size-bump));
  border-top: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .6);
}

.footer-inner {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) 1fr;
  gap: 18px 24px;
  align-items: start;
}

.footer-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text);
}

.footer-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 10px 24px rgba(37, 99, 235, .20);
  flex: 0 0 auto;
}

.footer-brand strong {
  display: block;
  font-size: calc(14px + var(--size-bump));
  letter-spacing: .2px;
}

.footer-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: calc(12px + var(--size-bump));
  line-height: 1.6;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 16px 20px;
}

.footer-title {
  font-size: calc(12px + var(--size-bump));
  color: var(--muted);
  letter-spacing: .2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.footer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.footer-link {
  color: var(--text);
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-link.is-disabled {
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}

.footer-bottom {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(15, 23, 42, .08);
  padding-top: 14px;
}

/* Responsive */
@media (max-width: 980px) {

  /* スマホ・タブレット（デフォルトはサイドバーを閉じた状態） */
  .app {
    grid-template-columns: 78px 1fr;
  }

  .brand-text,
  .sb-title,
  .sb-link span {
    display: none;
  }

  .sb-link {
    justify-content: center;
    padding: 12px 0;
  }

  .links {
    grid-template-columns: repeat(12, 1fr);
  }

  .linkcard {
    grid-column: span 12;
  }

  .footer-inner {
    grid-template-columns: 1fr;
  }

  /* ハンバーガーメニュー押下時（.collapsedクラスが付与された時＝スマホでは「開く」挙動にする）
     ※PCでは .collapsed ＝ 閉じる、スマホではアプリの初期状態が狭いため .collapsed で開かせる設計 */
  .app.collapsed {
    /* 画面上にサイドバーを覆い被せる */
    display: block;
  }

  .app.collapsed .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebarW);
    height: 100vh;
    z-index: 1000;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  }

  .app.collapsed .brand-text,
  .app.collapsed .sb-title,
  .app.collapsed .sb-link span {
    display: block;
    /* 中のテキストを再表示 */
  }

  .app.collapsed .sb-link {
    justify-content: flex-start;
    padding: 10px 10px;
  }

  /* サイドバー外側をクリックで閉じれるようにするオーバーレイ */
  .sidebar-overlay {
    display: none;
  }

  .app.collapsed .sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    cursor: pointer;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    flex-wrap: wrap;
  }

  .topbar .title {
    order: 0;
    flex-basis: 100%;
  }

  .topbar-controls-left {
    order: 1;
  }

  .topbar-controls-right {
    order: 2;
    margin-left: 0;
  }

  .topbar-controls .btn.topbar-btn-uniform {
    inline-size: auto;
  }

  :is(.kaisetsu-page, .siryoshu-page) .topbar-controls-right {
    margin-left: 0;
  }

  .footer-nav {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }

  /* スマホの小さな画面でサイドバーを開いた場合、画面全体を覆うようにする */
  .app.collapsed .sidebar {
    width: 100%;
  }
}