/* 
  RESET & BASICS 
*/
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Builder Theme */
    --bg-app: #0e0e12;
    --bg-sidebar: #13131a;
    --bg-panel: #1a1a24;
    --border-color: #2a2a3d;
    --text-primary: #e8e8f5;
    --text-secondary: #a0a0b0;
    --accent-color: #6c63ff;
    --accent-hover: #5a52d5;
    --danger-color: #ff4d4d;
    --success-color: #4ade80;

    /* Widget Defaults (will be overridden by JS) */
    --w-bg: #17171f;
    --w-surface: #1f1f2e;
    --w-border: #2a2a3d;
    --w-accent: #6c63ff;
    --w-accent-2: #ff6584;
    --w-me-bg: #6c63ff;
    --w-me-text: #ffffff;
    --w-other-bg: #2a2a3d;
    --w-other-text: #e8e8f0;
    --w-muted: #7070a0;
    --w-input-bg: #111118;
    --w-radius: 20px;
    --w-bubble-r: 16px;

    /* Dynamic Avatar Sizes */
    --avatar-size-bot: 40px;
    --avatar-size-user: 32px;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-app);
    height: 100vh;
    overflow: hidden;
}

.login-gate {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(1000px 500px at 10% -10%, rgba(108, 99, 255, 0.22), transparent 65%),
        radial-gradient(800px 420px at 100% 0%, rgba(102, 214, 255, 0.18), transparent 62%),
        var(--bg-app);
}

.login-card {
    width: min(420px, 96vw);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: rgba(19, 19, 26, 0.92);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    padding: 20px;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-card p {
    margin: 0 0 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.login-error {
    margin-top: 10px;
    min-height: 18px;
    color: #ff9f9f;
    font-size: 12px;
}

button {
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s ease, background-color 0.2s ease;
}

button:active:not(:disabled) {
    transform: translateY(2px) scale(0.99);
}

/* 
  APP LAYOUT 
*/
.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.sidebar-logo {
    height: 32px;
    width: auto;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0f1220;
    background: linear-gradient(135deg, #66d6ff 0%, #ff8fab 55%, #ffd077 100%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 3px 10px rgba(0, 0, 0, 0.35);
}

.template-picker {
    width: 100%;
    margin-top: 4px;
}

.template-picker label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.template-picker__row {
    display: flex;
    gap: 8px;
}

.template-picker__row select {
    flex: 1;
    min-width: 0;
}

#applyTemplateBtn {
    min-width: 74px;
    padding: 7px 10px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-btn {
    background: linear-gradient(180deg, #3f4249 0%, #1e2026 100%);
    border: 1px solid #50535c;
    color: #f2f3f6;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 999px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    text-align: center;
    width: 150px;
    max-width: 100%;
    margin-inline: auto;
    min-height: 34px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 8px rgba(0, 0, 0, 0.45);
}

.nav-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 14px rgba(0, 0, 0, 0.5);
}

.nav-btn.active {
    background: linear-gradient(180deg, #4c5058 0%, #262930 100%);
    border-color: #5f646e;
    color: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px rgba(0, 0, 0, 0.55);
}

.sidebar .btn-primary,
.sidebar .btn-secondary {
    background: linear-gradient(180deg, #3f4249 0%, #1e2026 100%);
    border: 1px solid #50535c;
    color: #f2f3f6;
    border-radius: 999px;
    font-weight: 600;
    padding: 8px 14px;
    font-size: 12px;
    min-height: 34px;
    max-width: 260px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 8px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.sidebar .btn-primary:hover,
.sidebar .btn-secondary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 14px rgba(0, 0, 0, 0.5);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cw-launcher-badge {
    position: absolute;
    background: #1f1f2e;
    color: white;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    pointer-events: none;
    animation: fadeInBadge 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Positioning based on launcher corner */
.cw-launcher-badge.pos-left {
    right: 100%;
    margin-right: 15px;
}

.cw-launcher-badge.pos-right {
    left: 100%;
    margin-left: 15px;
}

.cw-launcher-badge.pos-top {
    bottom: 100%;
    margin-bottom: 15px;
}

.cw-launcher-badge.pos-bottom {
    top: 100%;
    margin-top: 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel h3 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Form Controls */
.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group input[type="color"],
.control-group select {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
}

.control-group div[style*="display:flex"] {
    align-items: center;
    flex-wrap: nowrap;
    /* Ensure it doesn't wrap */
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

input[type="text"]:focus,
select:focus {
    border-color: var(--accent-color);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-color);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
}

.btn-icon:hover {
    background: var(--bg-panel);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    position: relative;
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

.toolbar {
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 14, 18, 0.9);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.toolbar-right {
    display: flex;
    gap: 10px;
}

.toolbar-right .btn-primary,
.toolbar-right .btn-secondary {
    width: 118px;
    min-width: 118px;
    text-align: center;
    border-radius: 999px;
    padding: 8px 14px;
    min-height: 34px;
    font-size: 12px;
    font-weight: 600;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.24),
        inset 0 -2px 0 rgba(0, 0, 0, 0.22),
        0 2px 0 rgba(0, 0, 0, 0.35),
        0 7px 14px rgba(0, 0, 0, 0.32);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.toolbar-right .btn-primary:hover,
.toolbar-right .btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.24),
        0 3px 0 rgba(0, 0, 0, 0.38),
        0 10px 18px rgba(0, 0, 0, 0.38);
}

.toolbar-right .btn-primary:active,
.toolbar-right .btn-secondary:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 2px 3px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 1px 0 rgba(0, 0, 0, 0.3);
}

.preview-area {
    flex: 1;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
}


.create-bot-btn {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 8;
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    background: linear-gradient(180deg, #8e1b33 0%, #6f1227 52%, #4f0b1a 100%);
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 8px 20px rgba(55, 8, 24, 0.55),
        inset 0 1px 0 rgba(255, 220, 230, 0.38),
        inset 0 -3px 8px rgba(24, 3, 10, 0.35);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.create-bot-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow:
        0 12px 24px rgba(55, 8, 24, 0.62),
        inset 0 1px 0 rgba(255, 220, 230, 0.42),
        inset 0 -3px 10px rgba(24, 3, 10, 0.4);
}

.create-bot-btn:active {
    transform: translateY(1px);
    box-shadow:
        0 6px 16px rgba(55, 8, 24, 0.48),
        inset 0 2px 6px rgba(24, 3, 10, 0.38);
}

.preview-layout,
.create-bot-mode {
    grid-area: 1 / 1;
    transition: opacity 220ms ease, transform 260ms ease;
}

.create-bot-mode {
    width: min(1120px, 100%);
    min-height: 700px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    visibility: hidden;
}

.preview-area.create-mode-on .preview-layout {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
    visibility: hidden;
}

.preview-area.create-mode-on .create-bot-mode {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

.preview-area.create-mode-on .create-bot-btn {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
}

.create-bot-back {
    position: absolute;
    top: 18px;
    left: 22px;
    border: none;
    background: transparent;
    color: #c4c8df;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.create-bot-back:hover {
    color: #f5f7ff;
}

.create-bot-cancel {
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 2;
    border: 1px solid rgba(164, 182, 234, 0.34);
    border-radius: 999px;
    background: rgba(19, 27, 54, 0.7);
    color: #d8def7;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.create-bot-cancel:hover {
    color: #ffffff;
    border-color: rgba(187, 203, 250, 0.55);
}

.create-bot-mode__canvas {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background:
        radial-gradient(circle at 1px 1px, rgba(155, 174, 255, 0.42) 1px, transparent 1px),
        linear-gradient(180deg, rgba(20, 28, 58, 0.62), rgba(15, 21, 44, 0.72));
    background-size: 20px 20px, auto;
    border: 1px solid rgba(126, 154, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.create-bot-mode__card {
    width: min(520px, 92%);
    padding: 20px 18px 14px;
    border-radius: 16px;
    border: none;
    background: transparent;
    box-shadow: none;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.create-bot-dropzone {
    width: 92px;
    height: 92px;
    border-radius: 20px;
    border: 2px dashed rgba(162, 183, 247, 0.78);
    background: rgba(31, 49, 108, 0.2);
    color: #eff4ff;
    font-size: 54px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.create-bot-dropzone__plus {
    transform: translateY(-2px);
}

.create-bot-mode__hint {
    margin: 14px 0 18px;
    color: #cfd7f5;
    font-size: 14px;
    text-align: center;
}

.create-bot-mode__actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: 100%;
}

.create-bot-mode__actions .btn-primary,
.create-bot-mode__actions .btn-secondary {
    width: min(360px, 100%);
    min-height: 52px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    border: 2px dashed rgba(162, 183, 247, 0.72);
    background: rgba(31, 49, 108, 0.2);
    color: #eff4ff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 6px 14px rgba(8, 15, 40, 0.36);
}

.create-bot-mode__actions #createModeStartFreshBtn {
    background: rgba(44, 69, 153, 0.34);
    border-color: rgba(170, 191, 255, 0.82);
    color: #ffffff;
}

.create-bot-mode__actions #createModeUseTemplatesBtn {
    background: rgba(31, 49, 108, 0.2);
    border-color: rgba(162, 183, 247, 0.72);
    color: #f3f6ff;
}

.create-bot-mode__actions #createModeAiBuildBtn {
    background: rgba(31, 49, 108, 0.14);
    border-color: rgba(132, 149, 198, 0.5);
    color: #7d879e;
    width: min(360px, 100%);
}

.create-bot-mode__actions .btn-secondary[disabled] {
    opacity: 1;
    cursor: not-allowed;
}

.create-bot-mode__actions .btn-primary:hover,
.create-bot-mode__actions .btn-secondary:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.create-bot-mode__actions .btn-primary:active,
.create-bot-mode__actions .btn-secondary:active {
    transform: translateY(1px);
}

.create-bot-mode__subhint {
    margin: 10px 0 0;
    color: #9fc2ff;
    font-size: 13px;
    line-height: 1.35;
}

.create-bot-mode__templates {
    width: 100%;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed rgba(132, 152, 228, 0.38);
}

.create-bot-mode__templates label {
    display: block;
    color: #c7d0ee;
    font-size: 13px;
    margin-bottom: 10px;
}

.create-bot-mode__templates-row {
    display: flex;
    gap: 10px;
}

.create-bot-mode__templates-row select {
    flex: 1;
    min-width: 0;
}

.preview-layout {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: relative;
    width: min(1120px, 100%);
    padding: 18px;
}

.chat-preview-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.backend-raw-panel {
    flex: 1 1 0;
    width: auto;
    height: 700px;
    border-radius: 18px;
    border: 1px solid rgba(131, 230, 255, 0.24);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(255, 159, 67, 0.12), transparent 60%),
        radial-gradient(120% 80% at 0% 100%, rgba(51, 217, 178, 0.12), transparent 58%),
        linear-gradient(165deg, rgba(18, 24, 52, 0.88), rgba(12, 16, 33, 0.9));
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 12px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.backend-raw-panel__head {
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.backend-raw-panel__body {
    margin: 0;
    font-family: "JetBrains Mono", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.45;
    color: #d6d9f0;
    white-space: pre-wrap;
    word-break: break-word;
    height: 100%;
    overflow: auto;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 12px;
    padding: 12px;
}

.telemetry-rail {
    width: 600px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    margin-left: auto;
}

.backend-panel {
    flex: 1 1 0;
    width: auto;
    height: 700px;
    border-radius: 18px;
    border: 1px solid rgba(131, 230, 255, 0.24);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(255, 159, 67, 0.15), transparent 60%),
        radial-gradient(120% 80% at 0% 100%, rgba(51, 217, 178, 0.14), transparent 58%),
        linear-gradient(165deg, rgba(18, 24, 52, 0.88), rgba(12, 16, 33, 0.9));
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.backend-activity-panel {
    flex: 1 1 0;
    width: auto;
    height: 700px;
    border-radius: 18px;
    border: 1px solid rgba(131, 230, 255, 0.24);
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(255, 159, 67, 0.12), transparent 60%),
        radial-gradient(120% 80% at 0% 100%, rgba(51, 217, 178, 0.12), transparent 58%),
        linear-gradient(165deg, rgba(18, 24, 52, 0.88), rgba(12, 16, 33, 0.9));
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 12px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(6px);
    overflow: hidden;
}

.backend-activity-panel__head {
    font-size: 12px;
    font-weight: 700;
    color: #dbe6ff;
    letter-spacing: 0.02em;
    margin-bottom: 8px;
}

.backend-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.backend-panel__head h4 {
    margin: 0 0 3px 0;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: #f0f5ff;
}

.backend-panel__head p {
    margin: 0;
    font-size: 11px;
    color: #95a4cb;
}

.backend-state {
    border-radius: 999px;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 5px 9px;
    font-weight: 700;
}

.backend-state--idle {
    background: rgba(126, 143, 173, 0.2);
    color: #bcc9e8;
}

.backend-state--active {
    background: rgba(69, 201, 255, 0.2);
    color: #7fe3ff;
    box-shadow: 0 0 0 1px rgba(127, 227, 255, 0.25);
}

.backend-state--done {
    background: rgba(51, 217, 178, 0.2);
    color: #72f0d1;
    box-shadow: 0 0 0 1px rgba(114, 240, 209, 0.25);
}

.backend-state--error {
    background: rgba(255, 107, 107, 0.2);
    color: #ff9f9f;
    box-shadow: 0 0 0 1px rgba(255, 159, 159, 0.25);
}

.backend-session {
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 10px;
    color: #adc1ee;
    font-size: 11px;
    font-family: "JetBrains Mono", "Consolas", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.backend-flow {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.backend-step {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 9px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.backend-step__title {
    font-size: 12px;
    font-weight: 600;
    color: #d7e4ff;
}

.backend-step__meta {
    margin: 2px 0 6px;
    font-size: 11px;
    color: #8ea3d5;
}

.backend-step__bar {
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.backend-step__bar span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #66d6ff, #ff8fab 55%, #ffd077);
    box-shadow: 0 0 12px rgba(150, 220, 255, 0.28);
    transition: width 0.25s ease;
}

.backend-step.is-active {
    border-color: rgba(127, 227, 255, 0.7);
    box-shadow: 0 0 0 1px rgba(127, 227, 255, 0.28), 0 0 18px rgba(68, 190, 255, 0.18);
    transform: none;
}

.backend-step.is-done {
    border-color: rgba(114, 240, 209, 0.6);
}

.backend-step.is-error {
    border-color: rgba(255, 159, 159, 0.6);
    box-shadow: 0 0 0 1px rgba(255, 159, 159, 0.18);
}

.backend-arrow {
    height: 10px;
    margin: 0 8px;
    position: relative;
}

.backend-arrow::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: rgba(152, 173, 220, 0.25);
}

.backend-arrow span {
    position: absolute;
    width: 9px;
    height: 9px;
    border-top: 2px solid rgba(152, 173, 220, 0.7);
    border-right: 2px solid rgba(152, 173, 220, 0.7);
    transform: rotate(45deg);
    top: 0;
    left: 0;
    opacity: 0;
}

.backend-arrow.is-active span {
    opacity: 1;
    animation: backendArrowFlow 0.9s linear infinite;
}

.backend-arrow.is-done span {
    opacity: 1;
    left: calc(100% - 12px);
}

@keyframes backendArrowFlow {
    0% {
        left: 0;
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    100% {
        left: calc(100% - 12px);
        opacity: 0;
    }
}

.backend-overall {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 9px;
}

.backend-overall__track {
    height: 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.backend-overall__track span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #66d6ff, #33d9b2 55%, #ffd077);
    box-shadow: 0 0 14px rgba(118, 219, 255, 0.25);
    transition: width 0.28s ease;
}

.backend-overall__meta {
    margin-top: 7px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    color: #8fa6da;
}

.backend-overall__meta #backendOverallLabel {
    color: #dbe6ff;
    font-weight: 700;
}

.backend-notice-stack {
    display: grid;
    gap: 8px;
}

.backend-notice {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    padding: 9px;
    display: grid;
    gap: 7px;
}

.backend-notice__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #dbe6ff;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.backend-notice__track {
    height: 7px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.13);
}

.backend-notice__track span {
    display: block;
    width: 100%;
    height: 100%;
}

.backend-notice--disconnected .backend-notice__track span {
    background: linear-gradient(90deg, #ff6b6b, #ff4d7a);
}

.backend-notice--connected .backend-notice__track span {
    background: linear-gradient(90deg, #34d399, #22c55e);
}

.backend-notice--production .backend-notice__track span {
    background: linear-gradient(90deg, #34d399, #22c55e);
}

.backend-notice--test .backend-notice__track span {
    background: linear-gradient(90deg, #ff6b6b, #ff4d7a);
}

.backend-status-symbol {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.backend-status-symbol--good {
    color: #eafff4;
    background: linear-gradient(180deg, #5cf4b7 0%, #22c55e 55%, #0f8a41 100%);
    border-color: rgba(149, 255, 204, 0.55);
}

.backend-status-symbol--bad {
    color: #fff4f4;
    background: linear-gradient(180deg, #ff8e8e 0%, #ef4444 55%, #a31f3f 100%);
    border-color: rgba(255, 173, 173, 0.52);
}

.backend-url-mode-list {
    display: grid;
    gap: 6px;
}

.backend-url-mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #c6d6fa;
    font-weight: 600;
}

.backend-url-mode-text {
    font-family: inherit;
    font-size: 12px;
}

.backend-loglist {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(6, 9, 20, 0.45);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    contain: layout paint;
}

.backend-loglist::-webkit-scrollbar {
    width: 6px;
}

.backend-loglist::-webkit-scrollbar-thumb {
    background: rgba(173, 194, 235, 0.34);
    border-radius: 999px;
}

.backend-log {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 7px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: #c6d6fa;
}

.backend-log__time {
    color: #8fa6da;
    font-family: "JetBrains Mono", "Consolas", monospace;
}

.backend-log--error {
    border-color: rgba(255, 159, 159, 0.35);
    background: rgba(255, 107, 107, 0.08);
}

.backend-log--success {
    border-color: rgba(114, 240, 209, 0.28);
    background: rgba(51, 217, 178, 0.09);
}

@media (max-width: 1280px) {
    .preview-layout {
        flex-direction: column;
        align-items: center;
        gap: 14px;
    }

    .telemetry-rail {
        width: min(760px, 92vw);
        margin-left: 0;
        flex-direction: row;
    }

    .backend-panel,
    .backend-activity-panel {
        width: 100%;
    }
}

@media (max-width: 1024px) {
    body {
        height: auto;
        min-height: 100dvh;
        overflow: auto;
    }

    .app-container {
        flex-direction: column;
        min-height: 100dvh;
        height: auto;
    }

    .sidebar {
        width: 100%;
        max-height: 52dvh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header {
        padding: 14px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding: 10px 10px 12px;
    }

    .sidebar-nav .nav-btn {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .main-content {
        min-height: 48dvh;
    }

    .toolbar {
        height: auto;
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-between;
    }

    .toolbar-right {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .toolbar-right .btn-primary,
    .toolbar-right .btn-secondary {
        width: 100%;
        min-width: 0;
        padding: 8px 10px;
        font-size: 11px;
    }


    .preview-area {
        overflow: auto;
        align-items: flex-start;
        justify-content: center;
        padding: 14px 10px 100px;
    }

    .create-bot-btn {
        top: 10px;
        right: 10px;
        padding: 9px 14px;
        font-size: 11px;
    }

    .create-bot-mode {
        min-height: 620px;
    }

    .create-bot-back {
        top: 10px;
        left: 10px;
    }

    .create-bot-cancel {
        top: 10px;
        right: 10px;
    }

    .create-bot-mode__card {
        width: min(520px, calc(100% - 16px));
        margin-top: 30px;
    }

    .preview-layout {
        width: 100%;
        max-width: 920px;
        padding: 0;
    }

    .chat-preview-stack {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .chat-widget,
    .chat-widget.desktop-view {
        width: min(92vw, 500px);
        height: 700px;
    }

    .telemetry-rail {
        width: min(92vw, 500px);
        flex-direction: column;
    }

    .backend-panel,
    .backend-activity-panel {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .sidebar {
        max-height: 58dvh;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .template-picker__row {
        flex-direction: column;
    }

    #applyTemplateBtn {
        width: 100%;
    }

    .toolbar-left {
        width: 100%;
        justify-content: flex-start;
    }

    .toolbar-right {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-widget,
    .chat-widget.mobile-view,
    .chat-widget.desktop-view {
        width: 94vw;
        height: 620px;
    }

    .telemetry-rail {
        width: 94vw;
    }

    .backend-panel,
    .backend-activity-panel {
        width: 100%;
    }

    .chat-widget__messages {
        padding: 14px 12px;
    }

    .chat-widget__input-row {
        padding: 10px 12px;
        gap: 8px;
    }

    .create-bot-btn {
        top: 8px;
        right: 8px;
    }

    .create-bot-mode {
        min-height: 560px;
    }

    .create-bot-cancel {
        top: 8px;
        right: 8px;
        padding: 6px 10px;
        font-size: 11px;
    }

    .create-bot-mode__card {
        padding: 24px 16px 18px;
        margin-top: 34px;
    }

    .create-bot-mode__templates-row {
        flex-direction: column;
    }

    .create-bot-mode__actions .btn-primary,
    .create-bot-mode__actions .btn-secondary {
        width: 100%;
        min-width: 0;
    }
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-left #aboutBtn {
    min-height: 34px;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
}

.divider-vertical {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

.about-hero3d {
    border-radius: 10px;
    padding: 18px 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f5f5f5;
    box-shadow: none;
    text-align: left;
}

.about-list {
    margin: 0 0 8px 18px;
    padding: 0;
    color: #1b1b1b;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 14px;
    line-height: 1.2;
}

.about-line {
    margin: 0 0 12px 18px;
    color: #1b1b1b;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 14px;
    line-height: 1.2;
}

/* 
  WIDGET STYLES (Scoped) 
*/

.chat-widget {
    width: 490px;
    height: 700px;
    background: var(--w-bg);
    border-radius: var(--w-radius);
    border: 1px solid var(--w-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(108, 99, 255, .15),
        0 32px 80px rgba(0, 0, 0, .6),
        0 8px 24px rgba(108, 99, 255, .12);
    position: relative;
    font-family: var(--font-family);
    transition: box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chat-widget.mode-transparent .chat-widget__messages {
    background: transparent;
}

.chat-widget.mobile-view {
    width: 320px;
    height: 640px;
}

.chat-widget.desktop-view {
    width: 490px;
    height: 700px;
}

.chat-widget__conversation-media {
    position: sticky;
    top: 0;
    z-index: 0;
    width: 100%;
    height: 220px;
    min-height: 220px;
    max-height: 220px;
    flex: 0 0 220px;
    overflow-anchor: none;
    margin: 0 0 12px 0;
    border-radius: 12px;
    overflow: hidden;
    border: none;
    background: #ffffff;
    opacity: 1;
}

.chat-widget__conversation-media.is-hiding {
    animation: videoFadeAway 0.8s ease forwards;
    pointer-events: none;
}

@keyframes videoFadeAway {
    from {
        opacity: 1;
        height: 360px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        height: 0;
        margin-bottom: 0;
    }
}

.chat-widget__conversation-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    background: #ffffff;
}

.chat-widget__conversation-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    background: #ffffff;
}

/* Header */
.chat-widget__header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 16px 20px;
    background: var(--w-surface);
    border-bottom: 1px solid var(--w-border);
    flex-shrink: 0;
}

.chat-widget__header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--w-accent), var(--w-accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(108, 99, 255, .35);
}

.chat-widget__header-avatar.is-draggable {
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.chat-widget__header-avatar.is-draggable.is-dragging {
    cursor: grabbing;
}

.chat-widget__header-info {
    flex: 1;
    margin-left: -1px;
}

.chat-widget__header-name {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #e8e8f5;
    letter-spacing: .01em;
}

.chat-widget__header-name.is-draggable {
    width: fit-content;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.chat-widget__header-name.is-draggable.is-dragging {
    cursor: grabbing;
}

.chat-widget__header-status {
    font-size: 12px;
    color: var(--w-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.chat-widget__header-status.is-draggable {
    width: fit-content;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.chat-widget__header-status.is-draggable.is-dragging {
    cursor: grabbing;
}

.chat-widget__header-status.is-draggable.is-editing {
    cursor: text;
    user-select: text;
    outline: 1px dashed var(--w-border);
    outline-offset: 2px;
}

.chat-widget__header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
    display: inline-block;
}

.chat-widget__header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.chat-widget__header-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--w-border);
    cursor: pointer;
    color: var(--w-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, color .2s;
}

.chat-widget__header-btn:hover {
    background: var(--w-border);
    color: #e8e8f5;
}

/* Messages */
.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: auto;
}

.chat-widget__messages::-webkit-scrollbar {
    width: 4px;
}

.chat-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
    background: var(--w-border);
    border-radius: 4px;
}

.chat-widget__anchor {
    height: 1px;
    flex-shrink: 0;
}


.chat-widget__divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--w-muted);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin: 0 0 4px 0;
}

.chat-widget__messages.video-hidden .chat-widget__divider {
    margin: 0 0 4px 0;
}

.chat-widget__messages:not(.video-hidden) .msg,
.chat-widget__messages:not(.video-hidden) .chat-widget__typing {
    animation: none;
}

.chat-widget__divider,
.msg,
.chat-widget__typing,
.chat-options,
.chat-widget__anchor {
    position: relative;
    z-index: 3;
}

.chat-widget__messages.chat-widget__messages--media-bg {
    position: relative;
}

.chat-widget__messages.chat-widget__messages--media-bg .chat-widget__conversation-media {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    opacity: 0.28;
    pointer-events: none;
}

.chat-widget__messages.chat-widget__messages--media-bg .chat-widget__divider,
.chat-widget__messages.chat-widget__messages--media-bg .msg,
.chat-widget__messages.chat-widget__messages--media-bg .chat-widget__typing,
.chat-widget__messages.chat-widget__messages--media-bg .chat-options,
.chat-widget__messages.chat-widget__messages--media-bg .chat-widget__anchor {
    position: relative;
    z-index: 3;
}

.chat-widget__divider::before,
.chat-widget__divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--w-border);
}

/* Preview Launcher */
.cw-launcher {
    position: absolute;
    bottom: -72px;
    right: 14px;
    width: 48px;
    height: 48px;
    background: var(--w-accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s;
    display: none;
}

/* Message Styles */
.msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgIn 280ms cubic-bezier(.34, 1.4, .64, 1) both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.msg--other {
    flex-direction: row;
}

.msg--me {
    flex-direction: row-reverse;
}

.msg__avatar {
    width: var(--avatar-size-bot);
    height: var(--avatar-size-bot);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--w-accent), var(--w-accent-2));
    overflow: hidden;
    /* For images */
}

.msg--me .msg__avatar {
    width: var(--avatar-size-user);
    height: var(--avatar-size-user);
    background: linear-gradient(135deg, var(--w-accent), #a78bfa);
}

.msg__bubble {
    display: flex;
    flex-direction: column;
    width: fit-content;
    min-width: 64px;
    max-width: 270px;
    padding: 7px 12px 4px;
    border-radius: var(--w-bubble-r);
    position: relative;
}

.msg--other .msg__bubble {
    background: var(--w-other-bg);
    color: var(--w-other-text);
    border-bottom-left-radius: 4px;
}

.msg--me .msg__bubble {
    background: var(--w-me-bg);
    color: var(--w-me-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 20px rgba(108, 99, 255, .35);
}

.msg__header {
    display: flex;
    align-items: baseline;
    gap: 0;
    margin-bottom: 2px;
}

.msg__name {
    font-size: 10px;
    font-weight: 600;
    opacity: .75;
}

.msg__name::after {
    content: ', ';
}

.msg__time {
    font-size: 9px;
    opacity: .55;
    margin-left: 2px;
}

.msg__text {
    font-size: 13px;
    line-height: 1.18;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg__text p {
    margin: 0 0 16px 0;
}

.msg__text p:last-child {
    margin-bottom: 0;
}

.msg__text ul,
.msg__text ol {
    margin: 8px 0;
    padding-left: 20px;
}

.msg__text li {
    margin-bottom: 4px;
}

.msg__text h1,
.msg__text h2,
.msg__text h3,
.msg__text h4 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
}

.msg__text h1:first-child,
.msg__text h2:first-child,
.msg__text h3:first-child,
.msg__text h4:first-child {
    margin-top: 0;
}

.msg__text a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.chat-widget__footer a:hover {
    text-decoration: underline;
}

/* Footer Animations */
.anim-footer-pulse {
    animation: footerPulse 2s infinite ease-in-out;
}

.anim-footer-fade {
    animation: fadeIn 0.8s ease-out;
}

.anim-footer-slide-up {
    animation: footerSlideUp 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes footerPulse {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
    }

    100% {
        opacity: 0.7;
        transform: scale(1);
    }
}

@keyframes footerSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg__text strong {
    font-weight: 600;
}

/* Typing Indicator */
.chat-widget__typing {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgIn 280ms ease both;
}

.typing-bubble {
    background: var(--w-other-bg);
    border-radius: var(--w-bubble-r);
    border-bottom-left-radius: 4px;
    padding: 14px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.typing-status {
    font-size: 11px;
    line-height: 1.2;
    color: var(--w-muted);
    opacity: 0.95;
}

.typing-status.is-visible {
    animation: slowTypingPulse 1.2s ease-in-out infinite;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--w-muted);
    animation: typeBounce 1.1s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: .18s;
}

.typing-dot:nth-child(3) {
    animation-delay: .36s;
}

@keyframes typeBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Widget Footer */
.chat-widget__footer {
    padding: 10px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 11px;
    color: var(--w-muted);
    border-top: 1px solid var(--w-border);
    background: var(--w-surface);
}

/* Input Row */
.chat-widget__input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--w-surface);
    border-top: 1px solid var(--w-border);
    flex-shrink: 0;
}

.chat-widget__input {
    flex: 1;
    background: var(--w-input-bg);
    border: 1px solid var(--w-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-family: var(--font-family);
    font-size: 14px;
    color: #e8e8f5;
    outline: none;
    transition: border-color .2s;
}

.chat-widget__input:focus {
    border-color: var(--w-accent);
}

.chat-widget__send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f8fbff;
    border: 1px solid #d8e2ef;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .15s;
    box-shadow:
        inset 0 2px 2px rgba(255, 255, 255, 0.95),
        inset 0 -2px 3px rgba(177, 188, 204, 0.45),
        0 8px 18px rgba(35, 53, 82, 0.28);
}

.chat-widget__send:hover {
    transform: scale(1.08);
}

.chat-widget__send:active {
    transform: scale(.95);
}

.chat-widget__send-plane {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    pointer-events: none;
    filter: drop-shadow(0 1px 1px rgba(9, 18, 38, 0.35));
}

#previewSendBtn {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #4cc9ff 0%, #2f8cff 55%, #1f6be6 100%);
    border: 1px solid rgba(189, 226, 255, 0.9);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.65),
        inset 0 -4px 8px rgba(9, 54, 139, 0.45),
        0 9px 18px rgba(8, 30, 78, 0.44);
    transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
    animation: sendBtnIdle 2s ease-in-out infinite;
}

#previewSendBtn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.72),
        inset 0 -4px 8px rgba(7, 44, 118, 0.52),
        0 12px 22px rgba(8, 30, 78, 0.48);
    filter: saturate(1.08);
}

#previewSendBtn:active {
    animation: none;
    transform: translateY(2px) scale(0.96);
    box-shadow:
        inset 0 2px 4px rgba(3, 24, 67, 0.55),
        inset 0 -1px 2px rgba(255, 255, 255, 0.22),
        0 4px 10px rgba(6, 20, 48, 0.34);
}

#previewSendBtn .chat-widget__send-plane {
    filter: drop-shadow(0 1px 1px rgba(9, 18, 38, 0.35));
}

@keyframes sendBtnIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-1px); }
}

/* Chat Options / Buttons */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end;
    /* Align to right like user responses? Or left? Usually right or center. Let's do right for now or wrap. Used inside msg bubble? No, usually separate. */
    /* Actually, let's put them inside the bubble or after it. 
       If after, they need to be distinct. 
       Let's put them in a separate container in the message list */
    padding: 0 14px;
    /* Align with bubble padding */
}

.chat-option-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--w-accent);
    background: transparent;
    color: var(--w-accent);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.chat-option-btn:hover {
    background: var(--w-accent);
    color: white;
}

/* Gradient Button Style */
.chat-option-btn.gradient {
    border: none;
    /* Gradient borders are tricky, let's do gradient bg with text */
    background: linear-gradient(135deg, var(--w-accent), var(--w-accent-2));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chat-option-btn.gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* 
  NEW FEATURE STYLES 
*/

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-panel);
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: white;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Launcher Animations */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(108, 99, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(108, 99, 255, 0);
    }
}

.anim-pulse {
    animation: pulse 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

.anim-bounce {
    animation: bounce 2s infinite;
}

@keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

.anim-spin {
    animation: spin 4s linear infinite;
}

/* Background Modes */
.bg-glass {
    background: rgba(23, 23, 31, 0.7) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.bg-frosted {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* .bg-gradient is handled via JS style property */

.btn-gradient {
    background: linear-gradient(135deg, var(--w-accent), var(--w-accent-2));
    border: none;
    color: white;
}

/* Drag and Drop Placeholder */
.control-group.dragging {
    opacity: 0.5;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 12px;
    z-index: 10000;
}

@keyframes slowTypingPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 500px;
    max-width: 90vw;
    max-height: calc(100vh - 48px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.modal-tabs .tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.modal-tabs .tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.modal-tabs .tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.deploy-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.5;
}

.code-block-container {
    position: relative;
    background: #000;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 15px;
    max-height: 52vh;
    overflow: auto;
}

.code-block-container pre {
    margin: 0;
    overflow: auto;
    max-height: calc(52vh - 30px);
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 13px;
    color: #4ade80;
    font-family: 'Courier New', Courier, monospace;
}

.code-block-container .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    font-size: 11px;
    background: var(--bg-panel);
}

.dragging {
    opacity: 0.5;
    border: 1px dashed var(--accent-color);
}

/* 
  NOTIFICATIONS PANEL 
*/
.notifications-rail {
    position: fixed;
    top: 90px;
    right: 0;
    left: auto;
    z-index: 100000;
    width: min(360px, 100vw);
    padding-right: max(12px, env(safe-area-inset-right));
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
}

.notifications-panel {
    position: static;
    top: auto;
    right: auto;
    left: auto;
    width: min(340px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-left: auto;
}

.notification-item {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    /* Re-enable clicks on the item itself */
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin-left: auto;
    animation: slideInRight 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notif-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.notif-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-icon.success {
    color: var(--success-color);
}

.notif-icon.error {
    color: var(--danger-color);
}

.notif-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.notif-percentage {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-weight: 500;
}

.notif-message {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.notif-progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.notif-progress-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.1s linear, background-color 0.3s ease;
    border-radius: 3px;
}

.notif-progress-fill.success {
    background: var(--success-color);
}

.notif-progress-fill.error {
    background: var(--danger-color);
}

.notif-actions {
    display: none;
    margin-top: 10px;
    justify-content: flex-end;
}

.notif-actions.show {
    display: flex;
}

.notif-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.notif-btn:hover {
    background: var(--bg-panel);
}

@media (max-width: 768px) {
    .notifications-rail {
        top: 72px;
        right: 0;
        width: 100vw;
        padding-right: 8px;
    }

    .notifications-panel {
        width: 100%;
    }

}
