/* Meta Council - Design System */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #232733;
    --bg-card: #1e2230;
    --bg-hover: #282d3e;
    --border: #2d3348;
    --border-light: #3a4160;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0b4;
    --text-muted: #6b7394;
    --accent: #6c8cff;
    --accent-hover: #8aa4ff;
    --accent-dim: rgba(108, 140, 255, 0.1);
    --success: #4ade80;
    --success-dim: rgba(74, 222, 128, 0.1);
    --warning: #fbbf24;
    --warning-dim: rgba(251, 191, 36, 0.1);
    --danger: #f87171;
    --danger-dim: rgba(248, 113, 113, 0.1);
    --info: #38bdf8;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: 150ms ease;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #eef0f4;
    --bg-card: #ffffff;
    --bg-hover: #f0f1f5;
    --border: #e0e3ea;
    --border-light: #d0d4de;
    --text-primary: #1a1d27;
    --text-secondary: #5a6178;
    --text-muted: #8890a8;
    --accent: #4f6df5;
    --accent-hover: #3d5be0;
    --accent-dim: rgba(79, 109, 245, 0.08);
    --success: #16a34a;
    --success-dim: rgba(22, 163, 74, 0.08);
    --warning: #d97706;
    --warning-dim: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-dim: rgba(220, 38, 38, 0.08);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
.app-layout {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, #161929 100%);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile hamburger button — hidden on desktop */
.sidebar-hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.sidebar-hamburger:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
    opacity: 0;
    transition: opacity 280ms ease;
}

.sidebar-overlay.visible {
    opacity: 1;
}

.sidebar-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.sidebar-brand p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

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

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav li a.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left-color: var(--accent);
}

.subnav-arrow {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.has-subnav > a.active .subnav-arrow,
.sidebar-subnav.open ~ a .subnav-arrow {
    color: var(--accent);
}
.sidebar-subnav.open + a .subnav-arrow { /* won't match but harmless */ }
li.has-subnav:has(.sidebar-subnav.open) > a .subnav-arrow {
    transform: rotate(-90deg);
}
.sidebar-subnav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
}
.sidebar-subnav.open {
    display: block;
}
.sidebar-subnav li a {
    padding: 7px 20px 7px 46px;
    font-size: 13px;
}
.sidebar-subnav li a .nav-icon {
    font-size: 14px;
}

.sidebar-nav li a .nav-icon {
    width: 22px;
    text-align: center;
    font-size: 17px;
    flex-shrink: 0;
    transition: transform var(--transition);
}

.sidebar-nav li a:hover .nav-icon {
    transform: scale(1.15);
}

.sidebar-nav li a.active .nav-icon {
    transform: scale(1.1);
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 32px 40px;
    max-width: 1200px;
}

/* Page transition */
.page {
    animation: pageEnter 220ms ease both;
}

@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Page header */
.page-header {
    margin-bottom: 28px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(108, 140, 255, 0.06);
    transform: translateY(-2px);
}

.card:active {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

/* Loading skeleton */
@keyframes shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-hover)    50%,
        var(--bg-tertiary) 75%
    );
    background-size: 600px 100%;
    animation: shimmer 1.6s infinite linear;
    border-radius: var(--radius);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-line {
    height: 13px;
    margin-bottom: 8px;
}

.skeleton-line.short  { width: 55%; }
.skeleton-line.medium { width: 75%; }
.skeleton-line.full   { width: 100%; }

.agent-card-skeleton {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.agent-card-skeleton .skeleton-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.agent-card-skeleton .skeleton-lines {
    flex: 1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* Agent grid */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.agent-card {
    cursor: pointer;
}

.agent-card-top {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.agent-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    overflow: hidden;
}

.agent-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agent-info h4 {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.agent-info .agent-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.agent-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
}

.weight-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.weight-critical { background: var(--danger-dim); color: var(--danger); }
.weight-high { background: var(--warning-dim); color: var(--warning); }
.weight-standard { background: var(--success-dim); color: var(--success); }
.weight-advisory { background: var(--accent-dim); color: var(--text-secondary); }

.agent-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 150ms ease, box-shadow 150ms ease, transform 100ms ease, border-color 150ms ease;
    text-decoration: none;
    position: relative;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
    box-shadow: none !important;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(108, 140, 255, 0.35);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(108, 140, 255, 0.5);
}

.btn-primary:active {
    background: #5578e8;
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
    box-shadow: 0 2px 8px rgba(248, 113, 113, 0.25);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-group {
    display: flex;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

textarea.form-control.tall {
    min-height: 400px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa0b4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.modal-overlay.visible .modal {
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

/* Council Query */
.query-section {
    margin-bottom: 24px;
}

.query-textarea {
    min-height: 150px;
    font-size: 15px;
    font-family: inherit;
}

/* Council Results */
.results-container {
    display: none;
}

.results-container.visible {
    display: block;
}

.phase-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.phase-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.phase-dot.active {
    background: var(--accent);
    animation: pulse 1.5s infinite;
}

.phase-dot.complete { background: var(--success); }
.phase-dot.failed { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Deliberation theater — the fun animated thinking display */
.deliberation-theater {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
    overflow: hidden;
    position: relative;
}

.deliberation-theater .theater-header {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.deliberation-word {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    min-height: 40px;
    animation: wordFade 2s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes wordFade {
    0%, 100% { opacity: 0.4; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1); }
}

.deliberation-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    min-height: 20px;
    transition: opacity 0.3s;
}

/* Orbiting agent avatars */
.orbit-ring {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 20px auto;
}

.orbit-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    animation: centerPulse 3s ease-in-out infinite;
    z-index: 2;
}

@keyframes centerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(108,140,255,0.4); }
    50% { box-shadow: 0 0 0 20px rgba(108,140,255,0); }
}

.orbit-agent {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    transition: all 0.5s ease;
    z-index: 1;
}

.orbit-agent.thinking {
    border-color: var(--accent);
    animation: agentThink 1.5s ease-in-out infinite;
}

.orbit-agent.done {
    border-color: var(--success);
    background: var(--success-dim);
    color: var(--success);
}

.orbit-agent.failed {
    border-color: var(--danger);
    background: var(--danger-dim);
    color: var(--danger);
}

@keyframes agentThink {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(108,140,255,0.3); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(108,140,255,0); }
}

/* Connection lines from center to agents */
.orbit-line {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 1px;
    background: var(--border);
    transform-origin: left center;
    z-index: 0;
    opacity: 0.4;
}

.orbit-line.active { background: var(--accent); opacity: 0.6; }
.orbit-line.done { background: var(--success); opacity: 0.5; }

/* Progress bar for overall deliberation */
.deliberation-progress {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin-top: 16px;
    overflow: hidden;
}

.deliberation-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* Synthesizing animation */
.synth-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 16px 0;
}

.synth-bar {
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
    animation: synthBounce 1s ease-in-out infinite;
}

.synth-bar:nth-child(2) { animation-delay: 0.1s; }
.synth-bar:nth-child(3) { animation-delay: 0.2s; }
.synth-bar:nth-child(4) { animation-delay: 0.3s; }
.synth-bar:nth-child(5) { animation-delay: 0.4s; }
.synth-bar:nth-child(6) { animation-delay: 0.5s; }
.synth-bar:nth-child(7) { animation-delay: 0.6s; }

@keyframes synthBounce {
    0%, 100% { height: 8px; opacity: 0.4; }
    50% { height: 28px; opacity: 1; }
}

.agent-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.agent-status-card {
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-status-card .status-icon {
    font-size: 18px;
}

.agent-status-card .agent-status-info h5 {
    font-size: 13px;
    font-weight: 600;
}

.agent-status-card .agent-status-info p {
    font-size: 11px;
    color: var(--text-muted);
}

.agent-status-card.pending { opacity: 0.5; }
.agent-status-card.running { border-color: var(--accent); }
.agent-status-card.completed { border-color: var(--success); }
.agent-status-card.failed { border-color: var(--danger); }

/* Synthesis results */
.synthesis-result {
    margin-top: 20px;
}

.synthesis-result .exec-summary {
    font-size: 15px;
    line-height: 1.8;
    padding: 20px;
    padding-left: 16px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 20px;
}

.synthesis-section {
    margin-bottom: 20px;
}

.synthesis-section h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--accent);
}

.synthesis-section ul {
    list-style: none;
    padding: 0;
}

.synthesis-section ul li {
    padding: 6px 0 6px 20px;
    position: relative;
    font-size: 14px;
    color: var(--text-secondary);
}

.synthesis-section ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.risk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.risk-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.risk-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.risk-table tr:hover td { background: var(--bg-hover); }

.likelihood-high, .impact-high { color: var(--danger); font-weight: 600; }
.likelihood-medium, .impact-medium { color: var(--warning); font-weight: 600; }
.likelihood-low, .impact-low { color: var(--success); }

/* Risk row severity backgrounds */
.risk-row-critical td { background: rgba(239, 68, 68, 0.08); }
.risk-row-high td { background: rgba(239, 68, 68, 0.04); }
.risk-row-medium td { background: rgba(245, 158, 11, 0.04); }
.risk-row-critical:hover td { background: rgba(239, 68, 68, 0.14) !important; }
.risk-row-high:hover td { background: rgba(239, 68, 68, 0.08) !important; }

/* Raised By column — highlight agent name */
.risk-raised-by { font-weight: 600; color: var(--accent); }

/* History card delete button */
.btn-icon-delete {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
}
.btn-icon-delete:hover {
    opacity: 1;
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.08);
}

/* Agent tier grouping — override parent grid when showing tiers */
.agent-grid:has(.agents-tier-header) {
    display: block;
}
.agents-tier-header {
    padding: 24px 0 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.agents-tier-header:first-child { padding-top: 4px; }
.agents-tier-header h3 { font-size: 1.05em; font-weight: 700; }
.agents-tier-header p { margin-top: 2px; }
.agents-tier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Model info bar below synthesis header */
.synthesis-models-info {
    padding: 6px 16px;
    font-size: 12px;
    color: var(--text-muted, #888);
    background: var(--bg-secondary, #f7f7f8);
    border-bottom: 1px solid var(--border);
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}

.confidence-label {
    font-size: 20px;
    font-weight: 700;
    min-width: 50px;
}

/* Agent detail panel in results */
.agent-result-card {
    margin-bottom: 12px;
    cursor: pointer;
}

.agent-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-result-header .left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-result-body {
    display: none;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.agent-result-body.expanded { display: block; }

.btn-icon-copy {
    background: none; border: none; cursor: pointer; font-size: 14px;
    opacity: 0.4; transition: opacity 0.15s; padding: 2px 4px;
}
.btn-icon-copy:hover { opacity: 1; }

.reasoning-block {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    max-height: 500px;
    overflow-y: auto;
    margin-top: 12px;
    user-select: text;
    cursor: text;
}

.reasoning-block h1, .reasoning-block h2, .reasoning-block h3 {
    font-size: 14px; color: var(--accent); margin: 12px 0 6px;
}
.reasoning-block p { margin-bottom: 8px; }
.reasoning-block ul, .reasoning-block ol { padding-left: 20px; margin-bottom: 8px; }
.reasoning-block li { margin-bottom: 3px; }
.reasoning-block strong { color: var(--text-primary); }

/* Profile image upload */
.profile-upload {
    position: relative;
    display: inline-block;
}

.profile-upload input[type="file"] {
    display: none;
}

.profile-upload .upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    cursor: pointer;
    font-size: 12px;
    color: white;
}

.profile-upload:hover .upload-overlay { opacity: 1; }

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    gap: 0;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

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

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: toastSlideIn 280ms cubic-bezier(0.34, 1.3, 0.64, 1) both;
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}

.toast.toast-dismiss {
    animation: toastSlideOut 220ms ease forwards;
}

.toast-success { background: var(--success); color: #000; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--accent);  color: #fff; }
.toast-warning { background: var(--warning); color: #000; }

@keyframes toastSlideIn {
    from { transform: translateX(calc(100% + 24px)); opacity: 0; }
    to   { transform: translateX(0);                  opacity: 1; }
}

@keyframes toastSlideOut {
    from { transform: translateX(0);                  opacity: 1; max-height: 80px; margin-bottom: 0; }
    to   { transform: translateX(calc(100% + 24px)); opacity: 0; max-height: 0;    margin-bottom: -8px; }
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
    flex-shrink: 0;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.spinner-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

/* Sticky footer */
.app-footer {
    margin-left: 240px;
    padding: 20px 40px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.app-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    flex-wrap: wrap;
    gap: 12px;
}

/* Responsive — tablet */
@media (max-width: 1024px) {
    .main-content { padding: 24px 28px; }
}

/* Responsive — mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-hamburger {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: 64px; /* room for hamburger */
    }

    .app-footer {
        margin-left: 0;
        padding: 16px;
    }

    .app-footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .app-footer-inner > div:last-child {
        flex-wrap: wrap;
        gap: 12px;
    }

    .agent-grid { grid-template-columns: 1fr; }
    .agents-tier-grid { grid-template-columns: 1fr; }
    .form-row   { grid-template-columns: 1fr; }

    /* Card header: allow wrapping so confidence meter drops below title */
    .card-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Confidence meter: full width when wrapped */
    .confidence-meter {
        min-width: 0;
        max-width: 100%;
        flex: 1 1 100%;
    }

    /* Risk table: horizontal scroll on small screens */
    .risk-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .risk-table thead,
    .risk-table tbody,
    .risk-table tr {
        display: table;
        width: 100%;
        table-layout: auto;
    }

    .risk-table th,
    .risk-table td {
        white-space: nowrap;
    }

    .risk-table td:first-child,
    .risk-table td:last-child {
        white-space: normal;
        min-width: 120px;
    }

    /* Synthesis models info: prevent overflow of long model names */
    .synthesis-models-info {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Tabs: horizontal scroll instead of wrapping */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn { white-space: nowrap; flex-shrink: 0; }

    /* Home page — hero responsive sizing */
    .hero-section { padding: 32px 16px 24px !important; }
    .hero-title { font-size: 1.7em !important; }
    .hero-subtitle { font-size: 1.05em !important; }
    .hero-desc { font-size: 0.95em !important; }

    /* Home page — pricing grid: force single column on narrow screens */
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }

    /* Home page — button rows: stack vertically */
    .home-final-cta .btn {
        display: block;
        width: 100%;
        margin: 0 0 10px 0 !important;
    }
    .home-btn-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .home-btn-row .btn {
        width: 100%;
        margin-left: 0 !important;
    }

    /* Home page — creator section: reduce padding on mobile */
    .home-creator-section {
        padding: 20px 16px !important;
    }

    /* Council page — button group: allow wrapping */
    .btn-group {
        flex-wrap: wrap;
        width: 100%;
    }
    .btn-group .btn {
        flex: 1 1 auto;
    }

    /* Council form — stack query + model override vertically */
    .form-row {
        display: flex;
        flex-direction: column;
        gap: 12px !important;
    }
    .form-row > .form-group {
        min-width: 0 !important;
        width: 100% !important;
    }

    /* Council buttons — stack */
    .flex-between {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    /* Workflow step cards — ensure full width, no overflow */
    .wf-step-card {
        flex-wrap: wrap;
    }
    .wf-step-badge {
        position: static !important;
        margin-top: 4px;
    }

    /* Workflow preview — full width on mobile */
    #wf-preview {
        max-width: 100% !important;
        margin-left: 12px !important;
        margin-right: 12px !important;
    }
    #wf-launcher .card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Workflow builder — stack canvas and sidebar vertically */
    #wb-layout {
        flex-direction: column;
    }
    #dag-node-list {
        width: 100% !important;
        min-width: 0 !important;
        max-height: 200px;
    }

    /* Modal — near full width on mobile */
    .modal-content, .modal-overlay > div {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto;
    }

    /* Select dropdowns — prevent overflow */
    select.form-control {
        max-width: 100%;
    }

    /* Page headers — smaller text */
    .page-header h2 {
        font-size: 1.3em;
    }

    /* Synthesis anchor nav — scroll horizontally */
    .overview-anchors {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }
    .overview-anchors .btn {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 11px !important;
        padding: 4px 8px !important;
    }

    /* Agent result cards — readable on small screens */
    .agent-result-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .agent-result-header .left {
        min-width: 0;
        flex: 1 1 100%;
    }

    /* Share buttons — stack */
    .share-buttons {
        flex-direction: column;
    }

    /* Hero buttons — stack on mobile */
    .hero-section .btn {
        display: block;
        width: 100%;
        margin: 6px 0 !important;
    }

    /* History items — full width */
    .history-card {
        flex-direction: column;
    }

    /* Sub-nav indentation — less on mobile */
    .sidebar-subnav li a {
        padding-left: 36px;
    }
}

/* Markdown content rendered inside synthesis */
.exec-summary h1, .exec-summary h2, .exec-summary h3 { font-size: 16px; margin: 12px 0 6px; color: var(--text-primary); }
.exec-summary p { margin-bottom: 10px; }
.exec-summary ul, .exec-summary ol { padding-left: 24px; margin-bottom: 10px; }
.exec-summary li { margin-bottom: 4px; }
.exec-summary strong { color: var(--text-primary); }

#tab-analysis h1, #tab-analysis h2, #tab-analysis h3 { font-size: 16px; margin: 16px 0 8px; color: var(--accent); }
#tab-analysis p { margin-bottom: 10px; color: var(--text-secondary); }
#tab-analysis ul, #tab-analysis ol { padding-left: 24px; margin-bottom: 10px; color: var(--text-secondary); }
#tab-analysis li { margin-bottom: 4px; }

#tab-action h1, #tab-action h2, #tab-action h3 { font-size: 16px; margin: 16px 0 8px; color: var(--accent); }
#tab-action p { margin-bottom: 10px; }
#tab-action ol { padding-left: 24px; }
#tab-action li { margin-bottom: 6px; }
#tab-action strong { color: var(--text-primary); }

/* Utility */
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Free-tier info banner on Council page */
.council-free-tier-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--accent-dim);
    border: 1px solid rgba(108, 140, 255, 0.25);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.council-free-tier-icon {
    font-size: 17px;
    flex-shrink: 0;
    color: var(--accent);
}

/* Guest save prompt after council completion */
.guest-save-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--success-dim);
    border: 1px solid rgba(74, 222, 128, 0.25);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.guest-save-icon {
    font-size: 20px;
    flex-shrink: 0;
}

/* Save & Share section */
.save-share-section {
    margin-bottom: 16px;
}

.permalink-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex: 1;
    min-width: 200px;
    max-width: 340px;
    overflow: hidden;
}

/* Agent count badge in page header */
.agent-count-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--accent-dim);
    border: 1px solid rgba(108, 140, 255, 0.25);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-left: 10px;
    vertical-align: middle;
}

/* History detail markdown content */
#history-detail-content .exec-summary {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    font-size: 15px;
    line-height: 1.8;
}
#history-detail-content .exec-summary h1,
#history-detail-content .exec-summary h2,
#history-detail-content .exec-summary h3 { font-size: 16px; margin: 12px 0 6px; color: var(--text-primary); }
#history-detail-content .exec-summary p { margin-bottom: 10px; }
#history-detail-content .exec-summary ul,
#history-detail-content .exec-summary ol { padding-left: 24px; margin-bottom: 10px; }
#history-detail-content .exec-summary li { margin-bottom: 4px; }

#hd-tab-analysis h1, #hd-tab-analysis h2, #hd-tab-analysis h3 { font-size: 16px; margin: 16px 0 8px; color: var(--accent); }
#hd-tab-analysis p { margin-bottom: 10px; color: var(--text-secondary); }
#hd-tab-analysis ul, #hd-tab-analysis ol { padding-left: 24px; margin-bottom: 10px; color: var(--text-secondary); }
#hd-tab-analysis li { margin-bottom: 4px; }

#hd-tab-action h1, #hd-tab-action h2, #hd-tab-action h3 { font-size: 16px; margin: 16px 0 8px; color: var(--accent); }
#hd-tab-action p { margin-bottom: 10px; }
#hd-tab-action ol { padding-left: 24px; }
#hd-tab-action li { margin-bottom: 6px; }
#hd-tab-action strong { color: var(--text-primary); }

/* Shimmer / skeleton loading animation */
/* Synthesis overview — anchored sections */
.synthesis-anchor-section {
    padding-top: 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}
.synthesis-anchor-section:last-child { border-bottom: none; }
.synthesis-section-header {
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    scroll-margin-top: 60px;
}
.synthesis-nav .tab-btn.active {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.shimmer {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.shimmer-line {
    height: 14px;
    margin-bottom: 10px;
    border-radius: 4px;
}
.shimmer-line.short { width: 60%; }
.shimmer-line.medium { width: 80%; }
.shimmer-line.long { width: 95%; }

/* Action steps — numbered step flow for recommended actions */
.action-steps ol, .action-steps ul {
    list-style: none;
    padding: 0;
    counter-reset: step-counter;
}
.action-steps ol li, .action-steps ul li {
    counter-increment: step-counter;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.action-steps ol li:last-child, .action-steps ul li:last-child { border-bottom: none; }
.action-steps ol li::before {
    content: counter(step-counter);
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* ── Workflow Template Gallery ── */
.wf-gallery-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}
.wf-gallery-search input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}
.wf-gallery-search input::placeholder { color: var(--text-muted); }
.wf-filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.wf-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.wf-filter-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.wf-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.wf-domain-section { margin-bottom: 8px; }
.wf-domain-header {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 24px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wf-domain-header:first-child { margin-top: 0; }
.wf-domain-icon {
    font-size: 16px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--accent-dim);
}
.wf-domain-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 4px;
}

.wf-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: default;
}
.wf-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(108, 140, 255, 0.08);
}
.wf-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    line-height: 1.3;
}
.wf-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 12px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.wf-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.wf-card-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.wf-badge-steps {
    background: var(--accent-dim);
    color: var(--accent);
}
.wf-badge-domain {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.wf-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}
.wf-card-actions .btn {
    flex: 1;
    font-size: 12px;
    padding: 6px 12px;
}
.wf-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}
@keyframes wf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.wf-pulse-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    animation: wf-pulse 1.5s ease-in-out infinite;
}

/* Workflow step output formatting */
.wf-step-output-body h1, .wf-step-output-body h2, .wf-step-output-body h3, .wf-step-output-body h4 {
    font-size: 1.05em;
    font-weight: 700;
    color: var(--text-primary);
    margin: 16px 0 8px 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
.wf-step-output-body h1 { font-size: 1.15em; }
.wf-step-output-body h2 { font-size: 1.1em; }
.wf-step-output-body ul, .wf-step-output-body ol {
    margin: 8px 0;
    padding-left: 24px;
}
.wf-step-output-body li {
    margin-bottom: 6px;
    line-height: 1.6;
}
.wf-step-output-body li > ul, .wf-step-output-body li > ol {
    margin-top: 4px;
}
.wf-step-output-body p {
    margin: 8px 0;
    line-height: 1.7;
}
.wf-step-output-body strong {
    color: var(--text-primary);
}
.wf-step-output-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 12px;
}
.wf-step-output-body th, .wf-step-output-body td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}
.wf-step-output-body th {
    background: var(--bg-tertiary);
    font-weight: 600;
}
.wf-step-output-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}
