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

:root {
    --bg: #0a0a0f;
    --surface: #12121a;
    --surface2: #1a1a26;
    --border: #2a2a3a;
    --text: #e0e0e8;
    --text-dim: #8888a0;
    --accent: #7c6ff0;
    --accent-dim: #5a50b0;
    --claim: #6ec1e4;
    --response: #7ce4a1;
    --question: #e4c76e;
    --rebuttal: #e47070;
    --agreement: #70e4a8;
    --tangent: #b070e4;
    --clarification: #e4a870;
    --evidence: #70b8e4;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.header-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.header-brand:hover { opacity: 0.8; }
.attribution {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.75rem;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}
.attribution:hover { color: var(--accent); }

/* Input row */
.input-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-upload {
    cursor: pointer;
}

/* Buttons */
.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}
.btn:hover { background: var(--accent-dim); }

.btn-record { display: flex; align-items: center; gap: 0.5rem; }
.record-dot {
    width: 10px; height: 10px;
    background: #e47070;
    border-radius: 50%;
}
.recording .record-dot { animation: pulse 1s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.record-time { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.record-controls { display: flex; align-items: center; gap: 1rem; }

/* Recording bar — persistent stop control */
.recording-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}
.recording-bar-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.recording-bar-top .speaker-names {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}
.recording-bar-top .type-legend {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    font-size: 0.75rem;
}
.recording-bar-top .btn-stop {
    margin-left: auto;
}
.btn-stop {
    background: var(--rebuttal);
    color: white;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: auto;
}
.btn-stop:hover { opacity: 0.85; }

/* Textarea */
textarea {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 0.5rem;
}
textarea:focus { outline: none; border-color: var(--accent-dim); }

.hint { color: var(--text-dim); font-size: 0.8rem; margin-bottom: 1rem; }

/* Spinner */
.htmx-indicator { display: none; }
.htmx-indicator.htmx-request {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--text-dim);
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error {
    background: #2a1520;
    border: 1px solid #e47070;
    color: #e47070;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 1rem 0;
}

/* Argument tree */
.argument-tree { margin-top: 1.5rem; }

.statement {
    margin: 0.25rem 0;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
    transition: opacity 0.3s, transform 0.3s;
}
.stmt-entering {
    opacity: 0;
    transform: translateY(-8px);
}
.stmt-removing {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

details > summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    list-style: none;
    transition: background 0.15s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.15s;
    color: var(--text-dim);
}
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { background: var(--surface); }

.leaf {
    padding: 0.5rem 0.75rem;
}

.children {
    padding-left: 1rem;
}

.type-badge {
    font-size: 0.95rem;
    padding: 0 0.2rem;
}

.type-legend {
    position: relative;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.legend-trigger {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    user-select: none;
}

.legend-trigger:hover {
    background: var(--surface2);
}

.legend-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 200;
    white-space: nowrap;
}

.type-legend:hover .legend-dropdown {
    display: flex;
}

.legend-item {
    white-space: nowrap;
}
.type-claim .type-badge { color: var(--claim); }
.type-response .type-badge { color: var(--response); }
.type-question .type-badge { color: var(--question); }
.type-rebuttal .type-badge { color: var(--rebuttal); }
.type-agreement .type-badge { color: var(--agreement); }
.type-tangent .type-badge { color: var(--tangent); }
.type-clarification .type-badge { color: var(--clarification); }
.type-evidence .type-badge { color: var(--evidence); }

.speaker {
    font-weight: 600;
    color: var(--text-dim);
}
.child-count {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Fact checking */
.flagged { border-left-color: var(--rebuttal) !important; }
.fact-check {
    display: block;
    margin-top: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    background: rgba(228, 112, 112, 0.1);
    border: 1px solid rgba(228, 112, 112, 0.25);
}
.fact-verdict {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.4rem;
}
.verdict-false .fact-verdict { color: var(--rebuttal); }
.verdict-misleading .fact-verdict { color: var(--question); }
.verdict-unverified .fact-verdict { color: var(--text-dim); }
.verdict-mostly-true .fact-verdict { color: var(--agreement); }
.fact-correction { color: var(--text); }
.fact-source {
    margin-left: 0.5rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.75rem;
}
.fact-source:hover { text-decoration: underline; }

/* Depth indentation colors */
.depth-0 { border-left-color: var(--accent); }
.depth-1 { border-left-color: var(--claim); }
.depth-2 { border-left-color: var(--response); }
.depth-3 { border-left-color: var(--question); }
.depth-4 { border-left-color: var(--tangent); }

/* Live transcript */
.live-transcript h2 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}
.live-text {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.8;
    font-size: 0.95rem;
}
.live-text .interim {
    color: var(--text-dim);
    font-style: italic;
}

/* Collapsible header/inputs */
header, .input-section { transition: opacity 0.3s, max-height 0.3s; overflow: hidden; }
.hidden-section { opacity: 0; max-height: 0; margin: 0; padding: 0; pointer-events: none; }

/* Live session layout */
.live-session { margin-top: 0.5rem; }

@media (min-width: 800px) {
    .live-session {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    .analyze-form { grid-column: 1 / -1; }
}

.argument-section {
    overflow-y: auto;
}

/* Diarized chat view */
.diarized-view { }

.speaker-names {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
}
.speaker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.speaker-input {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.speaker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.speaker-input input {
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 0.15rem 0.4rem;
    font-size: 0.8rem;
    font-family: inherit;
    width: 110px;
}
.speaker-input input:hover { border-color: var(--border); }
.speaker-input input:focus {
    outline: none;
    border-color: var(--speaker-color, var(--accent));
    background: var(--surface2);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    overflow-y: auto;
    padding: 0.5rem;
}
.chat-msg {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    background: var(--surface);
    line-height: 1.5;
}
.chat-speaker {
    font-weight: 600;
    margin-right: 0.5rem;
    font-size: 0.85rem;
}
.chat-text {
    font-size: 0.9rem;
}

/* Transcript result */
.transcript-result h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}
.transcript-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.btn-secondary {
    background: var(--surface2);
    color: var(--text-dim);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

.action-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    align-items: center;
}

/* Discovery */
.discovery {
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 600px) {
    .discovery { grid-template-columns: 1fr; }
}
.discovery-col h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}
.speakers-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.speaker-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    cursor: pointer;
}
.speaker-chip:hover {
    border-color: var(--accent-dim);
    background: var(--surface2);
}
.speaker-chip-name {
    color: var(--text);
    font-weight: 500;
    font-size: 0.85rem;
}
.speaker-chip-meta {
    color: var(--text-dim);
    font-size: 0.7rem;
    white-space: nowrap;
}
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.conversation-item {
    padding: 0.45rem 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.conversation-item:hover {
    border-color: var(--accent-dim);
    background: var(--surface2);
}
.conversation-title {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text);
}
.conversation-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

/* Speaker page */
.speaker-page {
    padding: 1rem 0;
}
.speaker-page h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.speaker-convos {
    margin-top: 1rem;
}
.speaker-convos .conversation-item {
    margin-bottom: 0.5rem;
}
.text-dim { color: var(--text-dim); font-size: 0.85rem; }

/* Header nav */
.header-nav {
    display: flex;
    gap: 1rem;
}
.header-nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.15s;
    white-space: nowrap;
}
.header-nav a:hover {
    color: var(--accent);
}

/* List pages (speakers, conversations) */
.list-page {
    padding: 1rem 0;
}
.list-page h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.list-items {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.list-item:hover {
    border-color: var(--accent-dim);
    background: var(--surface2);
}
.list-item-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text);
}
.list-item-title {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}
.list-item-meta {
    color: var(--text-dim);
    font-size: 0.7rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Anon speaker tag */
.speaker-anon-tag {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    background: var(--surface2);
    border: 1px dashed var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    margin-right: 0.3rem;
    cursor: help;
    flex-shrink: 0;
}
.speaker-input input.anon-name {
    color: var(--text-dim);
    font-style: italic;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 2px;
    text-decoration-color: var(--border);
}
.speaker-link {
    font-size: 0.75rem;
    color: var(--accent-dim);
    text-decoration: none;
    margin-right: 0.3rem;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.speaker-link:hover {
    opacity: 1;
    color: var(--accent);
}
