:root {
    --newton-orange: #FF6223;
    --newton-orange-dark-1: #C93B02;
    --newton-orange-dark-2: #A83200;
    --newton-slate: #282D37;
    --newton-slate-light-1: #3B424F;
    --newton-slate-light-2: #595F6B; /* darkened from #8892A0 for WCAG AA text contrast */
    --newton-slate-dark-1: #191D22;
    --newton-off-white: #EAEAEA;
    --newton-off-white-light-1: #F5F5F5;
    --newton-off-white-dark-1: #D9D7D8;
    --newton-white: #FFFFFF;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

/* Skip link — visible on focus for keyboard users (WCAG 2.4.1) */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--newton-slate);
    color: var(--newton-white);
    padding: 8px 16px;
    z-index: 100;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}
.skip-link:focus {
    top: 0;
}

body {
    font-family: 'Aptos', 'ES Klarheit Grotesk', system-ui, -apple-system, sans-serif;
    background: var(--newton-off-white);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
}

/* ── Left panel ── */
.left-panel {
    padding: 48px;
    border-right: 1px solid var(--newton-off-white-dark-1);
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
}

.logo img {
    height: 28px;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--newton-slate);
    line-height: 1.3;
}

.info-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    align-content: flex-start;
}

.info-item {
    padding: 14px 16px;
    background: var(--newton-white);
    border-radius: 8px;
    border-left: 3px solid var(--newton-orange);
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--newton-slate-light-2);
    font-weight: 700;
    margin-bottom: 4px;
}

.info-value {
    font-size: 15px;
    color: var(--newton-slate);
    font-family: 'Aptos Mono', 'Courier New', monospace;
    word-break: break-all;
}

/* ── Right panel ── */
.right-panel {
    display: flex;
    flex-direction: column;
    background: var(--newton-white);
    overflow: hidden;
}

/* Status bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--newton-off-white-dark-1);
    min-height: 64px;
    flex-shrink: 0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #767C88; /* 4.2:1 on white — passes WCAG 1.4.11 non-text contrast */
    flex-shrink: 0;
    transition: background 0.3s;
}

.status-dot.idle       { background: #767C88; }
.status-dot.connecting { background: var(--newton-orange); animation: pulse 1s infinite; }
.status-dot.listening  { background: var(--newton-orange); }
.status-dot.speaking   { background: var(--newton-orange); animation: pulse 0.6s infinite; }
.status-dot.ending     { background: #767C88; animation: pulse 1s infinite; }

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

.status-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--newton-slate);
}

/* Transcript */
.transcript {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.transcript-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--newton-slate-light-2);
    font-size: 14px;
    text-align: center;
    padding: 40px;
    line-height: 1.6;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    gap: 4px;
}

.message.agent {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--newton-slate-light-2);
    padding: 0 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.message.agent .message-bubble {
    background: var(--newton-off-white);
    color: var(--newton-slate);
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: var(--newton-orange-dark-1); /* #C93B02 — white text gives 4.86:1 (WCAG 1.4.3) */
    color: var(--newton-white);
    border-bottom-right-radius: 4px;
}

/* Controls */
.controls {
    padding: 24px 32px;
    border-top: 1px solid var(--newton-off-white-dark-1);
    flex-shrink: 0;
}

.btn-start {
    width: 100%;
    padding: 16px;
    background: var(--newton-orange-dark-1); /* #C93B02 — white text gives 4.86:1 (WCAG 1.4.3) */
    color: var(--newton-white);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-start:hover:not(:disabled) {
    background: var(--newton-orange-dark-2);
}

.btn-start:focus-visible {
    outline: 3px solid var(--newton-slate);
    outline-offset: 2px;
}

.btn-start:disabled {
    background: var(--newton-off-white-dark-1);
    color: var(--newton-slate-light-2);
    cursor: not-allowed;
}

.btn-end {
    width: 100%;
    padding: 16px;
    background: transparent;
    color: var(--newton-slate);
    border: 1px solid var(--newton-off-white-dark-1);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    display: none;
}

.btn-end:hover {
    background: var(--newton-off-white);
    color: var(--newton-slate);
}

.btn-end:focus-visible {
    outline: 3px solid var(--newton-slate);
    outline-offset: 2px;
}

.btn-download {
    width: 100%;
    padding: 16px;
    background: transparent;
    color: var(--newton-orange-dark-1); /* #C93B02 on white = 4.86:1 (WCAG 1.4.3) */
    border: 1px solid var(--newton-orange-dark-1);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    display: none;
    margin-top: 12px;
}

.btn-download:hover {
    background: var(--newton-orange-dark-1);
    color: var(--newton-white);
}

.btn-download:focus-visible {
    outline: 3px solid var(--newton-slate);
    outline-offset: 2px;
}

.error-message {
    background: rgba(255, 98, 35, 0.12);
    color: var(--newton-slate); /* #282D37 on tinted bg = ~9:1 (WCAG 1.4.3) */
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid var(--newton-orange);
    font-size: 13px;
    margin-bottom: 12px;
}

.hidden { display: none; }

/* ── Analysis panel ── */
.analysis-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
    border-top: 1px solid var(--newton-off-white-dark-1);
    padding-top: 24px;
}

.analysis-panel.visible {
    display: flex;
}

.analysis-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--newton-slate-light-2);
    font-weight: 700;
}

.analysis-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--newton-slate-light-2);
    font-size: 14px;
}

.analysis-loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--newton-slate-light-2);
    animation: pulse 1s infinite;
    flex-shrink: 0;
}

.analysis-error {
    font-size: 13px;
    color: var(--newton-slate-light-2);
}

.analysis-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.criterion-item {
    padding: 12px 16px;
    background: var(--newton-white);
    border-radius: 8px;
    border-left: 3px solid var(--newton-off-white-dark-1);
}

.criterion-item.success { border-left-color: #16A34A; }
.criterion-item.failure { border-left-color: var(--newton-orange); }

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

.criterion-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--newton-slate);
}

.criterion-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.criterion-badge.success { background: rgba(22,163,74,0.12);  color: #14532D; } /* dark green ~8:1 on tinted bg */
.criterion-badge.failure { background: rgba(255,98,35,0.15);  color: #7C2D12; } /* dark red-brown ~7.9:1 on tinted bg */
.criterion-badge.unknown { background: rgba(89,95,107,0.15);  color: var(--newton-slate-light-2); }

.criterion-rationale {
    font-size: 13px;
    color: var(--newton-slate-light-1);
    line-height: 1.5;
}

.datapoint-item {
    padding: 12px 16px;
    background: var(--newton-white);
    border-radius: 8px;
    border-left: 3px solid var(--newton-off-white-dark-1);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.datapoint-name {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--newton-slate-light-2);
    font-weight: 700;
}

.datapoint-value {
    font-size: 14px;
    color: var(--newton-slate);
    font-family: 'Aptos Mono', 'Courier New', monospace;
}

/* ── Responsive reflow (WCAG 1.4.10 — no horizontal scroll at 320 px) ── */
@media (max-width: 640px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    body {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
        min-height: 100vh;
    }

    .left-panel {
        border-right: none;
        border-bottom: 1px solid var(--newton-off-white-dark-1);
        padding: 24px;
    }

    .right-panel {
        overflow: visible;
        min-height: 60vh;
    }

    .transcript {
        overflow: visible;
        min-height: 200px;
    }

    .status-bar,
    .controls {
        padding: 16px 24px;
    }
}
