* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #0f172a;
    color: #e5e7eb;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

header {
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 1rem 0;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.status {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.status span {
    color: #60a5fa;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button {
    padding: 0.5rem 1rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover:not(:disabled) {
    background: #2563eb;
}

button:disabled {
    background: #475569;
    cursor: not-allowed;
    opacity: 0.6;
}

button.is-loading {
    position: relative;
}

button.is-loading::after {
    content: "";
    width: 0.8rem;
    height: 0.8rem;
    margin-left: 0.5rem;
    display: inline-block;
    vertical-align: -0.12rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 999px;
    animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

main {
    flex: 1;
    padding: 2rem 1rem;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.content-area {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 1rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    max-height: calc(100vh - 2rem);
}

.sidebar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.sidebar-eyebrow {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-bottom: 0.2rem;
}

.sidebar h2 {
    font-size: 1.1rem;
}

.sidebar-action,
.new-session-btn {
    width: 100%;
}

.sidebar-action {
    width: auto;
    padding-inline: 0.85rem;
    background: #334155;
}

.sidebar-action:hover:not(:disabled) {
    background: #475569;
}

.new-session-btn {
    background: #0f766e;
}

.new-session-btn:hover:not(:disabled) {
    background: #0d9488;
}

.sidebar-empty {
    font-size: 0.8125rem;
    color: #94a3b8;
    padding: 0.5rem 0.25rem;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.session-item {
    width: 100%;
    border: 1px solid #334155;
    border-radius: 0.65rem;
    background: #0f172a;
    color: #e5e7eb;
    padding: 0.85rem 0.9rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.session-item:hover:not(:disabled) {
    background: #132033;
}

.session-item.active {
    border-color: #60a5fa;
    background: #12233a;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.3);
}

.session-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    color: #f8fafc;
}

.session-meta {
    font-size: 0.72rem;
    color: #94a3b8;
}

.latency-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    color: #94a3b8;
}

.latency-item span {
    color: #60a5fa;
    font-weight: 600;
}

.latency-e2e {
    color: #fbbf24;
    font-weight: 600;
}

.card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.is-hidden {
    display: none !important;
}

#waveform {
    width: 100%;
    height: 200px;
    display: block;
    background: #0f172a;
    border-radius: 0.375rem;
}

.recent-audio-card {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.recent-audio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.recent-audio-toggle {
    background: #0f766e;
}

.recent-audio-toggle:hover:not(:disabled) {
    background: #0d9488;
}

.recent-audio-status {
    font-size: 0.8125rem;
    color: #94a3b8;
}

.recent-audio-panel {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.875rem;
    border-radius: 0.5rem;
    background: #0f172a;
    border: 1px solid #334155;
}

.recent-audio-player {
    width: 100%;
}

.recent-audio-hint {
    font-size: 0.75rem;
    color: #94a3b8;
}

.chat-card-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#messages {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.4;
    max-width: 80%;
    word-wrap: break-word;
}

.message-user {
    background: #334155;
    align-self: flex-end;
}

.message-assistant {
    background: #1e3a5f;
    align-self: flex-start;
}

.message-info {
    background: #374151;
    align-self: center;
    font-style: italic;
    color: #94a3b8;
}

.message-tool {
    background: #111827;
    border: 1px solid #475569;
    align-self: flex-start;
    max-width: 100%;
}

.message-tool-label {
    font-size: 0.75rem;
    color: #fbbf24;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.message-tool-args {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8125rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cbd5e1;
}

.message-tool-details {
    margin-top: 0.45rem;
}

.message-tool-summary {
    cursor: pointer;
    color: #93c5fd;
    font-size: 0.8125rem;
    user-select: none;
}

.message-tool-summary:hover {
    color: #bfdbfe;
}

.message-tool-details[open] .message-tool-summary {
    margin-bottom: 0.5rem;
}

.message-tool-result-label {
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    color: #a7f3d0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.message-tool-result {
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
    padding: 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #334155;
    background: #0f172a;
    color: #d1d5db;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.toggle-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.toggle-btn {
    background: #475569;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

.toggle-btn.active {
    background: #3b82f6;
}

.panel .panel-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel .panel-content {
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
}

footer {
    background: #1e293b;
    border-top: 1px solid #334155;
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: #94a3b8;
}

@media (max-width: 640px) {
    .recent-audio-header {
        align-items: flex-start;
    }
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
    }

    .session-list {
        max-height: 240px;
    }
}
