/* ═══════════════════════════════════════════════════════════
   CEREBRUS OS — style.css v2.0
   Aesthetic: Terminal civic OS · SEM 2063
   Fonts: Syne (display) + JetBrains Mono (data/code)
════════════════════════════════════════════════════════════ */

/* ─── TOKENS ─────────────────────────────────────────────── */
:root {
    --bg:           #0a0c10;
    --bg-panel:     #0f1219;
    --bg-input:     #161b24;
    --bg-hover:     #1a2030;
    --border:       #1e2535;
    --border-lit:   #2a3550;
    --text:         #c8d4e8;
    --text-muted:   #5a6a85;
    --text-dim:     #3a4a60;
    --accent:       #39ff14;
    --accent-dim:   rgba(57,255,20,0.12);
    --accent-blue:  #00cfff;
    --accent-warn:  #ffb300;
    --accent-err:   #ff3b30;
    --font-display: 'Syne', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
    --radius:       8px;
    --radius-lg:    12px;
    --transition:   0.18s ease;
}

[data-theme="light"] {
    --bg:           #f0f2f7;
    --bg-panel:     #ffffff;
    --bg-input:     #f5f7fa;
    --bg-hover:     #eef1f7;
    --border:       #dde2ec;
    --border-lit:   #c4ccd9;
    --text:         #1a2035;
    --text-muted:   #5a6a85;
    --text-dim:     #9aa5b8;
    --accent:       #1a7a00;
    --accent-dim:   rgba(26,122,0,0.08);
    --accent-blue:  #006ea8;
    --accent-warn:  #b87800;
    --accent-err:   #c0392b;
}

/* ─── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-mono);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 13px;
    min-height: 100vh;
}

/* ─── SYSTEM BAR ─────────────────────────────────────────── */
.system-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 36px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.sysbar-left { display: flex; align-items: center; gap: 12px; }

.sysbar-logo {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 12px;
    color: var(--accent);
    letter-spacing: 0.08em;
}

.sysbar-version { color: var(--text-muted); }

.sysbar-tick {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

.sysbar-right { display: flex; align-items: center; gap: 12px; }

.axiom-badge {
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 1px 6px;
    border-radius: 3px;
    opacity: 0.8;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-lit);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ─── HEADER ─────────────────────────────────────────────── */
.os-header {
    border-bottom: 1px solid var(--border);
    padding: 28px 24px 20px;
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.header-title-block h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
}

.header-sub {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.header-joule-block {
    min-width: 280px;
    flex: 1;
    max-width: 420px;
}

.joule-label-top {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

/* ─── JOULE METER ────────────────────────────────────────── */
.joule-meter-wrap { width: 100%; }

.joule-meter-track {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.joule-meter-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.joule-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-muted);
    gap: 8px;
    flex-wrap: wrap;
}

.axiom07-badge {
    color: var(--accent);
    opacity: 0.7;
}

/* ─── CONTAINER ──────────────────────────────────────────── */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* ─── STATE OVERVIEW ─────────────────────────────────────── */
.state-overview {
    margin-bottom: 20px;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

.overview-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    transition: background var(--transition), border-color var(--transition);
}

.overview-card:hover { background: var(--bg-hover); }

.ov-icon { font-size: 14px; line-height: 1; }

.ov-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 4px;
}

.ov-value {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.ov-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* ─── MODULE GRID ────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 12px;
}

/* ─── PANELS ─────────────────────────────────────────────── */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.panel:hover {
    border-color: var(--border-lit);
}

.panel-full {
    grid-column: 1 / -1;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-icon { font-size: 15px; flex-shrink: 0; }

.panel-header h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    flex: 1;
    letter-spacing: -0.01em;
}

.panel-tag {
    font-size: 9px;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.panel-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-output {
    flex: 1;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: background var(--transition), box-shadow var(--transition);
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background: rgba(57,255,20,0.22);
    box-shadow: 0 0 12px rgba(57,255,20,0.15);
}

.btn-primary:active {
    transform: scale(0.98);
}

[data-theme="light"] .btn-primary:hover {
    box-shadow: 0 0 8px rgba(26,122,0,0.2);
}

/* ─── INPUTS ─────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    border-color: var(--accent);
}

input::placeholder { color: var(--text-dim); }

textarea { resize: vertical; }

/* ─── PANEL RESULT BLOCKS ────────────────────────────────── */
.panel-result {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.panel-result-header h3 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.tick-stamp {
    font-size: 10px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

/* ─── KEY-VALUE ROWS ─────────────────────────────────────── */
.kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}

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

.kv-label {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.kv-value {
    font-size: 12px;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 2px 7px;
    border-radius: 3px;
    font-weight: 500;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-ok   { background: rgba(57,255,20,0.1);  color: var(--accent);      border: 1px solid rgba(57,255,20,0.25); }
.badge-warn { background: rgba(255,179,0,0.1);  color: var(--accent-warn); border: 1px solid rgba(255,179,0,0.25); }
.badge-err  { background: rgba(255,59,48,0.1);  color: var(--accent-err);  border: 1px solid rgba(255,59,48,0.25); }

[data-theme="light"] .badge-ok   { background: rgba(26,122,0,0.08);  border-color: rgba(26,122,0,0.2); }
[data-theme="light"] .badge-warn { background: rgba(184,120,0,0.08); border-color: rgba(184,120,0,0.2); }
[data-theme="light"] .badge-err  { background: rgba(192,57,43,0.08); border-color: rgba(192,57,43,0.2); }

/* ─── CHARTS ─────────────────────────────────────────────── */
.chart-wrap {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ─── DETAILS / RAW DATA ─────────────────────────────────── */
details.raw-details {
    margin-top: 6px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
}

details.raw-details summary {
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    user-select: none;
}

details.raw-details summary:hover { color: var(--text); }

pre {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 6px;
    max-height: 240px;
    overflow-y: auto;
}

/* ─── SUSTAINABILITY ACTIONS ─────────────────────────────── */
.action-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.action-row:last-child { border-bottom: none; }

.action-indicator {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.action-row ul {
    padding-left: 14px;
    font-size: 11px;
    color: var(--text-muted);
}

.action-row li { margin: 2px 0; }

/* ─── PUBLIC LEDGER ──────────────────────────────────────── */
.ledger-output {
    max-height: 340px;
    overflow-y: auto;
}

.ledger-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.ledger-entries {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ledger-entry {
    display: grid;
    grid-template-columns: 28px 90px 1fr 60px auto 70px;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 10px;
    font-family: var(--font-mono);
    transition: background var(--transition);
}

.ledger-entry:hover { background: var(--bg-hover); }

.le-seq   { color: var(--text-dim); }
.le-module{ color: var(--accent-blue); font-weight: 500; }
.le-action{ color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.le-time  { color: var(--text-dim); }
.le-joules{ color: var(--accent-warn); }
.le-hash  { color: var(--text-dim); font-size: 9px; text-align: right; overflow: hidden; text-overflow: ellipsis; }

/* ─── JOULE BAR (inline) ─────────────────────────────────── */
.joule-bar-wrap {
    position: relative;
    height: 16px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.joule-bar {
    height: 100%;
    background: var(--accent-warn);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.joule-label {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: var(--bg);
    font-weight: 600;
}

/* ─── DIM TEXT ───────────────────────────────────────────── */
.dim { color: var(--text-dim); font-size: 11px; font-style: italic; }

/* ─── FOOTER ─────────────────────────────────────────────── */
.os-footer {
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.04em;
    max-width: 1440px;
    margin: 0 auto;
}

.footer-chain { color: var(--text-dim); }
#chain-status { color: var(--accent); }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-lit); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .system-bar { padding: 0 12px; }
    .os-header { padding: 20px 16px 16px; }
    .container { padding: 12px 16px 32px; }

    .header-inner { flex-direction: column; align-items: flex-start; gap: 16px; }
    .header-joule-block { max-width: 100%; width: 100%; }

    .grid { grid-template-columns: 1fr; }
    .overview-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }

    .ledger-entry {
        grid-template-columns: 22px 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .le-hash, .le-time { display: none; }

    .btn-primary { width: 100%; }
    .sysbar-center { display: none; }
}

/* ─── ANIMATE PANELS ON BOOT ─────────────────────────────── */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel {
    animation: fadeSlideIn 0.3s ease both;
}

.panel:nth-child(1)  { animation-delay: 0.04s; }
.panel:nth-child(2)  { animation-delay: 0.08s; }
.panel:nth-child(3)  { animation-delay: 0.12s; }
.panel:nth-child(4)  { animation-delay: 0.16s; }
.panel:nth-child(5)  { animation-delay: 0.20s; }
.panel:nth-child(6)  { animation-delay: 0.24s; }
.panel:nth-child(7)  { animation-delay: 0.28s; }
.panel:nth-child(8)  { animation-delay: 0.32s; }
.panel:nth-child(9)  { animation-delay: 0.36s; }
.panel:nth-child(10) { animation-delay: 0.40s; }
.panel:nth-child(11) { animation-delay: 0.44s; }
.panel:nth-child(12) { animation-delay: 0.48s; }

/* ════════════════════════════════════════════════
   SEM v2.0 — CSS ADDITIONS
   Append to the end of static/css/style.css
   ════════════════════════════════════════════════ */

/* ── System Bar — SEM status ──────────────────── */
.sem-status-bar {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 1.5px;
    padding: 2px 8px;
    border-radius: 2px;
    border: 1px solid #333;
    color: #555;
    transition: all 0.4s;
}
.sem-status-bar.sem-loading { color: #555; border-color: #333; }
.sem-status-bar.sem-active  { color: #aa66ff; border-color: #aa66ff55; background: #aa66ff11; }

/* ── Ethics badges ────────────────────────────── */
.badge-ethics-ok   { background: #39ff1422; border: 1px solid #39ff1444; color: #39ff14; }
.badge-ethics-warn { background: #ffb30022; border: 1px solid #ffb30044; color: #ffb300; }
.badge-ethics-err  { background: #ff3b3022; border: 1px solid #ff3b3044; color: #ff3b30; }
.badge-ethics-dil  { background: #aa66ff22; border: 1px solid #aa66ff44; color: #aa66ff; }

/* ── View Reasoning button ────────────────────── */
.btn-ethics-log {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 1px;
    padding: 2px 8px;
    border: 1px solid #aa66ff55;
    background: #aa66ff11;
    color: #aa66ff;
    cursor: pointer;
    border-radius: 2px;
    margin-left: auto;
    transition: all 0.2s;
}
.btn-ethics-log:hover { background: #aa66ff33; border-color: #aa66ff; }

/* ── Intercepted result ───────────────────────── */
.result-intercepted { border-left: 3px solid #ff3b30 !important; opacity: 0.85; }
.intercept-msg {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: #ff3b30;
    padding: 0.4rem 0;
}

/* ── SEM panel ────────────────────────────────── */
.sem-panel { border-color: #aa66ff44 !important; }
.sem-tag   { background: #aa66ff22 !important; border-color: #aa66ff44 !important; color: #aa66ff !important; }

.sem-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.scenario-wrap {
    display: flex;
    flex: 1;
    gap: 0.5rem;
    min-width: 260px;
}
.scenario-wrap input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 0.35rem 0.6rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 2px;
}

/* ── SEM Stats ─────────────────────────────────── */
.sem-stats-wrap { padding: 0.25rem 0; }
.sem-header-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.sem-version { font-family: var(--font-mono); font-size: 0.75rem; color: #aa66ff; letter-spacing: 1px; }
.sem-rules   { font-size: 0.72rem; opacity: 0.5; }

.sem-stats-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.sem-stat {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    text-align: center;
    border-radius: 2px;
}
.sem-stat-value {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.25rem;
}
.sem-stat-label { font-size: 0.65rem; letter-spacing: 1px; opacity: 0.6; }
.sem-stat-ok   .sem-stat-value { color: #39ff14; }
.sem-stat-warn .sem-stat-value { color: #ffb300; }
.sem-stat-err  .sem-stat-value { color: #ff3b30; }
.sem-stat-dil  .sem-stat-value { color: #aa66ff; }

/* ── Ethics bar ───────────────────────────────── */
.sem-bar-wrap { margin-bottom: 1.25rem; }
.sem-bar-track {
    display: flex;
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface-raised);
    margin-bottom: 0.4rem;
}
.sem-bar-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.65rem;
    opacity: 0.7;
}

/* ── Ethics log list ──────────────────────────── */
.sem-ethics-log-list { margin-top: 0.75rem; }
.sem-log-header {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 2px;
    opacity: 0.5;
    margin-bottom: 0.5rem;
}
.sem-log-entry {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    flex-wrap: wrap;
}
.sle-seq      { opacity: 0.4; min-width: 28px; }
.sle-module   { color: #aa66ff; min-width: 60px; }
.sle-action   { opacity: 0.7; flex: 1; min-width: 100px; }
.sle-decision { font-weight: 700; min-width: 80px; }
.sle-weight   { opacity: 0.5; font-size: 0.65rem; }
.sle-time     { opacity: 0.4; margin-left: auto; }

/* ── Ontology ─────────────────────────────────── */
.ontology-wrap   { padding: 0.25rem 0; }
.ontology-title  { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 2px; opacity: 0.6; margin-bottom: 1rem; }
.ontology-tier   {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface-raised);
    border-radius: 2px;
}
.tier-header {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 2px;
    margin-bottom: 0.6rem;
    font-weight: 700;
}
.ontology-rule {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.ontology-rule:hover { background: var(--hover); margin: 0 -1rem; padding: 0.35rem 1rem; }
.rule-id         { font-family: var(--font-mono); font-size: 0.7rem; opacity: 0.7; min-width: 90px; }
.rule-name       { flex: 1; font-size: 0.78rem; }
.rule-weight     { font-family: var(--font-mono); font-size: 0.7rem; white-space: nowrap; }
.rule-exceptions { font-size: 0.65rem; opacity: 0.4; white-space: nowrap; }

/* ── Rule detail ──────────────────────────────── */
.rule-detail { padding: 0.25rem 0; }
.btn-back {
    background: none;
    border: 1px solid var(--border);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 3px 8px;
    cursor: pointer;
    margin-bottom: 1rem;
    opacity: 0.7;
}
.btn-back:hover { opacity: 1; }
.rule-detail-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    border-left: 3px solid;
    padding-left: 0.75rem;
    margin-bottom: 0.5rem;
}
.rule-detail-id   { font-family: var(--font-mono); font-size: 1rem; font-weight: 700; }
.rule-detail-tier { font-family: var(--font-mono); font-size: 0.65rem; opacity: 0.5; }
.rule-detail-name { font-family: var(--font-display); font-size: 1rem; margin-bottom: 0.75rem; }
.rule-detail-statement {
    font-size: 0.82rem;
    line-height: 1.7;
    opacity: 0.85;
    padding: 0.75rem;
    background: var(--surface-raised);
    border-radius: 2px;
    margin-bottom: 0.75rem;
    border-left: 2px solid var(--border);
}
.rule-detail-meta { margin-bottom: 0.75rem; }
.rule-exceptions-block { margin-top: 0.75rem; }
.rule-exc-title {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 2px;
    opacity: 0.5;
    margin-bottom: 0.5rem;
}
.rule-exc {
    padding: 0.6rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 2px;
    margin-bottom: 0.4rem;
}
.exc-cond   { font-size: 0.78rem; margin-bottom: 0.25rem; font-style: italic; opacity: 0.8; }
.exc-effect { font-size: 0.75rem; margin-bottom: 0.25rem; opacity: 0.7; }
.exc-adj    { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; }

/* ── Dilemma Modal ────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(6px);
}
.modal-box {
    background: var(--surface);
    border: 1px solid #aa66ff;
    box-shadow: 0 0 60px #aa66ff22, 0 0 120px #aa66ff0a;
    padding: 2rem;
    max-width: 560px;
    width: 92%;
    border-radius: 4px;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
.modal-header {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.modal-icon   { font-size: 1.5rem; }
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: #aa66ff;
    letter-spacing: 3px;
    margin: 0;
}
.modal-badge {
    margin-left: auto;
    font-size: 0.6rem;
    background: #aa66ff22;
    border: 1px solid #aa66ff44;
    color: #aa66ff;
    padding: 2px 8px;
    letter-spacing: 2px;
    white-space: nowrap;
}
.dilemma-text {
    font-size: 0.84rem;
    line-height: 1.7;
    margin-bottom: 1rem;
    opacity: 0.9;
}
.dilemma-reasoning {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: var(--surface-raised);
    border-radius: 2px;
}
.d-vote       { font-size: 0.72rem; opacity: 0.7; font-family: var(--font-mono); }
.d-vote strong { color: var(--accent); opacity: 1; }
.dilemma-weight-bar {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1.75rem;
}
.weight-label { font-size: 0.68rem; opacity: 0.6; white-space: nowrap; font-family: var(--font-mono); }
.weight-track {
    flex: 1; height: 5px;
    background: var(--border); border-radius: 2px;
}
.weight-fill  {
    height: 100%; background: #aa66ff;
    border-radius: 2px; transition: width 0.5s ease;
}
.weight-value { font-size: 0.68rem; opacity: 0.7; white-space: nowrap; font-family: var(--font-mono); }
.modal-footer { display: flex; gap: 1rem; margin-bottom: 1rem; }
.btn-dilemma-allow {
    flex: 1; padding: 0.65rem;
    background: #00c89622; border: 1px solid #00c896;
    color: #00c896; font-family: var(--font-mono); font-size: 0.8rem;
    cursor: pointer; letter-spacing: 1.5px; border-radius: 2px;
    transition: all 0.2s;
}
.btn-dilemma-allow:hover { background: #00c896; color: #000; }
.btn-dilemma-block {
    flex: 1; padding: 0.65rem;
    background: #ff3b3022; border: 1px solid #ff3b30;
    color: #ff3b30; font-family: var(--font-mono); font-size: 0.8rem;
    cursor: pointer; letter-spacing: 1.5px; border-radius: 2px;
    transition: all 0.2s;
}
.btn-dilemma-block:hover { background: #ff3b30; color: #fff; }
.modal-audit-note {
    font-size: 0.62rem; opacity: 0.35;
    text-align: center; letter-spacing: 1.5px;
    font-family: var(--font-mono);
}

/* ── Ethical Log Side Panel ───────────────────── */
.ethical-log-panel {
    position: fixed; right: 0; top: 0; bottom: 0;
    width: 430px; max-width: 95vw;
    background: var(--surface);
    border-left: 1px solid #aa66ff44;
    box-shadow: -12px 0 48px rgba(0,0,0,0.5), -1px 0 0 #aa66ff22;
    z-index: 900;
    display: flex; flex-direction: column;
    animation: slideIn 0.2s ease;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.log-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #aa66ff33;
    font-family: var(--font-mono); font-size: 0.7rem;
    letter-spacing: 2px; color: #aa66ff;
}
.log-panel-header button {
    background: none; border: none; color: var(--fg);
    cursor: pointer; font-size: 1rem; opacity: 0.5;
    transition: opacity 0.2s;
}
.log-panel-header button:hover { opacity: 1; }
.log-panel-content { flex: 1; overflow-y: auto; padding: 1.25rem; }

.log-decision {
    font-family: var(--font-mono); font-size: 1.1rem;
    font-weight: 700; letter-spacing: 2px;
    margin-bottom: 1rem;
    display: flex; align-items: center; gap: 1rem;
}
.log-weight { font-size: 0.68rem; opacity: 0.5; color: var(--fg); }
.log-triggered { margin-bottom: 0.85rem; font-size: 0.78rem; line-height: 1.8; }
.log-rule {
    display: inline-block;
    background: var(--surface-raised); border: 1px solid var(--border);
    padding: 1px 6px; margin: 2px;
    font-size: 0.68rem; font-family: var(--font-mono);
    border-radius: 2px;
}
.log-votes {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 0.85rem;
}
.vote {
    font-size: 0.68rem; padding: 3px 8px;
    border-radius: 2px; font-family: var(--font-mono);
}
.vote.deontologist  { background: #ff3b3015; border: 1px solid #ff3b3030; }
.vote.contextualizer{ background: #39ff1415; border: 1px solid #39ff1430; }
.vote.devils        { background: #aa66ff15; border: 1px solid #aa66ff30; }
.log-debate {
    margin-bottom: 0.85rem; opacity: 0.8;
    line-height: 1.6; font-size: 0.78rem;
}
.log-json-details summary {
    cursor: pointer; font-family: var(--font-mono);
    font-size: 0.65rem; opacity: 0.4; letter-spacing: 1px;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
}
.log-json {
    font-size: 0.62rem; opacity: 0.45;
    overflow-x: auto; white-space: pre-wrap;
    margin-top: 0.5rem;
    font-family: var(--font-mono);
}

/* ── Ledger SEM entries ───────────────────────── */
.le-sem { background: #aa66ff08 !important; }
.le-decision { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
