/* TROPTIONS Institutional Manual — readable light theme, no neon */
:root {
 --bg: #fafbfc;
 --bg-panel: #ffffff;
 --bg-sidebar: #f0f2f5;
 --border: #d8dee4;
 --text: #1c2128;
 --text-secondary: #424a53;
 --text-muted: #656d76;
 --accent: #8b6914;
 --accent-soft: #f5f0e1;
 --link: #0550ae;
 --live: #1a7f37;
 --devnet: #9a6700;
 --legacy: #656d76;
 --font: "Segoe UI", system-ui, -apple-system, sans-serif;
 --font-serif: Georgia, "Times New Roman", serif;
 --sidebar: 300px;
 --topbar: 56px;
 --line: 1.65;
}

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

body {
 font-family: var(--font);
 font-size: 16px;
 line-height: var(--line);
 color: var(--text);
 background: var(--bg);
 height: 100vh;
 overflow: hidden;
}

#app {
 display: grid;
 grid-template-columns: var(--sidebar) 1fr;
 grid-template-rows: var(--topbar) 1fr;
 height: 100vh;
}

.top-bar {
 grid-column: 1 / -1;
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 0 20px;
 background: var(--bg-panel);
 border-bottom: 1px solid var(--border);
 z-index: 10;
}

.logo {
 font-family: var(--font-serif);
 font-size: 1.25rem;
 font-weight: 700;
 color: var(--accent);
 letter-spacing: 0.02em;
}

.subtitle {
 font-size: 0.875rem;
 color: var(--text-muted);
 margin-left: 12px;
 padding-left: 12px;
 border-left: 1px solid var(--border);
}

.top-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.nav-pill {
 font-size: 0.8125rem;
 padding: 6px 12px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-panel);
 color: var(--text-secondary);
 text-decoration: none;
}
.nav-pill:hover { background: var(--accent-soft); color: var(--text); }

.btn-tts, .training-toggle {
 font-size: 0.8125rem;
 padding: 6px 12px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-panel);
 cursor: pointer;
 color: var(--text);
}
.btn-tts.active, .training-toggle.active { background: var(--accent-soft); border-color: var(--accent); }

.stats-badge {
 font-size: 0.75rem;
 padding: 4px 10px;
 background: var(--accent-soft);
 border-radius: 6px;
 color: var(--accent);
}

.sidebar {
 grid-column: 1;
 grid-row: 2;
 background: var(--bg-sidebar);
 border-right: 1px solid var(--border);
 overflow-y: auto;
 padding: 16px 0;
}

.sidebar h3 {
 font-size: 0.75rem;
 text-transform: uppercase;
 letter-spacing: 0.06em;
 color: var(--text-muted);
 padding: 0 16px 8px;
}

.nav-list { list-style: none; }

.nav-link {
 display: block;
 padding: 10px 16px;
 font-size: 0.9375rem;
 color: var(--text-secondary);
 text-decoration: none;
 border-left: 3px solid transparent;
}
.nav-link:hover { background: #e8ebef; color: var(--text); }
.nav-link.active {
 background: var(--bg-panel);
 color: var(--text);
 border-left-color: var(--accent);
 font-weight: 600;
}

.nav-divider { height: 1px; background: var(--border); margin: 8px 16px; }

.content {
 grid-column: 2;
 grid-row: 2;
 overflow-y: auto;
 padding: 32px 40px 100px;
 max-width: 920px;
 min-height: 0;
}

.section { display: none; }
.section.active { display: block; }

.section h1 {
 font-family: var(--font-serif);
 font-size: 1.75rem;
 font-weight: 700;
 margin-bottom: 8px;
 color: var(--text);
}

.section-subtitle {
 font-size: 1.0625rem;
 color: var(--text-secondary);
 margin-bottom: 24px;
}

.section h2 {
 font-size: 1.25rem;
 margin: 28px 0 12px;
 color: var(--text);
 border-bottom: 1px solid var(--border);
 padding-bottom: 6px;
}

.section h3 { font-size: 1.0625rem; margin: 20px 0 8px; }

.section p, .section li {
 font-size: 1rem;
 margin-bottom: 12px;
 color: var(--text-secondary);
}

.section ul, .section ol { margin: 0 0 16px 24px; }

.callout {
 background: var(--accent-soft);
 border: 1px solid #e8dfc4;
 border-radius: 8px;
 padding: 16px 20px;
 margin: 20px 0;
 font-size: 0.9375rem;
}

.callout strong { color: var(--accent); }

.stat-grid {
 display: grid;
 grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
 gap: 12px;
 margin: 20px 0;
}

.stat-card {
 background: var(--bg-panel);
 border: 1px solid var(--border);
 border-radius: 8px;
 padding: 16px;
 text-align: center;
}

.stat-num { font-size: 1.5rem; font-weight: 700; color: var(--accent); display: block; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); }

.data-table {
 width: 100%;
 border-collapse: collapse;
 font-size: 0.9375rem;
 margin: 16px 0;
}

.data-table th, .data-table td {
 border: 1px solid var(--border);
 padding: 10px 12px;
 text-align: left;
}

.data-table th { background: var(--bg-sidebar); font-weight: 600; }
.data-table a { color: var(--link); }

.badge {
 display: inline-block;
 font-size: 0.75rem;
 padding: 2px 8px;
 border-radius: 4px;
 font-weight: 600;
}
.badge-live { background: #dafbe1; color: var(--live); }
.badge-proven { background: #ddf4ff; color: #0550ae; }
.badge-devnet { background: #fff8c5; color: var(--devnet); }
.badge-pipeline { background: #fff1e5; color: #9a6700; }
.badge-draft { background: #f6f8fa; color: #656d76; border: 1px solid var(--border); }
.badge-repo { background: #fbefff; color: #6639ba; }
.badge-source { background: #fbefff; color: #6639ba; }
.badge-sandbox { background: #fff8c5; color: #9a6700; border: 1px dashed #d4a72c; }
.badge-partial { background: #fff8e1; color: #9a6700; border: 1px solid #d4a72c; }
.badge-recovery { background: #fff1e5; color: #bc4c00; border: 1px solid #fb923c; }
.badge-stub { background: #f6f8fa; color: #656d76; border: 1px dashed var(--border); }
.badge-phase2 { background: #ddf4ff; color: #0550ae; border: 1px dashed #54aeff; }
.badge-legacy { background: #eaeef2; color: var(--legacy); }
.badge-down { background: #ffebe9; color: #cf222e; border: 1px solid #ff8182; }
.badge-local { background: #ddf4ff; color: #0550ae; border: 1px solid #54aeff; }

.standing-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }

.mermaid-block {
 background: var(--bg-panel);
 border: 1px solid var(--border);
 border-radius: 8px;
 padding: 20px;
 overflow-x: auto;
 margin: 20px 0;
}
.mermaid-block pre {
 font-family: ui-monospace, "Cascadia Code", monospace;
 font-size: 11px;
 line-height: 1.5;
 color: var(--text-secondary);
 white-space: pre;
 margin: 0;
}
.standing-legend .badge { font-size: 0.6875rem; }

.audio-section-controls {
 margin: 16px 0;
 display: flex;
 gap: 8px;
 flex-wrap: wrap;
}

.audio-btn {
 font-size: 0.875rem;
 padding: 8px 16px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-panel);
 cursor: pointer;
 color: var(--text);
}
.audio-btn:hover { background: var(--accent-soft); }

.tts-panel {
 position: fixed;
 bottom: 0;
 left: var(--sidebar);
 right: 0;
 background: var(--bg-panel);
 border-top: 1px solid var(--border);
 padding: 12px 20px;
 z-index: 20;
}
.tts-panel.hidden { display: none; }

.tts-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.tts-btn {
 width: 36px; height: 36px;
 border: 1px solid var(--border);
 border-radius: 6px;
 background: var(--bg-panel);
 cursor: pointer;
 font-size: 1rem;
}

.audio-progress-container {
 flex: 1;
 min-width: 120px;
 height: 8px;
 background: var(--bg-sidebar);
 border-radius: 4px;
 cursor: pointer;
}
.audio-progress-fill {
 height: 100%;
 background: var(--accent);
 border-radius: 4px;
 width: 0;
}

.tts-status, .audio-time, .audio-voice-label {
 font-size: 0.8125rem;
 color: var(--text-muted);
}

.system-card {
 border: 1px solid var(--border);
 border-radius: 8px;
 padding: 16px;
 margin-bottom: 12px;
 background: var(--bg-panel);
}
.system-card h3 { margin: 0 0 8px; font-size: 1.0625rem; }
.system-card .meta { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 8px; }

/* System module layout — federated app modules */
.module-page { padding-bottom: 48px; }
.module-standing {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 gap: 8px;
 margin-bottom: 16px;
}
.standing-detail {
 font-size: 0.875rem;
 color: var(--text-secondary);
}
.module-identity {
 margin-bottom: 24px;
 padding: 20px;
 background: var(--bg-panel);
 border: 1px solid var(--border);
 border-radius: 10px;
}
.module-what {
 font-size: 1.0625rem;
 line-height: 1.7;
 margin: 12px 0 16px;
 color: var(--text);
}
.module-links {
 display: flex;
 flex-wrap: wrap;
 gap: 8px;
}
.module-link-pill { font-size: 0.8125rem; }
.module-grid {
 display: grid;
 grid-template-columns: repeat(2, 1fr);
 gap: 16px;
 margin: 24px 0;
}
.module-grid-condensed { margin: 16px 0; }
.module-card {
 padding: 18px;
 background: var(--bg-panel);
 border: 1px solid var(--border);
 border-radius: 10px;
 border-top: 3px solid var(--accent);
}
.module-card-label {
 font-family: var(--font-serif);
 font-size: 0.9375rem;
 font-weight: 600;
 margin: 0 0 10px;
 color: var(--accent);
 text-transform: uppercase;
 letter-spacing: 0.04em;
}
.module-card p {
 font-size: 0.9375rem;
 color: var(--text-secondary);
 line-height: 1.65;
 margin: 0;
}
.module-open { margin-top: 16px; }
.module-open-link {
 font-weight: 700;
 font-size: 1rem;
 color: var(--link);
}
.module-footer-nav {
 margin-top: 32px;
 padding-top: 16px;
 border-top: 1px solid var(--border);
 font-size: 0.9375rem;
}
.module-teaser { margin: 16px 0; }

@media (max-width: 768px) {
 .module-grid { grid-template-columns: 1fr; }
 .top-bar-right { max-height: 120px; overflow-y: auto; }
}

.nav-group-label {
 font-size: 0.6875rem;
 font-weight: 700;
 text-transform: uppercase;
 letter-spacing: 0.06em;
 color: var(--text-muted);
 padding: 8px 16px 4px;
}
.nav-external { font-weight: 500; }
.chapter-link {
 margin-top: 20px;
 padding: 12px 16px;
 background: var(--accent-soft);
 border-left: 3px solid var(--accent);
 border-radius: 0 6px 6px 0;
 font-size: 0.9375rem;
}
.chapter-link a { font-weight: 600; }

/* AI Knowledge Assistant */
.ai-fab {
 position: fixed;
 bottom: 24px;
 right: 24px;
 z-index: 9999;
 display: flex;
 align-items: center;
 gap: 8px;
 padding: 12px 20px;
 background: linear-gradient(135deg, #8b6914, #0550ae);
 color: #fff;
 border: none;
 border-radius: 50px;
 cursor: pointer;
 font-size: 14px;
 font-weight: 600;
 box-shadow: 0 4px 20px rgba(139, 105, 20, 0.35);
 transition: all 0.3s ease;
}
.ai-fab:hover { transform: translateY(-2px); }
.ai-fab-active { background: linear-gradient(135deg, #c44, #8b6914); }
.ai-panel {
 position: fixed;
 bottom: 80px;
 right: 24px;
 z-index: 9998;
 width: 420px;
 max-width: calc(100vw - 48px);
 height: 560px;
 max-height: calc(100vh - 120px);
 background: #fff;
 border: 1px solid var(--border);
 border-radius: 16px;
 display: flex;
 flex-direction: column;
 overflow: hidden;
 box-shadow: 0 12px 48px rgba(0,0,0,0.15);
 opacity: 0;
 transform: translateY(20px) scale(0.95);
 pointer-events: none;
 transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-panel.ai-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.ai-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--bg-sidebar); border-bottom: 1px solid var(--border); }
.ai-header-title { font-size: 14px; font-weight: 700; }
.ai-mode-btn { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; }
.ai-mode-simple { background: #e6f4ea; color: var(--live); }
.ai-mode-deep { background: #ddf4ff; color: var(--link); }
.ai-close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.ai-suggestion { padding: 4px 10px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px; font-size: 11px; cursor: pointer; }
.ai-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; }
.ai-msg-user { flex-direction: row-reverse; }
.ai-msg-avatar { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.ai-msg-user .ai-msg-avatar { background: var(--link); color: #fff; }
.ai-msg-assistant .ai-msg-avatar { background: var(--accent); color: #fff; }
.ai-msg-text { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.ai-msg-user .ai-msg-text { background: #ddf4ff; border-radius: 12px 12px 2px 12px; }
.ai-msg-assistant .ai-msg-text { background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: 12px 12px 12px 2px; }
.ai-msg-text strong { color: var(--accent); }
.ai-msg-text code { background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.ai-related { margin-top: 8px; font-size: 11px; color: var(--text-muted); }
.ai-input-area { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.ai-input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; outline: none; }
.ai-send { width: 38px; height: 38px; background: var(--accent); border: none; border-radius: 10px; color: #fff; font-size: 18px; cursor: pointer; }

@media (max-width: 900px) {
 #app { grid-template-columns: 1fr; }
 .sidebar { display: none; }
 .tts-panel { left: 0; }
 .content { padding: 20px; }
 .ai-panel { width: calc(100vw - 24px); right: 12px; bottom: 72px; }
 .ai-fab { right: 12px; bottom: 12px; }
}
