/* Cockpit Platform — Dark Theme */

:root {
    color-scheme: dark;
    --bg: #101418;
    --bg-surface: #161b22;
    --card-bg: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.1);
    --accent: #5da8ff;
    --accent-bg: rgba(93, 168, 255, 0.12);
    --text-primary: #f5f7fb;
    --text-muted: rgba(255, 255, 255, 0.55);
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.12);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.12);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.12);
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --radius: 10px;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────── */

.cockpit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logout-link {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: none;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: color 0.15s, border-color 0.15s;
}
.logout-link:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.meta-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.cockpit-layout {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: 180px;
    border-right: 1px solid var(--border);
    background: var(--bg-surface);
    padding: 0.8rem 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.12s ease;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-bg);
}

.nav-item.disabled {
    opacity: 0.25;
    pointer-events: none;
}

.nav-icon { font-size: 0.7rem; }

.nav-separator {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1rem;
}

.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

/* ── Panel header ────────────────────────────────────────────────────── */

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.panel-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    transition: background 0.12s;
}

.btn:hover { background: rgba(255, 255, 255, 0.1); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* ── Status dots ─────────────────────────────────────────────────────── */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online    { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.status-dot.offline   { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.status-dot.stale     { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.status-dot.no-report { background: var(--text-muted); box-shadow: none; }

/* ── Surfaces grid ───────────────────────────────────────────────────── */

.surfaces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.machine-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    background: var(--card-bg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.machine-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.machine-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.machine-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.machine-role {
    font-size: 0.68rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(93, 168, 255, 0.3);
    background: var(--accent-bg);
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.machine-status-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.machine-status-text {
    font-size: 0.85rem;
    font-weight: 600;
}

.machine-env {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.3rem;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.health-metric {
    text-align: center;
    padding: 0.35rem 0.25rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.health-metric .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.health-metric .value {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.health-ok   { color: var(--green); }
.health-warn { color: var(--yellow); }
.health-crit { color: var(--red); }

.last-seen {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ── Detail panel ────────────────────────────────────────────────────── */

.detail-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    margin-top: 1.5rem;
    background: var(--bg-surface);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.detail-header h3 { font-size: 1rem; font-weight: 600; }

.detail-content pre {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    max-height: 400px;
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 1rem;
}

.detail-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.info-table td {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-label {
    color: var(--text-muted);
    width: 100px;
    font-size: 0.78rem;
}

.service-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.service-tag {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    border: 1px solid;
}

.service-tag.running {
    background: var(--green-bg);
    color: var(--green);
    border-color: rgba(63, 185, 80, 0.3);
}

.service-tag.stopped {
    background: var(--red-bg);
    color: var(--red);
    border-color: rgba(248, 81, 73, 0.3);
}

/* ── Artifact filters ────────────────────────────────────────────────── */

.artifact-filters {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.artifact-filters label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.artifact-filters select,
.artifact-filters input[type="text"] {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    min-width: 140px;
}

.artifact-filters select:focus,
.artifact-filters input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.35rem !important;
}

/* ── Artifact table ──────────────────────────────────────────────────── */

.artifact-table-wrapper {
    overflow-x: auto;
}

.artifact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.artifact-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.artifact-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.artifact-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.artifact-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.type-badge {
    font-size: 0.68rem;
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid;
}

.type-digest         { background: rgba(93,168,255,0.12);  color: #5da8ff; border-color: rgba(93,168,255,0.3); }
.type-report         { background: rgba(63,185,80,0.12);   color: #3fb950; border-color: rgba(63,185,80,0.3); }
.type-spec           { background: rgba(210,153,34,0.12);  color: #d29922; border-color: rgba(210,153,34,0.3); }
.type-recommendation { background: rgba(168,85,247,0.12);  color: #a855f7; border-color: rgba(168,85,247,0.3); }
.type-evaluation     { background: rgba(248,81,73,0.12);   color: #f85149; border-color: rgba(248,81,73,0.3); }
.type-deliberation   { background: rgba(255,180,50,0.12);  color: #f0b040; border-color: rgba(255,180,50,0.3); }
.type-directive      { background: rgba(255,107,74,0.12);  color: #ff6b4a; border-color: rgba(255,107,74,0.3); }
.type-raw_data       { background: rgba(255,255,255,0.04); color: var(--text-muted); border-color: rgba(255,255,255,0.12); }

/* ── Artifact viewer (slide-in panel) ────────────────────────────────── */

.artifact-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: 55%;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
    flex-shrink: 0;
}

.viewer-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.viewer-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.viewer-content {
    flex: 1;
    padding: 1.2rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Chat panel ─────────────────────────────────────────────────────── */

.chat-surface-select {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    min-width: 160px;
}

.chat-surface-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.chat-agent-select {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    min-width: 130px;
}

.chat-agent-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.chat-agent-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-container {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 160px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    overflow: hidden;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Session sidebar ─────────────────────────────────────────────── */

.chat-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.15);
}

.chat-sidebar.hidden {
    display: none;
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

.chat-sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.btn-accent {
    background: var(--accent-bg);
    border-color: rgba(93, 168, 255, 0.3);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
}

.btn-accent:hover {
    background: rgba(93, 168, 255, 0.2);
}

.chat-session-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.3rem 0;
}

.session-item {
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.15s ease;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.session-item-active {
    background: var(--accent-bg);
    border-left: 2px solid var(--accent);
}

.session-item-title {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.session-item-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.session-item-meta .tool-badge {
    font-size: 0.62rem;
    padding: 0.05rem 0.3rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.chat-welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.chat-msg {
    max-width: 80%;
    animation: chatFadeIn 0.2s ease;
}

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

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-agent {
    align-self: flex-start;
}

.chat-msg-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    padding: 0 0.4rem;
}

.chat-msg-user .chat-msg-label { text-align: right; }

.chat-msg-body {
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-user .chat-msg-body {
    background: var(--accent-bg);
    border: 1px solid rgba(93, 168, 255, 0.25);
    color: var(--text-primary);
}

.chat-msg-agent .chat-msg-body {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.88rem;
    line-height: 1.6;
}

/* Markdown body inside agent messages */
.markdown-body p { margin: 0 0 0.6em; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin: 0.8em 0 0.4em;
    color: var(--accent);
    font-weight: 600;
}
.markdown-body h1 { font-size: 1.3em; }
.markdown-body h2 { font-size: 1.15em; }
.markdown-body h3 { font-size: 1.05em; }

.markdown-body code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.06);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75em 1em;
    overflow-x: auto;
    margin: 0.6em 0;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.84em;
    line-height: 1.5;
}

.markdown-body ul, .markdown-body ol {
    margin: 0.4em 0;
    padding-left: 1.5em;
}

.markdown-body li { margin: 0.2em 0; }

.markdown-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.6em 0;
    padding: 0.3em 0.8em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.markdown-body table {
    border-collapse: collapse;
    margin: 0.6em 0;
    width: 100%;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border);
    padding: 0.4em 0.7em;
    text-align: left;
}

.markdown-body th {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}

.markdown-body a:hover { text-decoration: underline; }

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.8em 0;
}

.chat-thinking {
    color: var(--text-muted);
    font-style: italic;
}

.thinking-dots span {
    animation: thinkingDot 1.4s infinite;
    opacity: 0.3;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingDot {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

.chat-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    resize: none;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.chat-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-send-btn {
    align-self: flex-end;
    padding: 0.55rem 1.2rem;
    background: var(--accent-bg);
    border-color: rgba(93, 168, 255, 0.3);
    color: var(--accent);
    font-weight: 600;
}

.chat-send-btn:hover:not(:disabled) {
    background: rgba(93, 168, 255, 0.2);
}

.chat-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-resume-indicator {
    text-align: center;
    padding: 0.6rem 1rem;
    margin: 0.5rem 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border);
    font-style: italic;
}

/* ── Sessions panel ─────────────────────────────────────────────────── */

.session-filters {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.session-filters label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.session-filters select {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-sans);
    min-width: 140px;
}

.session-filters select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.session-table-wrapper { overflow-x: auto; }

.session-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.session-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.session-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.session-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.session-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.session-title {
    font-weight: 500;
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-surface-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.tool-badge {
    font-size: 0.68rem;
    padding: 0.12rem 0.45rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid;
}

.tool-claude { background: rgba(93,168,255,0.12); color: #5da8ff; border-color: rgba(93,168,255,0.3); }
.tool-codex  { background: rgba(63,185,80,0.12);  color: #3fb950; border-color: rgba(63,185,80,0.3); }
.tool-gemini { background: rgba(168,85,247,0.12); color: #a855f7; border-color: rgba(168,85,247,0.3); }

.session-status {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-active    { color: var(--green); }
.status-completed { color: var(--text-muted); }

/* ── Session viewer (slide-in) ──────────────────────────────────────── */

.session-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: 55%;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

.viewer-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.btn-accent {
    background: var(--accent-bg);
    border-color: rgba(93, 168, 255, 0.3);
    color: var(--accent);
    font-weight: 600;
}

.btn-accent:hover { background: rgba(93, 168, 255, 0.2); }

.session-viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeline-entry { padding: 0.5rem 0; }

.timeline-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

.timeline-body {
    font-size: 0.85rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.timeline-user .timeline-body {
    padding: 0.5rem 0.8rem;
    background: var(--accent-bg);
    border: 1px solid rgba(93, 168, 255, 0.25);
    border-radius: 8px;
}

.timeline-agent .timeline-body {
    padding: 0.5rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.timeline-tool {
    padding: 0.2rem 0;
}

.timeline-tool-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    padding: 0.15rem 0.4rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.timeline-tool-result {
    padding: 0.1rem 0;
}

.timeline-tool-result pre {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Goals Dashboard ─────────────────────────────────────────────────── */

.goals-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.summary-stat {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 0.8rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
}

.summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.summary-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.15rem;
}

.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.goal-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    background: var(--card-bg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.goal-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.goal-card.goal-complete { border-color: rgba(63, 185, 80, 0.3); }
.goal-card.goal-complete:hover { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }

.goal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.goal-name {
    font-weight: 600;
    font-size: 0.92rem;
    text-transform: capitalize;
}

.goal-owner {
    font-size: 0.68rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(93, 168, 255, 0.3);
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.goal-description {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    line-height: 1.4;
}

.goal-progress-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.goal-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.goal-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.goal-progress-fill.goal-complete { background: var(--green); }
.goal-progress-fill.goal-progress { background: var(--accent); }
.goal-progress-fill.goal-early    { background: var(--yellow); }

.goal-progress-text {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: var(--font-mono);
    min-width: 36px;
    text-align: right;
}

.goal-milestones-summary {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Goal detail panel */

.goal-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 55%;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

.goal-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
}

.goal-context {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.context-tag {
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.goal-full-description {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.5;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

/* Milestones */

.milestone-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--card-bg);
}

.milestone-card.milestone-complete {
    border-color: rgba(63, 185, 80, 0.2);
    opacity: 0.75;
}

.milestone-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.milestone-status-icon { font-size: 0.85rem; }
.milestone-complete .milestone-status-icon { color: var(--green); }

.milestone-id {
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: capitalize;
}

.milestone-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid;
    margin-left: auto;
}

.ms-complete    { background: var(--green-bg);  color: var(--green);  border-color: rgba(63,185,80,0.3); }
.ms-in_progress { background: var(--accent-bg); color: var(--accent); border-color: rgba(93,168,255,0.3); }
.ms-pending     { background: rgba(255,255,255,0.04); color: var(--text-muted); border-color: var(--border); }
.ms-blocked     { background: var(--red-bg);    color: var(--red);    border-color: rgba(248,81,73,0.3); }

.milestone-description {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.milestone-deps {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.dep-tag {
    font-size: 0.68rem;
    padding: 0.05rem 0.35rem;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
}

.milestone-progress-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Criteria */

.criteria-list { margin-top: 0.4rem; }

.criterion-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.criterion-check {
    flex-shrink: 0;
    font-size: 0.78rem;
    width: 1.2rem;
    text-align: center;
    color: var(--text-muted);
}

.criterion-done .criterion-check { color: var(--green); }

.criterion-content { flex: 1; min-width: 0; }

.criterion-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.criterion-done .criterion-text { color: var(--text-muted); }

.criterion-evidence {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    font-style: italic;
    line-height: 1.35;
}

.criterion-evaluated {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* ── PM Monitor ──────────────────────────────────────────────────────── */

.pm-section { margin-bottom: 1.5rem; }

.pm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.pm-section-header h3 {
    font-size: 0.92rem;
    font-weight: 600;
}

/* Flow cards grid */

.flows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.8rem;
}

.flow-card {
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    background: var(--card-bg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.flow-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.flow-card.stage-complete  { border-left-color: var(--green); }
.flow-card.stage-running   { border-left-color: var(--yellow); }
.flow-card.stage-progress  { border-left-color: var(--accent); }
.flow-card.stage-failed    { border-left-color: var(--red); }
.flow-card.stage-pending   { border-left-color: var(--text-muted); }

.flow-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.flow-milestone {
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: capitalize;
}

.flow-stage-badge {
    font-size: 0.62rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid;
}

.flow-stage-badge.stage-complete  { background: var(--green-bg);  color: var(--green);  border-color: rgba(63,185,80,0.3); }
.flow-stage-badge.stage-running   { background: var(--yellow-bg); color: var(--yellow); border-color: rgba(210,153,34,0.3); }
.flow-stage-badge.stage-progress  { background: var(--accent-bg); color: var(--accent); border-color: rgba(93,168,255,0.3); }
.flow-stage-badge.stage-failed    { background: var(--red-bg);    color: var(--red);    border-color: rgba(248,81,73,0.3); }
.flow-stage-badge.stage-pending   { background: rgba(255,255,255,0.04); color: var(--text-muted); border-color: var(--border); }

.flow-goal {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin-bottom: 0.2rem;
}

.flow-brief {
    font-size: 0.72rem;
    color: var(--text-muted);
    opacity: 0.7;
    line-height: 1.3;
    margin-bottom: 0.4rem;
}

.flow-meta-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.flow-team-badge {
    font-size: 0.65rem;
    padding: 0.08rem 0.35rem;
    border-radius: 3px;
    background: var(--accent-bg);
    border: 1px solid rgba(93,168,255,0.2);
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
}

.flow-priority {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-critical { color: var(--red); }
.priority-high     { color: var(--yellow); }

.flow-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* PM Runs table */

.pm-runs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.pm-runs-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pm-runs-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.pm-run-project {
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.worker-badge {
    font-size: 0.68rem;
    padding: 0.08rem 0.35rem;
    border-radius: 3px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
}

/* Worker Stats */

.worker-stats-grid {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.worker-stat-card {
    flex: 1;
    min-width: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    background: var(--card-bg);
}

.worker-stat-name {
    font-weight: 600;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.worker-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.worker-metric { text-align: center; }

.worker-metric-value {
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: block;
}

.worker-metric-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Event timeline */

.pm-timeline {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.78rem;
}

.timeline-row:hover { background: rgba(255,255,255,0.02); }

.timeline-icon {
    flex-shrink: 0;
    width: 1rem;
    text-align: center;
    font-size: 0.75rem;
}

.timeline-source {
    flex-shrink: 0;
    font-size: 0.6rem;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.source-pm   { background: var(--accent-bg); color: var(--accent); }
.source-goal { background: var(--green-bg);  color: var(--green); }

.timeline-type {
    font-weight: 600;
    font-size: 0.75rem;
    min-width: 80px;
}

.timeline-project {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.timeline-phase {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.timeline-worker {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.timeline-duration {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.timeline-time {
    flex-shrink: 0;
    font-size: 0.68rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
}

/* Flow detail panel */

.flow-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.5);
}

.flow-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem;
}

/* ── Utilities ───────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.loading-placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .cockpit-layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: 0.5rem 0.8rem;
        white-space: nowrap;
    }

    .nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }

    .nav-separator { display: none; }

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

    .artifact-viewer { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   DIGESTS PANEL
   ═══════════════════════════════════════════════════════════════ */

.digests-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* ── Section heading ──────────────────────────────────────────── */

.section-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.75rem 0;
}

.feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.feed-header .section-heading {
    margin: 0;
}

/* ── Source cards ──────────────────────────────────────────────── */

.sources-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.source-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.source-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.source-card-active {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent), 0 2px 8px rgba(96,165,250,0.15);
}

.source-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.source-card-icon {
    font-size: 1.2rem;
}

.source-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.rec-badge {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
    margin-left: auto;
}

.source-card-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Source badge ──────────────────────────────────────────────── */

.digest-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.source-icon {
    font-size: 0.8rem;
}

/* ── Feed filter tabs ─────────────────────────────────────────── */

.feed-filters {
    display: flex;
    gap: 0.4rem;
}

.feed-filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.feed-filter-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.feed-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Feed items ───────────────────────────────────────────────── */

.digest-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.feed-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1.2rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.feed-item:hover {
    border-color: var(--accent);
}

.feed-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.feed-type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.type-digest {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}

.type-rec {
    background: rgba(251, 146, 60, 0.12);
    color: #fb923c;
}

.feed-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.feed-item-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.feed-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.feed-item-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    max-height: 3.0em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-item-meta {
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Detail panel (slide-in) ──────────────────────────────────── */

.digest-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 55%;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.4);
    overflow: hidden;
}

.digest-detail-panel.hidden {
    display: none;
}

.digest-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ── Markdown rendering ───────────────────────────────────────── */

.digest-rendered-content {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text);
}

.digest-rendered-content p {
    margin: 0 0 0.8rem 0;
}

.md-h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin: 1.5rem 0 0.6rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.md-h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin: 1.2rem 0 0.5rem 0;
}

.md-h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 1rem 0 0.4rem 0;
}

.md-code-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0.8rem 0;
}

.md-inline-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.md-link {
    color: var(--accent);
    text-decoration: none;
}

.md-link:hover {
    text-decoration: underline;
}

.md-ul, .md-ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.md-li, .md-li-num {
    margin: 0.25rem 0;
    line-height: 1.6;
}

.md-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.2rem 0;
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sources-row { grid-template-columns: 1fr; }
    .digest-detail-panel { width: 100%; }
    .feed-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
