/* @role: Manages all visual styling, layouts, printer settings, responsive behaviors, and navigation links for the specification documents. */

@page {
    size: A4;
    margin: 15mm 15mm;
    background-color: #ffffff;
    @bottom-right {
        content: counter(page);
        font-size: 9pt;
        font-family: 'Helvetica Neue', Arial, sans-serif;
        color: #64748b;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    background-color: #f8fafc;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    font-size: 9pt;
    line-height: 1.5;
    color: #1e293b;
    background-color: #ffffff;
    margin: 0 auto;
    padding: 15px;
    max-width: 100%;
}

@media (min-width: 768px) {
    body {
        max-width: 800px;
        margin: 30px auto;
        padding: 40px;
        border-radius: 8px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
    }
}

.cover {
    background-color: #0f172a;
    color: #ffffff;
    margin: -15px -15px 15px -15px;
    padding: 25px 20px;
    text-align: center;
}

@media (min-width: 768px) {
    .cover {
        margin: -40px -40px 20px -40px;
        border-radius: 8px 8px 0 0;
    }
}

.cover h1 {
    font-size: 18pt;
    margin: 0;
    color: #f8fafc;
    font-weight: 700;
    letter-spacing: 1px;
}

.cover p {
    font-size: 10pt;
    color: #94a3b8;
    margin-top: 8px;
}

h2 {
    font-size: 12pt;
    color: #0f172a;
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 4px;
    margin-top: 20px;
    margin-bottom: 10px;
    page-break-after: avoid;
}

h3 {
    font-size: 10.5pt;
    color: #0369a1;
    margin-top: 15px;
    margin-bottom: 8px;
    page-break-after: avoid;
}

p {
    margin-bottom: 8px;
}

ul, ol {
    margin-top: 4px;
    margin-bottom: 10px;
    padding-left: 20px;
}

li {
    margin-bottom: 4px;
}

.highlight-box {
    background-color: #eff6ff;
    border-left: 4px solid #3b82f6;
    padding: 10px 14px;
    margin-bottom: 12px;
    page-break-inside: avoid;
}

.highlight-box h4 {
    margin: 0 0 6px 0;
    color: #1d4ed8;
    font-size: 10pt;
}

/* --- Navigation & Table of Contents --- */
.nav-back {
    display: inline-block;
    margin-bottom: 15px;
    color: #0369a1;
    text-decoration: none;
    font-weight: bold;
    font-size: 9.5pt;
}

.nav-back:hover {
    text-decoration: underline;
    color: #0284c7;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}

.toc-list li {
    margin-bottom: 12px;
}

.toc-list a {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #0f172a;
    text-decoration: none;
    font-weight: bold;
    font-size: 10.5pt;
    transition: all 0.2s ease;
}

.toc-list a:hover {
    background-color: #e2e8f0;
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toc-list a::after {
    content: '➔';
    margin-left: auto;
    color: #64748b;
}

/* --- User Flow Diagram CSS --- */
.user-flow-container {
    margin-bottom: 15px;
    page-break-inside: avoid;
}
.uf-step {
    display: flex;
    align-items: stretch;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.uf-phase {
    background: #0284c7;
    color: #ffffff;
    font-weight: bold;
    padding: 10px;
    width: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 9pt;
    line-height: 1.3;
}
.uf-phase.record { background: #0284c7; }
.uf-phase.generate { background: #4f46e5; }
.uf-phase.execute { background: #059669; }
.uf-phase.heal { background: #d97706; }

.uf-content {
    padding: 8px 15px;
    flex-grow: 1;
}
.uf-title {
    font-weight: bold;
    color: #0f172a;
    font-size: 10pt;
    margin-bottom: 4px;
}
.uf-desc {
    font-size: 8.5pt;
    color: #475569;
}
.uf-arrow {
    text-align: center;
    color: #94a3b8;
    font-size: 14pt;
    line-height: 1;
    margin: 4px 0;
}

/* --- Diagrams CSS --- */
.diagram-container {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    page-break-inside: avoid;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.diagram-title {
    text-align: center;
    font-weight: bold;
    color: #475569;
    margin-bottom: 12px;
    font-size: 10pt;
}
.arch-flow {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.arch-box {
    width: 23%;
    background: #f1f5f9;
    border: 2px solid #0284c7;
    border-radius: 6px;
    padding: 8px 4px;
    text-align: center;
    font-weight: bold;
    color: #0f172a;
    font-size: 8.5pt;
}
.arch-arrow {
    color: #94a3b8;
    font-size: 14pt;
    font-weight: bold;
}
.arch-desc {
    font-size: 7.5pt;
    color: #475569;
    font-weight: normal;
    margin-top: 4px;
}
.val-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.val-node {
    background: #f8fafc;
    border: 1px solid #94a3b8;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: bold;
    margin-bottom: 0;
    z-index: 2;
}
.val-arrow-down {
    color: #94a3b8;
    font-size: 12pt;
    margin: 1px 0;
    z-index: 1;
}
.val-arrow-text {
    font-size: 7.5pt;
    color: #ef4444;
    margin-top: -2px;
    margin-bottom: 1px;
}
.val-stage-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 0;
}
.val-stage-main {
    background: #ffffff;
    border: 2px solid #3b82f6;
    border-left: 6px solid #3b82f6;
    padding: 6px 10px;
    border-radius: 4px;
    width: 50%;
    font-weight: bold;
    color: #1e293b;
    text-align: center;
}
.val-stage-arrow {
    color: #22c55e;
    font-size: 14pt;
    font-weight: bold;
    margin: 0 8px;
}
.val-stage-result {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 6px 10px;
    border-radius: 4px;
    width: 30%;
    text-align: center;
    font-weight: bold;
    font-size: 8.5pt;
}
.val-fail {
    border-color: #ef4444;
    border-left-color: #ef4444;
    background: #fef2f2;
}

/* --- Screen Transition Diagram CSS --- */
.transition-container {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 15px;
    page-break-inside: avoid;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.trans-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.trans-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 620px;
}
.trans-row.justify-center {
    justify-content: center;
}
.trans-row.justify-around {
    justify-content: space-around;
}
.trans-box {
    width: 190px;
    background: #f1f5f9;
    border: 2px solid #64748b;
    border-radius: 6px;
    padding: 10px 5px;
    text-align: center;
    font-weight: bold;
    color: #0f172a;
    font-size: 8.5pt;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.trans-box.primary { border-color: #0284c7; background: #f0f9ff; }
.trans-box.widget { border-color: #4f46e5; background: #f5f3ff; }
.trans-box.success { border-color: #059669; background: #f0fdf4; }
.trans-box.warning { border-color: #d97706; background: #fffbeb; }

.trans-arrow-horizontal-double {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    color: #94a3b8;
    font-weight: bold;
    font-size: 8pt;
}
.trans-arrow-label {
    color: #475569;
    font-size: 7.5pt;
}
.trans-arrow-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #94a3b8;
    font-size: 7.5pt;
    font-weight: bold;
    line-height: 1.4;
    padding: 4px 0;
}
.trans-arrow-text {
    color: #475569;
}

/* --- Data Tables & JSON --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 8pt;
    page-break-inside: avoid;
}
.data-table th, .data-table td {
    border: 1px solid #cbd5e1;
    padding: 6px 8px;
    text-align: left;
}
.data-table th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: bold;
}
.data-table td.type-col {
    color: #0284c7;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    width: 15%;
}
.data-table td.prop-col {
    font-weight: bold;
    width: 28%;
}

pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 8pt;
    page-break-inside: avoid;
    margin-bottom: 12px;
}

/* --- Optimization & Safety --- */
.opt-safe-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    page-break-inside: avoid;
}
.opt-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 12px 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.opt-card.safety {
    border-left: 4px solid #ef4444;
}
.opt-card.tuning {
    border-left: 4px solid #10b981;
}
.opt-title {
    font-size: 10.5pt;
    font-weight: bold;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
}
.opt-title.safety-title { color: #b91c1c; }
.opt-title.tuning-title { color: #047857; }

.formula-box {
    text-align: center;
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 8px;
    border-radius: 4px;
    margin: 8px 0;
    font-family: 'Times New Roman', serif;
    font-style: italic;
    font-weight: bold;
    color: #0369a1;
    font-size: 10.5pt;
}