:root {
    --bg: #0f1419;
    --panel: #1a2332;
    --border: #2d3a4d;
    --text: #e7ecf3;
    --muted: #8b9bb4;
    --accent: #5b9fd4;
    --accent-2: #3d7ea6;
    --ok: #3d9a6a;
    --warn: #c9a227;
    --err: #d45b5b;
    --chat: #2a3f55;
    --round: #3a3355;
    --review: #2f4a3a;
    font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Home: comfortable reading width. Room uses full viewport. */
.page main {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.home {
    max-width: 52rem;
    margin: 0 auto;
    padding: 1.5rem;
    box-sizing: border-box;
}

.room {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 1rem 1.25rem 1.25rem;
    box-sizing: border-box;
}

h1, h2, h3 { margin-top: 0; font-weight: 600; }
.lead { color: var(--muted); max-width: 40rem; }
.muted { color: var(--muted); }
.error { color: var(--err); }
.code { font-family: ui-monospace, monospace; letter-spacing: 0.08em; color: var(--accent); }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    max-width: 28rem;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.input, textarea.input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    width: 100%;
    font-family: inherit;
}

.btn {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 8px;
    padding: 0.55rem 1rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
    background: var(--accent-2);
    border-color: var(--accent);
}

.footer-note { margin-top: 2rem; color: var(--muted); font-size: 0.85rem; }
.footer-note code { color: var(--accent); }

.card.history { max-width: 40rem; }
.room-list { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.room-list li { border-bottom: 1px solid var(--border); }
.linkish {
    background: none; border: none; color: inherit; text-align: left;
    width: 100%; padding: 0.55rem 0; cursor: pointer; display: flex; flex-direction: column; gap: 0.15rem;
}
.linkish:hover { color: var(--accent); }
.room-list .phase { font-size: 0.8rem; color: var(--muted); }
.room-list .meta { font-size: 0.75rem; color: var(--muted); }

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.room-header .meta { color: var(--muted); margin: 0.25rem 0 0; }
.room-subject {
    margin: 0.35rem 0 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    max-width: 48rem;
}
.room-list-subject {
    display: block;
    margin-top: 0.15rem;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
}

.room-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

@media (max-width: 800px) {
    .room-grid { grid-template-columns: minmax(0, 1fr); }
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    min-height: 12rem;
    min-width: 0; /* prevent grid blowout */
    max-width: 100%;
}

.feed {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 6rem);
    min-width: 0;
}

.events {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 55vh;
    padding-right: 0.25rem;
    scroll-behavior: smooth;
}

.event {
    border-left: 3px solid var(--border);
    background: var(--bg);
    border-radius: 0 8px 8px 0;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
}

/* Event-type defaults (overridden by per-speaker colours for chat/review) */
.event.kind-chat { border-left-color: var(--accent); background: var(--chat); }
.event.kind-round_open { border-left-color: #9b7bde; background: var(--round); }
.event.kind-review { border-left-color: var(--ok); background: var(--review); }
.event.kind-round_closed,
.event.kind-room_closed { border-left-color: var(--warn); }
.event.kind-member_joined { border-left-color: var(--muted); }
.event.kind-bottom_line { border-left-color: var(--accent); background: #1a2a38; }
.event.kind-member_rejoined { border-left-color: var(--muted); }

/* Per-speaker colours (human / driver / participants) — applied to chat, review, compaction, etc. */
.event.speaker-human {
    border-left-color: #e67e22 !important;
    background: #3a2818 !important;
    box-shadow: inset 0 0 0 1px rgba(230, 126, 34, 0.35);
}
.event.speaker-human .author { color: #f0a868; }
.event.speaker-driver {
    border-left-color: #1abc9c !important;
    background: #14302c !important;
}
.event.speaker-driver .author { color: #5ee0c5; }
.event.speaker-system {
    border-left-color: var(--muted);
    background: var(--bg);
}
/* Distinct participant palette (stable by display-name hash) */
.event.speaker-p0 { border-left-color: #5b9fd4 !important; background: #1a2d42 !important; }
.event.speaker-p0 .author { color: #8ec4ee; }
.event.speaker-p1 { border-left-color: #9b7bde !important; background: #2a2240 !important; }
.event.speaker-p1 .author { color: #c4b0f0; }
.event.speaker-p2 { border-left-color: #3d9a6a !important; background: #162a20 !important; }
.event.speaker-p2 .author { color: #7dcea0; }
.event.speaker-p3 { border-left-color: #e74c8b !important; background: #351a28 !important; }
.event.speaker-p3 .author { color: #f5a0c4; }
.event.speaker-p4 { border-left-color: #c9a227 !important; background: #2e2814 !important; }
.event.speaker-p4 .author { color: #e8d48a; }
.event.speaker-p5 { border-left-color: #5dade2 !important; background: #1a3038 !important; }
.event.speaker-p5 .author { color: #a8d8f0; }

/* Colour block next to each member name (same palette as feed left border) */
.speaker-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
}
.speaker-swatch.speaker-human { background: #e67e22; }
.speaker-swatch.speaker-driver { background: #1abc9c; }
.speaker-swatch.speaker-system { background: var(--muted); }
.speaker-swatch.speaker-p0 { background: #5b9fd4; }
.speaker-swatch.speaker-p1 { background: #9b7bde; }
.speaker-swatch.speaker-p2 { background: #3d9a6a; }
.speaker-swatch.speaker-p3 { background: #e74c8b; }
.speaker-swatch.speaker-p4 { background: #c9a227; }
.speaker-swatch.speaker-p5 { background: #5dade2; }

.event header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: baseline;
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.event .kind {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    font-weight: 600;
}

.event .author { color: var(--text); font-weight: 600; }
.event .role { opacity: 0.7; }
.event .time { margin-left: auto; }
.event .body,
.body.md {
    margin: 0;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.35;
}

/* Markdown inside feed messages */
.body.md p { margin: 0.2rem 0; }
.body.md p:first-child { margin-top: 0; }
.body.md p:last-child { margin-bottom: 0; }
.body.md ul, .body.md ol { margin: 0.25rem 0; padding-left: 1.2rem; }
.body.md li { margin: 0.1rem 0; }
.body.md code {
    font-family: ui-monospace, monospace;
    font-size: 0.78rem;
    background: rgba(0,0,0,0.35);
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
}
.body.md pre {
    margin: 0.35rem 0;
    padding: 0.45rem 0.55rem;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.75rem;
    line-height: 1.35;
}
.body.md pre code { background: none; padding: 0; font-size: inherit; }
.body.md strong { color: var(--text); font-weight: 650; }
.body.md blockquote {
    margin: 0.3rem 0;
    padding-left: 0.6rem;
    border-left: 2px solid var(--accent);
    color: var(--muted);
}
.body.md h1, .body.md h2, .body.md h3, .body.md h4 {
    margin: 0.4rem 0 0.2rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.verdict { font-size: 0.78rem; color: var(--ok); margin-bottom: 0.2rem; }

.composer {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.composer-hint {
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.35;
}
.composer-hint code {
    font-size: 0.7rem;
    background: rgba(0,0,0,0.35);
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
}
.composer-input {
    font-size: 0.85rem;
    line-height: 1.35;
}

.members { list-style: none; padding: 0; margin: 0 0 1rem; }
.members-hint {
    margin: 0 0 0.45rem;
    font-size: 0.72rem;
    line-height: 1.35;
}
.members-aliases {
    margin: -0.4rem 0 0.85rem;
    font-size: 0.72rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.members li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.members li.member-filtered {
    opacity: 0.45;
}
.members li.member-filtered .handle-btn strong {
    text-decoration: line-through;
    text-decoration-color: var(--muted);
}
.member-filter {
    display: inline-flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.member-filter input[type="checkbox"] {
    width: 0.95rem;
    height: 0.95rem;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.feed-filter-banner {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    line-height: 1.35;
}
.feed-filter-banner .linkish {
    margin-left: 0.25rem;
    font-size: inherit;
}
.members .role { color: var(--muted); font-size: 0.8rem; }
.members .presence {
    color: var(--muted);
    font-size: 0.7rem;
    margin-left: 0.15rem;
}
.members li.on .presence { color: var(--ok); }
.members .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ok); margin-left: auto;
    flex-shrink: 0;
}
.members li.off .dot { background: var(--muted); }
.members li.off:not(.member-filtered) { opacity: 0.55; }
.handle-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}
.handle-btn:hover strong,
.handle-btn:hover code {
    color: var(--accent);
    text-decoration: underline;
}
.mentions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin: 0.25rem 0 0.35rem;
    font-size: 0.72rem;
}
.mentions-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.65rem;
}
.mention-chip {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(94, 224, 197, 0.12);
    border: 1px solid rgba(94, 224, 197, 0.35);
    color: #8eebdb;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
}
.body.md .mention {
    color: #8eebdb;
    font-weight: 600;
}

.bottom-line-panel {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: calc(100vh - 12rem);
    overflow-y: auto;
}
.bottom-line-panel > h2 {
    margin-bottom: 0;
    color: var(--accent);
}
.bottom-line-meta {
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.35;
}
.bl-section h3 {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.bl-outstanding h3 { color: var(--warn); }
.bl-human h3 { color: #f0c674; }
.bl-decisions h3 { color: var(--ok); }

.bottom-line-body {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 0.65rem 0.75rem;
    font-size: 0.84rem;
    line-height: 1.45;
}
.bl-outstanding .bottom-line-body {
    border-left-color: var(--warn);
    background: #2a2418;
}
.bl-human .bottom-line-body,
.bl-human-body {
    border-left-color: #e0b84a;
    border-width: 1px 1px 1px 4px;
    background: #2c2610;
    box-shadow: 0 0 0 1px rgba(224, 184, 74, 0.25);
    font-size: 0.9rem;
    font-weight: 500;
}
.bl-decisions .bottom-line-body {
    border-left-color: var(--ok);
    background: #16241c;
}
.bottom-line-body.md p { margin: 0.35rem 0; }
.bottom-line-body.md ul { margin: 0.4rem 0; padding-left: 1.15rem; }
.bottom-line-body.md li { margin: 0.3rem 0; }
.bottom-line-empty {
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

.bl-links h3 { color: var(--accent); }
.related-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.related-links li {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.related-links a {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.84rem;
    text-decoration: none;
    word-break: break-word;
}
.related-links a:hover {
    text-decoration: underline;
}
.related-links .link-sub {
    font-size: 0.7rem;
    color: var(--muted);
}

.round-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 0.65rem;
    font-size: 0.8rem;
}
.round-card .kind { color: var(--muted); font-size: 0.72rem; }
.round-card h3 { margin: 0.3rem 0; font-size: 0.9rem; }
.round-card .body.md { font-size: 0.78rem; max-height: 14rem; overflow-y: auto; }
.mini-review {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
}
.mini-review .body.md {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.76rem;
}

#blazor-error-ui {
    background: var(--err);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
