/* style.css - 学習コンテンツ用メインスタイル */

/* ========================================
   リセット・ベース
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

/* アンカーリンクのスクロール位置調整（固定ヘッダー対応） */
:target {
    scroll-margin-top: 70px;
}

/* MathJax \eqref ジャンプ先（mjx-container）にも適用 */
mjx-container[id],
[id^="mjx-eqn"] {
    scroll-margin-top: 90px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    line-height: 1.8;
    color: var(--color-text-primary);
    background-color: var(--color-bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.has-fixed-header {
    padding-top: 56px;
}

/* ========================================
   ヘッダ（ページレベル）
   ======================================== */
body > header {
    background-color: var(--color-header-bg);
    color: var(--color-header-text);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

body > header h1 {
    font-size: 1.5rem;
    margin: 0;
    padding: 0.75rem 1.5rem;
    color: var(--color-header-text) !important;
    border: none;
}

body > header p {
    font-size: 0.9rem;
    margin: 0;
    padding: 0 1.5rem 0.75rem;
    opacity: 0.9;
    color: var(--color-header-text) !important;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 56px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s;
}

.logo a:hover {
    opacity: 0.8;
}

.logo i {
    font-size: 1.2rem;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

/* 章目次: グローバルの nav ul (flex) を上書きして複数行グリッドに */
nav.chapter-toc ul {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem 1.25rem;
    padding-left: 0;
}
nav.chapter-toc li {
    line-height: 1.5;
}

nav a {
    color: var(--color-header-text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: opacity 0.3s;
}

nav a:hover {
    opacity: 0.8;
}

/* ========================================
   メインコンテンツ
   ======================================== */
main {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ========================================
   記事スタイル
   ======================================== */
article {
    background: var(--color-bg-base);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    margin-bottom: 2rem;
}

article h1 {
    font-size: 2rem;
    color: var(--color-text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 3px solid var(--color-primary);
}

article h2 {
    font-size: 1.5rem;
    color: var(--color-text-primary);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 4px solid var(--color-primary);
}

article h3 {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

article h4 {
    font-size: 1.15rem;
    color: var(--color-text-secondary);
    margin-top: 1.75rem;
    margin-bottom: 0.6rem;
}

article h5 {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

article h6 {
    font-size: 1.05rem;
    color: var(--color-text-secondary);
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
}

article p {
    margin-bottom: 1.25rem;
    text-align: justify;
}

article ul, article ol {
    margin-left: 1.5rem;
    margin-bottom: 1.25rem;
}

article li {
    margin-bottom: 0.5rem;
}

article a {
    color: var(--color-link);
    text-decoration: none;
    transition: color 0.2s;
}

article a:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

/* ========================================
   数式ブロック
   ======================================== */
.math-block {
    background: var(--color-math-bg);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* MathJax調整 */
.MathJax_Display {
    overflow-x: auto;
    overflow-y: hidden;
}

/* ========================================
   コードブロック
   ======================================== */
pre {
    background: var(--color-code-bg);
    color: var(--color-code-text);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: var(--color-bg-subtle);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

pre code {
    background: none;
    padding: 0;
}

/* ========================================
   カードグリッド（トップページ用）
   ======================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

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

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background: var(--color-card-hover);
}

.see-more {
    text-align: right;
    margin-top: 0.5em;
}

.see-more a {
    color: var(--color-text-secondary);
    font-size: 0.95em;
}

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

.card p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 0;
}

.card .tag {
    display: inline-block;
    background: var(--color-info);
    color: var(--color-info-dark);
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-top: 0.75rem;
}

/* ========================================
   ヒーローセクション
   ======================================== */
.hero {
    background: var(--gradient-brand);
    color: var(--color-text-white);
    padding: 3rem 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    border: none;
    padding: 0;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
}

/* ========================================
   パンくずリスト
   ======================================== */
.breadcrumb {
    padding: 1rem 0;
    font-size: 0.9rem;
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    margin: 0;
}

.breadcrumb li:not(:last-child)::after {
    content: '>';
    margin-left: 0.5rem;
    color: var(--color-text-muted);
}

.breadcrumb a {
    color: var(--color-link);
    text-decoration: none;
}

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

/* ========================================
   フッタ
   ======================================== */
footer {
    background-color: var(--color-footer-bg);
    color: var(--color-footer-text);
    padding: 2rem 1rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--color-footer-text);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.footer-links a:hover {
    opacity: 1;
}

.copyright {
    font-size: 0.85rem;
    opacity: 0.8;
}

.footer-bottom {
    text-align: center;
    padding: 0.5rem 0;
}

.footer-bottom p {
    margin: 0;
    font-size: 0.9rem;
}

.footer-bottom a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 500;
}

.footer-bottom a:hover {
    color: #e0e0e0;
}

.footer-bottom .rf-link {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    padding: 0.25em 0.7em;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.footer-bottom .rf-link:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}

.footer-bottom .rf-link i {
    margin-right: 0.3em;
}

.footer-bottom .sangi-icon {
    height: 1.4em;
    vertical-align: -0.3em;
    margin-right: 0.15em;
}

/* ========================================
   目次（Table of Contents）
   ======================================== */
.toc {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.toc h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-secondary);
}

.toc ul {
    display: block;
    list-style: disc;
    margin: 0;
    padding-left: 1.25rem;
}

.toc li {
    margin-bottom: 0.4rem;
}

.toc a {
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.95rem;
}

.toc a:hover {
    text-decoration: underline;
}

/* ========================================
   補足ボックス
   ======================================== */
.note {
    background: linear-gradient(135deg, var(--color-info) 0%, #e8f4fc 100%);
    border-left: 4px solid var(--color-info-dark);
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.note-title {
    font-weight: bold;
    color: var(--color-info-dark);
    margin-bottom: 0.5rem;
}

.warning {
    background: linear-gradient(135deg, var(--color-warning) 0%, #fcf4e8 100%);
    border-left: 4px solid var(--color-warning-dark);
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}

.warning-title {
    font-weight: bold;
    color: var(--color-warning-dark);
    margin-bottom: 0.5rem;
}

/* ========================================
   テーブル
   ======================================== */
.data-table, .styled-table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.95rem;
}

/* 数式を含む幅広の表（レスポンシブ対応） */
.data-table.formula-table-wide {
    table-layout: fixed;
    min-width: 100%;
}

/* 3列テーブルの列幅設定（公式:60%, 備考:30%, 証明:10%） */
.data-table.formula-table-wide th:nth-child(1),
.data-table.formula-table-wide td:nth-child(1) {
    width: 60%;
}

.data-table.formula-table-wide th:nth-child(2),
.data-table.formula-table-wide td:nth-child(2) {
    width: 30%;
}

.data-table.formula-table-wide th:nth-child(3),
.data-table.formula-table-wide td:nth-child(3) {
    width: 10%;
}

.data-table.formula-table-wide td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 数式テーブルのスクロールコンテナ */
.formula-table-container {
    overflow-x: auto;
    margin: 1rem 0;
}

.data-table th,
.data-table td,
.styled-table th,
.styled-table td {
    border: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    text-align: left;
}

.data-table.text-center th,
.data-table.text-center td {
    text-align: center;
}

.data-table th,
.styled-table th {
    background: var(--color-bg-subtle);
    font-weight: 600;
    color: var(--color-text-primary);
}

.styled-table thead th {
    background: linear-gradient(to bottom, #4a90e2, #357abd);
    color: white;
    font-weight: 600;
    text-align: center;
}

.styled-table tbody tr {
    background: #ffffff;
}

.styled-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.styled-table tbody tr:hover {
    background: #e3f2fd;
    transition: background 0.2s;
}

/* 色付き box (.example-box, .note-box, .definition-box, .theorem-box) 内の表を
   背景から浮き上げる: 外枠を濃く + 軽い影 + 角丸 + 内部 overflow 隠し +
   内容幅にフィット (列数が少ない表で右側に白余白が出るのを防ぐ) */
.example-box .styled-table,
.example-box .data-table,
.note-box .styled-table,
.note-box .data-table,
.definition-box .styled-table,
.definition-box .data-table,
.theorem-box .styled-table,
.theorem-box .data-table {
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--color-border-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

/* レイアウト別の色分け */
.data-table tr.layout-numerator {
    background: #fff0f3;  /* 薄いピンク - 分子レイアウト */
}

.data-table tr.layout-denominator {
    background: #f0f8ff;  /* 薄い水色 - 分母レイアウト */
}

.data-table tr.layout-mixed {
    background: #f5f5f5;  /* 薄い灰色 - 混在・その他 */
}

.data-table tbody tr:hover {
    filter: brightness(0.95);
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .data-table tr.layout-numerator {
        background: #3d2a2e;  /* 暗いピンク - 分子レイアウト */
    }

    .data-table tr.layout-denominator {
        background: #2a3340;  /* 暗い水色 - 分母レイアウト */
    }

    .data-table tr.layout-mixed {
        background: #2d2d2d;  /* 暗い灰色 - 混在・その他 */
    }

    .data-table tbody tr:hover {
        filter: brightness(1.1);
    }

    .styled-table thead th {
        background: linear-gradient(to bottom, #2c5f8d, #1e4668);
    }

    .styled-table tbody tr:nth-child(even) {
        background: #2d2d2d;
    }

    .styled-table tbody tr:hover {
        background: #1e3a5f;
    }
}

[data-theme="dark"] .data-table tr.layout-numerator {
    background: #3d2a2e;
}

[data-theme="dark"] .data-table tr.layout-denominator {
    background: #2a3340;
}

[data-theme="dark"] .data-table tr.layout-mixed {
    background: #2d2d2d;
}

[data-theme="dark"] .data-table tbody tr:hover {
    filter: brightness(1.1);
}

[data-theme="dark"] .styled-table thead th {
    background: linear-gradient(to bottom, #2c5f8d, #1e4668);
}

[data-theme="dark"] .styled-table tbody tr:nth-child(even) {
    background: #2d2d2d;
}

[data-theme="dark"] .styled-table tbody tr:hover {
    background: #1e3a5f;
}

/* レスポンシブテーブル */
@media (max-width: 768px) {
    /* 表を横スクロール可能にする */
    .data-table, .styled-table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .styled-table thead,
    .styled-table tbody,
    .styled-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td,
    .styled-table th,
    .styled-table td {
        padding: 0.4rem 0.5rem;
        white-space: normal;
        word-wrap: break-word;
    }

    /* SVG内のテキストサイズをスマホで調整 */
    .figure svg text {
        font-size: 10px;
    }

    /* 用語集のスタイル調整 */
    .glossary {
        font-size: 0.9rem;
    }

    .glossary dt {
        font-size: 0.95rem;
    }

    .glossary dd {
        margin-left: 1rem;
        font-size: 0.85rem;
    }

}

/* 数式のスマホ対応（タッチデバイスのみ。PCの狭いウィンドウでは縮小しない） */
@media (max-width: 768px) and (pointer: coarse) {
    mjx-container[jax="SVG"][display="true"] {
        font-size: 0.6em !important;
        overflow-x: auto;
        overflow-y: hidden;
    }

    mjx-container[jax="SVG"]:not([display="true"]) {
        font-size: 0.6em !important;
        vertical-align: -0.1em !important;
    }
}

/* ========================================
   参考文献
   ======================================== */
.references {
    background: var(--color-bg-subtle);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-top: 2rem;
}

.references h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    margin-top: 0;
}

.references ul {
    margin: 0;
    padding-left: 1.25rem;
}

.references li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 768px) {
    body.has-fixed-header {
        padding-top: 52px;
    }

    .header-container {
        height: 52px;
    }

    .logo {
        font-size: 1.2rem;
    }

    nav ul {
        gap: 1rem;
    }

    nav a {
        font-size: 0.85rem;
    }

    /* スマホ: 余白を詰めて数式の表示領域を確保する */
    main {
        padding: 0.5rem;
    }

    article {
        padding: 0.75rem;
    }

    /* 証明カード・各種ボックスのパディング縮小 */
    .proof-card {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .proof-card-formula,
    .proof-card-conditions,
    .proof-card-notes,
    .proof-card-terms {
        padding: 0.5rem 0.75rem;
    }

    .theorem-box,
    .example-box,
    .proof-box,
    .definition-box,
    .solution,
    .summary-box,
    .goal-box {
        padding: 0.75rem;
    }

    .info-box {
        padding: 0.75rem;
    }

    article h1 {
        font-size: 1.5rem;
    }

    article h2 {
        font-size: 1.25rem;
    }

    .hero {
        padding: 2rem 1rem;
    }

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

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

    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}

/* ========================================
   印刷スタイル
   ======================================== */
@media print {
    header, footer, .toc {
        display: none;
    }

    body {
        background: white;
        color: black;
        padding-top: 0 !important;
        font-size: 20pt;
        line-height: 1.7;
    }

    body.has-fixed-header {
        padding-top: 0 !important;
    }

    main {
        max-width: 100%;
        padding: 0;
    }

    article {
        box-shadow: none;
        padding: 8mm 12mm;
        margin: 0;
    }

    article h1 {
        font-size: 32pt;
        margin-bottom: 1rem;
    }

    article h2 {
        font-size: 26pt;
        margin-top: 1.5rem;
    }

    article h3 {
        font-size: 22pt;
    }

    article p {
        font-size: 20pt;
        margin-bottom: 0.8rem;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    /* 数式ブロック：スクロールバーを無効化し、折り返しを許可 */
    .math-block {
        overflow: visible !important;
        overflow-x: visible !important;
        page-break-inside: avoid;
        background: none;
        padding: 0.8rem 0;
        margin: 0.8rem 0;
    }

    /* MathJax の印刷対応 */
    .MathJax_Display {
        overflow: visible !important;
        overflow-x: visible !important;
    }

    .MathJax {
        font-size: 150% !important;
    }

    /* 長い数式は縮小して収める */
    mjx-container {
        overflow: visible !important;
        max-width: 100% !important;
    }

    /* コードブロック */
    pre {
        overflow: visible !important;
        white-space: pre-wrap;
        word-wrap: break-word;
        background: #f5f5f5;
        color: black;
        page-break-inside: avoid;
    }

    /* セクションの改ページ制御 */
    h2, h3 {
        page-break-after: avoid;
    }

    p, .math-block {
        orphans: 3;
        widows: 3;
    }

    /* 参考文献は改ページを避ける */
    .references {
        page-break-inside: avoid;
    }
}

/* ========================================
   ページヘッダー内のパンくずリスト等
   ======================================== */
body > header .header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 1rem;
}

body > header .breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0;
    margin: 0;
}

body > header .breadcrumb a {
    color: var(--color-header-text);
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

body > header .breadcrumb a:hover {
    opacity: 1;
}

body > header .breadcrumb .separator {
    opacity: 0.6;
}

body > header .breadcrumb .current {
    opacity: 0.8;
}

/* ========================================
   記事ヘッダー
   ======================================== */
.article-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-primary);
}

.article-header h1 {
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    padding: 0;
    border: none;
}

.article-header .subtitle {
    font-size: 1.1rem;
    color: var(--color-text-secondary);
    margin: 0;
    text-align: center;
}

/* ========================================
   チャプターリスト（目次ページ用）
   ======================================== */
.chapter-list {
    display: grid;
    gap: 1rem;
    margin: 1.5rem 0;
}

.chapter-item {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.chapter-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.chapter-item a {
    display: block;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
}

.chapter-item h3 {
    background: none;
    padding: 0;
    font-size: 1.1rem;
    color: var(--color-primary);
    margin: 0 0 0.5rem 0;
}

.chapter-item p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ========================================
   前提知識ボックス
   ======================================== */
.prerequisites {
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border-left: 4px solid var(--color-primary);
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}

.prerequisites h3 {
    font-size: 1rem;
    color: var(--color-primary);
    margin: 0 0 0.75rem 0;
}

.prerequisites ul {
    margin: 0;
    padding-left: 1.25rem;
}

.prerequisites li {
    margin-bottom: 0.25rem;
    color: var(--color-text-secondary);
}

/* ========================================
   チャプターナビゲーション
   ======================================== */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.chapter-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.chapter-nav a:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.chapter-nav .prev {
    margin-right: auto;
}

.chapter-nav .next {
    margin-left: auto;
}

/* ========================================
   セクションナビゲーション（既存ページ用）
   ======================================== */
.section-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
    gap: 1rem;
}

.section-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.section-nav a:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ========================================
   学習コンテンツボックス類
   ======================================== */
.definition-box,
.theorem-box,
.example-box,
.proof-box,
.solution,
.summary-box,
.goal-box {
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.definition-box {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    border-left: 4px solid #4f46e5;
}

.definition-box h3 {
    color: #4f46e5;
    font-size: 1rem;
    margin: 0 0 0.75rem 0;
}

.theorem-box {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #d97706;
}

.theorem-box h3 {
    color: #b45309;
    font-size: 1rem;
    margin: 0 0 0.75rem 0;
}

.example-box {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-left: 4px solid #059669;
}

.example-box h3 {
    color: #047857;
    font-size: 1rem;
    margin: 0 0 0.75rem 0;
}

.proof-box {
    background: linear-gradient(135deg, #fdf4ff 0%, #fae8ff 100%);
    border-left: 4px solid #a855f7;
}

.proof-box h3 {
    color: #7c3aed;
    font-size: 1rem;
    margin: 0 0 0.75rem 0;
}

.solution {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 4px solid #64748b;
    font-size: 0.95rem;
}

.example {
    background: linear-gradient(135deg, #faf8f3 0%, #f5f1eb 100%);
    border-left: 4px solid #8b7355;
    padding: 1.2rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.example-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #5d4037;
    margin: 0 0 1rem 0;
    display: block;
}

.step-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6d4c41;
    display: inline-block;
    margin-top: 0.8rem;
    margin-bottom: 0.4rem;
}

.solution .answer {
    font-weight: bold;
    color: var(--color-primary);
    margin-top: 1rem;
}

.summary-box {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #3b82f6;
}

.summary-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.summary-box li {
    margin-bottom: 0.5rem;
}

.goal-box {
    background: linear-gradient(135deg, #f0f7ff 0%, #e0eef9 100%);
    border: 2px solid #5b9bd5;
}

.goal-box h3 {
    background: #5b9bd5;
    color: #fff;
    font-size: 1rem;
    padding: 0.5em 1.5rem;
    margin: -1.25rem -1.5rem 0.75rem;
    border-radius: 8px 8px 0 0;
}

.goal-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.goal-box li {
    margin: 0.4em 0;
    line-height: 1.6;
}

/* ========================================
   目次コンテナ（index用）
   ======================================== */
.toc-container {
    margin: 1rem 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: 0.75rem;
}

.toc-list a {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.toc-list a:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.toc-list .chapter-num {
    display: inline-block;
    color: var(--color-primary);
    font-weight: bold;
    margin-right: 0.5rem;
}

.toc-list .chapter-title {
    color: var(--color-text-primary);
    font-weight: 600;
}

.toc-list .chapter-desc {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: 0.25rem 0 0 0;
}

/* 無効化されたtoc項目 */
.toc-list li.disabled .disabled-link {
    display: block;
    padding: 1rem 1.25rem;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    text-decoration: none;
    opacity: 0.4;
    cursor: not-allowed;
}

.toc-list li.disabled .chapter-num,
.toc-list li.disabled .chapter-title {
    color: var(--color-text-secondary);
}

.toc-list li.disabled .chapter-desc {
    color: var(--color-text-secondary);
}

/* ボックス内の最終段落余白を詰める */
.definition-box p:last-child, .theorem-box p:last-child,
.example-box p:last-child, .proof-box p:last-child,
.solution p:last-child, .example p:last-child {
    margin-bottom: 0;
}

.prerequisites p:last-child, .formula-box p:last-child,
.goal-box p:last-child, .summary-box p:last-child {
    margin-bottom: 0;
}

/* ========================================
   ダークモード対応（学習コンテンツ）
   ======================================== */
@media (prefers-color-scheme: dark) {
    .definition-box {
        background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    }

    .theorem-box {
        background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
    }

    .example-box {
        background: linear-gradient(135deg, #022c22 0%, #064e3b 100%);
    }

    .proof-box {
        background: linear-gradient(135deg, #2e1065 0%, #4c1d95 100%);
    }

    .solution {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    }

    .prerequisites {
        background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%);
    }
}

/* ダークモードトグル (data-theme="dark") — 学習コンテンツボックス
   article.css の table 同様、@media と同一の背景色を data-theme でも適用 */
[data-theme="dark"] .definition-box {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
}

[data-theme="dark"] .theorem-box {
    background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
}

[data-theme="dark"] .example-box {
    background: linear-gradient(135deg, #022c22 0%, #064e3b 100%);
}

[data-theme="dark"] .proof-box {
    background: linear-gradient(135deg, #2e1065 0%, #4c1d95 100%);
}

[data-theme="dark"] .solution {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

[data-theme="dark"] .prerequisites {
    background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%);
}

/* ========================================
   証明カード（proofs.html用）
   ======================================== */
.proof-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-card-border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-sm);
}

.proof-card-header {
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.proof-card-header h4 {
    color: var(--color-primary);
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
}

.proof-card-formula {
    background: linear-gradient(135deg, #f8f9ff 0%, #eef1ff 100%);
    border-left: 4px solid var(--color-primary);
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.5rem;
    margin: 1rem 0;
}

.proof-card-conditions {
    background: linear-gradient(135deg, #fff8e6 0%, #fff3d4 100%);
    border-left: 4px solid #f0a500;
    border-radius: 0 8px 8px 0;
    padding: 0.8rem 1.2rem;
    margin: 1rem 0;
    font-size: 0.95rem;
}

.proof-card-conditions strong {
    color: #c08000;
}

.proof-card-body {
    margin-top: 1rem;
}

.proof-card-body h5 {
    color: var(--color-text-secondary);
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem 0;
}

.proof-card-notes {
    background: linear-gradient(135deg, #f0fff0 0%, #e0f8e0 100%);
    border-left: 4px solid #2e8b57;
    border-radius: 0 8px 8px 0;
    padding: 0.8rem 1.2rem;
    margin-top: 1.5rem;
    font-size: 0.95rem;
}

.proof-card-notes strong {
    color: #1e6b47;
}

.proof-card-terms {
    background: linear-gradient(135deg, #f5f0ff 0%, #ebe0ff 100%);
    border-left: 4px solid #7c3aed;
    border-radius: 0 8px 8px 0;
    padding: 0.8rem 1.2rem;
    margin-top: 1.5rem;
    font-size: 0.95rem;
}

.proof-card-terms strong {
    color: #5b21b6;
}

/* 印刷時のカードスタイル */
@media print {
    .proof-card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* ========================================
   レベルグリッド・レベルカード（トップページ用）
   ======================================== */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.level-card {
    position: relative;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.level-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.level-card h3 {
    font-size: 1.3rem;
    margin: 0 0 0.5rem 0;
}

.level-card h3 a {
    color: var(--color-primary);
    text-decoration: none;
}

/* ::after でカード全体をクリック可能にする */
.level-card h3 a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
}

.level-card h3 a:hover {
    text-decoration: underline;
}

.level-card h3 i {
    margin-right: 0.5rem;
}

.level-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.topic-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 2rem;
    margin: 1rem 0;
    padding: 0;
}

.topic-list li {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.topic-item {
    padding: 0 1em;
    break-inside: avoid;
}

.topic-item h4 {
    margin-top: 1.2em;
}

.topic-item p {
    margin: 0 0 0.5em;
}

.chapter-count {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: 0;
}

/* ========================================
   ロードマップ
   ======================================== */
.roadmap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--color-bg-surface);
    border-radius: 12px;
}

.roadmap-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-bg-base);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.roadmap-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.roadmap-content h4 {
    font-size: 0.95rem;
    margin: 0;
    color: var(--color-text-primary);
}

.roadmap-content p {
    font-size: 0.8rem;
    margin: 0;
    color: var(--color-text-secondary);
}

.roadmap-arrow {
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

/* ========================================
   公式ボックス
   ======================================== */
.formula-box {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
}

.formula-box h3 {
    font-size: 1rem;
    color: var(--color-primary);
    margin: 0 0 0.75rem 0;
    padding: 0;
    border: none;
}

.formula-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.formula-box li {
    margin-bottom: 0.5rem;
}

/* ========================================
   レスポンシブ（レベルカード・ロードマップ）
   ======================================== */
@media (max-width: 768px) {
    .topic-list {
        grid-template-columns: 1fr;
    }

    .roadmap {
        flex-direction: column;
    }

    .roadmap-arrow {
        transform: rotate(90deg);
    }
}

/* ========================================
   印刷用スタイル
   ======================================== */
@media print {
    /* 基本設定 - 本文 11pt */
    body {
        font-size: 11pt !important;
        line-height: 1.4 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        color: black !important;
    }

    body.has-fixed-header {
        padding-top: 0 !important;
    }

    /* ヘッダー・ナビゲーション・広告非表示（フッターは印刷） */
    body > header,
    nav.breadcrumb,
    .toc,
    .ad-container,
    .chapter-nav,
    ins.adsbygoogle,
    [class*="adsbygoogle"] {
        display: none !important;
    }

    /* フッター（印刷時も表示 - 薄い背景に黒字） */
    body > footer {
        display: block !important;
        margin-top: 20pt !important;
        padding: 8pt !important;
        border-top: 0.5pt solid #ccc !important;
        font-size: 6pt !important;
        text-align: center !important;
        color: #000 !important;
        background: #f5f5f5 !important;
    }

    body > footer .footer-container {
        display: block !important;
        background: transparent !important;
    }

    body > footer .footer-links {
        display: none !important;
    }

    body > footer .copyright {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #000 !important;
    }

    /* メインコンテンツ */
    main {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    article {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* 見出し */
    h1 {
        font-size: 18pt !important;
        margin-bottom: 12pt !important;
    }

    h2 {
        font-size: 14pt !important;
        margin-top: 18pt !important;
        margin-bottom: 6pt !important;
    }

    h3 {
        font-size: 12pt !important;
    }

    /* 本文 11pt */
    p {
        font-size: 11pt !important;
        margin-bottom: 5pt !important;
        orphans: 3;
        widows: 3;
    }

    li {
        font-size: 11pt !important;
    }

    /* 数式共通 */
    .math-block,
    .MathJax,
    .MathJax_Display,
    mjx-container {
        overflow: visible !important;
        max-width: 100% !important;
    }

    /* ディスプレイ数式（ブロック数式）- scaleなしで式番号を右端に */
    .math-block mjx-container[jax="SVG"],
    mjx-container[jax="SVG"][display="true"] {
        width: 100% !important;
        font-size: 0.81em !important;
    }

    /* インライン数式 - 小さめに */
    p mjx-container[jax="SVG"],
    li mjx-container[jax="SVG"] {
        font-size: 0.6em !important;
    }

    /* 改ページ制御は削除（空白が発生するため） */

    /* リンクのURL表示抑制 */
    a[href]::after {
        content: none !important;
    }

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

    /* 背景色を白に */
    .note,
    .warning,
    .tip-box,
    .formula-box,
    code,
    pre {
        background: #f5f5f5 !important;
        border: 1px solid #ccc !important;
    }

    /* 表の印刷スタイル */
    .data-table,
    .styled-table {
        width: 100% !important;
        font-size: 9pt !important;
        page-break-inside: auto;
    }

    .data-table thead,
    .styled-table thead {
        display: table-header-group;
    }

    .data-table tr,
    .styled-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .data-table th,
    .data-table td,
    .styled-table th,
    .styled-table td {
        padding: 4pt 6pt !important;
        font-size: 9pt !important;
        border: 1px solid #ccc !important;
    }

    .data-table th,
    .styled-table th {
        background: #f0f0f0 !important;
        font-weight: bold !important;
    }

    /* 行の背景色を印刷用に調整 */
    .data-table tr.layout-numerator,
    .data-table tr.layout-denominator,
    .data-table tr.layout-mixed {
        background: #f8f8f8 !important;
    }

    /* 余白調整 */
    @page {
        margin: 10mm;
    }
}

/* ========================================
   無効化リンク（未公開ページ用）
   ======================================== */
.disabled-link {
    color: #999 !important;
    pointer-events: none;
    cursor: default;
    text-decoration: none;
}

.disabled-link:hover {
    color: #999 !important;
}

.toc-list .disabled-link .chapter-title,
.toc-list .disabled-link .chapter-num {
    color: #999 !important;
}

/* 無効化カード（未公開コンテンツ用） */
.level-card.disabled,
.card.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
    filter: grayscale(30%);
}

.level-card.disabled:hover,
.card.disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========================================
   図・figcaption
   ======================================== */
figure {
    margin: 1.5rem 0;
    text-align: center;
}

figure img,
figure svg {
    max-width: 100%;
    height: auto;
}

figcaption,
article figcaption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
    padding: 0 1rem;
    /* 2 行に渡るキャプションで 2 行目が極端に短くなる現象を緩和 (Chrome 114+) */
    text-wrap: balance;
}

/* JS (figcaption-balance.js) 経由で付与されるクラス:
 * 2 行に渡り、かつ 2 行目のテキストが短い (50% 未満) ときに左寄せにする */
figcaption.fc-short-2nd-line,
article figcaption.fc-short-2nd-line {
    text-align: left;
}

/* 無効リンク（存在しないページへのリンク） */
a.disabled-link {
    color: #333333;
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

a.disabled-link:hover {
    color: #333333;
    opacity: 0.6;
}

/* ========================================
   計算機ボックス
   ======================================== */
.calculator-box {
    margin: 1.5rem 0;
    padding: 1.2rem;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.calculator-box .calc-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.calculator-box input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.calculator-box button {
    padding: 6px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.calculator-box button:hover {
    opacity: 0.85;
}

.calculator-box .calc-result {
    margin-top: 1rem;
    font-size: 1.1rem;
}

.calculator-box .calc-check {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.calculator-box .check-ok {
    color: #4CAF50;
}

.calculator-box .check-ng {
    color: #E91E63;
}

/* ========================================
   練習問題ボックス
   ======================================== */
.exercise-box {
    margin: 1.5rem 0;
    padding: 1.2rem;
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
}

.exercise-box > h4 {
    margin-top: 0;
    color: #ff9800;
}

.exercise-box details {
    margin-top: 1rem;
}

.exercise-box summary {
    cursor: pointer;
    color: #ff9800;
    font-weight: bold;
}

.exercise-box .answers {
    margin-top: 0.75rem;
}

/* ========================================
   サイト内検索（Google検索）
   ======================================== */
.search-box {
    margin: 1rem 0 1.5rem;
}

.site-search-form {
    display: flex;
    gap: 0.5rem;
    max-width: 400px;
}

.site-search-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-bg-base);
    color: var(--color-text-primary);
}

.site-search-input:focus {
    outline: none;
    border-color: var(--color-link);
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.15);
}

.site-search-btn {
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.site-search-btn:hover {
    opacity: 0.85;
}

/* ========================================
   SNS シェアボタン
   ======================================== */
.share-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.share-buttons-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-right: 0.25rem;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    font-size: 1rem;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.2s;
}

.share-btn:hover {
    opacity: 0.85;
    transform: translateY(-2px);
    color: #fff;
    text-decoration: none;
}

.share-btn.twitter  { background: #1da1f2; }
.share-btn.facebook { background: #1877f2; }
.share-btn.hatena   { background: #00a4de; font-weight: 700; font-size: 0.85rem; }
.share-btn.line     { background: #06c755; }

/* ========================================
   Sangi (算木) Unicode numerals — U+1D360–U+1D37F
   Web-loaded via Google Fonts (Noto Sans Symbols 2) for cross-platform
   rendering; system fallback fonts below for offline / pre-load state.
   ======================================== */
.sangi-numeral {
    font-family: "Noto Sans Symbols 2", "BabelStone Han", "Segoe UI Symbol", "STSong", sans-serif;
}

/* Inline <svg class="sangi-logo-inline"> in <h1>: align with text + spacing.
   The SVG itself uses fill="currentColor" so the mark inherits the text colour. */
.sangi-logo-inline {
    vertical-align: middle;
    margin-right: 0.15em;
    height: 1em;
    width: auto;
}

/* Sangi 0-9 digit table — sub-section, centered, modest heading. */
.sangi-digit-block {
    text-align: center;
    margin: 1.2em 0 1em;
}
.sangi-digit-heading {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--muted, #555);
    background: none;
    padding: 0;
    margin: 0 0 0.6em;
    text-align: center;
}
.sangi-digit-table {
    display: inline-table;
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 0.95em;
}
.sangi-digit-table th,
.sangi-digit-table td {
    border: 1px solid var(--border, #e0e0e0);
    padding: 6px 10px;
    text-align: center;
    min-width: 36px;
}
.sangi-digit-table th {
    background: rgba(127, 127, 127, 0.06);
    font-weight: 600;
}
.sangi-digit-table .sangi-numeral {
    font-size: 1.1em;
    line-height: 1;
}

/* Inline SVG rendering of sangi numerals — replaces Unicode SMP chars
   to guarantee cross-browser display without depending on Noto Sans Symbols 2 etc. */
.sangi-svg {
    display: inline-block;
    vertical-align: middle;
    height: 1.3em;
    width: auto;
    fill: currentColor;
}
.sangi-digit-table .sangi-svg {
    height: 1.6em;
}

/* Inline sangi logo prefix for links from note articles to sangi pages.
   Used inside <a href="/lib/sangi/..."> together with the link text.
   Attribute-selector fallback catches any inline SVG inside a sangi link
   even when .sangi-link-icon was forgotten on the <svg> tag (prevents
   the default 300x150 SVG size from blowing up the line). */
.sangi-link-icon,
a[href*="/lib/sangi/"] > svg {
    display: inline-block;
    vertical-align: -0.15em;
    width: 0.95em;
    height: 0.95em;
    max-width: 0.95em;
    max-height: 0.95em;
    margin-right: 0.25em;
    fill: currentColor;
    flex-shrink: 0;
}
.sangi-digit-table .sangi-digit-logo-col {
    background: rgba(0, 123, 255, 0.07);
}
.sangi-digit-note {
    font-size: 0.85em;
    color: var(--muted, #666);
    text-align: left;
    margin: 0.8em auto 0;
    max-width: 56em;
}
