/* ═══════════════════════════════════════════════
   AI EDITOR — SiteForge  
   Dark IDE-style theme — v2
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Tokens ── */
:root {
    --bg-app: #0d1117;
    --bg-panel: #161b22;
    --bg-panel-alt: #1c2333;
    --bg-hover: #1f2937;
    --bg-active: #253147;
    --bg-input: #0d1117;
    --border: #30363d;
    --border-focus: #58a6ff;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --accent-bg: rgba(56, 139, 253, 0.15);
    --green: #3fb950;
    --orange: #d29922;
    --red: #f85149;
    --purple: #bc8cff;
    --gradient-accent: linear-gradient(135deg, #58a6ff 0%, #bc8cff 100%);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
    --transition: 0.2s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   SITE SELECTOR — Full-screen overlay
   ═══════════════════════════════════════════════ */

.site-selector {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.site-selector.hidden {
    opacity: 0;
    pointer-events: none;
}

.selector-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-app);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(88, 166, 255, 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(188, 140, 255, 0.08), transparent);
}

.selector-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 740px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
}

.selector-header {
    text-align: center;
    margin-bottom: 32px;
}

.selector-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.selector-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    box-shadow: 0 8px 32px rgba(88, 166, 255, 0.25);
}

.selector-brand h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.selector-brand h1 span {
    color: var(--accent);
}

.selector-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.selector-search-wrap {
    position: relative;
    margin-bottom: 20px;
}

.selector-search-wrap i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
}

.selector-search {
    width: 100%;
    padding: 14px 18px 14px 46px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.selector-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.selector-search::placeholder {
    color: var(--text-muted);
}

.selector-scroll-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 24px;
    padding-right: 4px; /* for scrollbar */
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: max-content;
    gap: 12px;
}

.site-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.site-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.site-card:hover {
    border-color: var(--accent);
    background: var(--bg-panel-alt);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.site-card:hover::before {
    opacity: 1;
}

.site-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent);
}

.site-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.site-card-pages {
    font-size: 12px;
    color: var(--text-muted);
}

.site-card-pages i {
    margin-right: 4px;
    color: var(--text-muted);
}

/* No results */
.selector-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.selector-no-results i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

/* ═══════════════════
   MAIN LAYOUT
   ═══════════════════ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Top Bar ── */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.app-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-topbar-brand .logo-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
}

.app-topbar-brand h1 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.app-topbar-brand h1 span {
    color: var(--accent);
}

.topbar-site-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding: 4px 12px;
    background: var(--accent-bg);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ── Main Content ── */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ═══════════════════
   LEFT PANEL — SIDEBAR
   ═══════════════════ */

.panel-left {
    width: 280px;
    min-width: 220px;
    max-width: 400px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.panel-left.collapsed {
    width: 40px;
    min-width: 40px;
    overflow: hidden;
}

.panel-left.collapsed .sidebar-section {
    display: none;
}

.sidebar-toggle-bar {
    display: flex;
    justify-content: flex-end;
    padding: 6px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: var(--transition);
}

.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Sidebar collapsible sections */
.sidebar-section {
    border-bottom: 1px solid var(--border);
}

.sidebar-section .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
    border-bottom: none;
}

.sidebar-section .panel-header:hover {
    background: var(--bg-hover);
}

.sidebar-section .panel-header h2 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
}

.panel-header-actions {
    display: flex;
    gap: 4px;
}

.panel-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.panel-icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.chevron-toggle i {
    transition: transform 0.2s ease;
    font-size: 11px;
}

.sidebar-section-body {
    display: none;
    padding: 4px 0;
}

.sidebar-section-body.open {
    display: block;
}

/* ── Tree page groups (collapse/expand) ── */
.tree-page-group {
    border-bottom: 1px solid var(--border);
}

.tree-page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
    user-select: none;
}

.tree-page-header:hover {
    background: var(--bg-hover);
}

.tree-page-header .chevron {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.tree-page-header.expanded .chevron {
    transform: rotate(90deg);
}

.tree-page-header .page-icon {
    color: var(--accent);
    font-size: 14px;
}

.tree-page-header .section-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-panel-alt);
    padding: 1px 7px;
    border-radius: 10px;
}

.tree-page-sections {
    display: none;
    padding-left: 10px;
}

.tree-page-sections.visible {
    display: block;
}

.tree-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 6px 22px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.tree-section:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-section.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    font-weight: 600;
}

.tree-section-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition);
}

.tree-section:hover .tree-section-actions {
    opacity: 1;
}

.sidebar-section .panel-header.collapsed .chevron-toggle i {
    transform: rotate(-90deg);
}

/* File tree items */
.tree-page {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    transition: var(--transition);
    user-select: none;
}

.tree-page:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-page.active {
    background: var(--bg-active);
    color: var(--accent);
}

.tree-page .page-icon {
    color: var(--accent);
    font-size: 13px;
    opacity: 0.7;
}

/* Section tree items */
.tree-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 20px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    transition: var(--transition);
    user-select: none;
}

.tree-section:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-section.active {
    background: var(--bg-active);
    color: var(--accent);
}

.tree-section .section-idx {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.tree-section .section-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-section .section-tag {
    font-size: 11px;
    color: var(--purple);
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.7;
}

.tree-section-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.tree-section:hover .tree-section-actions {
    opacity: 1;
}

.tree-section-actions .panel-icon-btn {
    font-size: 12px;
    padding: 3px;
}

/* ── Sections Tree: Page groups ── */
.tree-page-group {
    margin-bottom: 2px;
}

.tree-page-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    transition: var(--transition);
    user-select: none;
}

.tree-page-header:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tree-page-header .chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
    width: 14px;
    text-align: center;
}

.tree-page-header.expanded .chevron {
    transform: rotate(90deg);
}

.tree-page-header .page-icon {
    color: var(--orange);
    font-size: 13px;
}

.section-count {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
}

.tree-page-sections {
    display: none;
    padding-left: 8px;
}

.tree-page-sections.visible {
    display: block;
}

/* ═══════════════════
   CENTER PANEL — EDITOR / PREVIEW
   ═══════════════════ */

.panel-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.editor-tabs {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
}

.editor-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
    font-weight: 500;
}

.editor-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.editor-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    background: var(--bg-panel-alt);
}

.editor-tab i {
    font-size: 14px;
}

.editor-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-app);
}

.tab-pane {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

/* Welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 20px;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}

.welcome-screen .welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--accent);
}

.welcome-screen h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-secondary);
}

.welcome-screen p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 400px;
    line-height: 1.7;
}

/* ═══════════════════
   RIGHT PANEL — AI CHAT
   ═══════════════════ */

.panel-right {
    width: 360px;
    min-width: 280px;
    max-width: 500px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* ── Chat mode: Site (preview tab) — blue accent ── */
.chat-mode-site {
    border-top: 3px solid var(--accent);
}

.chat-mode-site > .panel-header {
    background: linear-gradient(135deg, rgba(88,166,255,0.08) 0%, transparent 100%);
}

.chat-mode-site > .panel-header h2 {
    color: var(--accent);
}

.chat-mode-site .chat-send-btn {
    background: var(--accent);
}

.chat-mode-site .chat-send-btn:hover {
    background: var(--accent-hover);
}

/* ── Chat mode: Section (section/code tabs) — purple accent ── */
.chat-mode-section {
    border-top: 3px solid var(--purple);
}

.chat-mode-section > .panel-header {
    background: linear-gradient(135deg, rgba(188,140,255,0.08) 0%, transparent 100%);
}

.chat-mode-section > .panel-header h2 {
    color: var(--purple);
}

.chat-mode-section .chat-send-btn {
    background: var(--purple);
}

.chat-mode-section .chat-send-btn:hover {
    background: #d4a8ff;
}

.panel-right>.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-right>.panel-header h2 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: msgFadeIn 0.3s ease;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message .msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    font-weight: 700;
}

.chat-message.system .msg-avatar {
    background: var(--accent-bg);
    color: var(--accent);
}

.chat-message.user .msg-avatar {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green);
}

.chat-message.ai .msg-avatar {
    background: rgba(188, 140, 255, 0.15);
    color: var(--purple);
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-body .msg-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.msg-body .msg-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    word-break: break-word;
}

.msg-body .msg-text code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-app);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.msg-body .msg-text pre {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.msg-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Chat Input */
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-panel-alt);
}

.chat-input-context {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--accent-bg);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent);
}

.chat-input-context.visible {
    display: flex;
}

.chat-input-context .context-label {
    font-weight: 600;
}

.chat-input-context .context-dismiss {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition);
}

.chat-input-context .context-dismiss:hover {
    opacity: 1;
}

.chat-input-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color var(--transition);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.chat-mic-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-mic-btn:hover {
    background: var(--bg-panel-alt);
    color: var(--accent);
    border-color: var(--accent);
}

.chat-mic-btn.recording {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

/* ═══════════════════
   RESIZE HANDLES
   ═══════════════════ */

.resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--transition);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.resize-handle:hover,
.resize-handle.active {
    background: var(--accent);
}

/* Drag overlay — covers iframes during resize to prevent mouse capture */
.drag-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    cursor: col-resize;
}

.drag-overlay.active {
    display: block;
}

.section-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* ═══════════════════
   LOADING / EMPTY
   ═══════════════════ */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.empty-state.small {
    padding: 20px 14px;
}

.empty-state.small p {
    font-size: 12px;
}

.empty-state i {
    font-size: 32px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 13px;
}

/* ═══════════════════
   TOASTS
   ═══════════════════ */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}

.toast {
    background: var(--bg-panel-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

/* ── AI Action Buttons (Apply / Cancel) ── */
.ai-action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.ai-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ai-action-buttons p {
    flex-basis: 100%;
    margin-bottom: 4px;
}

.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.ai-btn-apply {
    background: var(--accent);
    color: #fff;
}

.ai-btn-apply:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.ai-btn-cancel {
    background: var(--red);
    color: #fff;
}

.ai-btn-cancel:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.ai-elapsed {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
}

.toast.success {
    border-left: 3px solid var(--green);
}

.toast.error {
    border-left: 3px solid var(--red);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════
   CODE VIEW — Ace Editor
   ═══════════════════ */

.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}

.code-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-toolbar-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.code-toolbar-label i {
    color: var(--accent);
    margin-right: 4px;
}

.code-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.save-btn {
    background: var(--green) !important;
    border-color: var(--green) !important;
    color: #fff !important;
    font-weight: 600;
}

.save-btn:hover {
    filter: brightness(1.15);
}

.code-editors-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-editor-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.code-editor-block+.code-editor-block {
    border-top: 1px solid var(--border);
}

.code-editor-label {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.code-editor-label i {
    margin-right: 6px;
    font-size: 12px;
}

.ace-editor-container {
    flex: 1;
    min-height: 120px;
    width: 100%;
}