/* Midori Society - Dark Professional Theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --border-color: #30363d;
    --border-accent: #3d444d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #656d76;
    --accent-green: #3fb950;
    --accent-green-dim: #238636;
    --accent-blue: #58a6ff;
    --accent-gold: #d4a017;
    --accent-red: #f85149;
    --accent-purple: #bc8cff;
    --font-serif: "Noto Serif JP", "Georgia", "Times New Roman", serif;
    --font-sans: "Noto Sans JP", "Helvetica Neue", "Arial", sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
}

/* === HEADER === */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-green);
    text-decoration: none;
    letter-spacing: 0.05em;
}

.site-title span {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.85rem;
    margin-left: 0.75rem;
}

nav {
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}

nav a:hover,
nav a.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-green);
}

/* === MAIN CONTENT === */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

/* === HERO SECTION === */
.hero {
    text-align: center;
    padding: 3rem 0 2.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2.5rem;
}

.hero h1 {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    letter-spacing: 0.02em;
}

.hero .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.8;
}

/* === FORMS === */
.question-form {
    max-width: 750px;
    margin: 0 auto 3rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

textarea,
input[type="text"] {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.15);
}

textarea {
    min-height: 120px;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--accent-green-dim);
    color: #fff;
    border: 1px solid var(--accent-green);
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    font-family: var(--font-sans);
}

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

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-accent);
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* === CARDS & SECTIONS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--border-accent);
}

.card h2 {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card h3 {
    font-size: 1.05rem;
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.card h3:first-child {
    margin-top: 0;
}

.section-label {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-green);
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding: 0.2rem 0.6rem;
    background: rgba(63, 185, 80, 0.1);
    border-radius: 3px;
}

/* === RESULT PAGE === */
.result-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--accent-green-dim);
}

.result-header h1 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    margin-bottom: 0.5rem;
}

.result-header .question-text {
    font-size: 1.15rem;
    color: var(--accent-gold);
    font-style: italic;
    margin-top: 0.5rem;
}

.topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.topic-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--accent-blue);
}

/* Analysis content */
.analysis-content {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.evidence-item {
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-blue);
    border-radius: 0 6px 6px 0;
}

.evidence-item .discipline {
    font-size: 0.8rem;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.evidence-item .heading {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.evidence-item ul {
    list-style: none;
    padding: 0;
}

.evidence-item li {
    padding: 0.2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.evidence-item li::before {
    content: "\2014\00a0";
    color: var(--text-muted);
}

/* Frameworks */
.framework-item {
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-purple);
    border-radius: 0 6px 6px 0;
}

.framework-item .name {
    font-weight: 600;
    color: var(--accent-purple);
    margin-bottom: 0.35rem;
}

.framework-item .description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* Counterarguments */
.counter-item {
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-gold);
    border-radius: 0 6px 6px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* Fallacy warnings */
.fallacy-item {
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.5rem;
    background: rgba(248, 81, 73, 0.05);
    border-left: 3px solid var(--accent-red);
    border-radius: 0 6px 6px 0;
}

.fallacy-item .name {
    font-weight: 600;
    color: var(--accent-red);
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.fallacy-item .warning {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Sources */
.source-list {
    list-style: none;
    padding: 0;
    columns: 2;
    column-gap: 2rem;
}

.source-list li {
    padding: 0.3rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    break-inside: avoid;
}

.source-list li::before {
    content: "\25B8\00a0";
    color: var(--accent-green);
}

/* Conclusion */
.conclusion {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text-primary);
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* === DEBATE MODE === */
.debate-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.debate-for {
    border-left-color: var(--accent-green) !important;
}

.debate-for .section-label {
    color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
}

.debate-against {
    border-left-color: var(--accent-red) !important;
}

.debate-against .section-label {
    color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
}

.argument-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.argument-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.argument-item .name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.argument-item .base {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.argument-item .evidence-line {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border-color);
    margin-top: 0.25rem;
}

/* === ISSUES LIST === */
.issues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.issue-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
    display: block;
}

.issue-card:hover {
    border-color: var(--accent-green);
    transform: translateY(-2px);
}

.issue-card .category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-green);
    margin-bottom: 0.5rem;
}

.issue-card h3 {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.issue-card .title-en {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.issue-card .preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* === ISSUE DETAIL === */
.issue-detail h1 {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.issue-detail .title-en {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.perspective-block {
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-blue);
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.perspective-block strong {
    color: var(--accent-blue);
}

/* === SEARCH === */
.search-form {
    display: flex;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.search-form input {
    flex: 1;
}

.search-result {
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.search-result .meta {
    font-size: 0.8rem;
    color: var(--accent-green);
    margin-bottom: 0.35rem;
}

.search-result h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.search-result .content-preview {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-height: 100px;
    overflow: hidden;
}

/* === MODE TABS === */
.mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.mode-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    font-family: var(--font-sans);
}

.mode-tab:hover {
    color: var(--text-primary);
}

.mode-tab.active {
    color: var(--accent-green);
    border-bottom-color: var(--accent-green);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* === FOOTER === */
footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    margin-top: 3rem;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

/* === UTILITY === */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.back-link {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent-green);
}

.back-link::before {
    content: "\2190\00a0";
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state h2 {
    font-family: var(--font-serif);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 0.6rem;
        align-items: flex-start;
        padding: 0 1rem;
    }

    .site-title { font-size: 1.25rem; }
    .site-title span { display: block; margin-left: 0; font-size: 0.72rem; }

    nav {
        gap: 1rem;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    nav::-webkit-scrollbar { display: none; }
    nav a { white-space: nowrap; flex: none; }

    .hero h1 {
        font-size: 1.6rem;
    }

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

    .source-list {
        columns: 1;
    }

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

    .btn-group {
        flex-direction: column;
    }
}

/* === LOADING INDICATOR === */
.loading {
    display: none;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading.active {
    display: block;
}

.loading .spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Topic browser + bilingual detail (Cycle 23, compacted Cycle 30) ---- */
.theme-en {
    font-size: 0.7em;
    color: var(--text-muted);
    font-weight: 400;
}

.issue-card-ja {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.issue-card-en {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Japanese is primary; English is the secondary, retained-for-fidelity layer. */
.bi-ja {
    margin-bottom: 0.5rem;
}

.bi-en {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.65;
    border-left: 2px solid var(--border-accent);
    padding-left: 0.8rem;
    margin-top: 0.35rem;
}

/* ---- Compact tabbed topic detail (Cycle 30) ---- */
.topic-head {
    margin-bottom: 1rem;
}

.topic-head h1 {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    margin: 0.35rem 0 0.4rem;
    color: var(--text-primary);
}

.topic-q {
    color: var(--accent-gold);
    font-size: 0.9rem;
    font-style: italic;
}

.topic-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
}

.ttab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}

.ttab:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.ttab.active {
    background: var(--accent-green-dim);
    border-color: var(--accent-green);
    color: #fff;
}

.tpane {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
}

.tpane.active {
    display: block;
    animation: fadein 0.15s ease;
}

@keyframes fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tpane h2 {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    margin: 0 0 0.7rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.tpane .analysis-content {
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-line;
}

.stake {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.stake:last-child { border-bottom: none; }

.stake-name {
    font-weight: 700;
    color: var(--accent-blue);
    font-size: 0.92rem;
    margin-bottom: 0.25rem;
}

.stake .bi-ja {
    font-size: 0.88rem;
    margin-bottom: 0.25rem;
}

.stake .bi-en {
    font-size: 0.8rem;
}

/* Related-topics cross-navigation on the topic detail page */
.related-topics {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.related-topics h2 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}
.related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.related-link {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: border-color 0.15s, background 0.15s;
}
.related-link:hover {
    border-color: var(--accent-green);
    background: var(--bg-card);
}
.related-link .theme-en {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Home hero search box */
.hero-search {
    display: flex;
    gap: 0.75rem;
    max-width: 600px;
    margin: 1.5rem auto 0;
}
.hero-search input {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.hero-search input:focus {
    outline: none;
    border-color: var(--accent-green);
}

/* ── Home: usage guide + catalog overview (information architecture) ── */
.usage-guide {
    margin: 2rem 0;
}
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.usage-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem 1.5rem 1.25rem;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: border-color 0.2s, transform 0.2s;
}
.usage-card:hover {
    border-color: var(--accent-green);
    transform: translateY(-2px);
}
.usage-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--accent-green-dim);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.usage-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}
.usage-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0 0 0.9rem;
}
.usage-cta {
    color: var(--accent-blue);
    font-weight: 500;
    font-size: 0.9rem;
}
.catalog-overview {
    margin: 2.5rem 0 1rem;
}
.overview-line {
    color: var(--text-secondary);
    margin: 0 0 0.9rem;
}
.theme-index {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.theme-index a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: border-color 0.2s, color 0.2s;
}
.theme-index a:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}
.theme-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}
.theme-index a:hover .theme-count {
    color: var(--accent-green);
}
/* offset anchor jumps so the sticky-ish header doesn't cover the heading */
[id^="theme-"], [id^="cat-"], #themes {
    scroll-margin-top: 1.5rem;
}

/* ── Breadcrumb (topic / issue detail orientation) ── */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}
.breadcrumb a:hover {
    color: var(--accent-green);
    text-decoration: underline;
}
.crumb-sep {
    color: var(--text-muted);
}
.crumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Learn-through-dialogue (みどり先生 × ぐりっぴー) ── */
.dialogue-head {
    margin-bottom: 1.5rem;
}
.dialogue-lead {
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0.75rem 0 1rem;
}
.cast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}
.cast-member {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-weight: 700;
}
.cast-member small {
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.8;
}
.cast-teacher {
    background: rgba(63, 185, 80, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}
.cast-student {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent-blue);
    border: 1px solid rgba(88, 166, 255, 0.3);
}
.cast-x {
    color: var(--text-muted);
}

.dialogue {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    margin: 1.5rem 0;
}
.turn {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}
.turn-teacher {
    align-self: flex-start;
    align-items: flex-start;
}
.turn-student {
    align-self: flex-end;
    align-items: flex-end;
}
.turn-speaker {
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    padding: 0 0.4rem;
}
.turn-teacher .turn-speaker { color: var(--accent-green); }
.turn-student .turn-speaker { color: var(--accent-blue); }
.turn-bubble {
    padding: 0.85rem 1.1rem;
    border-radius: 14px;
    line-height: 1.85;
    font-size: 1rem;
}
.turn-teacher .turn-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}
.turn-student .turn-bubble {
    background: rgba(88, 166, 255, 0.08);
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-top-right-radius: 4px;
}
.dialogue-takeaway {
    border-left: 3px solid var(--accent-green);
}
.dialogue-takeaway p {
    line-height: 1.9;
    margin: 0;
}
.dialogue-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* CTA on the topic page inviting users into the dialogue first */
.dialogue-cta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.25rem 0 0.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(63, 185, 80, 0.35);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(63, 185, 80, 0.10), rgba(63, 185, 80, 0.03));
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
}
.dialogue-cta:hover {
    border-color: var(--accent-green);
    transform: translateY(-2px);
}
.dialogue-cta-badge {
    flex-shrink: 0;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: var(--accent-green-dim);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}
.dialogue-cta-text {
    flex: 1;
    min-width: 200px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}
.dialogue-cta-text strong {
    display: block;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.15rem;
}
.dialogue-cta-go {
    flex-shrink: 0;
    color: var(--accent-green);
    font-weight: 700;
}

/* ── Example chips (/free onboarding: click to fill the box) ── */
.example-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}
.example-chips-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.chip {
    padding: 0.35rem 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--accent-blue);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, transform 0.1s;
}
.chip:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
    transform: translateY(-1px);
}

/* ── Search results grouped by discipline ── */
.search-group {
    margin-bottom: 2rem;
}
.search-group-head {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

/* === NO-SCROLL app shell (design/NO_SCROLL.md) ===
   The page itself never scrolls: header/footer are a fixed HUD and
   <main> is the single designated internal pane (rule 6). */
html { height: 100%; }
body { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
header { flex: none; }
main { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
footer { flex: none; padding: 0.5rem 1rem; }

/* === NO-SCROLL home: compact dashboard + theme tabs === */
.ns-home .hero { padding: 0.9rem 1rem 0.8rem; margin-bottom: 0.6rem; }
.ns-home .hero h1 { font-size: 1.15rem; margin: 0 0 0.25rem; }
.ns-home .hero .subtitle { font-size: 0.78rem; line-height: 1.5; margin: 0 0 0.55rem; }
.ns-home .hero-search input { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
.ns-home .hero-search .btn { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.ns-home .usage-guide { padding: 0; margin-bottom: 0.6rem; }
.ns-home .usage-guide .section-label { font-size: 0.72rem; margin-bottom: 0.3rem; }
/* Narrower track than the base 240px: the cards are single-line here (p is
   hidden below), and a 4th card wrapping to a second row costs height this
   page doesn't have. Keeps all four on one row down to ~890px wide. */
.ns-home .usage-grid { gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ns-home .usage-card { padding: 0.5rem 0.7rem; }
.ns-home .usage-card h3 { font-size: 0.82rem; margin: 0; display: inline; }
.ns-home .usage-card p { display: none; }  /* details live behind the click */
.ns-home .usage-card .usage-num { font-size: 0.7rem; }
.ns-home .usage-card .usage-cta { font-size: 0.7rem; margin-left: 0.3rem; }
.ns-home .catalog-overview { padding: 0; margin-bottom: 0.5rem; }
.ns-home .overview-line { font-size: 0.75rem; margin: 0.15rem 0 0.35rem; }
.ns-home .theme-index { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ns-home .theme-index a { font-size: 0.78rem; padding: 0.22rem 0.6rem; border-radius: 999px; border: 1px solid var(--border, #2c3744); text-decoration: none; }
.ns-home .theme-index a.active { background: var(--accent, #5ab0ff); color: #04121f; border-color: var(--accent, #5ab0ff); font-weight: 700; }
.ns-home .card[id^="theme-"] { display: none; }
.ns-home .card[id^="theme-"].active { display: block; animation: nsIn 0.25s ease; padding: 0.8rem 1rem; }
@keyframes nsIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ns-home .card[id^="theme-"] h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.ns-home .issues-grid { gap: 0.45rem; }
.ns-home .issue-card { padding: 0.45rem 0.65rem; font-size: 0.85rem; }
.ns-home .card.mt-3 { padding: 0.6rem 1rem; margin-top: 0.6rem; }
.ns-home .card.mt-3 h3 { font-size: 0.85rem; margin: 0 0 0.2rem; }
.ns-home .card.mt-3 p { font-size: 0.75rem; margin-bottom: 0.4rem !important; }
@media (prefers-reduced-motion: reduce) { .ns-home .card[id^="theme-"].active { animation: none; } }
/* second density pass: fit 1280x800 */
main:has(.ns-home) { padding: 16px 24px; }
.ns-home .hero { padding: 0.6rem 1rem 0.6rem; }
.ns-home .hero .subtitle br { display: none; }
.ns-home .catalog-overview .section-label { display: none; }
.ns-home .overview-line { margin: 0 0 0.3rem; }
.ns-home .theme-index a { font-size: 0.72rem; padding: 0.15rem 0.5rem; }
.ns-home .card.mt-3 { display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 1rem; }
.ns-home .card.mt-3 p { display: none; }
.ns-home .card.mt-3 h3 { margin: 0; white-space: nowrap; }
.ns-home .card.mt-3 .btn { padding: 0.3rem 0.8rem; font-size: 0.8rem; }
/* final fit pass */
.ns-home .hero .subtitle { display: none; }
.ns-home .overview-line { display: none; }
.ns-home > div { margin-bottom: 0.45rem; }
.ns-home .card[id^="theme-"].active { padding: 0.6rem 0.9rem; }
.ns-home .issue-card { padding: 0.35rem 0.55rem; font-size: 0.8rem; }

/* === MOTION v1 (NO_SCROLL.md): entrance stagger + hover lift; reduced-motion safe === */
@keyframes mvRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .ns-home .usage-card, .ns-home .issue-card { animation: mvRise 0.3s ease both; }
  .ns-home .issue-card:nth-child(2) { animation-delay: 0.04s; }
  .ns-home .issue-card:nth-child(3) { animation-delay: 0.08s; }
  .ns-home .issue-card:nth-child(4) { animation-delay: 0.12s; }
  .ns-home .issue-card:nth-child(5) { animation-delay: 0.16s; }
  .ns-home .issue-card:nth-child(6) { animation-delay: 0.20s; }
  .ns-home .usage-card, .ns-home .issue-card, .ns-home .theme-index a { transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease; }
  .ns-home .usage-card:hover, .ns-home .issue-card:hover { transform: translateY(-2px); }
}

/* ===== 学問の基礎 (/study) =====
   Lecture notes are long-form Japanese prose, unlike the dense analysis dumps
   elsewhere — hence serif, a reading measure, and looser leading. These pages
   are plain children of <main>, so they scroll inside it (see the app-shell
   rules above); they are not .ns-home and its density overrides don't apply. */
.study-head { margin-bottom: 1.5rem; }
.study-head h1 { font-family: var(--font-serif); margin: 0.3rem 0 0.5rem; }
.study-lead { color: var(--text-secondary); max-width: 46rem; line-height: 1.8; }
.discipline-q { color: var(--text-secondary); font-family: var(--font-serif); line-height: 1.7; }
.discipline-card .discipline-q { margin: 0.4rem 0 0.7rem; font-size: 0.92rem; }

.syllabus { list-style: none; counter-reset: none; margin: 0; padding: 0; }
.lec-row { border-bottom: 1px solid var(--border-color); }
.lec-row:last-child { border-bottom: none; }
.lec-row a { display: flex; gap: 0.9rem; align-items: baseline; padding: 0.7rem 0.2rem; text-decoration: none; color: var(--text-primary); }
.lec-row a:hover { color: var(--accent-green); }
.lec-row.unauthored { display: flex; gap: 0.9rem; align-items: baseline; padding: 0.7rem 0.2rem; color: var(--text-muted); }
.lec-num { flex: 0 0 4.2rem; font-size: 0.85rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.lec-row.unauthored .lec-num { color: var(--text-muted); }
.lec-title { flex: 1 1 auto; font-family: var(--font-serif); }
.lec-todo { flex: 0 0 auto; font-size: 0.75rem; color: var(--text-muted); border: 1px solid var(--border-color); border-radius: 4px; padding: 1px 6px; }

.lecture-aims ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.lecture-aims li { margin: 0.35rem 0; line-height: 1.7; }
.lecture-bridge { color: var(--text-secondary); border-left: 2px solid var(--border-accent); padding-left: 0.9rem; margin: 1.2rem 0; line-height: 1.8; }
.lecture-body { max-width: 42rem; font-family: var(--font-serif); line-height: 1.9; }
.lecture-body h2 { font-size: 1.15rem; margin: 2rem 0 0.7rem; color: var(--accent-green); }
.lecture-body p { margin: 0 0 1.1rem; }

.term-list { margin: 0.4rem 0 0; }
.term-list dt { font-weight: 700; color: var(--accent-blue); margin-top: 0.8rem; }
.term-list dd { margin: 0.25rem 0 0; color: var(--text-secondary); line-height: 1.75; }

.quiz { border-bottom: 1px solid var(--border-color); padding: 0.6rem 0; }
.quiz:last-child { border-bottom: none; }
.quiz summary { cursor: pointer; font-family: var(--font-serif); }
.quiz summary:hover { color: var(--accent-green); }
.quiz-a { margin: 0.6rem 0 0.2rem; color: var(--text-secondary); line-height: 1.8; }

.reading-list { margin: 0.4rem 0 0; padding-left: 1.2rem; color: var(--text-secondary); }
.reading-list li { margin: 0.4rem 0; line-height: 1.7; }

.lecture-foot { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }

/* === 図書館 (library) ===
   Shelf = compact rows (コラム), never tall: 44×64 cover · title · small tags. Wide
   screens pack the rows into 2–3 columns for 一覧性; phones get one column. */
.lib-head { margin-bottom: 1rem; }
.lib-head h1 { font-family: var(--font-serif); margin: 0.3rem 0 0.4rem; font-size: 1.5rem; }
.lib-head-row { display: flex; gap: 1.5rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.lib-search { display: flex; gap: 0.5rem; margin-top: 0.4rem; min-width: 280px; }
.lib-search input { flex: 1; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); padding: 0.5rem 0.75rem; font-family: var(--font-sans); font-size: 0.9rem; }
.lib-search .btn { padding: 0.5rem 1rem; font-size: 0.9rem; }
.lib-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }
.lib-tags .chip { text-decoration: none; font-size: 0.8rem; padding: 0.25rem 0.7rem; display: inline-flex; align-items: center; gap: 0.35rem; }
.lib-tags .chip.active { border-color: var(--accent-green); color: var(--accent-green); background: rgba(63,185,80,0.08); }
.lib-tags .chip .theme-count { height: 1.1rem; min-width: 1.1rem; font-size: 0.68rem; }
.lib-count { color: var(--text-muted); font-size: 0.8rem; margin: 0.2rem 0 0.6rem; }

.lib-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 0.5rem 0.9rem; }
.lib-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0.6rem 0.45rem 0.45rem; min-height: 60px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; text-decoration: none; color: inherit;
    transition: border-color 0.15s, transform 0.15s; }
.lib-row:hover { border-color: var(--accent-green); transform: translateY(-1px); }
.lib-row.is-draft { opacity: 0.7; border-style: dashed; }
.lib-cover { width: 44px; height: 64px; flex: none; object-fit: cover; border-radius: 3px; background: var(--bg-tertiary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5), inset 2px 0 0 rgba(255,255,255,0.06); }
.lib-cover-ph { display: flex; align-items: center; justify-content: center; font-family: var(--font-serif); font-size: 0.8rem;
    color: var(--text-secondary); background: linear-gradient(160deg, #2a3340, #1c2128); border: 1px solid var(--border-color); }
.lib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.lib-kicker { font-size: 0.68rem; color: var(--accent-green); letter-spacing: 0.06em; }
.lib-title { font-family: var(--font-serif); font-size: 0.95rem; font-weight: 700; line-height: 1.35; color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-author { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-row-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.15rem; }
.lib-tag { display: inline-block; font-size: 0.66rem; line-height: 1.5; padding: 0 0.45rem; border-radius: 999px;
    background: var(--bg-tertiary); border: 1px solid var(--border-color); color: var(--accent-blue); text-decoration: none; white-space: nowrap; }
a.lib-tag:hover { border-color: var(--accent-green); color: var(--accent-green); }
.lib-arrow { color: var(--text-muted); font-size: 1.1rem; flex: none; }
.lib-draft { font-size: 0.65rem; color: var(--accent-gold); border: 1px solid var(--accent-gold); border-radius: 4px; padding: 0 0.3rem; vertical-align: middle; font-family: var(--font-sans); font-weight: 400; }
.lib-disclosure { margin-top: 1.6rem; font-size: 0.72rem; color: var(--text-muted); line-height: 1.6; max-width: 46rem; }
.lib-shelf-compact { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.lib-cite { margin: 1rem 0; max-width: 32rem; }

/* book page: side column (cover · 書誌 · buy) + the 編集部's 解説 */
.book-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2rem; align-items: start; }
.book-side { position: sticky; top: 0.5rem; }
.book-cover { width: 180px; height: auto; max-height: 260px; object-fit: contain; border-radius: 4px; background: var(--bg-tertiary);
    box-shadow: 0 4px 14px rgba(0,0,0,0.5), inset 3px 0 0 rgba(255,255,255,0.06); display: block; }
.book-cover-ph { width: 180px; height: 250px; display: flex; align-items: center; justify-content: center; padding: 1rem; text-align: center;
    font-family: var(--font-serif); color: var(--text-secondary); font-size: 1rem; line-height: 1.5;
    background: linear-gradient(160deg, #2a3340, #1c2128); border: 1px solid var(--border-color); }
.book-title { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.4; margin: 0.9rem 0 0.5rem; }
.book-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.book-meta dt { color: var(--text-muted); }
.book-meta dd { margin: 0; color: var(--text-primary); }
.book-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.9rem; }
.btn-amazon { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; width: 100%; padding: 0.6rem 1rem;
    background: #f0a33a; border-color: #d98a1e; color: #111; text-decoration: none; }
.btn-amazon:hover { background: #ffb24a; }
.btn-amazon-label { font-weight: 700; font-size: 0.95rem; }
.btn-amazon-label::before { content: "🛒 "; }
.btn-amazon-sub { font-size: 0.65rem; font-weight: 400; opacity: 0.8; }
.book-nobuy { font-size: 0.8rem; color: var(--text-muted); }
.book-disc { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.8rem; }
.book-disc a { color: var(--accent-blue); text-decoration: none; }
.book-editor { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.6rem; }
.book-body { max-width: 44rem; }
.book-body h3 { font-size: 1.02rem; margin: 1.4rem 0 0.5rem; color: var(--text-primary); }
.book-body ul { padding-left: 1.3rem; margin: 0.4rem 0 0.9rem; }
.book-body li { margin: 0.3rem 0; }
.book-body p { margin: 0 0 0.9rem; }
.book-summary { font-family: var(--font-sans); color: var(--text-secondary); border-left: 2px solid var(--accent-green); padding-left: 0.9rem; }
.book-pending { color: var(--text-muted); }
.book-ref { color: var(--accent-blue); text-decoration: none; border-bottom: 1px dotted var(--accent-blue); }
.book-ref::before { content: "📖 "; }
.book-ref:hover { color: var(--accent-green); border-bottom-color: var(--accent-green); }

@media (max-width: 768px) {
    .lib-shelf, .lib-shelf-compact { grid-template-columns: 1fr; }
    .lib-search { min-width: 0; width: 100%; }
    .book-layout { grid-template-columns: 1fr; gap: 1.2rem; }
    .book-side { position: static; display: grid; grid-template-columns: 110px 1fr; gap: 0.3rem 1rem; align-items: start; }
    .book-side .book-cover, .book-side .book-cover-ph { width: 110px; height: auto; max-height: 160px; grid-row: 1 / span 5; }
    .book-side .book-cover-ph { height: 150px; font-size: 0.8rem; }
    .book-side .book-title { margin-top: 0; font-size: 1.1rem; }
    .btn-amazon { grid-column: 1 / -1; }
}
