/* Frontier Labs Chat (TinyLM) - DM Sans, indigo accent, light/dark tokens (aligned with frontierlabs.nl) */

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

:root {
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-md: 0.9375rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;

    /* Layout */
    --sidebar-width: 280px;
    --max-message-width: 768px;
    --input-max-height: 200px;
    --border-radius: 10px;
    --border-radius-lg: 14px;
    --border-radius-xl: 14px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #16161e;
    --bg-hover: #1a1a26;
    --bg-active: #22222e;
    --bg-input: #12121a;
    --bg-message-user: rgba(99, 102, 241, 0.14);
    --bg-message-assistant: transparent;
    --bg-code: #0e0e16;
    --bg-code-inline: #1e1e2e;

    --text-primary: #e0e0e8;
    --text-secondary: #c0c0d0;
    --text-tertiary: #8888a0;
    --text-link: #818cf8;

    --border-primary: #1e1e2e;
    --border-secondary: #1e1e2e;
    --border-hover: #3a3a4e;

    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-bg: rgba(99, 102, 241, 0.12);
    --accent-subtle: rgba(99, 102, 241, 0.12);

    --success: #22c55e;
    --warning: #f59e0b;
    --error: #f87171;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

    --scrollbar-thumb: #2a2a3a;
    --scrollbar-track: transparent;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f9;
    --bg-tertiary: #f0f0f4;
    --bg-hover: #ebebf0;
    --bg-active: #e2e2ea;
    --bg-input: #f7f7f9;
    --bg-message-user: rgba(99, 102, 241, 0.1);
    --bg-message-assistant: transparent;
    --bg-code: #f0f0f4;
    --bg-code-inline: #e6e6ec;

    --text-primary: #111118;
    --text-secondary: #3a3a42;
    --text-tertiary: #8a8a96;
    --text-link: #6366f1;

    --border-primary: #e6e6ec;
    --border-secondary: #e6e6ec;
    --border-hover: #c8c8d0;

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-bg: rgba(99, 102, 241, 0.08);
    --accent-subtle: rgba(99, 102, 241, 0.12);

    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);

    --scrollbar-thumb: #c8c8d0;
    --scrollbar-track: transparent;
}

/* ── Base Styles ───────────────────────────────────────────── */

html, body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

body {
    display: flex;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.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;
}

/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-md);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-sm);
    border-bottom: 1px solid var(--border-secondary);
}

.brand-block {
    min-width: 0;
    flex: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: var(--border-radius);
    padding: 2px 4px 2px 2px;
    margin: -2px;
    transition: background 0.15s;
}

.brand:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.brand-logo {
    height: 28px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    line-height: 1.2;
}

.brand-name {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-by {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

.sidebar-search {
    padding: var(--space-sm) var(--space-md);
}

.input-search {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-search:focus {
    border-color: var(--accent);
}

.input-search::placeholder {
    color: var(--text-tertiary);
}

/* ── Conversation List ─────────────────────────────────────── */

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.conversation-list-empty {
    padding: var(--space-lg) var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.5;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--accent-bg);
    border: 1px solid var(--border-primary);
}

.conversation-item .conv-title {
    flex: 1;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.conversation-item .conv-meta {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-left: var(--space-sm);
    white-space: nowrap;
}

.conversation-item .conv-delete {
    opacity: 0;
    padding: 4px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
}

.conversation-item:hover .conv-delete {
    opacity: 1;
}

.conversation-item .conv-delete:hover {
    color: var(--error);
    background: var(--bg-hover);
}

/* ── Sidebar Footer ────────────────────────────────────────── */

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-secondary);
}

/* ── Loaded Models ───────────────────────────────────────────── */

.loaded-models {
    margin-bottom: var(--space-md);
}

.loaded-models-label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.loaded-models-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 120px;
    overflow-y: auto;
}

.loaded-model-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
}

.loaded-model-item .loaded-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success, #22c55e);
    flex-shrink: 0;
}

.loaded-model-item .loaded-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loaded-model-item .eject-btn {
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.loaded-model-item .eject-btn:hover {
    color: var(--error, #ef4444);
    background: var(--bg-hover);
}

.loaded-models-empty {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    padding: var(--space-sm);
    text-align: center;
}

.model-selector {
    margin-bottom: var(--space-sm);
}

.model-selector label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-model {
    display: none;
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    outline: none;
}

.select-model:focus {
    border-color: var(--accent);
}

.sidebar-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════
   Main Content
   ═══════════════════════════════════════════════════════════════ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
}

/* ── Top Bar ───────────────────────────────────────────────── */

.top-bar {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border-secondary);
    background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: var(--space-md);
    min-height: 52px;
    flex-shrink: 0;
}

.chat-title {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    transition: background var(--transition-normal);
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.error {
    background: var(--error);
}

/* ── Messages ──────────────────────────────────────────────── */

.messages-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.messages {
    max-width: var(--max-message-width);
    margin: 0 auto;
    padding: var(--space-lg);
}

.message {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Headline tiles (news-intent): top of assistant message, above streamed reply */
.news-tiles-strip {
    margin: 0 0 var(--space-md);
    padding: var(--space-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-lg);
    background: var(--bg-secondary);
    animation: fadeIn 0.3s ease;
}

.assistant-stream-target {
    min-width: 0;
}

.news-tiles-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.news-tiles-heading {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.news-source {
    min-width: 0;
}

.news-source-label {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-sm);
}

.news-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm);
}

.news-tile {
    min-width: 0;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.news-tile:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.news-tile-link {
    display: block;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--text-link);
    text-decoration: none;
    word-break: break-word;
}

.news-tile-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.news-tile-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.news-tile-title {
    display: block;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--text-primary);
    word-break: break-word;
}

.news-tiles-status,
.news-tiles-error {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.news-tiles-error {
    color: var(--error);
}

@media (max-width: 640px) {
    .news-tile-grid {
        grid-template-columns: 1fr;
    }
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--accent);
}

.message-avatar svg {
    width: 18px;
    height: 18px;
}

.message.user .message-avatar {
    background: var(--accent-bg);
    color: var(--accent);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.message-role {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.message-content {
    font-size: var(--font-size-md);
    line-height: 1.7;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content p {
    margin-bottom: var(--space-sm);
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Markdown styles within messages */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: var(--space-md);
    margin-bottom: var(--space-sm);
    font-weight: 600;
}

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.05em; }

.message-content ul,
.message-content ol {
    margin: var(--space-sm) 0;
    padding-left: var(--space-lg);
}

.message-content li {
    margin-bottom: var(--space-xs);
}

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: var(--space-md);
    color: var(--text-secondary);
    margin: var(--space-sm) 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

/* Code blocks */
.message-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 2px 6px;
    background: var(--bg-code-inline);
    border-radius: 4px;
}

.message-content pre {
    margin: var(--space-md) 0;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.message-content pre code {
    display: block;
    padding: var(--space-md);
    background: var(--bg-code);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    overflow-x: auto;
    line-height: 1.5;
    font-size: var(--font-size-sm);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.code-header + code {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

.copy-btn {
    padding: 2px 8px;
    background: none;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-size-xs);
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
    font-size: var(--font-size-sm);
}

.message-content th,
.message-content td {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-primary);
    text-align: left;
}

.message-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

/* Streaming cursor */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 1s steps(1) infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* ── Welcome Screen ────────────────────────────────────────── */

.welcome-screen {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg) var(--space-xl);
    max-width: 560px;
    margin: 0 auto;
}

.welcome-mark {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.welcome-logo {
    height: 56px;
    width: auto;
    max-width: min(280px, 90vw);
    display: block;
}

.welcome-title {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    font-size: 0.9375rem;
    line-height: 1.6;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-foot {
    margin-top: var(--space-xl);
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.welcome-foot a {
    font-weight: 600;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    max-width: 500px;
    margin: 0 auto;
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: 18px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-lg);
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.feature-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.feature-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    background: var(--accent-bg);
    border: 1px solid var(--border-primary);
}

.feature-text {
    display: flex;
    flex-direction: column;
}

.feature-text strong {
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.feature-text span {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* ── Input Area ────────────────────────────────────────────── */

.input-area {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-secondary);
}

.input-wrapper {
    max-width: var(--max-message-width);
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-xl);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: var(--input-max-height);
    padding: var(--space-sm) 0;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.input-footer {
    max-width: var(--max-message-width);
    margin: var(--space-xs) auto 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-md);
}

.token-count {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.model-badge {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
}

.btn:hover {
    background: var(--bg-hover);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
}

.btn-icon {
    padding: var(--space-sm);
    background: transparent;
    border: none;
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-radius: var(--border-radius);
}

.btn-send {
    padding: var(--space-sm);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-stop {
    padding: var(--space-sm);
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--border-radius);
}

.btn-stop:hover {
    opacity: 0.9;
}

/* ── Theme Toggle Icons ────────────────────────────────────── */

[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ── Loading State: bot pushing square boulder, horizontal ground, sweat ─ */

.sisyphus-loader {
    padding: var(--space-md) 0 var(--space-sm);
    max-width: 280px;
}

.sisyphus-scene {
    position: relative;
    height: 108px;
    margin: 0 auto;
    max-width: 240px;
    overflow: visible;
}

.sisyphus-sky-glow {
    position: absolute;
    inset: 0 10% auto 10%;
    height: 64px;
    top: 4px;
    border-radius: 50%;
    background: radial-gradient(ellipse 80% 70% at 50% 80%, var(--accent-bg), transparent 70%);
    opacity: 0.85;
    pointer-events: none;
    animation: sisyphus-glow 3.2s ease-in-out infinite;
}

@keyframes sisyphus-glow {
    0%, 100% { opacity: 0.55; transform: scaleX(1); }
    50% { opacity: 1; transform: scaleX(1.06); }
}

/* Flat ground */
.sisyphus-ground {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18px;
    height: 8px;
    border-radius: 3px;
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--accent) 22%, var(--border-primary)) 0%,
        var(--border-primary) 55%,
        color-mix(in srgb, var(--bg-primary) 40%, var(--border-primary)) 100%
    );
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 2px 8px rgba(0, 0, 0, 0.12);
}

.sisyphus-dust {
    position: absolute;
    left: 0;
    bottom: 22px;
    width: 100%;
    height: 28px;
    pointer-events: none;
}

.sisyphus-dust span {
    position: absolute;
    bottom: 0;
    width: 4px;
    height: 4px;
    border-radius: 1px;
    background: var(--text-tertiary);
    opacity: 0;
    animation: sisyphus-dust 3.2s ease-out infinite;
}

.sisyphus-dust span:nth-child(1) { left: 22%; animation-delay: 0.15s; }
.sisyphus-dust span:nth-child(2) { left: 30%; animation-delay: 0.6s; width: 3px; height: 3px; }
.sisyphus-dust span:nth-child(3) { left: 38%; animation-delay: 1.05s; }
.sisyphus-dust span:nth-child(4) { left: 46%; animation-delay: 1.55s; width: 3px; height: 3px; }

@keyframes sisyphus-dust {
    0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
    12% { opacity: 0.8; }
    100% { opacity: 0; transform: translate(-22px, -12px) scale(1); }
}

/* Push struggle along X only (slip, shove, reset) */
.sisyphus-carriage {
    position: absolute;
    left: 12px;
    bottom: 26px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 0;
    transform-origin: 50% 100%;
    animation: sisyphus-carriage 3.4s cubic-bezier(0.42, 0, 0.58, 1) infinite;
}

@keyframes sisyphus-carriage {
    0%, 100% {
        transform: translateX(0);
    }
    22% {
        transform: translateX(28px);
    }
    34% {
        transform: translateX(20px);
    }
    55% {
        transform: translateX(44px);
    }
    68% {
        transform: translateX(36px);
    }
    88% {
        transform: translateX(54px);
    }
}

.sisyphus-boulder-block {
    position: relative;
    flex-shrink: 0;
    width: 30px;
    height: 34px;
    margin-right: -2px;
    margin-bottom: 2px;
}

/* Square boulder */
.sisyphus-boulder {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: 0;
    background:
        linear-gradient(145deg,
            color-mix(in srgb, var(--text-primary) 22%, var(--bg-tertiary)) 0%,
            var(--bg-tertiary) 40%,
            color-mix(in srgb, var(--accent) 25%, var(--bg-code)) 100%);
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border-primary));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -6px 12px rgba(0, 0, 0, 0.2),
        2px 4px 12px rgba(0, 0, 0, 0.25);
    animation: sisyphus-boulder 3.4s ease-in-out infinite;
    z-index: 2;
}

.sisyphus-boulder-shadow {
    position: absolute;
    width: 26px;
    height: 8px;
    left: 2px;
    bottom: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.22);
    filter: blur(3px);
    z-index: 0;
    animation: sisyphus-shadow 3.4s ease-in-out infinite;
}

@keyframes sisyphus-boulder {
    0%, 100% { transform: rotate(-6deg) scale(1); }
    25% { transform: rotate(4deg) scale(1.02); }
    50% { transform: rotate(-3deg) scale(1); }
    75% { transform: rotate(5deg) scale(1.03); }
}

@keyframes sisyphus-shadow {
    0%, 100% { opacity: 0.45; transform: scaleX(1); }
    55% { opacity: 0.65; transform: scaleX(1.15) translateX(4px); }
}

.sisyphus-bot-wrap {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 48px;
    margin-left: -4px;
    margin-bottom: -2px;
}

.sisyphus-sweat {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 70%;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}

.sisyphus-drop {
    position: absolute;
    width: 5px;
    height: 6px;
    border-radius: 50% 50% 50% 50% / 45% 45% 55% 55%;
    background: linear-gradient(
        165deg,
        color-mix(in srgb, #7dd3fc 70%, var(--accent)) 0%,
        color-mix(in srgb, #38bdf8 55%, var(--accent)) 100%
    );
    box-shadow: 0 0 4px color-mix(in srgb, #7dd3fc 40%, transparent);
    opacity: 0;
    animation: sisyphus-sweat-fall 2.1s ease-in infinite;
}

.sisyphus-drop:nth-child(1) {
    left: 6px;
    top: 14px;
    animation-delay: 0s;
}

.sisyphus-drop:nth-child(2) {
    left: 16px;
    top: 12px;
    width: 4px;
    height: 5px;
    animation-delay: 0.35s;
}

.sisyphus-drop:nth-child(3) {
    left: 22px;
    top: 15px;
    animation-delay: 0.7s;
}

.sisyphus-drop:nth-child(4) {
    left: 11px;
    top: 10px;
    width: 3px;
    height: 5px;
    animation-delay: 1.05s;
}

@keyframes sisyphus-sweat-fall {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    10% {
        opacity: 1;
    }
    75% {
        opacity: 0.95;
    }
    100% {
        opacity: 0;
        transform: translateY(38px) scale(0.9);
    }
}

.sisyphus-bot {
    width: 100%;
    height: 100%;
    color: var(--text-secondary);
    z-index: 1;
}

.sisyphus-bot-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.sisyphus-bot-antenna {
    transform-origin: 17px 4px;
    animation: sisyphus-antenna 2s ease-in-out infinite;
}

@keyframes sisyphus-antenna {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: rotate(4deg); }
}

.sisyp-arm-back {
    transform-origin: 10px 18px;
    animation: sisyphus-arm-back 3.4s ease-in-out infinite;
}

.sisyp-arm-front {
    transform-origin: 24px 18px;
    animation: sisyphus-arm-front 3.4s ease-in-out infinite;
}

@keyframes sisyphus-arm-back {
    0%, 100% { transform: rotate(0deg); }
    30% { transform: rotate(14deg); }
    50% { transform: rotate(4deg); }
    70% { transform: rotate(18deg); }
}

@keyframes sisyphus-arm-front {
    0%, 100% { transform: rotate(0deg); }
    30% { transform: rotate(-10deg); }
    50% { transform: rotate(-3deg); }
    70% { transform: rotate(-14deg); }
}

.sisyp-leg-l {
    transform-origin: 13px 28px;
    animation: sisyphus-leg 0.55s ease-in-out infinite;
}

.sisyp-leg-r {
    transform-origin: 21px 28px;
    animation: sisyphus-leg 0.55s ease-in-out infinite reverse;
}

@keyframes sisyphus-leg {
    0%, 100% { transform: rotate(-6deg); }
    50% { transform: rotate(10deg); }
}

.sisyphus-caption {
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    text-align: center;
    letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
    .sisyphus-sky-glow,
    .sisyphus-dust span,
    .sisyphus-boulder,
    .sisyphus-boulder-shadow,
    .sisyphus-bot-antenna,
    .sisyp-arm-back,
    .sisyp-arm-front,
    .sisyp-leg-l,
    .sisyp-leg-r,
    .sisyphus-drop {
        animation: none !important;
    }

    .sisyphus-carriage {
        transform: translateX(24px);
        animation: none !important;
    }

    .sisyphus-dust span {
        opacity: 0;
    }

    .sisyphus-drop {
        opacity: 0;
    }
}

/* ── Utility Classes ───────────────────────────────────────── */

.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .messages {
        padding: var(--space-md);
    }

    .input-area {
        padding: var(--space-sm) var(--space-md);
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }
}

.message-content .message-error {
    color: var(--error);
    font-size: var(--font-size-md);
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: var(--font-size-xl);
    }

    .message {
        gap: var(--space-sm);
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
}
