@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg-main: #F5F3FF; --bg-deep: #EDE9FE; --surface: #FFFFFF; --surface-hover: #FAFAFE;
    --primary: #A78BFA; --primary-hover: #8B5CF6; --primary-soft: #EDE9FE;
    --secondary: #6EE7B7; --secondary-hover: #34D399; --secondary-soft: #D1FAE5;
    --accent: #F9A8D4; --accent-hover: #F472B6; --accent-soft: #FCE7F3;
    --warning: #FCD34D; --warning-soft: #FEF3C7;
    --danger: #FCA5A5; --danger-hover: #F87171; --danger-soft: #FEE2E2;
    --text-primary: #1E1B4B; --text-secondary: #6B7280; --text-inverse: #FFFFFF;
    --border: #E5E7EB; --border-focus: #A78BFA; --divider: #F3F4F6;
    --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius-xs: 4px; --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px; --radius-pill: 9999px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04); --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08); --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
    --shadow-float: 0 16px 48px rgba(0,0,0,0.12);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg-main); color: var(--text-primary); font-family: var(--font-ui); height: 100vh; overflow: hidden; position: relative; -webkit-font-smoothing: antialiased; }
input, button, textarea { font-family: inherit; }
button { cursor: pointer; border: none; background: none; }
a { text-decoration: none; color: inherit; }

/* ── AMBIENT BG ── */
.ambient-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.3; animation: blobFloat 14s infinite alternate ease-in-out; }
.blob-1 { top: -15%; left: -10%; width: 500px; height: 500px; background: var(--primary); }
.blob-2 { bottom: -20%; right: -10%; width: 600px; height: 600px; background: var(--secondary); animation-delay: -5s; }
.blob-3 { top: 40%; left: 55%; width: 400px; height: 400px; background: var(--accent); animation-delay: -3s; }
@keyframes blobFloat { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(30px,20px) scale(1.08); } }

/* ── APP LAYOUT ── */
.app-layout-modern { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── TOPBAR ── */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; background: rgba(255,255,255,0.82);
    backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border); height: 54px; z-index: 100; flex-shrink: 0;
    box-shadow: var(--shadow-xs);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: 14px; flex-shrink: 0;
}
.brand-text { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.brand-text .highlight { color: var(--primary); }
.build-tag {
    font-size: 0.65rem; background: var(--primary-soft); padding: 3px 8px;
    border-radius: var(--radius-pill); font-weight: 700; color: var(--primary-hover);
    white-space: nowrap; letter-spacing: 0.3px;
}

/* ── ACTION CENTER ── */
.action-center { display: flex; align-items: center; gap: 8px; }
.editor-actions { display: flex; align-items: center; gap: 6px; }
.vertical-divider { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.compile-group {
    display: flex; align-items: center; gap: 4px; background: var(--bg-deep);
    padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* ── TOOL BUTTONS ── */
.tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 0.8rem; transition: var(--transition);
    white-space: nowrap; line-height: 1;
}
.tool-btn.compile { background: var(--secondary-soft); color: #065F46; border: 1px solid var(--secondary); }
.tool-btn.compile:hover { background: var(--secondary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tool-btn.decompile-btn { background: var(--primary-soft); color: var(--primary-hover); border: 1px solid var(--primary); }
.tool-btn.decompile-btn:hover { background: var(--primary); color: white; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tool-btn.security-trigger { background: var(--accent-soft); color: #9D174D; border: 1px solid var(--accent); }
.tool-btn.security-trigger:hover { background: var(--accent); color: white; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tool-btn.save { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); }
.tool-btn.save:hover { background: var(--bg-main); border-color: var(--primary); }
.tool-btn.ai-trigger {
    background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
    color: var(--primary-hover); border: 1px solid var(--primary);
    box-shadow: var(--shadow-xs);
}
.tool-btn.ai-trigger:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); filter: brightness(0.97); }
.tool-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.tool-icon {
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); color: var(--text-secondary); background: var(--surface);
    border: 1px solid var(--border); transition: var(--transition); font-size: 0.85rem; flex-shrink: 0;
}
.tool-icon:hover { color: var(--primary-hover); background: var(--primary-soft); border-color: var(--primary); }

/* ── FORMAT TOGGLE ── */
.format-toggle { display: flex; border-radius: var(--radius-xs); overflow: hidden; }
.fmt-btn {
    padding: 4px 10px; font-size: 0.7rem; font-weight: 700;
    background: transparent; color: var(--text-secondary); transition: var(--transition);
}
.fmt-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); border-radius: var(--radius-xs); }

/* ── VERSION DROPDOWN ── */
.custom-dropdown { position: relative; width: 100%; max-width: 160px; }
.dropdown-selected {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); cursor: pointer; font-size: 0.8rem; font-weight: 600;
    transition: var(--transition); gap: 6px;
}
.dropdown-selected:hover { border-color: var(--primary); }
.selected-content { display: flex; align-items: center; gap: 6px; }
.selector-icon { font-size: 0.75rem; color: var(--primary); }
.selector-arrow { font-size: 0.6rem; color: var(--text-secondary); transition: transform 0.2s var(--ease); }
.custom-dropdown.open .selector-arrow { transform: rotate(180deg); }
.dropdown-options {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); display: none; z-index: 50; overflow: hidden;
}
.custom-dropdown.open .dropdown-options,
.custom-dropdown:hover .dropdown-options { display: block; }
.dropdown-item {
    padding: 8px 12px; font-size: 0.8rem; cursor: pointer; transition: var(--transition);
    color: var(--text-secondary); font-weight: 500;
}
.dropdown-item:hover { background: var(--primary-soft); color: var(--primary-hover); }
.dropdown-item.active { color: var(--primary-hover); font-weight: 700; background: var(--primary-soft); }

/* ── SECURITY POPOVER ── */
.security-dropdown-wrapper { position: relative; }
.security-popover {
    position: absolute; top: calc(100% + 8px); right: 0; width: 90vw; max-width: 340px;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(20px);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-float); padding: 20px;
    border: 1px solid var(--border); z-index: 200;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
    display: flex; flex-direction: column; gap: 14px;
}
.panel-hidden { opacity: 0; pointer-events: none; transform: translateY(-8px); }
.card-header-mini { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.95rem; color: var(--text-primary); border-bottom: 1px solid var(--divider); padding-bottom: 12px; }
.card-header-mini i { color: var(--primary); }
.mode-switch-wrapper { display: flex; background: var(--bg-main); border-radius: var(--radius-sm); padding: 3px; }
.switch-btn {
    flex: 1; padding: 7px; font-size: 0.8rem; font-weight: 600;
    border-radius: var(--radius-xs); color: var(--text-secondary); transition: var(--transition);
}
.switch-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.input-wrapper { display: flex; flex-direction: column; width: 100%; position: relative; }
.input-wrapper input[type="text"], .input-wrapper input[type="password"] {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-main);
    font-size: 0.8rem; transition: var(--transition); outline: none; color: var(--text-primary);
}
.input-wrapper input:focus { border-color: var(--border-focus); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.pass-field { position: relative; }
.toggle-password {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    cursor: pointer; color: var(--text-secondary); font-size: 0.85rem; transition: var(--transition);
}
.toggle-password:hover { color: var(--primary); }
.meta-grid { display: flex; gap: 10px; align-items: center; }
.format-select-modern { display: flex; align-items: center; }
.modern-dropzone {
    border: 2px dashed var(--border); border-radius: var(--radius-md);
    padding: 16px; text-align: center; cursor: pointer; background: var(--bg-main); transition: var(--transition);
}
.modern-dropzone:hover, .modern-dropzone.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.zone-content i { font-size: 20px; color: var(--primary); margin-bottom: 6px; }
.zone-content p { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.hero-btn {
    width: 100%; padding: 10px; background: var(--text-primary); color: white;
    border-radius: var(--radius-sm); font-weight: 700; font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition);
}
.hero-btn:disabled { background: var(--border); color: var(--text-secondary); cursor: not-allowed; }
.hero-btn:not(:disabled):hover { background: #0F0A3C; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.status-text { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); margin-top: 6px; }
.progress-bar-wrapper { height: 3px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); width: 0%; transition: width 0.3s ease; border-radius: var(--radius-pill); }
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.input-wrapper.hidden { display: none; }
/* ── EDITOR TABS ── */
.editor-tabs-bar {
    display: flex; background: var(--bg-deep); border-bottom: 1px solid var(--border);
    overflow-x: auto; flex-shrink: 0;
}
.editor-tabs-bar::-webkit-scrollbar { height: 3px; }
.editor-tab {
    display: flex; align-items: center; gap: 10px; padding: 8px 14px;
    background: var(--bg-deep); border-right: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.78rem; font-weight: 600;
    cursor: pointer; user-select: none; min-width: 120px; max-width: 180px;
    border-bottom: 2px solid transparent; transition: var(--transition);
}
.editor-tab.active { background: var(--surface); color: var(--text-primary); border-bottom-color: var(--primary); }
.editor-tab:hover:not(.active) { background: var(--bg-main); }
.tab-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-title i { margin-right: 5px; color: var(--primary); font-size: 0.75rem; }
.tab-close { border-radius: 4px; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); transition: var(--transition); font-size: 0.65rem; }
.tab-close:hover { background: var(--danger); color: white; }

/* ── EDITOR WORKSPACE ── */
.main-workspace { flex: 1; display: flex; padding: 0; min-height: 0; overflow: hidden; }
.workspace-panel {
    flex: 1; display: flex; flex-direction: column; background: var(--surface);
    border: none; min-height: 0; overflow: hidden;
}
.editor-area-wrapper { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.editor-header-compact {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-main); flex-shrink: 0;
}
.search-module {
    position: relative; display: flex; align-items: center; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 10px; width: 100%; max-width: 320px;
    transition: var(--transition);
}
.search-module:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-module i { color: var(--text-secondary); font-size: 0.8rem; }
.search-module input { border: none; padding: 7px 10px; width: 100%; outline: none; font-size: 0.8rem; background: transparent; color: var(--text-primary); }
.search-dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; right: auto; width: 100vw; max-width: 420px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    box-shadow: var(--shadow-float); max-height: 320px; overflow-y: auto; z-index: 10; display: none;
}
.result-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--divider); cursor: pointer; transition: background 0.15s; }
.result-item:hover { background: var(--primary-soft); }
.result-text { font-size: 0.8rem; font-family: var(--font-mono); color: var(--text-primary); flex: 1; padding-right: 12px; line-height: 1.5; }
.opcode-badge { background: var(--primary-soft); color: var(--primary-hover); padding: 2px 7px; border-radius: var(--radius-xs); font-weight: 700; font-size: 0.7rem; margin-right: 8px; display: inline-block; letter-spacing: 0.5px; border: 1px solid var(--primary); }
.result-copy-btn { background: var(--secondary-soft); color: #065F46; width: 28px; height: 28px; border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0; font-size: 0.8rem; border: 1px solid var(--secondary); }
.result-copy-btn:hover { background: var(--secondary); transform: scale(1.05); }
.editor-tools-right { display: flex; gap: 8px; align-items: center; }

/* ── EDITOR BODY ── */
.editor-body { flex: 1; display: flex; position: relative; background: var(--surface); min-height: 0; overflow: hidden; }
.gutter {
    width: 48px; background: var(--bg-main); border-right: 1px solid var(--border);
    padding: 14px 8px; text-align: right; color: var(--text-secondary);
    font-family: var(--font-mono); font-size: 13px; line-height: 1.6; user-select: none; overflow: hidden;
}
.code-stage { flex: 1; position: relative; min-height: 0; }
#codeEditor, #codeHighlight {
    margin: 0; padding: 14px; width: 100%; height: 100%; border: none; outline: none;
    font-family: var(--font-mono); font-size: 13px; line-height: 1.6; white-space: pre;
    tab-size: 4; box-sizing: border-box; letter-spacing: 0.2px;
    position: absolute; top: 0; left: 0;
}
#codeEditor { background: transparent; color: transparent; caret-color: var(--text-primary); resize: none; z-index: 2; overflow: auto; }
#codeHighlight { pointer-events: none; z-index: 1; color: var(--text-primary); overflow: hidden; }

/* ── SYNTAX HIGHLIGHTING ── */
.cleo-keyword { color: #7C3AED; font-weight: 600; }
.cleo-opcode { color: #2563EB; font-weight: 600; }
.cleo-number { color: #D97706; }
.cleo-string { color: #059669; }
.cleo-comment { color: #9CA3AF; font-style: italic; }
.cleo-label { color: #7C3AED; font-weight: 600; }
.cleo-variable { color: #DC2626; }
.hl-opcode { color: #2563EB; font-weight: 700; }
.hl-string { color: #059669; }
.hl-var-global { color: #DC2626; }
.hl-var-local { color: #EA580C; }
.hl-label { color: #7C3AED; font-weight: 700; }
.hl-label-ref { color: #9333EA; }
.hl-comment { color: #9CA3AF; font-style: italic; }
.hl-number { color: #D97706; }
.hl-keyword { color: #7C3AED; font-weight: 600; }
.hl-symbol { color: var(--text-secondary); }
.hl-punct { color: var(--text-secondary); }

/* ── STATUS BAR ── */
.editor-statusbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 14px; background: var(--text-primary); color: rgba(255,255,255,0.8);
    font-size: 0.7rem; font-family: var(--font-mono); flex-shrink: 0; letter-spacing: 0.3px;
}
.right-stat .sep { margin: 0 8px; opacity: 0.4; }

/* ── EMPTY STATE ── */
.empty-state-container {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--bg-main); text-align: center; padding: 24px; animation: fadeIn 0.4s var(--ease); min-height: 0;
}
.empty-state-content { max-width: 480px; display: flex; flex-direction: column; align-items: center; width: 100%; }
.empty-state-content .modal-graphic { width: 80px; height: 80px; font-size: 36px; margin-bottom: 20px; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ── FAB REFERENCE ── */
.fab-reference {
    position: fixed; bottom: 28px; right: 28px; width: 52px; height: 52px;
    border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white; box-shadow: var(--shadow-lg); font-size: 18px; z-index: 150;
    transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275), box-shadow 0.3s var(--ease);
    display: flex; align-items: center; justify-content: center;
}
.fab-reference:hover { transform: scale(1.1) rotate(-5deg); box-shadow: var(--shadow-float); }
.fab-tooltip {
    position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--text-primary); color: white; font-size: 0.7rem; font-weight: 600;
    padding: 4px 10px; border-radius: var(--radius-sm); white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease);
}
.fab-reference:hover .fab-tooltip { opacity: 1; }

/* ── DRAWERS (Reference + AI Chat) ── */
.reference-drawer, .chat-drawer {
    position: fixed; top: 0; right: 0; width: 100vw; max-width: 380px; height: 100vh;
    background: var(--surface); box-shadow: var(--shadow-float); z-index: 300;
    display: flex; flex-direction: column; transform: translateX(100%);
    transition: transform 0.3s var(--ease); border-left: 1px solid var(--border);
}
.reference-drawer.panel-hidden, .chat-drawer.panel-hidden { transform: translateX(100%); opacity: 1; pointer-events: auto; }
.reference-drawer:not(.panel-hidden), .chat-drawer:not(.panel-hidden) { transform: translateX(0); }
.drawer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg-main); flex-shrink: 0;
}
.drawer-header h2 { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--text-primary); }
.drawer-header h2 i { color: var(--primary); }
.close-drawer { font-size: 1.25rem; color: var(--text-secondary); transition: var(--transition); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.close-drawer:hover { color: var(--danger-hover); background: var(--danger-soft); transform: rotate(90deg); }

/* Reference Drawer specifics */
.reference-drawer .search-box { margin: 12px 20px; position: relative; }
.reference-drawer .search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 0.8rem; }
.reference-drawer .search-box input { width: 100%; padding: 9px 14px 9px 36px; border-radius: var(--radius-sm); border: 1px solid var(--border); outline: none; background: var(--bg-main); transition: var(--transition); font-size: 0.8rem; }
.reference-drawer .search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ref-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 20px; }
.ref-tab { flex: 1; padding: 10px 0; font-weight: 600; font-size: 0.8rem; color: var(--text-secondary); border-bottom: 2px solid transparent; transition: var(--transition); text-align: center; }
.ref-tab.active { color: var(--primary-hover); border-bottom-color: var(--primary); }
.ref-tab:hover:not(.active) { color: var(--text-primary); }
.ref-results { flex: 1; overflow-y: auto; padding: 12px 20px; }
.hint { text-align: center; color: var(--text-secondary); font-size: 0.8rem; margin-top: 20px; }
.no-results { text-align: center; color: var(--text-secondary); font-size: 0.8rem; margin-top: 20px; }
.ref-item { padding: 10px; background: var(--bg-main); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; transition: var(--transition); cursor: pointer; }
.ref-item:hover { transform: translateY(-1px); border-color: var(--primary); box-shadow: var(--shadow-sm); }
.ref-item strong { display: block; color: var(--text-primary); font-size: 0.8rem; margin-bottom: 3px; }
.ref-item span { color: var(--text-secondary); font-size: 0.7rem; font-family: var(--font-mono); }

/* Reference Table */
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.ref-table thead { position: sticky; top: 0; z-index: 2; }
.ref-table th { background: var(--bg-deep); color: var(--text-secondary); font-weight: 700; padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--border); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }
.ref-table td { padding: 7px 10px; border-bottom: 1px solid var(--divider); color: var(--text-primary); }
.ref-table tr { cursor: pointer; transition: background 0.15s; }
.ref-table tr:hover { background: var(--primary-soft); }
.ref-table .id-cell { font-family: var(--font-mono); font-weight: 700; color: var(--primary-hover); font-size: 0.75rem; }

/* ── CHAT DRAWER ── */
.chat-history { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--bg-main); }
.chat-msg { display: flex; gap: 10px; max-width: 90%; }
.chat-msg.user-msg { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.ai-msg { align-self: flex-start; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.user-msg .msg-avatar { background: var(--text-primary); color: white; }
.ai-msg .msg-avatar { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; }
.msg-bubble { padding: 10px 14px; border-radius: var(--radius-md); font-size: 0.8rem; line-height: 1.5; box-shadow: var(--shadow-xs); }
.user-msg .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-top-right-radius: 4px; }
.ai-msg .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; overflow-wrap: anywhere; }
.chat-input-area { padding: 12px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.chat-input-area textarea { flex: 1; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-main); outline: none; font-family: var(--font-ui); font-size: 0.8rem; resize: none; max-height: 100px; transition: var(--transition); }
.chat-input-area textarea:focus { border-color: var(--primary); }
.chat-input-area button { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--text-primary); color: white; display: flex; align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0; }
.chat-input-area button:hover { background: #0F0A3C; transform: translateY(-1px); }
.typing-indicator { display: flex; gap: 4px; padding: 4px 8px; }
.typing-indicator span { width: 5px; height: 5px; background: var(--text-secondary); border-radius: 50%; animation: typing 1s infinite alternate; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0% { opacity: 0.3; transform: translateY(0); } 100% { opacity: 1; transform: translateY(-4px); } }

/* ── MODALS ── */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(30,27,75,0.4);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: none; justify-content: center; align-items: center; z-index: 1000;
}
.modal-backdrop.active { display: flex; }
.modal-card {
    background: var(--surface); padding: 28px; border-radius: var(--radius-xl);
    width: 90%; max-width: 440px; text-align: center; box-shadow: var(--shadow-float);
    animation: modalIn 0.3s var(--ease); max-height: 90vh; overflow-y: auto;
}
.modal-graphic {
    width: 60px; height: 60px; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
    color: var(--primary-hover); border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 26px; margin: 0 auto 16px;
}
.modal-card h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; color: var(--text-primary); }
.modal-card p { color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.8rem; margin-bottom: 20px; word-break: break-word; line-height: 1.5; }
.welcome-desc { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 16px; line-height: 1.6; word-wrap: break-word; font-family: var(--font-ui); }
.feature-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 20px; }
.badge { background: var(--bg-main); border: 1px solid var(--border); padding: 5px 10px; border-radius: var(--radius-pill); font-size: 0.7rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 5px; }
.badge i { color: var(--primary); font-size: 0.65rem; }
.warning-text { font-size: 0.75rem; color: var(--text-primary); margin-bottom: 20px; font-weight: 600; background: var(--bg-main); padding: 8px 12px; border-radius: var(--radius-sm); display: inline-block; border: 1px solid var(--border); }
.warning-text i { color: var(--primary); margin-right: 6px; }
.modal-actions-row { display: flex; gap: 10px; }
.modal-action {
    flex: 1; padding: 10px; border-radius: var(--radius-sm); font-weight: 700;
    transition: var(--transition); display: flex; align-items: center; justify-content: center;
    gap: 6px; font-size: 0.85rem; border: none; cursor: pointer;
}
.modal-action#decompileModalYes { background: var(--text-primary); color: white; }
.modal-action#decompileModalYes:hover { background: #0F0A3C; transform: translateY(-1px); }
.modal-action.secondary { background: var(--bg-main); border: 1px solid var(--border); color: var(--text-primary); }
.modal-action.secondary:hover { background: var(--bg-deep); }
.modal-close-top {
    position: absolute; top: 14px; right: 14px; background: var(--bg-main); border: 1px solid var(--border);
    color: var(--text-secondary); width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: var(--transition); font-size: 0.9rem; z-index: 10;
}
.modal-close-top:hover { background: var(--danger-soft); color: var(--danger-hover); border-color: var(--danger); transform: rotate(90deg); }
.team-section { background: var(--bg-main); padding: 14px; border-radius: var(--radius-md); border: 1px solid var(--border); margin-bottom: 20px; text-align: left; }
.section-title { font-size: 0.65rem; color: var(--text-secondary); font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1px; }
.btn-support { background: var(--secondary-soft); color: #065F46; border: 1px solid var(--secondary); }
.btn-support:hover { background: var(--secondary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-close-welcome { background: var(--danger-soft); color: #991B1B; border: 1px solid var(--danger); }
.btn-close-welcome:hover { background: var(--danger); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-profile-owner { background: var(--primary-soft); color: var(--primary-hover); border: 1px solid var(--primary); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 700; transition: var(--transition); }
.btn-profile-owner:hover { background: var(--primary); color: white; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-profile-partner { background: var(--accent-soft); color: #9D174D; border: 1px solid var(--accent); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 700; transition: var(--transition); }
.btn-profile-partner:hover { background: var(--accent); color: white; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.modal-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; margin: 0 auto 14px; }
.modal-icon.success { background: var(--secondary-soft); color: #065F46; border: 2px solid var(--secondary); }
.modal-icon.error { background: var(--danger-soft); color: #991B1B; border: 2px solid var(--danger); }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; max-width: 90vw; }
.toast {
    display: flex; align-items: center; gap: 10px; padding: 10px 18px;
    border-radius: var(--radius-md); font-size: 0.8rem; font-weight: 600;
    box-shadow: var(--shadow-md); pointer-events: auto; white-space: nowrap;
    animation: toastIn 0.3s var(--ease); backdrop-filter: blur(12px);
}
.toast.success { background: rgba(209,250,229,0.95); color: #065F46; border: 1px solid var(--secondary); }
.toast.error { background: rgba(254,226,226,0.95); color: #991B1B; border: 1px solid var(--danger); }
.toast.warning { background: rgba(254,243,199,0.95); color: #92400E; border: 1px solid var(--warning); }
.toast.info { background: rgba(237,233,254,0.95); color: var(--primary-hover); border: 1px solid var(--primary); }
.toast.hiding { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px) scale(0.95); } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── SKELETON SHIMMER ── */
.skeleton { background: linear-gradient(90deg, var(--bg-main) 25%, var(--border) 50%, var(--bg-main) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── LOADING STATE ── */
.tool-btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.tool-btn.loading::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
    .topbar { padding: 0 14px; }
    .btn-label { display: none; }
    .tool-btn { padding: 6px 10px; }
}
@media (max-width: 850px) {
    .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
    .brand { flex-shrink: 0; }
    .action-center { flex: 1; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
    .editor-actions { flex-wrap: wrap; gap: 6px; }
    .vertical-divider { display: none; }
    .security-popover {
        position: fixed; top: 50%; left: 50%;
        transform: translate(-50%, -50%) !important;
        width: 90vw; max-width: 380px; max-height: 85vh; overflow-y: auto;
        box-shadow: var(--shadow-float); z-index: 1000;
    }
    .security-popover.panel-hidden {
        transform: translate(-50%, -45%) !important;
        opacity: 0; pointer-events: none;
    }
}
@media (max-width: 600px) {
    .topbar { padding: 8px 12px; }
    .brand-text { font-size: 1rem; }
    .build-tag { display: none; }
    .custom-dropdown { max-width: 130px; }
    .editor-header-compact { flex-direction: column; gap: 8px; align-items: stretch; }
    .search-module { max-width: 100%; width: 100%; }
    .editor-tools-right { justify-content: flex-end; width: 100%; }
    .modal-card { padding: 20px; width: 95%; }
    .modal-actions-row, .team-section > div {
        display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%;
    }
    .empty-state-content div[style*="display: flex"] { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
    .empty-state-content div[style*="display: flex"] .tool-btn { width: 100%; max-width: none; }
    .fab-reference { bottom: 20px; right: 20px; width: 46px; height: 46px; font-size: 16px; }
    .fab-tooltip { display: none; }
    .editor-statusbar { flex-direction: column; gap: 4px; align-items: center; font-size: 0.65rem; }
    .empty-state-content .brand-text { font-size: 2rem !important; }
    .tool-icon { width: 36px !important; height: 36px !important; }
    .tool-btn { flex: 1 1 auto; max-width: none; justify-content: center; padding: 6px 8px; font-size: 0.75rem; }
    .security-dropdown-wrapper { flex: 1 1 auto; display: flex; }
    .security-dropdown-wrapper .tool-btn { width: 100%; max-width: none; }
    .compile-group { flex: 1 1 100%; justify-content: center; }
    .custom-dropdown { width: 100%; max-width: 100%; }
    .reference-drawer, .chat-drawer { max-width: 100vw; }
}
@media (max-width: 380px) {
    .topbar { padding: 6px 8px; }
    .editor-actions { gap: 4px; }
    .action-center { gap: 4px; }
}

/* ── MISSING CLASS FIXES ── */
.selected-text { font-size: inherit; color: inherit; }
.btn-text { font-size: inherit; color: inherit; }
.file-status { font-size: 0.75rem; color: var(--text-secondary); margin-top: 8px; font-weight: 600; }
.hidden { display: none !important; }
.open .dropdown-options { display: block; }
.pulse { animation: pulse 0.3s var(--ease); }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }
.btn-label { pointer-events: none; }
