:root {
    color-scheme: light;
    --bg: #efe5d5;
    --panel: rgba(255, 248, 239, 0.92);
    --panel-strong: #fffaf4;
    --panel-muted: rgba(255, 250, 244, 0.72);
    --ink: #201812;
    --muted: #6e6358;
    --line: rgba(32, 24, 18, 0.1);
    --accent: #a0452b;
    --accent-strong: #7f2e18;
    --accent-soft: rgba(160, 69, 43, 0.14);
    --success-soft: rgba(46, 128, 87, 0.14);
    --shadow: 0 18px 60px rgba(61, 40, 20, 0.14);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(160, 69, 43, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(38, 107, 118, 0.12), transparent 24%),
        linear-gradient(180deg, #fbf6ef 0%, var(--bg) 100%);
}

button,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 20px;
    width: min(1480px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 20px 0;
}

.sidebar,
.workspace {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.sidebar-top,
.workspace-header,
.artifact-top,
.composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sidebar-top {
    align-items: flex-start;
}

.eyebrow,
.section-label,
.meta-pill,
.status-badge,
.composer-hint,
.message-meta,
.chat-meta,
.artifact-meta,
.notice {
    letter-spacing: 0.04em;
}

.eyebrow,
.section-label {
    margin: 0 0 10px;
    font-size: 0.76rem;
    text-transform: uppercase;
    color: var(--accent);
}

.sidebar h1,
.workspace-header h2,
.artifact-top h3,
.empty-state h3 {
    margin: 0;
}

.sidebar h1 {
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    line-height: 0.92;
}

.workspace {
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.workspace-header {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.workspace-header h2 {
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1;
}

.workspace-subtitle {
    max-width: 700px;
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.sidebar-meta,
.header-actions,
.artifact-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sidebar-meta {
    margin: 18px 0 26px;
}

.meta-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-muted);
    font-size: 0.82rem;
    color: var(--muted);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.chat-list,
.artifact-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.chat-list {
    overflow: auto;
    padding-right: 4px;
}

.chat-list-item {
    width: 100%;
    padding: 16px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--panel-muted);
    transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.chat-list-item:hover,
.chat-list-item:focus-visible,
.artifact-card:hover,
.artifact-card:focus-within {
    transform: translateY(-2px);
    border-color: rgba(160, 69, 43, 0.25);
}

.chat-list-item.active {
    border-color: rgba(160, 69, 43, 0.38);
    background: linear-gradient(180deg, rgba(160, 69, 43, 0.14), rgba(255, 250, 244, 0.92));
}

.chat-list-item-title {
    margin: 0 0 8px;
    font-size: 1rem;
}

.chat-list-item-preview {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.5;
}

.chat-meta,
.artifact-meta,
.message-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--muted);
}

.chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 360px);
    gap: 20px;
    flex: 1;
    min-height: 0;
    padding-top: 24px;
}

.chat-panel,
.artifact-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-strong);
}

.chat-panel {
    padding: 18px;
}

.artifact-panel {
    padding: 18px;
    gap: 18px;
}

.voice-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(38, 107, 118, 0.08), rgba(255, 250, 244, 0.92));
}

.artifact-top-separator {
    padding-top: 6px;
    border-top: 1px solid var(--line);
}

.voice-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.voice-help,
.voice-meta {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.notice {
    min-height: 22px;
    font-size: 0.9rem;
    color: var(--muted);
}

.notice.error {
    color: var(--accent-strong);
}

.notice.success {
    color: #1f6e4f;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 280px;
    flex: 1;
    overflow: auto;
    padding: 8px 4px 20px;
}

.message {
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    width: min(100%, 760px);
    padding: 16px 18px;
    border-radius: 24px;
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(61, 40, 20, 0.08);
}

.message.user .message-bubble {
    background: linear-gradient(180deg, rgba(160, 69, 43, 0.18), rgba(255, 245, 237, 0.96));
    border-bottom-right-radius: 10px;
}

.message-bubble.live {
    box-shadow: 0 0 0 3px rgba(38, 107, 118, 0.12), 0 10px 30px rgba(61, 40, 20, 0.08);
}

.message.assistant .message-bubble {
    background: linear-gradient(180deg, rgba(38, 107, 118, 0.08), rgba(255, 250, 244, 0.96));
    border-bottom-left-radius: 10px;
}

.message-body {
    margin: 10px 0 0;
    line-height: 1.65;
    white-space: pre-wrap;
}

.composer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.composer-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    color: var(--muted);
}

.composer textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    resize: vertical;
    background: #fffdf9;
    color: var(--ink);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer textarea:focus {
    border-color: rgba(160, 69, 43, 0.38);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

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

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: transform 140ms ease, opacity 140ms ease, border-color 140ms ease;
}

.primary-button {
    background: linear-gradient(180deg, #b24f32, #8e361c);
    color: #fffaf4;
    box-shadow: 0 10px 26px rgba(160, 69, 43, 0.24);
}

.secondary-button {
    background: var(--panel-muted);
    color: var(--ink);
    border-color: var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.artifact-action-button:hover {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.artifact-action-button:disabled,
.composer textarea:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
}

.artifact-actions {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.artifact-action-button[data-busy="true"] {
    background: var(--accent-soft);
}

.artifact-list {
    overflow: auto;
    padding-right: 4px;
}

.artifact-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel-muted);
    transition: transform 160ms ease, border-color 160ms ease;
}

.artifact-card h4 {
    margin: 0;
    font-size: 1.1rem;
}

.artifact-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.artifact-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.artifact-download {
    color: var(--accent-strong);
    text-decoration: none;
}

.artifact-download:hover {
    text-decoration: underline;
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    min-height: 220px;
    padding: 24px;
    border: 1px dashed rgba(32, 24, 18, 0.14);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 251, 246, 0.92), rgba(246, 235, 221, 0.56));
}

.empty-state.compact {
    min-height: 160px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

body.ready .sidebar,
body.ready .workspace,
body.ready .chat-panel,
body.ready .artifact-panel {
    animation: rise 520ms ease-out both;
}

body.ready .workspace {
    animation-delay: 90ms;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: 280px;
    }

    .chat-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100%, calc(100% - 20px));
        padding: 10px 0;
    }

    .sidebar,
    .workspace,
    .chat-panel,
    .artifact-panel {
        border-radius: 24px;
    }

    .sidebar,
    .workspace,
    .chat-panel,
    .artifact-panel {
        padding: 16px;
    }

    .sidebar-top,
    .workspace-header,
    .artifact-top,
    .composer-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .message-bubble {
        width: 100%;
    }

    .composer textarea {
        min-height: 108px;
    }
}
