/* ===========================
   Base Variables
   =========================== */
:root {
    --primary: #42a4af;
    --primary-dark: #357a82;
    --primary-light: #e8f4f5;
    --hirogeru: #ff8c42;
    --hirogeru-dark: #c66a2e;
    --hirogeru-light: #fff1e6;
    --text: #333333;
    --text-light: #666666;
    --bg: #ffffff;
    --border: #e0e0e0;
    --gray-bg: #f8f9fa;
}

/* ===========================
   Reset & Base
   =========================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Arial, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    line-height: 1.8;
    font-size: 15px;
}

/* ===========================
   Header
   =========================== */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 60px 20px;
    text-align: center;
}
header h1 { margin: 0; font-size: 2.2rem; font-weight: 800; }
header p { margin-top: 10px; opacity: 0.9; font-size: 14px; }

/* ===========================
   Navigation (Sticky)
   =========================== */
nav {
    background: #f8f9fa;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
nav ul {
    display: flex;
    justify-content: center;
    gap: 8px;
    list-style: none;
    flex-wrap: wrap;
    max-width: 1100px;
    margin: 0 auto;
}
nav a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}
nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
}
nav a.active {
    color: #fff;
    background: var(--primary);
}
nav a.ln-eraberu { border-left: 3px solid var(--primary); padding-left: 9px; }
nav a.ln-hirogeru { border-left: 3px solid var(--hirogeru); padding-left: 9px; }
nav a.ln-hirogeru:hover { color: var(--hirogeru); background: var(--hirogeru-light); }
nav a.ln-hirogeru.active { color: #fff; background: var(--hirogeru); }

/* ===========================
   Main Content
   =========================== */
.container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
}

/* ===========================
   Collapsible Sections
   =========================== */
h2 {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-top: 56px;
    margin-bottom: 24px;
    font-size: 1.6rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.collapse-icon {
    font-size: 14px;
    color: var(--text-light);
    transition: transform .3s;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light);
    border-radius: 50%;
    flex-shrink: 0;
}
.section-block.collapsed .collapse-icon { transform: rotate(-90deg); }
.section-block.collapsed .section-content {
    max-height: 0; overflow: hidden; opacity: 0;
}
.section-content {
    max-height: 50000px; overflow: hidden; opacity: 1;
    transition: max-height .4s ease, opacity .3s ease;
}

/* Brand badge on H2 */
.brand-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    color: white;
    letter-spacing: 0.05em;
}
.brand-badge.brand-eraberu { background: var(--primary); }
.brand-badge.brand-hirogeru { background: var(--hirogeru); }

/* H2 with hirogeru badge */
.section-block h2:has(.brand-hirogeru) {
    color: var(--hirogeru-dark);
    border-bottom-color: var(--hirogeru);
}
.section-block h2:has(.brand-hirogeru) .collapse-icon {
    background: var(--hirogeru-light);
}

/* Toggle All */
.toggle-all-bar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.toggle-all-btn {
    padding: 6px 16px; border: 1px solid var(--border); background: #fff;
    color: var(--text-light); font-size: 12px; font-weight: 600;
    border-radius: 6px; cursor: pointer; transition: all .2s;
}
.toggle-all-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ===========================
   Typography
   =========================== */
h3 {
    margin-top: 32px;
    margin-bottom: 14px;
    font-size: 1.15rem;
    border-left: 5px solid var(--primary);
    padding-left: 14px;
}
h4 { font-size: 1rem; margin: 18px 0 8px; font-weight: 700; color: var(--text); }
p { margin-bottom: 14px; }
ul, ol { margin: 0 0 16px 24px; }
li { margin-bottom: 6px; }
strong { color: #1a1a1a; }

/* ===========================
   Tables
   =========================== */
.table-wrap { overflow-x: auto; margin: 16px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 14px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background-color: var(--gray-bg); color: var(--text); font-weight: 700; }
tr:hover td { background: #fafbfc; }

/* ===========================
   Highlight Box
   =========================== */
.highlight-box {
    background-color: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    margin: 18px 0;
    font-size: 14px;
}
.highlight-box h4 { margin-top: 16px; }
.highlight-box h4:first-child { margin-top: 0; }
.highlight-box.hirogeru-box {
    background-color: var(--hirogeru-light);
    border-left-color: var(--hirogeru);
}

/* Blockquote */
blockquote {
    border-left: 4px solid var(--primary);
    margin: 20px 0;
    padding: 16px 20px;
    background-color: var(--gray-bg);
    color: var(--text-light);
    border-radius: 0 6px 6px 0;
}
blockquote strong { color: var(--text); }

/* ===========================
   Chapter Accordion (details/summary)
   =========================== */
details.chapter {
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s;
    background: white;
}
details.chapter[open] {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
details.chapter summary {
    cursor: pointer;
    padding: 14px 18px;
    background: var(--gray-bg);
    font-weight: 600;
    font-size: 14.5px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}
details.chapter summary::-webkit-details-marker { display: none; }
details.chapter summary::before {
    content: "▶";
    font-size: 9px;
    color: var(--text-light);
    transition: transform 0.2s;
}
details.chapter[open] summary::before { transform: rotate(90deg); }
details.chapter summary:hover { background: #eef0f3; }
details.chapter.brand-eraberu summary { border-left: 4px solid var(--primary); }
details.chapter.brand-hirogeru summary { border-left: 4px solid var(--hirogeru); }

.chapter-body {
    padding: 22px 18px;
}
.chapter-role {
    background: var(--gray-bg);
    border-left: 3px solid var(--text);
    padding: 12px 16px;
    margin: 0 0 20px;
    font-size: 13.5px;
    border-radius: 0 4px 4px 0;
    line-height: 1.7;
}

/* ===========================
   Layout 2-column
   =========================== */
.layout-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.rationale h4 {
    margin: 14px 0 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    padding-left: 10px;
    border-left: 3px solid var(--primary);
}
.rationale.rationale-hirogeru h4 { border-left-color: var(--hirogeru); }
.rationale h4:first-child { margin-top: 0; }
.rationale ul {
    margin: 0 0 10px;
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.65;
}
.rationale li { margin-bottom: 3px; }

/* ===========================
   Mermaid Wrap
   =========================== */
.mermaid-wrap {
    background: var(--gray-bg);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 16px 0;
}
.mermaid {
    text-align: center;
    min-height: 200px;
    font-size: 14px;
}
.mermaid small,
.mermaid foreignObject small {
    font-size: 11px;
    color: #666;
    font-weight: normal;
    display: block;
    margin-top: 2px;
    line-height: 1.4;
}

/* ===========================
   Course Cards
   =========================== */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin: 16px 0 28px;
}
.course-grid-secondary {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.course-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: white;
    border-top: 3px solid var(--primary);
    transition: box-shadow .2s, transform .2s;
}
.course-card:hover {
    box-shadow: 0 4px 12px rgba(66,164,175,0.15);
    transform: translateY(-2px);
}
.course-card.sub { border-top-color: var(--text-light); }
.course-num {
    font-size: 11px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.05em;
}
.course-card.sub .course-num { color: var(--text-light); }
.course-title {
    font-weight: 700;
    margin: 6px 0;
    font-size: 14px;
    line-height: 1.5;
}
.course-meta {
    font-size: 12px;
    color: var(--text-light);
    line-height: 1.6;
}

/* ===========================
   Course Detail — scannability (courses.html)
   =========================== */
.course-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 10px;
    margin: 0 0 22px;
}
.stat {
    background: var(--gray-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 6px;
    padding: 9px 13px;
}
.stat .stat-label {
    font-size: 10px; color: var(--text-light); font-weight: 700;
    letter-spacing: .06em; display: block; margin-bottom: 3px;
}
.stat .stat-value { font-size: 12.5px; font-weight: 700; color: var(--text); line-height: 1.5; }
.stat.is-money { border-left-color: var(--hirogeru); }
.stat.is-money .stat-value { color: var(--hirogeru-dark); }
.stat .ok { color: #2e9e6b; }
.stat .pending { color: #c98a1a; }

/* Accordion bullets → readable spec rows */
.chapter-body > ul {
    margin: 0; padding: 0; list-style: none;
}
.chapter-body > ul > li {
    padding: 11px 2px; margin: 0;
    border-bottom: 1px dashed var(--border);
    line-height: 1.75; font-size: 14px;
}
.chapter-body > ul > li:last-child { border-bottom: none; padding-bottom: 2px; }
.chapter-body > ul > li > strong:first-child {
    color: var(--primary-dark); font-size: 13px;
}

/* nested sub-bullets inside a spec row */
.chapter-body ul.sub { list-style: none; margin: 7px 0 0; padding: 0; }
.chapter-body ul.sub > li {
    position: relative; padding: 3px 0 3px 18px; margin: 0;
    border: none; font-size: 13.5px; line-height: 1.7;
}
.chapter-body ul.sub > li::before {
    content: ""; position: absolute; left: 3px; top: 12px;
    width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
}
.chapter-body ul.sub .tag {
    display: inline-block; background: var(--primary-light); color: var(--primary-dark);
    font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 4px;
    margin-right: 7px; white-space: nowrap;
}

/* ===========================
   Format List (numbered)
   =========================== */
.format-list {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    counter-reset: format;
}
.format-list li {
    counter-increment: format;
    padding: 12px 14px 12px 54px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    position: relative;
    background: white;
    font-size: 14px;
    font-weight: 600;
}
.format-list li::before {
    content: counter(format);
    position: absolute;
    left: 14px;
    top: 11px;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    line-height: 28px;
}
.format-list li .goal {
    display: block;
    font-size: 12px;
    color: var(--primary-dark);
    margin-top: 4px;
    font-weight: 500;
}

/* ===========================
   Tool Grid (HIROGERU幅用) - legacy
   =========================== */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0 24px;
}
.tool-chip {
    background: var(--hirogeru-light);
    border: 1px solid var(--hirogeru);
    border-radius: 6px;
    padding: 10px 12px;
}
.tool-chip .tool-name { font-weight: 700; color: var(--hirogeru-dark); font-size: 13.5px; }
.tool-chip .tool-desc { font-size: 11px; color: var(--text-light); margin-top: 3px; line-height: 1.5; }

/* ===========================
   Format Box (共通フォーマット表示)
   =========================== */
.format-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 16px 0 28px;
}
.format-col {
    background: var(--gray-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
}
.format-col-head {
    font-weight: 700;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 10px;
}
.format-col-head.base {
    background: var(--hirogeru);
    color: white;
}
.format-col-head.ext {
    background: var(--hirogeru-light);
    color: var(--hirogeru-dark);
    border: 1px solid var(--hirogeru);
}
.format-mini {
    margin: 0 0 0 22px;
    padding: 0;
    font-size: 13px;
    line-height: 1.7;
}
.format-mini li { margin-bottom: 3px; }
.format-note {
    font-size: 12px;
    color: var(--text-light);
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

/* ===========================
   Tool List (展開可能カード)
   =========================== */
.tool-hint {
    font-size: 12px;
    color: var(--text-light);
    margin: 8px 0 12px;
    padding-left: 14px;
    border-left: 2px solid var(--hirogeru);
}
.tool-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 10px;
    margin: 8px 0 28px;
}
.tool-detail {
    background: white;
    border: 1px solid var(--border);
    border-left: 3px solid var(--hirogeru);
    border-radius: 6px;
    overflow: hidden;
    transition: box-shadow .2s;
}
.tool-detail[open] { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.tool-detail summary {
    cursor: pointer;
    padding: 12px 14px;
    background: var(--hirogeru-light);
    font-size: 13.5px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background .2s;
}
.tool-detail summary::-webkit-details-marker { display: none; }
.tool-detail summary::before {
    content: "▶";
    font-size: 9px;
    color: var(--hirogeru-dark);
    transition: transform .2s;
}
.tool-detail[open] summary::before { transform: rotate(90deg); }
.tool-detail summary:hover { background: #ffe4cf; }

.tool-detail .tool-num {
    background: var(--hirogeru);
    color: white;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}
.tool-detail .tool-title {
    font-weight: 700;
    color: var(--hirogeru-dark);
    flex: 1;
}
.tool-detail .tool-vendor {
    font-size: 11px;
    color: var(--text-light);
}
.tool-body {
    padding: 14px 16px;
    background: white;
}
.tool-body h5 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.func-list {
    margin: 0 0 0 22px;
    padding: 0;
    font-size: 13px;
    line-height: 1.7;
}
.func-list li { margin-bottom: 2px; }
.func-list li:last-child {
    color: var(--text-light);
    font-style: italic;
    font-size: 12px;
}
.tool-body .todo {
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
    margin: 0;
}

@media (max-width: 768px) {
    .format-box { grid-template-columns: 1fr; }
}

/* ===========================
   Back to Top
   =========================== */
.back-to-top {
    position: fixed; bottom: 30px; right: 30px;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary); color: #fff; border: none;
    font-size: 20px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    opacity: 0; visibility: hidden;
    transition: opacity .3s, visibility .3s, transform .2s;
    z-index: 150;
}
.back-to-top.show { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-3px); }

/* ===========================
   Footer
   =========================== */
footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    header h1 { font-size: 1.5rem; }
    header { padding: 40px 16px; }
    nav a { font-size: 11px; padding: 3px 6px; }
    h2 { font-size: 1.25rem; }
    .layout-2col { grid-template-columns: 1fr; }
    .course-grid { grid-template-columns: 1fr; }
    .container { padding: 0 14px; }
    .chapter-body { padding: 16px 12px; }
}
