@charset "UTF-8";

/* =========================================
   effboki Design System (v4.1 Final)
   コンセプト：機能的ミニマリズムと「空間」と「付箋」の使い分け
   ========================================= */

:root {
  /* --- 🎨 Base Colors (目に優しいスレート基調へ変更) --- */
  --bg-body: #F8FAFC;       /* 背景：真っ白ではなく、ごく薄い青グレー（目の保護） */
  --bg-card: #FFFFFF;       /* コンテンツ背景：白 */
  --text-main: #0F172A;     /* 見出し：ほぼ黒に近い紺色（高級感・可読性） */
  --text-body: #334155;     /* 本文：読みやすいスレートグレー */
  --text-sub: #64748B;      /* 補足：薄すぎないグレー */
  --border: #E2E8F0;        /* 境界線：主張しないグレー */

  /* --- 🟦 Primary (構造・メイン) --- */
  --primary: #2563EB;       /* 知的なブルー */
  --primary-light: #EFF6FF; /* 背景用 */
  --primary-border: #BFDBFE;
  --unit-border: #C7D2E1;   /* Unit card border (muted blue) */
  --unit-border-open: #8FA3BD; /* Unit card open border (muted blue) */

  /* --- 🟩 Definition/Success (定義・正解) --- */
  --def-text: #059669;      /* 落ち着いたグリーン */
  --def-bg: #F2FEF8;
  --def-border: #C8F5E1;

  /* --- 🟥 Alert/Danger (警告・重要) --- */
  --note-warn: #DC2626;     /* 警告の赤 */
  --warn-bg: #FEF2F2;
  --warn-border: #FECACA;

  /* --- 🟧 Hint/Story (ヒント・物語) --- */
  --note-hint: #D97706;     /* 視認性の高いアンバー */
  --hint-bg: #FFFBEB;
  --hint-border: #FDE68A;

  /* --- 🟪 Concept/Mind (概念・思考) --- */
  --mind-text: #4F46E5;     /* インディゴ */
  --mind-bg: #EEF2FF;
  --mind-border: #C7D2FE;

  /* --- Badge Colors --- */
  --badge-high: #BE123C;    /* 頻出・重要 */
  --badge-calc: #047857;    /* 計算注意 */

  /* --- Card Palette (Muted) --- */
  --card-primary: #3E74F2;
  --card-primary-bg: #EFF4FF;
  --card-primary-border: #D8E4FF;
  --card-primary-line: #07123E;
  --card-primary-dash: #2E55C9;
  --card-primary-dash-light: #6D89E4;
  --card-green: #2FAF84;
  --card-green-bg: #EAFBF3;
  --card-green-border: #CDEFE2;
  --card-green-line: #041F18;
  --card-green-dash: #2D8E6C;
  --card-green-dash-light: #66B596;
  --card-orange: #F28A2B;
  --card-orange-bg: #FFEFDD;
  --card-orange-border: #FFD6B3;
  --card-orange-line: #411700;
  --card-orange-dash: #B76A2E;
  --card-orange-dash-light: #D79B63;
  --card-red: #F26666;
  --card-red-bg: #FFEDED;
  --card-red-border: #FFD0D0;
  --card-red-line: #4B1212;
  --card-red-dash: #B94949;
  --card-red-dash-light: #D57777;
  --card-gray: #7F8BA3;
  --card-gray-bg: #F2F4F9;
  --card-gray-border: #DDE4F1;
  --card-gray-line: #6B768D;
  --card-gray-dash: #768CB0;
  --card-gray-dash-light: #93A5C3;
  --card-yellow: #EAB000;
  --card-yellow-bg: #FFF2D5;
  --card-yellow-border: #FFE0A8;
  --card-yellow-line: #352300;
  --card-yellow-dash: #B07B1D;
  --card-outline: #111827;
  --card-yellow-dash-light: #D3A455;

  /* --- Layout --- */
  --sidebar-width: 240px;
  --right-sidebar-width: 280px;
  --book-column-gap: 28px;

  /* --- Sidebar Typography Hierarchy --- */
  --sidebar-caption0-font-size: 1.02rem;
  --sidebar-category-font-size: 0.98rem;
  --sidebar-chapter-font-size: 0.86rem;
  --sidebar-unit-font-size: 0.82rem;
  --sidebar-submenu-font-size: 0.74rem;
  
  /* --- Header Specific --- */
  --header-bg: #42536D;     /* さらに明るめのスレート */
  --header-text: #F8FAFC;   
  --header-border: #566880; 
}

/* Base Settings */
* { box-sizing: border-box; }

html {
  font-size: 15px;
}

body {
  margin: 0; padding: 0;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  
  /* ★重要：数字を等幅にする（簿記の桁揃えのため） */
  font-feature-settings: "palt" 1, "tnum" 1; 
  font-variant-numeric: tabular-nums;
  
  background-color: var(--bg-body);
  color: var(--text-body);
  display: flex; height: 100vh; overflow: hidden;
  font-size: 14px; 
  line-height: 1.75; /* 読みやすさのため少し広めに */
  -webkit-font-smoothing: antialiased;
}

/* テキスト選択時の色をブランドカラーに合わせる */
::selection {
  background: rgba(37, 99, 235, 0.15);
  color: inherit;
}

html.book-view {
  font-size: 14px;
}

summary { outline: none; list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }


/* =========================================
   ① 左サイドバー (Navigation)
   ========================================= */
nav.left-nav {
  width: var(--sidebar-width);
  background: #0F172A; /* より深い色で画面を引き締める */
  color: #E2E8F0;
  display: flex; flex-direction: column; flex-shrink: 0; z-index: 20;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid #000;
  white-space: nowrap; 
  overflow: hidden; 
}

body.book-view nav.left-nav {
  width: 0;
  padding: 0;
  border: none;
  overflow: hidden;
}

body.book-view nav.left-nav .brand-area,
body.book-view nav.left-nav .nav-scroll {
  display: none;
  min-width: 0;
}

.brand-area {
  padding: 16px; font-size: 1.1rem; font-weight: 800; color: #fff;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: #020617;
  min-width: var(--sidebar-width);
}
.brand-icon {
  width: 24px; height: 24px; min-width: 24px;
  background: linear-gradient(135deg, var(--primary), #60A5FA); 
  border-radius: 6px; display: flex; align-items: center; justify-content: center; 
  font-size: 0.8rem; font-weight: bold; color: #fff;
}

.nav-scroll { 
  overflow-y: auto; padding: 12px; flex: 1; 
  min-width: var(--sidebar-width);
}

/* チャプター開閉用 */
.chapter-label {
  font-size: var(--sidebar-chapter-font-size); font-weight: 800; color: #B8D0EF; letter-spacing: 0.04em;
  margin: 16px 0 6px 8px; text-transform: uppercase;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; padding-right: 10px;
  user-select: none;
  line-height: 1.45;
}

.chapter-group.open > .chapter-label {
  color: #E8F2FF;
}

.chapter-group.is-caption-group > .chapter-label,
.chapter-group.is-chapter-group > .chapter-label {
  font-size: var(--sidebar-caption0-font-size);
  font-weight: 900;
  color: #93C5FD;
  letter-spacing: 0.03em;
}

.chapter-group.is-category-group > .chapter-label {
  font-size: var(--sidebar-category-font-size);
  font-weight: 900;
  color: #A7CCFF;
  letter-spacing: 0.02em;
}

.chapter-group.is-caption-group > .chapter-label,
.chapter-group.is-chapter-group > .chapter-label,
.chapter-group.is-category-group > .chapter-label {
  margin-top: 18px;
  margin-bottom: 8px;
}

.chapter-arrow {
  transition: transform 0.3s ease;
  font-size: 0.8em;
  color: currentColor;
  opacity: 0.95;
}
.chapter-group.closed .chapter-arrow { transform: rotate(-90deg); }
.chapter-group.closed .chapter-items { display: none; }

.nav-item {
  display: flex; align-items: center; padding: 8px 10px;
  border-radius: 8px; color: #D3E3FB; text-decoration: none; font-size: var(--sidebar-unit-font-size);
  margin-bottom: 2px; transition: all 0.2s;
  line-height: 1.45;
  font-weight: 700;
  border: 1px solid transparent;
}
.nav-item:hover { background: rgba(121, 171, 255, 0.2); color: #FFFFFF; }
.nav-item.active { 
  background: linear-gradient(135deg, rgba(80, 145, 255, 0.34) 0%, rgba(46, 112, 230, 0.26) 100%);
  color: #F8FCFF;
  font-weight: 900;
  border: 1px solid rgba(155, 199, 255, 0.48);
  box-shadow: 0 8px 16px rgba(9, 31, 73, 0.38);
}

.nav-item.is-home-link {
  min-height: 50px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 1.16rem;
  font-weight: 900;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(86, 151, 255, 0.24) 0%, rgba(44, 108, 226, 0.2) 100%);
  border: 1px solid rgba(134, 188, 255, 0.44);
  box-shadow: 0 8px 18px rgba(8, 28, 67, 0.36);
}

.nav-item.is-home-link:hover {
  background: linear-gradient(135deg, rgba(104, 167, 255, 0.32) 0%, rgba(58, 123, 240, 0.26) 100%);
}

.nav-item.is-home-link .status-icon {
  width: 1.28rem;
  height: 1.28rem;
  min-width: 1.28rem;
  margin-right: 10px;
  border: none;
  background: transparent;
  box-shadow: none;
}

.nav-item.is-home-link.active {
  border-color: rgba(190, 224, 255, 0.65);
  box-shadow: 0 10px 22px rgba(7, 28, 71, 0.44);
}

.status-icon {
  margin-right: 10px; width: 8px; height: 8px; min-width: 8px;
  border: 2px solid #7FA4CF; border-radius: 50%;
}
.nav-item.active .status-icon {
  border-color: #C5E2FF;
  background: #7EC0FF;
  box-shadow: 0 0 0 3px rgba(108, 176, 255, 0.2);
}

.nav-sub-group { margin-left: 20px; padding-left: 10px; border-left: 1px solid #54739F; margin-bottom: 8px; margin-top: 4px; }
.nav-item.active + .nav-sub-group {
  margin-left: 14px;
  padding: 8px 10px;
  border-left-color: #7FB4F4;
  border-radius: 10px;
  background: rgba(88, 138, 221, 0.12);
}
.nav-sub-item {
  display: block; padding: 5px 8px; font-size: var(--sidebar-submenu-font-size); color: #BED4F2; text-decoration: none; transition: color 0.2s, background 0.2s, border-color 0.2s;
  line-height: 1.4;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid transparent;
}
.nav-sub-item:hover {
  color: #FFFFFF;
  background: rgba(107, 164, 255, 0.16);
}
.nav-sub-item.current {
  color: #FFFFFF;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(94, 157, 255, 0.28) 0%, rgba(69, 131, 235, 0.2) 100%);
  border: 1px solid rgba(145, 194, 255, 0.44);
}
.nav-sub-item.current::before { content: none; }

/* -----------------------------------------
   SEO静的サイドバー（JavaScript無効時のフォールバック）
   -----------------------------------------
   目的:
   - HTML初期状態でも内部リンクを並べて、クローラーに構造を伝える
   - JS有効時は createSidebar(...) が nav全体を書き換えるため、この見た目は一瞬のみ
*/
.seo-static-sidebar {
  padding: 14px 12px;
  overflow-y: auto;
  min-width: var(--sidebar-width);
}

.seo-static-sidebar-title {
  margin: 0 0 12px;
  font-size: 0.76rem;
  font-weight: 700;
  color: #93C5FD;
  letter-spacing: 0.03em;
}

.seo-static-sidebar-list,
.seo-static-sidebar-list ul {
  margin: 0;
  padding-left: 14px;
}

.seo-static-sidebar-list > li {
  margin-bottom: 8px;
}

.seo-static-sidebar-list a {
  color: #C7D2FE;
  text-decoration: none;
  font-size: 0.78rem;
  line-height: 1.55;
}

.seo-static-sidebar-list a:hover {
  color: #FFFFFF;
  text-decoration: underline;
}

@media (min-width: 769px) {
  /* デスクトップ: 閉じた状態は「縮小」ではなく完全に閉じる */
  body.sidebar-closed nav.left-nav {
    width: 0;
    border-right: none;
  }

  body.sidebar-closed nav.left-nav .brand-area,
  body.sidebar-closed nav.left-nav .nav-scroll {
    visibility: hidden;
    pointer-events: none;
  }

  nav.left-nav .btn-sidebar-close {
    display: none;
  }
}


/* =========================================
   ② メインレイアウト & ヘッダー
   ========================================= */
.main-wrapper {
  flex: 1; display: flex; flex-direction: column; height: 100vh;
  overflow-y: auto; scroll-behavior: smooth; position: relative;
  background: var(--bg-body);
}

/* ヘッダー背景 */
.sticky-header {
  position: sticky; top: 0; z-index: 50;
  background: transparent; 
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  display: flex; flex-direction: column; 
  pointer-events: none; 
}

/* ヘッダー帯部分 */
.header-container { 
  display: flex; align-items: flex-start; padding: 0 24px; 
  min-height: 60px;
  background: var(--header-bg);
  color: var(--header-text);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  width: 100%;
  pointer-events: auto; 
}

/* ハンバーガーボタン */
.btn-hamburger {
  margin-top: 14px; margin-right: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; 
  color: #E2E8F0;
  flex-shrink: 0; transition: all 0.2s;
}
.btn-hamburger:hover { background: rgba(255,255,255,0.1); color: #fff; }
.icon-menu { font-size: 1.2rem; }

/* 2面表示トグル */
.btn-book-toggle {
  margin-top: 12px;
  margin-left: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  color: #E2E8F0;
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-book-toggle:hover { background: rgba(255,255,255,0.16); color: #fff; }

.btn-book-toggle.is-active {
  background: #fff;
  color: var(--header-bg);
  border-color: #fff;
}

body:not(.sidebar-closed) .btn-book-toggle {
  opacity: 0.9;
}


/* --- モダンなタイトルデザイン --- */
details.header-toggle { flex: 1; margin-top: 8px; }

details.header-toggle summary {
  padding: 8px 12px; 
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 8px;
  transition: background 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
}
details.header-toggle summary:hover { background: rgba(255, 255, 255, 0.08); }

/* タイトル周り */
.header-title-wrapper { display: flex; align-items: center; gap: 10px; }
.title-icon { font-size: 1.2rem; }
.page-title {
  margin: 0; padding: 0;
  font-size: 1.1rem; 
  font-weight: 800;
  color: #fff; 
  line-height: 1.4;
}

/* 右側の開閉ステータス */
.toggle-status { display: flex; align-items: center; gap: 8px; }
.status-text {
  font-size: 0.75rem; 
  color: #fff; 
  font-weight: 700;
  background: var(--primary);
  padding: 4px 10px; border-radius: 20px;
  opacity: 1; transition: opacity 0.2s;
}
details.header-toggle[open] .status-text {
  background: var(--header-border); color: #CBD5E1;
}
.toggle-arrow {
  width: 20px; height: 20px; border-radius: 50%; 
  background: var(--header-border); color: #94A3B8;
  display: flex; align-items: center; justify-content: center; 
  font-size: 0.6rem; 
  transition: transform 0.3s;
}
details.header-toggle[open] .toggle-arrow { 
  transform: rotate(180deg); 
  background: #fff; color: var(--header-bg);
}

.header-content {
  display: flex; gap: 16px; padding: 12px 4px 16px 4px;
  animation: slideDown 0.3s ease-out;
  border-top: 1px dashed rgba(255,255,255,0.2);
  margin-top: 8px;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* スマホ対応 */
@media (max-width: 600px) {
  .page-title { font-size: 0.95rem; }
  .status-text { display: none; }
  .header-content { flex-direction: column; gap: 10px; }
  .btn-book-toggle { display: none; }
}

/* ヘッダーカード */
.concept-card {
  flex: 1; padding: 12px 16px; border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.concept-card.def { background: var(--def-bg); border: 1px solid var(--def-border); }
.concept-card.mind { background: var(--mind-bg); border: 1px solid var(--mind-border); }

.label-jp { font-size: 0.65rem; font-weight: 800; opacity: 0.8; letter-spacing: 0.05em; display: block; }
.concept-card.def .label-jp { color: var(--def-text); }
.concept-card.mind .label-jp { color: var(--mind-text); }

.text-jp { font-size: 0.9rem; font-weight: 700; line-height: 1.5; margin: 0; color: var(--text-main); }


/* =========================================
   ③ コンテンツエリア (Content)
   ========================================= */
.content-flex-container { display: flex; width: 100%; position: relative; }
.center-column { 
  flex: 1; 
  padding: 24px 32px; 
  max-width: 1000px; 
  margin: 0 auto; 
}

/* -----------------------------------------
   SEO/UX パンくず
   -----------------------------------------
   - 章・単元の位置を明示して回遊を増やす
   - 内部リンクを増やしてクロール構造を理解しやすくする
*/
.seo-breadcrumb {
  margin: 4px 0 16px;
}

.seo-breadcrumb ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #64748B;
  font-size: 0.78rem;
}

.seo-breadcrumb li {
  display: inline-flex;
  align-items: center;
}

.seo-breadcrumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: #94A3B8;
}

.seo-breadcrumb a {
  color: #2563EB;
  text-decoration: none;
}

.seo-breadcrumb a:hover {
  text-decoration: underline;
}

.book-spread {
  display: block;
}

.book-page {
  min-width: 0;
}

.book-page-right {
  display: none;
}

.book-scroll {
  height: auto;
  overflow: visible;
}

.book-content {
  min-width: 0;
}

@media (min-width: 769px) {
  body.sidebar-closed.book-view .main-wrapper {
    overflow: hidden;
  }

  body.sidebar-closed.book-view .content-flex-container {
    flex: 1;
    min-height: 0;
  }

  body.sidebar-closed.book-view .center-column {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 8px 24px 16px;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body.sidebar-closed.book-view .book-spread {
    flex: 1;
    display: flex;
    gap: var(--book-column-gap);
    min-height: 0;
    position: relative;
  }

  body.sidebar-closed.book-view .book-page {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body.sidebar-closed.book-view .book-page-right {
    display: flex;
  }

  body.sidebar-closed.book-view .book-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  }

  body.sidebar-closed.book-view .book-page-left .book-scroll {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08), inset -12px 0 18px rgba(15, 23, 42, 0.05);
  }

  body.sidebar-closed.book-view .book-page-right .book-scroll {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08), inset 12px 0 18px rgba(15, 23, 42, 0.05);
  }

  body.sidebar-closed.book-view .book-spread::before {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, transparent, rgba(148, 163, 184, 0.7) 12%, rgba(148, 163, 184, 0.7) 88%, transparent);
    border-radius: 999px;
    pointer-events: none;
  }

  body.sidebar-closed.book-view .book-spread::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 18px;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(37, 99, 235, 0.8);
    border-bottom: 2px solid rgba(37, 99, 235, 0.8);
    transform: translateX(-50%) rotate(45deg);
    animation: book-flow 2.4s ease-in-out infinite;
    pointer-events: none;
  }

  body.sidebar-closed.book-view aside.right-notes {
    width: 220px;
    min-width: 220px;
    padding: 16px 12px;
  }

  body.sidebar-closed.book-view.notes-closed aside.right-notes {
    width: 0;
    min-width: 0;
    padding: 0;
    border: none;
    opacity: 0;
    display: none;
  }

  body.sidebar-closed.book-view .notes-header {
    margin-bottom: 12px;
  }

  body.sidebar-closed.book-view .note-card {
    padding: 10px 12px;
    margin-bottom: 12px;
  }
}

@keyframes book-flow {
  0% { transform: translate(-50%, 0) rotate(45deg); opacity: 0; }
  20% { opacity: 0.9; }
  70% { transform: translate(-50%, 36px) rotate(45deg); opacity: 0.9; }
  100% { transform: translate(-50%, 52px) rotate(45deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body.sidebar-closed.book-view .book-spread::after {
    animation: none;
    opacity: 0.6;
  }
}

.section-title {
  font-size: 1.2rem; font-weight: 800; color: var(--text-main);
  margin-top: 24px; margin-bottom: 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.text-body { font-size: 0.95rem; color: var(--text-body); line-height: 1.75; margin-bottom: 16px; }
.marker { background: linear-gradient(transparent 60%, #FEF08A 60%); font-weight: 700; padding: 0 2px; }
.keyword { font-weight: 800; color: var(--text-main); }


/* --- 大見出しカード (unit-card) --- */
details.unit-card {
  background: var(--bg-card);
  border: 1px solid var(--unit-border); 
  border-radius: 10px;
  margin-bottom: 16px; 
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); 
  overflow: hidden; 
  transition: all 0.3s ease;
}

details.unit-card[open] {
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.1);
  border-color: var(--unit-border-open);
}

summary.unit-summary {
  padding: 12px 16px;
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 12px;
  background: var(--primary-light); 
  border-bottom: 1px solid var(--unit-border);
  transition: background 0.2s;
}

summary.unit-summary:hover { background: #DBEAFE; }

/* アイコン */
.unit-icon {
  width: 26px; height: 26px; border-radius: 6px;
  background: #fff; 
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; 
  font-size: 0.9rem; 
  flex-shrink: 0; 
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* タイトル */
.unit-title { 
  font-size: 1rem; 
  font-weight: 800; 
  color: var(--primary); 
  flex: 1; 
}

.unit-toggle-arrow { transition: transform 0.3s; color: var(--primary); opacity: 0.7; }
details.unit-card[open] .unit-toggle-arrow { transform: rotate(180deg); opacity: 1; }

/* コンテンツ部分の余白 */
.unit-content { padding: 10px 20px 24px 20px; }


/* --- 中見出しカード (section-toggle) --- */
details.section-toggle { 
  margin-top: 16px; border: 1px solid #94A3B8; border-radius: 8px;
  background: #fff; overflow: hidden;
}
summary.section-summary {
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  background: #F1F5F9; 
  transition: all 0.2s; 
  cursor: pointer;
}
summary.section-summary:hover { background: #E2E8F0; }

details.section-toggle[open] summary.section-summary { 
  background: #F1F5F9; 
  border-bottom: 1px solid #94A3B8; 
}

.section-title-wrap { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-body); font-size: 0.95rem; }

.section-number {
  width: 20px; height: 20px; 
  background: #94A3B8; 
  color: #fff;
  border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
}
details.section-toggle[open] .section-number { background: #64748B; }

.section-icon-plus { font-size: 1.1rem; color: #94A3B8; font-weight: 300; line-height: 1; }
.section-icon-plus::after { content: "+"; }
details.section-toggle[open] .section-icon-plus::after { content: "−"; }
details.section-toggle[open] .section-icon-plus { color: #94A3B8; }

.section-inner, .text-content { padding: 12px 20px 20px 20px; background: #fff; }

details.section-toggle.is-highlight {
  border-color: #F59E0B;
  background: #FFFBEB;
}
details.section-toggle.is-highlight summary.section-summary {
  background: #FEF3C7;
}
details.section-toggle.is-highlight summary.section-summary:hover {
  background: #FDE68A;
}
details.section-toggle.is-highlight[open] summary.section-summary {
  border-bottom: 1px solid #F59E0B;
}
details.section-toggle.is-highlight .section-title-wrap {
  color: #B45309;
}
details.section-toggle.is-highlight .section-number {
  background: #F59E0B;
}
details.section-toggle.is-highlight .section-icon-plus {
  color: #B45309;
}
details.section-toggle.is-highlight .section-inner {
  background: #FFFBEB;
}


/* =========================================
   ★小見出しカード (sub-title)
   ========================================= */
h3.sub-title {
  font-size: 1rem;       /* 本文より少し大きく */
  font-weight: 800;      /* 太字で強調 */
  color: var(--text-main);
  border-left: 5px solid #CBD5E1; 
  padding-left: 12px;
  margin-top: 28px;      
  margin-bottom: 12px;   
  line-height: 1.4;
}


/* =========================================
   ★学習用コンポーネント (Learning Parts & Cards)
   ★変更点：FillとBorderの使い分けロジックを追加
   ========================================= */

/* カード名の対応表（プロンプト用）
   大見出しカード: details.unit-card
   中見出しカード: details.section-toggle
   小見出しカード: h3.sub-title
   比較カード: details.compare-box
   縦線カード: .card-border
   縦線背景色カード: .card-border-fill
   背景色カード: .card-fill
   点線背景色カード: .card-fill-dashed
   透明枠カード: .card-outline
*/

/* --- C. Utility Cards (汎用カードクラス) ★NEW --- */

/* 1. 背景色カード (card-fill) */
.card-fill {
  background-color: var(--card-gray-bg); /* グレー */
  border: 1px solid var(--card-gray-border);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.card-fill.is-primary { background-color: var(--card-primary-bg); border-color: var(--card-primary-border); }
.card-fill.is-green { background-color: var(--card-green-bg); border-color: var(--card-green-border); }
.card-fill.is-orange { background-color: var(--card-orange-bg); border-color: var(--card-orange-border); }
.card-fill.is-red { background-color: var(--card-red-bg); border-color: var(--card-red-border); }

/* 2. 縦線カード (card-border) */
.card-border {
  background-color: #fff;
  border: 1px solid var(--border);
  border-left-width: 5px; /* 太い左線 */
  border-left-color: var(--card-gray);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.card-border.is-green { border-left-color: var(--card-green); }
.card-border.is-red   { border-left-color: var(--card-red); }
.card-border.is-primary { border-left-color: var(--card-primary); }
.card-border.is-orange { border-left-color: var(--card-orange); }

/* 3. 縦線背景色カード (card-border-fill) */
.card-border-fill {
  background-color: var(--card-gray-bg);
  border: 1px solid var(--card-gray-border);
  border-left-width: 5px;
  border-right-width: 5px;
  border-left-color: var(--card-gray-dash);
  border-right-color: var(--card-gray-dash);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.card-border-fill.is-primary {
  border-left-color: var(--card-primary-dash);
  border-right-color: var(--card-primary-dash);
  background-color: var(--card-primary-bg);
  border-color: var(--card-primary-border);
}
.card-border-fill.is-green {
  border-left-color: var(--card-green-dash);
  border-right-color: var(--card-green-dash);
  background-color: var(--card-green-bg);
  border-color: var(--card-green-border);
}
.card-border-fill.is-orange {
  border-left-color: var(--card-orange-dash);
  border-right-color: var(--card-orange-dash);
  background-color: var(--card-orange-bg);
  border-color: var(--card-orange-border);
}
.card-border-fill.is-red {
  border-left-color: var(--card-red-dash);
  border-right-color: var(--card-red-dash);
  background-color: var(--card-red-bg);
  border-color: var(--card-red-border);
}

/* 4. 点線背景色カード (card-fill-dashed) */
.card-fill-dashed {
  background-color: var(--card-gray-bg);
  border: 2px dashed var(--card-gray-dash-light);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.card-fill-dashed.is-primary { background-color: var(--card-primary-bg); border-color: var(--card-primary-dash-light); }
.card-fill-dashed.is-green { background-color: var(--card-green-bg); border-color: var(--card-green-dash-light); }
.card-fill-dashed.is-orange { background-color: var(--card-orange-bg); border-color: var(--card-orange-dash-light); }
.card-fill-dashed.is-red { background-color: var(--card-red-bg); border-color: var(--card-red-dash-light); }

/* 5. 透明枠カード (card-outline) */
.card-outline {
  background: transparent;
  border: 1px solid var(--card-outline);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.example-card {
  margin-bottom: 18px;
}

.example-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
}

.example-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 900;
}

.example-note {
  margin-top: 10px;
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.card-demo {
  margin-bottom: 0;
  height: 100%;
}

.card-demo-title {
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.card-demo-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-sub);
}


/* --- 既存コンポーネントへの適用 --- */

/* 1. Story & Formula -> Fill Style */
.story-box { 
  background: var(--hint-bg); border: 1px solid var(--hint-border); border-radius: 8px; 
  padding: 16px 20px; margin-bottom: 16px; 
}
.story-title { font-weight: 800; color: #B45309; margin-bottom: 8px; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }

.formula-box {
  background: var(--primary-light); border: 2px dashed var(--primary-border);
  border-radius: 8px; padding: 16px; text-align: center;
  font-weight: 800; color: var(--primary); font-size: 1rem; margin: 16px 0;
}
.formula-caption { font-size: 0.75rem; color: var(--text-sub); font-weight: normal; margin-top: 4px; display: block; }

/* 2. Practice (練習問題) -> Border Style (Warning) */
.practice-zone { margin-top: 24px; }
details.practice-toggle { 
  background: #fff; border: 1px solid var(--warn-border); border-left: 5px solid var(--note-warn);
  border-radius: 6px; overflow: hidden; margin-bottom: 16px;
}
details.practice-toggle summary {
  padding: 12px 16px; color: var(--note-warn); font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; gap: 8px; transition: background 0.2s; cursor: pointer;
  background: #fff; /* Border styleなので白背景 */
}
details.practice-toggle summary:hover { background: var(--warn-bg); }
.answer-area { padding: 16px; border-top: 1px dashed var(--warn-border); background: #fff; font-family: monospace; font-weight: 700; color: var(--note-warn); font-size: 0.95rem; }

/* 3. Process Flow (手順の流れ図) */
.process-flow {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0;
  counter-reset: flow-step;
}
.flow-step {
  flex: 1; min-width: 140px;
  background: #fff; border: 1px solid var(--border); border-bottom: 3px solid var(--border);
  border-radius: 8px;
  padding: 12px 12px 12px 36px; /* 左側に番号スペース */
  position: relative;
  font-size: 0.85rem; color: var(--text-body); font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.flow-step::before {
  counter-increment: flow-step;
  content: counter(flow-step);
  position: absolute; left: 10px; top: 12px;
  width: 20px; height: 20px;
  background: var(--primary); color: #fff;
  border-radius: 50%; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
/* 矢印（スマホでは下向き、PCでは右向き） */
.flow-step:not(:last-child)::after {
  content: "▶";
  position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
  color: #94A3B8; font-size: 0.8rem; z-index: 1;
}
.process-flow.is-points {
  counter-reset: none;
}
.process-flow.is-points .flow-step {
  padding: 12px;
}
.process-flow.is-points .flow-step::before,
.process-flow.is-points .flow-step::after {
  content: none;
}
.flow-point {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--card-primary-bg);
  border: 1px solid var(--card-primary-border);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.process-flow.is-vertical {
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 820px;
  margin: 20px auto;
}
.process-flow.is-vertical .flow-step {
  width: 100%; min-width: 0;
  display: grid; grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 8px 18px; align-items: start;
  padding-left: 44px;
}
.process-flow.is-vertical .flow-step-title {
  font-size: 0.9rem; font-weight: 800; color: inherit;
}
.process-flow.is-vertical .flow-step-desc { font-size: 0.85rem; line-height: 1.6; color: inherit; }
.process-flow.is-vertical .flow-step-lead { font-weight: 600; }
.process-flow.is-vertical .flow-step-note { font-size: 0.78rem; opacity: 0.8; margin-top: 4px; }
.process-flow.is-vertical .flow-step:not(:last-child)::after {
  content: "▼";
  right: 50%; top: auto; bottom: -18px; transform: translateX(50%);
}
@media (max-width: 720px) {
  .process-flow.is-vertical .flow-step { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 600px) {
  .process-flow { flex-direction: column; gap: 16px; }
  .flow-step:not(:last-child)::after {
    content: "▼"; right: 50%; top: auto; bottom: -18px; transform: translateX(50%);
  }
}

/* 3.5 Closing Transfer (決算振替イメージ) */
.closing-transfer {
  background: #fff;
  border: 1px solid var(--border);
  padding: 24px 18px;
  --closing-transfer-gap: 16px;
  --branch-zero-length: 420px;
  --branch-zero-top: 2px;
  --profit-arrow-up: 260px;
  --profit-arrow-down: 60px;
}
.closing-transfer-row {
  display: grid;
  gap: var(--closing-transfer-gap);
  width: 100%;
}
.closing-transfer-row.is-top,
.closing-transfer-row.is-arrows {
  grid-template-columns: repeat(2, minmax(360px, 1fr));
}
.closing-transfer-row.is-postclose {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  justify-items: center;
  margin-top: 12px;
}
.closing-transfer-row.is-center {
  grid-template-columns: minmax(260px, 1fr);
  justify-items: center;
}
.closing-transfer-node {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.closing-transfer-node.is-wide { max-width: 520px; width: 100%; }
.closing-transfer-node.is-equity { background: var(--card-green-bg); border-color: var(--card-green-border); }
.closing-transfer-title {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-main);
  margin-bottom: 8px;
}
.closing-transfer-note { font-size: 0.75rem; color: var(--text-sub); margin-top: 6px; }
.closing-transfer-sum { font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-top: 4px; }
.closing-transfer-amount { font-weight: 800; font-size: 1rem; color: var(--primary); }
.closing-transfer-arrow {
  text-align: center;
  font-size: 0.8rem;
  color: #64748B;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: visible;
}
.closing-transfer-arrow-sub { font-size: 0.7rem; color: var(--text-sub); font-weight: 600; }
.closing-transfer-arrow-lines { display: grid; gap: 4px; margin: 4px 0; }
.closing-transfer-journal {
  font-size: 0.72rem;
  color: #334155;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
}
.closing-transfer-arrow-note {
  font-size: 0.72rem;
  color: var(--text-body);
  font-weight: 700;
  margin-top: 2px;
}
.closing-transfer-journal-card {
  border: 1px dashed #CBD5E1;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  margin: 6px 0;
  display: grid;
  gap: 4px;
}
.closing-transfer-branch {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin: 2px 0 4px;
  position: relative;
  --branch-zero-offset: 0%;
}
.closing-transfer-branch-to-center,
.closing-transfer-branch-to-zero {
  display: grid;
  justify-items: center;
  gap: 2px;
  color: #64748B;
  font-weight: 700;
}
.closing-transfer-branch-to-zero { grid-column: 2; }
.closing-transfer-branch-to-center {
  grid-column: 3;
  justify-self: end;
}
.closing-transfer-branch.is-right .closing-transfer-branch-to-center {
  grid-column: 1;
  justify-self: start;
}
.closing-transfer-branch.is-left,
.closing-transfer-branch.is-right {
  --branch-zero-offset: 0%;
}
.closing-transfer-branch-label {
  font-size: 0.64rem;
  color: var(--text-sub);
  font-weight: 600;
  line-height: 1;
}
.closing-transfer-arrow-icon.is-diagonal {
  display: inline-block;
  transform: rotate(45deg);
}
.closing-transfer-branch.is-right .closing-transfer-arrow-icon.is-diagonal {
  transform: rotate(-45deg);
}
.closing-transfer-branch-to-zero {
  position: absolute;
  left: calc(50% + var(--branch-zero-offset));
  top: calc(100% + var(--branch-zero-top));
  transform: translateX(-50%);
  width: 2px;
  height: var(--branch-zero-length);
  background: #64748B;
  z-index: 2;
  pointer-events: none;
}
.closing-transfer-branch-to-zero::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #64748B;
}
.closing-transfer-zero {
  border: 1px dashed #E2E8F0;
  border-radius: 10px;
  padding: 6px 8px;
  background: #fff;
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}
.closing-transfer-row.is-postclose .closing-transfer-zero {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
  position: relative;
  z-index: 1;
}
.closing-transfer-arrow.is-profit-link {
  position: relative;
  padding: 6px 0;
}
.closing-transfer-arrow.is-profit-link::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--profit-arrow-up));
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: calc(var(--profit-arrow-up) + var(--profit-arrow-down));
  background: #64748B;
}
.closing-transfer-arrow.is-profit-link::after {
  content: "";
  position: absolute;
  top: calc(var(--profit-arrow-down) - 2px);
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #64748B;
}
.closing-transfer-arrow-label {
  font-size: 0.78rem;
  color: #64748B;
  font-weight: 700;
  background: #fff;
  padding: 0 6px;
  position: relative;
  z-index: 1;
}
.closing-transfer-zero-title {
  font-size: 0.68rem;
  color: var(--text-sub);
  font-weight: 700;
}
.closing-transfer-zero-stack {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
.closing-transfer-taccount.is-zero { max-width: 120px; width: 120px; }
.closing-transfer-taccount.is-zero .taccount-name { font-size: 0.7rem; }
.closing-transfer-taccount.is-zero .taccount-row { font-size: 0.66rem; }
.closing-transfer-taccount.is-zero .taccount-cause { font-size: 0.6rem; }
.closing-transfer-taccount.is-zero .taccount-amount { font-size: 0.72rem; }
.taccount-entry.is-zero .taccount-amount { color: #0F172A; }
.closing-transfer-arrow.is-wide { grid-column: 1 / -1; }
.closing-transfer-arrow-icon { font-size: 1.2rem; line-height: 1; }
.closing-transfer-arrow-icon.is-mini { font-size: 0.9rem; }
.closing-transfer-taccount { margin: 0 auto; max-width: 150px; width: 150px; }
.closing-transfer-row.is-center .closing-transfer-taccount { max-width: 320px; width: 320px; }
.closing-transfer-stack {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: nowrap;
}
.closing-transfer-taccount.is-large .taccount-row { font-size: 0.78rem; }
.closing-transfer-taccount.is-large .taccount-cause { font-size: 0.72rem; }
.closing-transfer-taccount.is-large .taccount-amount { font-size: 0.82rem; }
.closing-transfer .taccount-table {
  overflow: hidden;
  border-radius: 4px;
}
.closing-transfer .taccount-side,
.closing-transfer .taccount-entry,
.closing-transfer .taccount-row {
  min-width: 0;
}
.closing-transfer .taccount-row {
  padding: 0 8px;
  column-gap: 6px;
}
.closing-transfer .taccount-cause,
.closing-transfer .taccount-amount {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}
.taccount-entry.is-empty { color: transparent; }
.taccount-entry.is-profit .taccount-amount { color: #16A34A; }
@media (max-width: 720px) {
  .closing-transfer { --branch-zero-length: 260px; --branch-zero-top: 2px; --profit-arrow-up: 200px; --profit-arrow-down: 50px; }
  .closing-transfer-row.is-top,
  .closing-transfer-row.is-arrows {
    grid-template-columns: 1fr;
  }
  .closing-transfer-row.is-postclose {
    grid-template-columns: 1fr;
  }
  .closing-transfer-stack { flex-wrap: wrap; }
  .closing-transfer-arrow-icon { transform: none; }
  .closing-transfer-branch {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .closing-transfer-branch-to-center,
  .closing-transfer-branch-to-zero {
    grid-column: auto;
    justify-self: center;
  }
  .closing-transfer-branch-to-zero {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    height: 32px;
  }
  .closing-transfer-arrow-icon.is-diagonal { transform: rotate(0deg); }
}

/* 4. Mask (暗記用目隠し) */
.mask {
  background-color: #475569; /* 黒塗り */
  color: transparent;
  padding: 0 4px; border-radius: 4px;
  cursor: pointer; user-select: none;
  transition: all 0.2s ease;
  font-weight: 700;
}
.mask:hover, .mask:active {
  background-color: var(--hint-border); /* 黄色のマーカー風に変化 */
  color: #92400E;
}
/* スマホでタップしやすいように調整 */
@media (hover: none) {
  .mask:active { background-color: var(--hint-border); color: #92400E; }
}

/* 5. Exam Badge (試験対策バッジ) */
.badge-exam {
  display: inline-block; background: var(--badge-high); color: #fff;
  font-size: 0.65rem; padding: 2px 6px; border-radius: 4px;
  margin-right: 6px; vertical-align: middle; font-weight: bold; letter-spacing: 0.05em;
}
.badge-calc {
  background: var(--badge-calc);
}

/* =========================================
   ④ 右サイドバー (Right Sidebar)
   ========================================= */
aside.right-notes {
  width: var(--right-sidebar-width); flex-shrink: 0;
  border-left: 1px solid var(--border); background: #fff;
  height: calc(100vh - 65px); position: sticky; top: 65px;
  padding: 20px; overflow-y: auto; transition: all 0.3s ease;
}

/* 備考ボタンのJS制御で非表示になる時 */
body.notes-closed aside.right-notes {
  width: 0; padding: 20px 0; border: none; opacity: 0;
}

/* 以前の制御（念のため残し） */
aside.right-notes.closed { width: 0; padding: 20px 0; border: none; opacity: 0; }

.notes-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; font-size: 0.7rem; font-weight: 800; color: #94A3B8; letter-spacing: 0.05em;
}
.btn-close {
  background: none; border: none; color: #94A3B8; cursor: pointer;
  font-size: 0.8rem; display: flex; align-items: center; gap: 4px; font-weight: 600;
}
.btn-close:hover { color: var(--text-main); }

/* 右サイドバーのカード（Border Styleを適用） */
.note-card {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 16px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  border-left-width: 4px; border-left-style: solid; font-size: 0.85rem; line-height: 1.6;
}
.note-card.hint { border-left-color: var(--note-hint); }
.note-card.warn { border-left-color: var(--note-warn); }
.note-card.info { border-left-color: var(--primary); }

.note-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 800; margin-bottom: 6px; }
.note-card.hint .note-badge { color: var(--note-hint); }
.note-card.warn .note-badge { color: var(--note-warn); }
.note-card.info .note-badge { color: var(--primary); }

.note-title { display: block; font-size: 0.9rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px; }
.note-desc { font-size: 0.85rem; color: var(--text-sub); line-height: 1.5; margin: 0; }


/* =========================================
   ⑤ ユーティリティ (Utility Classes)
   ========================================= */
.grade-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 20px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.grade-switcher-link {
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  background: #F8FAFC;
  transition: all 0.2s ease;
}

.grade-switcher-link:hover {
  color: var(--text-main);
  background: #fff;
}

.grade-switcher-link.is-current {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

/* --- Grid (レイアウト用グリッド) --- */

/* 2列レイアウト */
.layout-grid-2 {
  display: grid; 
  grid-template-columns: repeat(2, 1fr); /* 2等分 */
  gap: 16px;
  width: 100%; 
  margin-bottom: 24px; 
  align-items: start;
}

/* 3列レイアウト */
.layout-grid-3 {
  display: grid; 
  grid-template-columns: repeat(3, 1fr); /* 3等分 */
  gap: 16px;
  width: 100%; 
  margin-bottom: 24px; 
  align-items: start;
}

/* スマホ対応（画面が狭い時は全部1列にする） */
@media (max-width: 768px) {
  .layout-grid-2, 
  .layout-grid-3 { 
    grid-template-columns: 1fr; /* 1列に崩す */
  }
}

/* --- Journal Entry (仕訳：修正完了版) --- */
.journal-grid {
  --journal-col-min: 130px;
  --journal-col-gap: clamp(10px, 3vw, 7ch);
  --journal-bottom-gap: 14px;
  --journal-group-gap: 10px;
  --journal-row-gap: 4px;
  --journal-row-attr-gap: 8px;
  --journal-paren-pad: 1em;
  display: flex;
  flex-wrap: wrap; 
  width: 100%;
  max-width: 600px; 
  margin: 10px auto 0; 
  padding-bottom: var(--journal-bottom-gap);
  justify-content: center; 
  align-items: stretch;
  row-gap: 10px;
  column-gap: var(--journal-col-gap);
}

.journal-grid > div {
  /* 幅が足りない時でも文字サイズに合わせる（min-width: 0を削除） */
  flex: 1 0 var(--journal-col-min); 
  display: flex;
  flex-direction: column;
}

/* 比較カード内の仕訳はスマホと同じ間隔ルールにする */
.journal-grid.journal-compact {
  max-width: none;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  flex-wrap: nowrap;
  --journal-col-min: 0px;
  column-gap: min(var(--journal-col-gap), 5em);
}

.journal-grid.journal-compact:not(.is-stacked) > div {
  flex: 0 0 auto;
}

.journal-grid.journal-compact.journal-bleed {
  width: calc(100% + var(--journal-bleed-left, 0px) + var(--journal-bleed-right, 0px));
  margin-left: calc(-1 * var(--journal-bleed-left, 0px));
  margin-right: calc(-1 * var(--journal-bleed-right, 0px));
}

/* Stack when two columns cannot fit on one line */
.journal-grid.is-stacked {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.journal-grid.is-stacked > div {
  flex: 0 0 auto;
  width: 100%;
}

/* 1. 借方（左側） */
.journal-grid > div:nth-child(1) {
  align-items: flex-end; /* 中央寄りに寄せて隙間を一定化 */
}

/* 2. 貸方（右側） */
.journal-grid > div:nth-child(2) {
  align-items: flex-start; /* 中央寄りに寄せて隙間を一定化 */
  margin-left: 0;
  border-left: none;
}

/* Stack時は外側に寄せる */
.journal-grid.is-stacked > div:nth-child(1) {
  align-items: flex-start;
  order: 1;
}

.journal-grid.is-stacked > div:nth-child(2) {
  align-items: flex-end;
  order: 2;
}

/* Legacy padding for non-group rows */
.journal-grid > div:not(.journal-group):nth-child(1) {
  padding-right: 5px;
}

.journal-grid > div:not(.journal-group):nth-child(2) {
  padding-left: 5px;
}

/* Remove column padding when stacked */
.journal-grid.is-stacked > div:not(.journal-group):nth-child(1),
.journal-grid.is-stacked > div:not(.journal-group):nth-child(2) {
  padding-left: 0;
  padding-right: 0;
}

/* Grouped rows (for compound entries) */
.journal-group {
  align-self: stretch;
}

.journal-group-inner {
  display: inline-grid;
  grid-template-columns: var(--journal-label-width, max-content) var(--journal-account-width, max-content) var(--journal-amount-width, max-content);
  column-gap: var(--journal-group-gap);
  row-gap: var(--journal-row-gap);
  align-items: baseline;
}

.journal-grid.journal-no-label .journal-group-inner {
  grid-template-columns: var(--journal-account-width, max-content) var(--journal-amount-width, max-content);
}

.journal-row {
  display: contents;
}

.journal-row.has-attr:not(:last-child) > .journal-label,
.journal-row.has-attr:not(:last-child) > .journal-account,
.journal-row.has-attr:not(:last-child) > .journal-amount {
  margin-bottom: var(--journal-row-attr-gap);
}

.journal-label {
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  white-space: nowrap;
}

.journal-label.is-empty {
  visibility: hidden;
}

.journal-grid.journal-no-label .journal-label {
  display: none;
}

.journal-account {
  position: relative;
  padding: 0 var(--journal-paren-pad);
  text-align: center;
  white-space: nowrap;
}

.journal-account::before,
.journal-account::after {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  font-weight: inherit;
  color: inherit;
}

.journal-account::before {
  content: "（";
  left: 0;
}

.journal-account::after {
  content: "）";
  right: 0;
}

.journal-amount {
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  position: relative;
  padding-right: 0;
  min-width: 0;
  justify-self: stretch;
}

/* --- 金額の下に補足文字を入れる --- */
.amount-stack {
  display: inline-flex;
  position: relative;
  justify-content: flex-end;
  text-align: right;
  flex-direction: row;
}

.amount-stack small,
.amount-stack span.attr {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.7em;
  color: var(--text-sub);
  font-weight: normal;
  line-height: 1;
  padding-top: 1px;
}

/* --- 金額の右に注記マークを付ける --- */
.amount-mark {
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: inherit;
  position: absolute;
  right: 0;
  top: 0;
  line-height: 1;
}

/* --- 左端の仕訳番号 --- */
.journal-label.journal-index {
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 1.6em;
  color: var(--text-main);
}

.journal-grid.journal-has-amount-mark .journal-amount {
  padding-right: 1.4em;
}

/* --- 横一列に揃える設定 --- */
.journal-grid > div:not(.journal-group) > div {
  align-items: baseline !important; 
  margin-bottom: 18px; 
  display: inline-flex;
  /* ★修正: 文字（科目+金額）は絶対に折り返さない */
  flex-wrap: nowrap; 
  white-space: nowrap; 
  gap: 6px;
}

/* --- 勘定科目と属性のスタック設定 --- */
.account-stack {
  display: inline-flex;
  position: relative; 
  justify-content: center;
  text-align: center;
  flex-direction: row; 
  /* ★属性が長い場合に備えて行間に少し余裕を持つ */
  line-height: 1.2;
}

/* --- 属性（(資産)など）を絶対配置で下にぶら下げる --- */
.account-stack small, 
.account-stack span.attr {
  position: absolute;       
  top: 100%;                
  left: 50%;                
  transform: translateX(-50%); 
  white-space: nowrap;      
  
  font-size: 0.7em;         
  color: var(--text-sub);
  font-weight: normal;
  line-height: 1;
  padding-top: 1px;         
}

.account-stack small::before,
.account-stack small::after,
.account-stack span.attr::before,
.account-stack span.attr::after {
  content: "-";
}


/* スマホ調整 */
@media (max-width: 450px) {
  .journal-grid {
    max-width: none;
    flex-wrap: nowrap;
    --journal-group-gap: 3px;
    --journal-col-min: 0px;
    column-gap: min(var(--journal-col-gap), 5em);
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .journal-grid:not(.is-stacked) > div {
    flex: 0 0 auto;
  }

  .journal-grid.journal-bleed {
    width: calc(100% + var(--journal-bleed-left, 0px) + var(--journal-bleed-right, 0px));
    margin-left: calc(-1 * var(--journal-bleed-left, 0px));
    margin-right: calc(-1 * var(--journal-bleed-right, 0px));
  }

  .journal-grid:not(.is-stacked) > div:nth-child(1) {
    align-items: flex-start;
  }

  .journal-grid:not(.is-stacked) > div:nth-child(2) {
    align-items: flex-end;
  }
}

/* --- Images --- */
.img-box {
  width: 100%; border-radius: 8px; border: 1px solid var(--border);
  overflow: hidden; margin-bottom: 20px; background: #fff;
  padding: 20px; display: flex; justify-content: center;
}
.img-box svg, .img-box img { width: 100%; height: auto; display: block; }
.slide-caption {
  font-size: 0.8rem; color: var(--text-sub); text-align: center;
  padding: 8px; background: #F9FAFB; border-top: 1px solid var(--border);
}

/* --- Tables (集計表：修正完了版) --- */
.comparison-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 0.9rem; }
.comparison-table th, .comparison-table td { border: 1px solid var(--border); padding: 10px 12px; }
.comparison-table th { background: #F3F4F6; color: var(--text-main); font-weight: 800; width: 30%; }
.comparison-table td { background: #fff; color: var(--text-body); }

/* ゼブラストライプ（1行おきに色を変える）★NEW */

/* --- T Account (Reusable) --- */
.taccount {
  --taccount-border: #334155;
  --taccount-range: 120px;
  --taccount-min-height: 12px;
  --taccount-max: 100;
  --taccount-date-width: 2.8em;
  --taccount-cause-width: 1fr;
  --taccount-amount-width: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.taccount-name {
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #0F172A;
}
.taccount-table {
  display: flex;
  align-items: flex-start;
  position: relative;
}
.taccount-table::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--taccount-border);
  transform: translateX(-1px);
}
.taccount-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-top: 2px solid var(--taccount-border);
  border-bottom: 2px solid var(--taccount-border);
}
.taccount-side.is-left {
  border-left: 2px solid var(--taccount-border);
  border-right: 0;
}
.taccount-side.is-right {
  border-right: 2px solid var(--taccount-border);
  border-left: 0;
}
.taccount-side.is-empty {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  background: transparent;
}
.taccount-side.is-strong {
  border-width: 3px;
}
.taccount-side.is-fixed {
  height: var(--side-height);
}
.taccount-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--taccount-border);
  background: var(--entry-bg, transparent);
  height: calc((var(--value) / var(--taccount-max)) * var(--taccount-range) + var(--taccount-min-height));
}
.taccount-entry:first-child { border-top: none; }
.taccount-side.is-fixed .taccount-entry {
  height: auto;
  flex: var(--weight, var(--value, 1));
  min-height: var(--taccount-min-height);
}
.taccount-entry.is-strong {
  box-shadow: inset 0 0 0 2px var(--taccount-border);
}
.taccount-row {
  display: grid;
  grid-template-columns: var(--taccount-date-width) minmax(2.6em, var(--taccount-cause-width)) var(--taccount-amount-width);
  width: 100%;
  align-items: center;
  column-gap: 6px;
  padding: 0 8px;
  font-size: 0.72rem;
  color: #334155;
  font-weight: 700;
}
.taccount-row.is-no-date {
  grid-template-columns: minmax(2.6em, var(--taccount-cause-width)) var(--taccount-amount-width);
}
.taccount-row.is-no-date .taccount-date { display: none; }
.taccount-date { font-size: 0.62rem; color: #475569; text-align: left; }
.taccount-cause { font-size: 0.7rem; color: #334155; white-space: nowrap; word-break: keep-all; text-align: center; }
.taccount-amount { font-size: 0.78rem; font-weight: 800; color: #0F172A; text-align: right; }
.taccount.is-retained-earnings {
  transform: scale(1.03, 1.12);
  transform-origin: top center;
}
.taccount-totals {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  gap: 8px;
}
.taccount-total {
  flex: 1;
  text-align: center;
}

.taccount-wrap {
  position: relative;
  display: inline-block;
}
.taccount-bracket {
  position: absolute;
  left: calc(100% + 10px);
  top: var(--bracket-top, 0px);
  height: var(--bracket-height, 40px);
  border-right: 2px solid var(--taccount-border);
}
.taccount-bracket::before,
.taccount-bracket::after {
  content: "";
  position: absolute;
  right: -2px;
  width: 14px;
  border-top: 2px solid var(--taccount-border);
}
.taccount-bracket::before { top: 0; }
.taccount-bracket::after { bottom: 0; }
.taccount-bracket-label {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: #334155;
  white-space: nowrap;
}

/* --- 勘定科目紹介t字勘定 (Reusable) --- */
.勘定科目紹介t字勘定 {
  --kanjo-home-extra-height: 10px;
  --kanjo-liability-offset-x: -14px;
}
.勘定科目紹介t字勘定 .taccount-preview-card {
  margin-top: 14px;
  margin-bottom: 10px;
}
.勘定科目紹介t字勘定 .taccount-preview-title {
  font-weight: 900;
  color: #0f172a;
}
.勘定科目紹介t字勘定 .taccount-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin: 0 0 16px;
}
.勘定科目紹介t字勘定 .taccount-quick-item {
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount {
  width: 100%;
  min-width: 0;
  --taccount-min-height: 18px;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-name {
  font-size: 0.9rem;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-table {
  align-items: flex-start;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-side.is-fixed {
  height: var(--quick-away-height, 44px);
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-side.is-home.is-fixed {
  height: calc(var(--quick-home-height, 72px) + var(--kanjo-home-extra-height));
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-side.is-home .taccount-entry {
  background: #dbeafe;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount.is-liability .taccount-side.is-home .taccount-entry {
  background: #fee2e2;
}
.勘定科目紹介t字勘定 .taccount-quick-item .taccount-cause {
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  font-size: 0.72rem;
  text-align: left;
  padding: 0 6px;
}
.勘定科目紹介t字勘定 .taccount-quick-diff {
  position: absolute;
  top: var(--quick-away-height, 44px);
  left: calc(50% - 1px);
  height: calc(var(--quick-home-height, 72px) + var(--kanjo-home-extra-height) - var(--quick-away-height, 44px));
  width: 0;
  pointer-events: none;
  z-index: 3;
}
.勘定科目紹介t字勘定 .taccount-quick-diff-brace {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 100%;
  line-height: 1;
  font-family: "Courier New", "Consolas", "SFMono-Regular", monospace;
  font-size: calc(var(--quick-home-height, 72px) + var(--kanjo-home-extra-height) - var(--quick-away-height, 44px) + 6px);
  font-weight: 400;
  text-align: center;
  color: #475569;
}
.勘定科目紹介t字勘定 .taccount-quick-diff-brace::before {
  content: "}";
}
.勘定科目紹介t字勘定 .taccount-quick-diff-brace::after {
  content: none;
}
.勘定科目紹介t字勘定 .taccount-quick-diff.is-right .taccount-quick-diff-brace::before {
  content: "{";
}
.勘定科目紹介t字勘定 .taccount-quick-diff-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  line-height: 1.1;
  font-size: 0.78rem;
  font-weight: 800;
  color: #334155;
}
.勘定科目紹介t字勘定 .taccount-quick-diff.is-left .taccount-quick-diff-label {
  left: 14px;
  text-align: left;
}
.勘定科目紹介t字勘定 .taccount-quick-diff.is-right .taccount-quick-diff-label {
  right: 14px;
  text-align: right;
}
.comparison-table tr:nth-child(even) td {
  background-color: #F9FAFB;
}
/* ホバーで行を強調 */
.comparison-table tr:hover td {
  background-color: #EFF6FF;
}
/* 数値セル専用クラス（右寄せ＋等幅フォント）★NEW */
.td-num {
  text-align: right;
  font-family: 'Roboto Mono', monospace; 
  letter-spacing: 0.05em;
}

/* --- Textbook Account (教科書風勘定) --- */
.textbook-account {
  --tb-line: #334155;
  --tb-muted: #64748B;
  --tb-row-height: 22px;
  font-family: "Noto Sans JP", sans-serif;
  color: #0F172A;
  max-width: 640px;
  margin: 0 auto;
}
.textbook-account-title {
  text-align: center;
  font-weight: 800;
  margin-bottom: 6px;
}
.textbook-account-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 0.75rem;
  color: var(--tb-muted);
  margin-bottom: 4px;
}
.textbook-account-head-cell {
  text-align: center;
}
.textbook-account-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 2px solid var(--tb-line);
  position: relative;
}
.textbook-account-body::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--tb-line);
  transform: translateX(-1px);
}
.textbook-account-side {
  padding: 6px 8px;
  display: grid;
  row-gap: 4px;
}
.textbook-account-row {
  display: grid;
  grid-template-columns: 44px 1fr 72px;
  column-gap: 6px;
  align-items: center;
  height: var(--tb-row-height);
  line-height: var(--tb-row-height);
  font-size: 0.8rem;
}
.textbook-account-row .amount {
  text-align: right;
  font-weight: 700;
}
.textbook-account-blank.is-slash {
  height: calc(var(--tb-row-height) * var(--tb-slash-rows, 2));
  position: relative;
}
.textbook-account-blank.is-slash::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border-top: none;
  background: linear-gradient(to top right, transparent 49.2%, var(--tb-line) 49.6%, var(--tb-line) 50.4%, transparent 50.8%);
}
.textbook-account-sum {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.textbook-account-sum-side {
  padding: 0 8px 6px;
}
.textbook-account-sum-line {
  border-top: 1px solid var(--tb-line);
  margin-top: 6px;
}
.textbook-account-sum-row {
  display: grid;
  grid-template-columns: 44px 1fr 72px;
  column-gap: 6px;
  align-items: center;
  margin-top: 4px;
  font-size: 0.8rem;
}
.textbook-account-sum-row .amount {
  text-align: right;
  font-weight: 700;
}
.textbook-account-close {
  border-top: 3px double var(--tb-line);
  margin-top: 6px;
}
.textbook-account.is-no-total .textbook-account-sum-line,
.textbook-account.is-no-total .textbook-account-sum-row {
  display: none;
}
.textbook-account.is-no-close .textbook-account-close {
  display: none;
}
.textbook-account.is-no-slash .textbook-account-blank.is-slash {
  display: none;
}
.textbook-account.is-one-line .textbook-account-sum-line,
.textbook-account.is-one-line .textbook-account-sum-row {
  display: none;
}
.textbook-account.is-one-line .textbook-account-close {
  margin-top: 4px;
}
.textbook-account-row.is-blue { background: #DBEAFE; }
.textbook-account-row.is-yellow { background: #FEF3C7; }
.textbook-account-row.is-green { background: #DCFCE7; }
.textbook-account-row.is-gray { background: #F1F5F9; }


/* =========================================
   ⑥ 比較カード (compare-box) - Collapsible
   ========================================= */
details.compare-box {
  background: #fff; 
  border: 1px solid #E5E7EB; 
  border-radius: 8px;
  overflow: hidden; 
  display: flex; flex-direction: column;
  height: auto; 
  margin-bottom: 0; 
}

summary.compare-header {
  padding: 10px 16px; 
  font-weight: 800; 
  font-size: 0.9rem;
  border-bottom: 1px solid transparent; 
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s;
}

details.compare-box[open] summary.compare-header {
  border-bottom-color: #E5E7EB;
}

summary.compare-header::after {
  content: "▼";
  font-size: 0.75rem;
  margin-left: 10px;
  transition: transform 0.3s ease;
  opacity: 0.5;
}
details.compare-box:not([open]) summary.compare-header::after {
  transform: rotate(-90deg);
}

/* ★修正ポイント: 比較カード内部の上部余白を減らす (16px -> 10px) */
.compare-content { padding: 10px 16px 16px 16px; background: #fff; }

/* バリエーション（色） */
details.compare-box.gray summary.compare-header {
  background: var(--card-gray-bg);
  color: var(--card-gray);
  border-top: 4px solid var(--card-gray);
}
details.compare-box.red summary.compare-header {
  background: var(--card-red-bg);
  color: var(--card-red);
  border-top: 4px solid var(--card-red);
}
details.compare-box.green summary.compare-header {
  background: var(--card-green-bg);
  color: var(--card-green);
  border-top: 4px solid var(--card-green);
}
details.compare-box.yellow summary.compare-header {
  background: var(--card-yellow-bg);
  color: var(--card-yellow);
  border-top: 4px solid var(--card-yellow);
}


/* =========================================
   ⑦ 備考ボタン (Improved - Hanging Style)
   ========================================= */

/* ボタンを包むエリア（ヘッダーの下にぶら下がる） */
.notes-toggle-area {
  width: 100%;
  display: none; 
  justify-content: flex-end; 
  padding: 0 24px;
  background: transparent; 
  pointer-events: none; 
}

body.notes-closed .notes-toggle-area {
  display: flex;
  animation: slideDownFade 0.3s ease;
}

/* ボタン本体のデザイン */
.btn-notes-toggle {
  pointer-events: auto; 
  margin-top: 10px; 
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08); 
  transition: all 0.2s;
}

.btn-notes-toggle:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-2px); 
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}


/* =========================================
   ⑧ スマホ対応（★重要修正ポイント）
   ========================================= */
@media (max-width: 768px) {

  :root {
    --sidebar-caption0-font-size: 0.98rem;
    --sidebar-category-font-size: 0.94rem;
    --sidebar-chapter-font-size: 0.84rem;
    --sidebar-unit-font-size: 0.8rem;
    --sidebar-submenu-font-size: 0.73rem;
  }

  .nav-item.is-home-link {
    min-height: 46px;
    padding: 9px 12px;
    font-size: 1.06rem;
  }

  html { font-size: 14px; }
  body { font-size: 13px; }
  
  /* 1. 左サイドバーをフローから除外する（重要！） */
  /* ★修正: PC用の「閉じた時 width: 0」を無効化し、幅を確保 */
  body.sidebar-closed nav.left-nav,
  nav.left-nav {
    position: fixed; 
    top: 0; left: 0; bottom: 0;
    width: 240px; 
    transform: translateX(-100%); /* 普段は隠す */
    z-index: 1000;
    transition: transform 0.3s ease;
    border-right: 1px solid #000;
    padding: 0;
  }
  
  /* 左サイドバーを開いた時のスタイル（JSで制御想定） */
  body.sidebar-open nav.left-nav {
    transform: translateX(0);
  }
  body.sidebar-open .btn-sidebar-close {
    display: flex;
  }

  /* 2. メインラッパーを横スクロール可能に */
  .main-wrapper {
    width: 100%; 
    overflow-x: auto; 
  }

  /* 3. コンテンツコンテナの幅設定 */
  .content-flex-container {
    width: max-content; /* 中身に合わせて幅を広げる（備考がある時用） */
    min-width: 100%;
  }

  /* 4. メインカラム（教科書本文）の設定 */
  .center-column {
    /* 備考が開いている時（デフォルト）：画面幅いっぱいに固定 */
    width: 100vw; 
    min-width: 100vw;
    flex-shrink: 0; 
    padding: 20px 16px;
  }

  /* 5. 右サイドバー（備考） */
  aside.right-notes {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    height: auto; 
    border-left: 1px solid #E5E7EB;
  }
  
  /* 6. ★重要：備考が閉じている時のリセット処理 */
  body.notes-closed .content-flex-container {
    width: 100%; /* コンテナを画面幅に合わせる */
  }
  
  body.notes-closed .center-column {
    /* ここがポイント：固定幅(100vw)を解除し、親に合わせる */
    width: 100%; 
    min-width: 0;
  }
  
  /* 念のため非表示 */
  body.notes-closed aside.right-notes {
    display: none;
  }
  
  /* 7. 黒い背景（オーバーレイ）の追加 */
  body.sidebar-open::after {
    content: "";
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900; 
    pointer-events: auto;
  }
}

@media (max-width: 600px) {
  .center-column { padding: 16px 10px; }

  details.unit-card { margin-bottom: 12px; }
  summary.unit-summary { padding: 10px 12px; }
  .unit-content { padding: 8px 12px 16px 12px; }

  .layout-grid-2,
  .layout-grid-3 {
    gap: 10px;
    margin-bottom: 16px;
  }

  details.section-toggle { margin-top: 12px; }
  summary.section-summary { padding: 10px 12px; }
  .section-inner,
  .text-content { padding: 10px 12px 16px 12px; }

  summary.compare-header { padding: 8px 12px; }
  .compare-content { padding: 8px 12px 12px 12px; }
}

/* =========================================
   ⑨ 印刷設定（Print Layout）
   教科書として印刷・PDF化する際の最適化
   ========================================= */
@media print {
  /* 不要なUIを非表示 */
  nav.left-nav,
  .sticky-header,
  .btn-notes-toggle,
  .notes-toggle-area,
  .btn-hamburger,
  .btn-book-toggle {
    display: none !important;
  }

  /* レイアウトのリセット */
  body, html, .main-wrapper, .content-flex-container {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
    font-size: 11pt; /* 印刷用の読みやすいサイズ */
    background: #fff !important;
  }

  .center-column {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 備考（右サイドバー）の扱い：印刷時は末尾にまとめるか非表示にする */
  aside.right-notes {
    display: none !important;
  }

  /* インク節約と視認性 */
  details {
    break-inside: avoid; /* 途中でページが切れないように */
  }
  
  details[open] summary {
    border-bottom: 1px solid #000;
  }

  /* リンクの色を黒にして下線を消す */
  a { text-decoration: none; color: #000; }
  
  /* 背景色の調整（薄い色は印刷で消えることがあるため枠線を強化） */
  .story-box, .formula-box, .unit-card, .section-toggle, .flow-step, .card-fill, .card-border {
    border: 1px solid #000 !important;
    background: none !important;
    color: #000 !important;
    box-shadow: none !important;
  }
}

/* =========================================
   ⑨ Public Pages (Home / Preview / Dictionary / Gate)
   ========================================= */
body.public-page {
  display: block;
  height: auto;
  overflow: auto;
  background: var(--bg-body);
}

.public-shell {
  min-height: 100vh;
}

.public-container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.public-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #0F172A;
  color: #E2E8F0;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
}

.public-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}

.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1rem;
  color: #F8FAFC;
  text-decoration: none;
}

.public-brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563EB, #60A5FA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
}

.public-nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.public-nav-links a {
  color: #E2E8F0;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.public-nav-links a:hover {
  border-color: rgba(148, 163, 184, 0.5);
  background: rgba(148, 163, 184, 0.12);
}

.public-hero {
  background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 50%, #2563EB 100%);
  color: #F8FAFC;
  padding: 72px 0 48px;
}

.public-hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: center;
}

.public-hero h1 {
  margin: 0 0 12px;
  font-size: 2.1rem;
  letter-spacing: 0.02em;
}

.public-hero p {
  margin: 0 0 16px;
  color: #E2E8F0;
}

.public-hero-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.2);
}

.public-section {
  padding: 48px 0;
}

.public-section.alt {
  background: #F1F5F9;
}

.public-section h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
  color: var(--text-main);
}

.public-section p {
  margin: 0 0 12px;
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.public-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.public-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  color: var(--text-main);
}

.public-card p {
  margin: 0 0 10px;
  color: var(--text-body);
}

.public-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1E40AF;
  background: #DBEAFE;
  border-radius: 999px;
  padding: 4px 10px;
}

.public-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #065F46;
  background: #D1FAE5;
  border-radius: 999px;
  padding: 4px 8px;
}

.public-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.public-btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 16px rgba(37, 99, 235, 0.25);
}

.public-btn.primary:hover {
  filter: brightness(1.05);
}

.public-btn.outline {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff;
}

.public-btn.ghost {
  border-color: rgba(148, 163, 184, 0.5);
  color: #334155;
  background: transparent;
}

.public-btn + .public-btn {
  margin-left: 8px;
}

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

.public-list li {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-body);
}

.public-cta {
  padding: 32px 0 64px;
}

.public-footer {
  padding: 24px 0 40px;
  color: #64748B;
  font-size: 0.85rem;
  text-align: center;
}

.public-inline-note {
  font-size: 0.85rem;
  color: #64748B;
}

@media (max-width: 860px) {
  .public-container {
    width: min(1100px, calc(100% - 24px));
  }

  .public-nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 0 12px;
  }

  .public-brand {
    justify-content: center;
  }

  .public-nav-links {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    margin: 0 -2px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .public-nav-links::-webkit-scrollbar {
    height: 5px;
  }

  .public-nav-links::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
  }

  .public-nav-links a {
    white-space: nowrap;
    flex: 0 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid rgba(148, 163, 184, 0.46);
    background: rgba(148, 163, 184, 0.16);
  }

  .public-hero {
    padding: 54px 0 38px;
  }

  .public-hero-grid {
    gap: 16px;
  }

  .public-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .public-hero {
    padding: 44px 0 30px;
  }

  .public-hero h1 {
    font-size: clamp(1.5rem, 8vw, 1.88rem);
    line-height: 1.42;
  }

  .public-hero-card,
  .public-card {
    padding: 14px;
  }

  .public-section {
    padding: 34px 0;
  }

  .public-cta {
    padding: 28px 0 44px;
  }

  .public-btn {
    width: 100%;
  }

  .public-btn + .public-btn {
    margin-left: 0;
    margin-top: 8px;
  }
}
