/* ──────────────────────────────────────────────────────────────────
   Yollai Design System
   Startup energy: warm orange primary, amber accent, clean white canvas
   Inspired by Vetric style guide — adapted with orange/yellow palette
   ────────────────────────────────────────────────────────────────── */

/* ═══ RESET & BASE ═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }
textarea { resize: none; }

/* ═══ DESIGN TOKENS ══════════════════════════════════════════════ */
:root {
    /* Core neutrals */
    --ink:     #0F0F1A;
    --ink-2:   #2A2A3D;
    --white:   #FFFFFF;
    --surface: #F8F8FA;
    --surface-2: #F1F1F5;
    --border:  #E4E4EB;
    --border-2: #CFCFD9;
    --muted:   #72728A;
    --muted-2: #A8A8C0;

    /* Brand palette — orange/amber startup */
    --flame:        #F97316;
    --flame-dark:   #EA6A0F;
    --flame-light:  #FB923C;
    --amber:        #FBBF24;
    --amber-dark:   #F59E0B;
    --flame-wash:   #FFF4EE;
    --amber-wash:   #FFFBEB;

    /* Gradient */
    --grad:      linear-gradient(135deg, #F97316 0%, #FBBF24 100%);
    --grad-soft: linear-gradient(135deg, rgba(249,115,22,0.10) 0%, rgba(251,191,36,0.10) 100%);
    --grad-text: linear-gradient(135deg, #F97316, #FBBF24);

    /* Status */
    --success:  #22C55E;
    --success-wash: #F0FDF4;
    --error:    #EF4444;
    --error-wash: #FEF2F2;
    --info:     #3B82F6;
    --info-wash: #EFF6FF;

    /* Layout */
    --icon-bar-w: 56px;
    --left-panel-w: 256px;
    --right-panel-w: 500px;

    /* Radii */
    --r-sm:  4px;
    --r:     8px;
    --r-md:  10px;
    --r-lg:  14px;
    --r-xl:  20px;

    /* Shadows (minimal) */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow:    0 2px 8px rgba(0,0,0,0.08);
}

/* ═══ APP LAYOUT ═════════════════════════════════════════════════ */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ═══ LEFT ICON BAR ══════════════════════════════════════════════ */
#icon-bar {
    width: var(--icon-bar-w);
    min-width: var(--icon-bar-w);
    height: 100%;
    background: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 4px;
    border-right: 1px solid rgba(255,255,255,0.06);
    z-index: 100;
}

.icon-bar-logo {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    width: 100%;
    display: flex;
    justify-content: center;
}

.logo-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r);
    background: rgba(249,115,22,0.12);
    transition: background 0.15s;
}
.logo-mark:hover { background: rgba(249,115,22,0.20); }

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--r);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-2);
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.icon-btn.active { background: rgba(249,115,22,0.18); color: var(--flame); }

.icon-bar-spacer { flex: 1; }

/* ═══ LEFT SLIDING PANEL ═════════════════════════════════════════ */
#left-panel {
    width: var(--left-panel-w);
    height: 100%;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(calc(-1 * var(--left-panel-w)));
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    left: var(--icon-bar-w);
    top: 0;
    z-index: 90;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}
#left-panel.panel-open { transform: translateX(0); }

.panel-content { display: none; flex-direction: column; height: 100%; }
.panel-content.active { display: flex; }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.panel-close {
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
    color: var(--muted);
    transition: background 0.12s, color 0.12s;
}
.panel-close:hover { background: var(--surface-2); color: var(--ink); }

/* History list */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.history-empty {
    text-align: center;
    color: var(--muted-2);
    font-size: 13px;
    padding: 40px 16px;
    line-height: 1.6;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--r);
    cursor: pointer;
    transition: background 0.12s;
    border: 1px solid transparent;
    position: relative;
    margin-bottom: 2px;
}
.history-item:hover { background: var(--surface); }
.history-item.active { background: var(--flame-wash); border-color: rgba(249,115,22,0.2); }

.history-item-icon {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: var(--muted);
    font-size: 11px;
}
.history-item.active .history-item-icon {
    background: rgba(249,115,22,0.15);
    color: var(--flame);
}

.history-item-info { flex: 1; min-width: 0; }
.history-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.history-item-meta {
    font-size: 11px;
    color: var(--muted-2);
    margin-top: 1px;
}
.history-item.active .history-item-title { color: var(--flame-dark); }

.history-item-del {
    width: 22px; height: 22px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-2);
    opacity: 0;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { background: var(--error-wash); color: var(--error); }

/* Settings content */
.settings-content { padding: 16px; flex: 1; overflow-y: auto; }
.settings-section { margin-bottom: 16px; }
.settings-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.settings-value { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.settings-divider { border-top: 1px solid var(--border); margin: 16px 0; }

/* ═══ MAIN CHAT AREA ═════════════════════════════════════════════ */
#chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    background: var(--white);
    border-right: 1px solid var(--border);
    position: relative;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 32px 0 16px;
    scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ── Welcome Screen ── */
#welcome-screen {
    max-width: 520px;
    margin: 0 auto;
    padding: 40px 24px;
    text-align: center;
}
.welcome-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px; height: 72px;
    border-radius: var(--r-lg);
    background: var(--flame-wash);
    margin-bottom: 20px;
    border: 1px solid rgba(249,115,22,0.15);
}
.welcome-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 32px;
    font-weight: 800;
    background: var(--grad-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.04em;
    margin-bottom: 12px;
}
.welcome-sub {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 32px;
}
.welcome-prompts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}
.prompt-chip {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--white);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    line-height: 1.4;
}
.prompt-chip:hover {
    border-color: var(--flame);
    background: var(--flame-wash);
    transform: translateX(2px);
}

/* ── Messages ── */
.message-wrap {
    max-width: 680px;
    margin: 0 auto 24px;
    padding: 0 24px;
}

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

.msg-bubble {
    max-width: 82%;
    border-radius: var(--r-lg);
    padding: 12px 16px;
    line-height: 1.65;
    font-size: 14px;
}
.message-user .msg-bubble {
    background: var(--ink);
    color: var(--white);
    border-bottom-right-radius: var(--r-sm);
}
.message-assistant .msg-bubble {
    background: var(--surface);
    color: var(--ink);
    border-bottom-left-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.msg-bubble code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: rgba(0,0,0,0.07);
    padding: 1px 5px;
    border-radius: 3px;
}
.message-user .msg-bubble code { background: rgba(255,255,255,0.15); }

.msg-bubble pre {
    background: var(--ink);
    color: #e4e4e8;
    padding: 14px;
    border-radius: var(--r);
    overflow-x: auto;
    margin: 10px 0;
    font-size: 12px;
    line-height: 1.6;
}
.msg-bubble pre code { background: none; padding: 0; color: inherit; }

.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; }
.msg-bubble ul,
.msg-bubble ol  { padding-left: 22px; margin: 6px 0 10px; }
.msg-bubble li  { margin-bottom: 4px; line-height: 1.5; }
.msg-bubble ul  { list-style-type: disc; }
.msg-bubble ol  { list-style-type: decimal; }
/* User bubble lists — ensure markers are visible on dark background */
.message-user .msg-bubble ul,
.message-user .msg-bubble ol { color: var(--white); }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    margin-bottom: 8px;
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; }
.msg-bubble a { color: var(--flame); text-decoration: underline; }

/* Artifact badge in message */
.artifact-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 7px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: 12px;
    font-weight: 600;
    color: var(--flame);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.artifact-badge:hover { border-color: var(--flame); background: var(--flame-wash); }
.artifact-badge svg { flex-shrink: 0; }

/* HTML generation in-progress indicator (replaces HTML code block in chat) */
.email-gen-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 9px 14px;
    background: var(--grad-soft);
    border: 1px solid rgba(249,115,22,0.2);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--flame-dark);
}
.email-gen-icon {
    display: flex;
    align-items: center;
    opacity: 0.8;
}
.email-gen-text { color: var(--flame-dark); }
.email-gen-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.email-gen-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--flame);
    animation: gen-pulse 1.2s ease-in-out infinite;
}
.email-gen-dots span:nth-child(2) { animation-delay: 0.3s; }
.email-gen-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes gen-pulse {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
    40%           { opacity: 1;    transform: scale(1);   }
}

/* File attachment in message */
.msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.msg-file-thumb {
    max-width: 160px;
    max-height: 120px;
    border-radius: var(--r-sm);
    object-fit: cover;
    border: 1px solid var(--border);
}
.msg-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    background: rgba(0,0,0,0.06);
    border-radius: var(--r-sm);
    font-size: 12px;
    color: var(--muted);
}
.message-user .msg-file-chip { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.8); }

/* ── Design Suggestion Cards ── */
.design-suggestions {
    max-width: 680px;
    margin: 0 auto 24px;
    padding: 0 24px;
}
.design-suggestions-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}
.design-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 900px) {
    .design-cards { grid-template-columns: 1fr; }
}

.design-card {
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
    background: var(--white);
    position: relative;
}
.design-card:hover {
    border-color: var(--flame-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.design-card.selected {
    border-color: var(--flame);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
.design-card.dimmed { opacity: 0.4; pointer-events: none; }

.design-card-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
    background: var(--surface-2);
}
.design-card-img-placeholder {
    width: 100%;
    height: 120px;
    background: var(--grad-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--flame);
    font-size: 28px;
}

.design-card-body { padding: 12px; }
.design-card-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 4px;
}
.design-card-cat {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--flame);
    background: var(--flame-wash);
    border-radius: var(--r-sm);
    padding: 2px 6px;
    margin-bottom: 6px;
}
.design-card-reason {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

.design-card-selected-badge {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--flame);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    display: none;
}
.design-card.selected .design-card-selected-badge { display: block; }

/* ── Typing Indicator ── */
#typing-indicator {
    max-width: 680px;
    margin: 0 auto 16px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    border-bottom-left-radius: var(--r-sm);
}
.typing-dots span {
    width: 6px; height: 6px;
    background: var(--muted-2);
    border-radius: 50%;
    animation: bounce 1.2s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); background: var(--flame-light); }
}
.typing-label { font-size: 12px; color: var(--muted-2); }

/* ═══ INPUT AREA ═════════════════════════════════════════════════ */
#input-area {
    flex-shrink: 0;
    padding: 0 24px 20px;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

#file-preview-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.file-preview-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 12px;
    color: var(--ink-2);
}
.file-preview-img {
    width: 32px; height: 32px;
    object-fit: cover;
    border-radius: 3px;
}
.file-preview-remove {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--muted-2);
    color: white;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.12s;
    flex-shrink: 0;
}
.file-preview-remove:hover { background: var(--error); }

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    padding: 8px 8px 8px 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-row:focus-within {
    border-color: var(--flame);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}
#file-preview-bar + .input-row {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.attach-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-sm);
    color: var(--muted);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.attach-btn:hover { background: var(--surface-2); color: var(--ink); }

#message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    line-height: 1.6;
    min-height: 36px;
    max-height: 160px;
    overflow-y: auto;
    padding: 4px 0;
}
#message-input::placeholder { color: var(--muted-2); }

#send-btn {
    width: 36px; height: 36px;
    border-radius: var(--r);
    background: var(--grad);
    color: white;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}
#send-btn:hover:not(:disabled) { opacity: 0.9; transform: scale(1.04); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
    font-size: 11px;
    color: var(--muted-2);
    margin-top: 6px;
    padding-left: 4px;
}
.input-hint kbd {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0px 4px;
    font-size: 10px;
    font-family: inherit;
}

/* ═══ RIGHT PANEL ════════════════════════════════════════════════ */
#right-panel {
    position: relative;
    width: var(--right-panel-w);
    min-width: var(--right-panel-w);
    height: 100%;
    background: var(--white);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Resize Handle ───────────────────────────────────────────────── */
#panel-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 30;
    /* Subtle grip indicator */
}
#panel-resize-handle::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 36px;
    background: var(--border-2);
    border-radius: 99px;
    opacity: 0;
    transition: opacity 0.15s;
}
#panel-resize-handle:hover::after,
#panel-resize-handle.is-dragging::after {
    opacity: 1;
    background: var(--flame);
}

.rpanel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    background: var(--white);
}
.rpanel-header:hover { background: var(--surface); }

.rpanel-header-left {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.rpanel-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.collapse-arrow {
    color: var(--muted);
    transition: transform 0.2s;
}
#branding-section.collapsed .collapse-arrow { transform: rotate(180deg); }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 32px; height: 18px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute; inset: 0;
    background: var(--border-2);
    border-radius: 9px;
    transition: background 0.2s;
}
.toggle-track::after {
    content: '';
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: white;
    top: 3px; left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--flame); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(14px); }

/* Branding body */
#branding-body {
    padding: 14px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    transition: max-height 0.25s, opacity 0.2s, padding 0.2s;
    max-height: 600px;
}
#branding-section.collapsed #branding-body {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.branding-row { margin-bottom: 12px; }
.branding-row:last-of-type { margin-bottom: 0; }
.branding-row-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field-col { display: flex; flex-direction: column; }
.field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 5px;
}
.field-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.field-input {
    width: 100%;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--r);
    outline: none;
    color: var(--ink);
    background: var(--white);
    transition: border-color 0.15s;
    font-size: 13px;
}
.field-input:focus { border-color: var(--flame); }
.field-input::placeholder { color: var(--muted-2); }

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
input[type="color"] {
    width: 32px; height: 32px;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    padding: 2px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.color-text-field { flex: 1; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

.save-branding-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 14px;
    padding: 9px;
    background: var(--ink);
    color: white;
    border-radius: var(--r);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}
.save-branding-btn:hover { background: var(--ink-2); }

.branding-saved {
    text-align: center;
    font-size: 12px;
    color: var(--success);
    font-weight: 600;
    margin-top: 8px;
    padding: 6px;
}

/* Preview section */
#preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.preview-header-bar {
    cursor: default;
    flex-shrink: 0;
}
.preview-header-bar:hover { background: var(--white); }

.preview-tab-group {
    display: flex;
    gap: 2px;
    background: var(--surface);
    border-radius: var(--r-sm);
    padding: 2px;
}
.preview-tab {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    color: var(--muted);
    transition: background 0.15s, color 0.15s;
}
.preview-tab.active { background: var(--white); color: var(--ink); box-shadow: var(--shadow-sm); }

.preview-actions { display: flex; gap: 4px; }
.icon-action-btn {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
    transition: background 0.12s, color 0.12s;
}
.icon-action-btn:hover { background: var(--surface-2); color: var(--ink); }

#preview-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    background: var(--surface);
}

#preview-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted-2);
    padding: 32px;
    text-align: center;
}
#preview-placeholder p { font-size: 14px; font-weight: 500; color: var(--muted); }
#preview-placeholder span { font-size: 12px; }

#email-iframe {
    border: none;
    display: block;
    width: 100%;
    /* height is set dynamically after zoom injection */
}

#code-view {
    flex: 1;
    overflow-y: auto;
    background: var(--ink);
}
#code-pre {
    padding: 16px;
    margin: 0;
    min-height: 100%;
}
#code-content {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11.5px;
    line-height: 1.7;
    color: #e4e4e8;
    white-space: pre;
    display: block;
}

/* ═══ IMAGES SECTION ════════════════════════════════════════════ */
#images-section {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
    max-height: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: max-height 0.25s, opacity 0.2s;
}
#images-section.collapsed {
    max-height: 44px;
}
#images-section.collapsed #images-body {
    display: none;
}
#images-body {
    padding: 10px 14px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
}
.images-upload-area {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--r);
    background: var(--surface);
    transition: border-color 0.15s, background 0.15s;
}
.images-upload-area:hover {
    border-color: var(--flame);
    background: var(--flame-wash);
}
.images-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 14px 12px;
    cursor: pointer;
    color: var(--muted);
}
.images-upload-label svg { color: var(--flame); }
.images-upload-label span:first-of-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}
.images-upload-hint {
    font-size: 11px;
    color: var(--muted-2);
}
.images-url-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.images-url-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r);
    background: var(--ink);
    color: white;
    transition: background 0.15s;
}
.images-url-btn:hover { background: var(--ink-2); }
.images-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.images-progress-fill {
    height: 100%;
    background: var(--grad);
    border-radius: 2px;
    width: 0%;
    transition: width 0.2s;
}
#images-upload-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.images-progress-label {
    font-size: 11px;
    color: var(--muted);
}
.images-gallery {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.images-gallery-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--white);
    transition: border-color 0.12s;
}
.images-gallery-item:hover { border-color: var(--flame-light); }
.images-gallery-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.images-gallery-info {
    flex: 1;
    min-width: 0;
}
.images-gallery-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.images-gallery-url {
    font-size: 10px;
    color: var(--muted-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.images-copy-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--muted);
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.images-copy-btn:hover { background: var(--surface-2); color: var(--flame); }
.images-delete-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--muted-2);
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.images-delete-btn:hover { background: var(--error-wash); color: var(--error); }

/* Mobile close button (hidden on desktop) */
#mobile-panel-close {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
#mobile-panel-close:hover { background: var(--border); color: var(--ink); }

/* ═══ TOAST ══════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: white;
    padding: 10px 20px;
    border-radius: var(--r-lg);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    box-shadow: var(--shadow);
    pointer-events: none;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

/* ═══ SCROLLBAR GLOBAL ═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ═══ UTILITIES ══════════════════════════════════════════════════ */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ═══ LOADING SPINNER ════════════════════════════════════════════ */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--flame);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ RESPONSIVE ═════════════════════════════════════════════════ */
@media (max-width: 1100px) {
    :root { --right-panel-w: 420px; }
}
@media (max-width: 800px) {
    #right-panel {
        position: fixed;
        top: 0;
        right: 0;
        width: 100vw !important;
        max-width: 100vw;
        height: 100%;
        z-index: 200;
        transform: translateX(100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        box-shadow: -4px 0 24px rgba(0,0,0,0.18);
        min-width: unset !important;
    }
    #right-panel.mobile-open {
        transform: translateX(0);
    }
    #panel-resize-handle { display: none; }
    #left-panel { box-shadow: 2px 0 20px rgba(0,0,0,0.15); }
    #btn-mobile-artifacts { display: flex !important; }
    /* Mobile close button for right panel */
    #mobile-panel-close {
        display: flex !important;
    }
}
