/* ===== Re-Flow v6 — Core Styles ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #07080d;
    --surface: #0f1018;
    --card: #161822;
    --card-hover: #1c1f2e;
    --border: rgba(255,255,255,0.06);
    --border-active: rgba(124,106,239,0.3);
    --text: #e8e9f0;
    --text-muted: #6b6d83;
    --text-dim: #4a4c60;
    --accent: #7c6aef;
    --accent-glow: rgba(124,106,239,0.3);
    --accent-light: #9b8aff;
    --green: #36d6b5;
    --green-glow: rgba(54,214,181,0.2);
    --orange: #f0a54b;
    --red: #ef5466;
    --blue: #4ba3f0;
    --cyan: #36c5d6;
    --pink: #e06aad;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --radius-pill: 99px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== App Layout ===== */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    height: 100vh;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-header h3 { font-size: 0.9rem; font-weight: 600; }

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15rem;
}
.brand-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--accent-glow);
    position: relative;
}
.brand-icon .mini-ring {
    width: 12px; height: 12px;
    border: 2px solid white;
    border-radius: 50%;
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.section-title i { margin-right: 6px; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ===== Agent Items ===== */
.agent-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.agent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.agent-item:hover { background: rgba(255,255,255,0.04); }
.agent-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    font-weight: 700;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-role { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Agent colors */
.color-gemini { background: linear-gradient(135deg, #4285f4, #34a853); }
.color-claude { background: linear-gradient(135deg, #d97706, #f59e0b); }
.color-user { background: linear-gradient(135deg, var(--accent), #9b8aff); }
.color-gpt { background: linear-gradient(135deg, #10a37f, #1a7f64); }
.color-system { background: linear-gradient(135deg, var(--text-dim), var(--text-muted)); }
.color-custom { background: linear-gradient(135deg, var(--pink), var(--red)); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 30px var(--accent-glow); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.btn-danger { background: rgba(239,84,102,0.15); color: var(--red); }
.btn-danger:hover { background: rgba(239,84,102,0.25); }
.btn-dashed {
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.1);
    color: var(--text-muted);
}
.btn-dashed:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-xs { padding: 4px 8px; font-size: 0.75rem; }
.btn-icon {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}
.btn-icon:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ===== Topbar ===== */
.topbar {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 12px;
    flex-shrink: 0;
}
.topbar-center { flex: 1; }
.topbar-center h1 { font-size: 1rem; font-weight: 700; }
.topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
}
.meta-item { font-size: 0.75rem; color: var(--text-muted); }
.meta-item i { margin-right: 4px; }
.topbar-actions { display: flex; gap: 4px; }

/* ===== Main Content ===== */
.main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

/* ===== Chat ===== */
.chat-container { flex: 1; overflow-y: auto; padding: 20px; }
.chat-messages { display: flex; flex-direction: column; gap: 16px; max-width: 900px; margin: 0 auto; }

.msg {
    display: flex;
    gap: 12px;
    animation: msgIn 0.4s ease-out both;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.msg-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    font-weight: 700;
}
.msg-body { flex: 1; min-width: 0; }
.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.msg-name { font-weight: 700; font-size: 0.9rem; }
.msg-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-weight: 600;
}
.msg-badge.gemini { background: rgba(66,133,244,0.15); color: #4285f4; }
.msg-badge.claude { background: rgba(217,119,6,0.15); color: #f59e0b; }
.msg-badge.user { background: rgba(124,106,239,0.15); color: var(--accent); }
.msg-badge.system { background: rgba(107,109,131,0.15); color: var(--text-muted); }
.msg-badge.gpt { background: rgba(16,163,127,0.15); color: #10a37f; }
.msg-badge.step {
    background: rgba(54,214,181,0.15);
    color: var(--green);
}
.msg-time { font-size: 0.7rem; color: var(--text-dim); }
.msg-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px var(--radius) var(--radius) var(--radius);
    padding: 14px 18px;
    font-size: 0.88rem;
    line-height: 1.7;
    position: relative;
}
.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content code {
    font-family: var(--font-mono);
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
}
.msg-content pre {
    background: #0d0e14;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
    position: relative;
}
.msg-content pre code {
    background: none;
    padding: 0;
    font-size: 0.82rem;
    line-height: 1.6;
}
.msg-content h1, .msg-content h2, .msg-content h3 {
    margin: 16px 0 8px;
    font-weight: 700;
}
.msg-content h1 { font-size: 1.2rem; }
.msg-content h2 { font-size: 1.05rem; }
.msg-content h3 { font-size: 0.95rem; }
.msg-content ul, .msg-content ol { padding-left: 20px; margin: 8px 0; }
.msg-content li { margin: 4px 0; }
.msg-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}
.msg-content a { color: var(--accent); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }
.msg-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.83rem;
}
.msg-content th, .msg-content td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}
.msg-content th { background: rgba(255,255,255,0.04); font-weight: 600; }

/* Copy button on code blocks */
.code-copy-btn {
    position: absolute;
    top: 8px; right: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.msg-content pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: rgba(255,255,255,0.15); color: var(--text); }

/* System messages */
.msg-system .msg-content {
    background: rgba(124,106,239,0.06);
    border-color: rgba(124,106,239,0.15);
    text-align: center;
}
.system-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1rem;
}

/* Step indicator */
.msg-step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(54,214,181,0.08);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.78rem;
    color: var(--green);
    font-weight: 600;
}
.msg-step-indicator i { font-size: 0.7rem; }

/* Typing indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.typing-dots { display: flex; gap: 3px; }
.typing-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: typingBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== Input Area ===== */
.input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}
.input-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}
.input-toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.char-count { font-size: 0.7rem; color: var(--text-dim); }
.input-compose {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
}
.input-compose textarea {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
    transition: border-color var(--transition);
}
.input-compose textarea:focus { border-color: var(--accent); }
.input-compose textarea::placeholder { color: var(--text-dim); }
.btn-send {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send:not(:disabled):hover { transform: scale(1.05); box-shadow: 0 4px 20px var(--accent-glow); }

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-lg { max-width: 640px; }
.modal-header {
    padding: 28px 28px 20px;
    text-align: center;
}
.modal-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--green));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.3rem;
    color: white;
}
.modal-header h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.modal-header p { font-size: 0.85rem; color: var(--text-muted); }
.modal-body {
    padding: 0 28px 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Input Groups ===== */
.input-group { margin-bottom: 20px; }
.input-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.input-group input, .input-group textarea, .input-group select {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition);
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
    border-color: var(--accent);
}
.input-wrap {
    display: flex;
    gap: 4px;
}
.input-wrap input { flex: 1; }
.input-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.input-hint a { color: var(--accent); text-decoration: none; }
.input-hint i { margin-right: 4px; }

/* ===== Provider Cards ===== */
.provider-cards { display: flex; flex-direction: column; gap: 8px; }
.provider-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    transition: all var(--transition);
}
.provider-card:hover { border-color: rgba(255,255,255,0.1); }
.provider-card.selected { border-color: var(--accent); background: rgba(124,106,239,0.08); }
.provider-icon { font-size: 1.4rem; }
.provider-info { flex: 1; }
.provider-info strong { display: block; font-size: 0.88rem; }
.provider-info span { font-size: 0.75rem; color: var(--text-muted); }
.provider-check { color: var(--accent); display: none; }
.provider-card.selected .provider-check { display: block; }

/* ===== Setup Wizard ===== */
.setup-steps {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0 28px 20px;
}
.setup-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: all var(--transition);
}
.setup-step.active { background: rgba(124,106,239,0.12); color: var(--accent); }
.setup-step.done { color: var(--green); }
.step-num {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}
.setup-step.active .step-num { background: var(--accent); color: white; }
.setup-step.done .step-num { background: var(--green); color: white; }
.setup-page { display: none; }
.setup-page.active { display: block; }

/* ===== Badges ===== */
.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.08);
    font-weight: 600;
}
.status-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: var(--radius-pill); font-weight: 600; }
.status-active { background: rgba(54,214,181,0.15); color: var(--green); }
.status-idle { background: rgba(240,165,75,0.15); color: var(--orange); }
.status-error { background: rgba(239,84,102,0.15); color: var(--red); }

/* ===== Chain Visual ===== */
.chain-visual {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.chain-node {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    background: rgba(255,255,255,0.02);
    transition: all var(--transition);
}
.chain-node.active { background: rgba(124,106,239,0.1); border-left: 2px solid var(--accent); }
.chain-node.done { border-left: 2px solid var(--green); opacity: 0.7; }
.chain-node.waiting { border-left: 2px solid var(--text-dim); opacity: 0.5; }
.chain-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.chain-dot.active { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.chain-dot.done { background: var(--green); }
.chain-dot.waiting { background: var(--text-dim); }

/* Progress bar */
.depth-bar {
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}
.depth-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ===== Settings Groups ===== */
.settings-group {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.settings-group:last-child { border-bottom: none; }
.settings-group h4 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-muted);
}
.settings-group h4 i { margin-right: 8px; color: var(--accent); }
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.control-row label { font-size: 0.82rem; color: var(--text-muted); flex-shrink: 0; }
.control-row input[type="text"], .control-row input[type="number"], .control-row input[type="password"] {
    flex: 1;
    max-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
}
.control-row input:focus { border-color: var(--accent); }

/* Toggle switch */
.switch {
    position: relative;
    width: 40px; height: 22px;
    display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 11px;
    cursor: pointer;
    transition: 0.3s;
}
.slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}
input:checked + .slider { background: var(--accent); }
input:checked + .slider::before { transform: translateX(18px); }

/* ===== Toast ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 0.85rem;
    animation: toastIn 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 350px;
}
.toast.success { border-color: rgba(54,214,181,0.3); }
.toast.success i { color: var(--green); }
.toast.error { border-color: rgba(239,84,102,0.3); }
.toast.error i { color: var(--red); }
.toast.info { border-color: rgba(124,106,239,0.3); }
.toast.info i { color: var(--accent); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Splash ===== */
.splash {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.5s;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash-content { text-align: center; }
.splash-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}
.logo-rings { position: relative; width: 48px; height: 48px; }
.ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
}
.ring.r1 { border-top-color: var(--accent); animation: spin 1.5s linear infinite; }
.ring.r2 { inset: 4px; border-right-color: var(--green); animation: spin 2s linear infinite reverse; }
.ring.r3 { inset: 8px; border-bottom-color: var(--orange); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo-text { font-size: 2rem; font-weight: 900; letter-spacing: -0.03em; }
.splash-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.splash-loader { display: flex; gap: 6px; justify-content: center; }
.splash-loader span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: typingBounce 1.4s infinite;
}
.splash-loader span:nth-child(2) { animation-delay: 0.2s; }
.splash-loader span:nth-child(3) { animation-delay: 0.4s; }

/* ===== Workflow Panel (Right sidebar) ===== */
.workflow-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    position: relative;
}
.workflow-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 15px;
    top: 44px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.workflow-step.active::after { background: var(--accent); }
.workflow-step.done::after { background: var(--green); }
.workflow-num {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(255,255,255,0.06);
    color: var(--text-dim);
}
.workflow-step.active .workflow-num { background: var(--accent); color: white; }
.workflow-step.done .workflow-num { background: var(--green); color: white; }
.workflow-info h4 { font-size: 0.82rem; font-weight: 600; margin-bottom: 2px; }
.workflow-info p { font-size: 0.73rem; color: var(--text-muted); }

/* ===== GitHub Panel ===== */
.github-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.github-panel h5 { font-size: 0.78rem; font-weight: 600; margin-bottom: 8px; }
.github-info { font-size: 0.75rem; color: var(--text-muted); }
.github-info a { color: var(--accent); }

/* ===== Rate Limit Bar ===== */
.rate-limit-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(240,165,75,0.08);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--orange);
    margin-top: 8px;
}
.rate-limit-bar i { font-size: 0.7rem; }
.rate-limit-countdown {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ===== Mobile ===== */
.btn-mobile-menu { display: none; }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 49;
}

@media (max-width: 1024px) {
    .app-container { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .sidebar.open {
        display: flex;
        position: fixed;
        top: 0; bottom: 0;
        width: 300px;
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    .sidebar-left.open { left: 0; }
    .sidebar-right.open { right: 0; }
    .sidebar-overlay.show { display: block; }
    .btn-mobile-menu { display: flex; }
}
@media (max-width: 480px) {
    .modal-card { margin: 10px; border-radius: var(--radius); }
    .modal-header { padding: 20px 20px 16px; }
    .modal-body { padding: 0 20px 16px; }
    .modal-footer { padding: 12px 20px; }
    .chat-container { padding: 12px; }
    .input-area { padding: 12px; }
}

/* ===== API error ===== */
.api-error {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(239,84,102,0.1);
    border: 1px solid rgba(239,84,102,0.2);
    color: var(--red);
    font-size: 0.82rem;
    margin-top: 12px;
}

/* ===== Stepper ===== */
.stepper {
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-step {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-step:hover { background: rgba(255,255,255,0.1); }
.stepper span { min-width: 24px; text-align: center; font-size: 0.85rem; font-weight: 600; }

/* ===== Search Bar ===== */
.search-bar {
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    animation: slideDown 0.2s ease-out;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.search-bar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
}
.search-bar-inner input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
}
.search-bar-inner input::placeholder { color: var(--text-dim); }
.msg.search-highlight .msg-content { border-color: var(--accent) !important; box-shadow: 0 0 12px var(--accent-glow); }
.msg.search-current .msg-content { border-color: var(--green) !important; box-shadow: 0 0 16px var(--green-glow); }

/* ===== Onboarding Hints ===== */
.hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: rgba(124,106,239,0.08);
    border: 1px solid rgba(124,106,239,0.15);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
}
.hint-chip i { font-size: 0.65rem; }

/* ===== Keyboard Shortcuts Modal ===== */
.shortcuts-list { display: flex; flex-direction: column; gap: 8px; }
.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
}
.shortcut-item kbd {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}
.shortcut-item span { font-size: 0.82rem; color: var(--text-muted); }

/* ===== Select elements ===== */
.input-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b6d83'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 32px;
    cursor: pointer;
}
.input-group select option {
    background: var(--surface);
    color: var(--text);
}

/* ===== ETA display ===== */
#topbar-eta {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    background: rgba(240,165,75,0.08);
}

/* ===== No animation class ===== */
.msg.no-anim { animation: none; }
