:root {
    /* Colors */
    --primary: #6FCF97;
    --primary-hover: #27AE60;
    --background: #f3f4f6;
    --surface: #ffffff;
    --text-main: #111827;
    --text-secondary: #6B7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;

    /* Tag Colors */
    --tag-welcome-bg: #ecfdf5;
    --tag-welcome-text: #059669;
    --tag-name-bg: #e9f2ff;
    --tag-name-text: #2F80ED;
    --tag-phone-bg: #fdf2f8;
    --tag-phone-text: #db2777;
    --tag-short-bg: #f0f9ff;
    --tag-short-text: #0284c7;
    --tag-choice-bg: #ecfdf3;
    --tag-choice-text: #16a34a;
    --tag-thanks-bg: #f0fdfa;
    --tag-thanks-text: #0f766e;
    --tag-default-bg: #f3f4f6;
    --tag-default-text: #4b5563;

    /* Typography */
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.dashboard-page {
    background-color: var(--background);
}

body.editor-page {
    background-color: var(--background);
}

/* User Menu */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.user-menu-btn:hover {
    background: #e5e7eb;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #d1d5db;
    position: relative;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px #cbd5e1;
}

.user-avatar::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f3f4f6;
}

.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 10px;
    border-radius: 10px 10px 6px 6px;
    background: #f3f4f6;
}

.user-name {
    white-space: nowrap;
}

.user-caret {
    font-size: 12px;
    color: var(--text-secondary);
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 50;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.user-dropdown-item:hover {
    background: #f3f4f6;
}

.user-dropdown-item.danger {
    color: var(--danger);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* Editor Layout */
.editor-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Top Nav */
.top-nav {
    height: 60px;
    background: var(--primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
    font-weight: 500;
    font-size: 14px;
}

.back-btn {
    color: inherit;
    text-decoration: none;
    font-size: 18px;
    margin-right: 8px;
}

.form-title {
    font-weight: 600;
    color: inherit;
}

.form-title-editable {
    cursor: text;
    padding: 2px 6px;
    border-radius: 6px;
}

.form-title-editable:focus {
    outline: none;
    background: #ecfdf3;
    box-shadow: 0 0 0 2px rgba(111, 207, 151, 0.2);
}

.nav-center {
    display: flex;
    gap: 24px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 18px 0;
    position: relative;
}

.nav-link.active {
    color: var(--text-main);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text-main);
}

.nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-nav-outline {
    border: 1px solid var(--border);
    background: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
}

.btn-nav-outline svg {
    width: 14px;
    height: 14px;
    display: block;
}

.btn-nav-outline:hover {
    background: #f9fafb;
}

.btn-nav-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-nav-primary:hover {
    background: var(--primary-hover);
}

/* Top nav green theme */
.top-nav,
.top-nav .back-btn,
.top-nav .form-title {
    color: #fff;
}

.top-nav .nav-link {
    color: rgba(255, 255, 255, 0.85);
}

.top-nav .nav-link:hover,
.top-nav .nav-link.active {
    color: #fff;
}

.top-nav .nav-link.active::after {
    background: #fff;
}

.top-nav .form-title-editable:focus {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.top-nav .btn-nav-outline {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}

.top-nav .btn-nav-outline:hover {
    background: rgba(255, 255, 255, 0.2);
}

.top-nav .btn-nav-primary {
    background: #fff;
    color: var(--primary);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.top-nav .btn-nav-primary:hover {
    background: rgba(255, 255, 255, 0.9);
}

/* Main Content */
.editor-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    /* Context for absolute popover if needed, but we might place popover in canvas card */
}

/* Settings Popover (formerly Properties Panel) */
.settings-popover {
    position: absolute;
    top: 50px;
    /* Below the header buttons */
    right: 20px;
    width: 300px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 16px;
    z-index: 100;
    display: none;
    animation: fadeIn 0.1s ease-out;
}

.settings-popover.active {
    display: block;
}

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.properties-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.close-prop-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-list {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.sidebar-item {
    display: flex;
    padding: 12px;
    margin-bottom: 4px;
    cursor: pointer;
    border-radius: 6px;
    background: transparent;
    transition: all 0.2s;
    position: relative;
    border: 1px solid transparent;
}

.sidebar-item:hover {
    background: #f9fafb;
    border-color: var(--border);
}

.sidebar-item.active {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.sidebar-item.dragging {
    opacity: 0.5;
}

.sidebar-item.drag-over {
    border-color: var(--primary);
    background: #ecfdf3;
}

.border-indicator {
    width: 3px;
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    background: transparent;
    border-radius: 0 4px 4px 0;
}

.sidebar-item.active .border-indicator {
    background: var(--primary);
}

.item-number {
    width: 24px;
    font-size: 12px;
    color: var(--text-secondary);
    padding-top: 2px;
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.item-tag {
    align-self: flex-start;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    text-transform: capitalize;
}

.item-actions {
    display: none;
    margin-left: auto;
    gap: 8px;
    color: var(--text-secondary);
}

.sidebar-item:hover .item-actions {
    display: flex;
}

.action-icon {
    cursor: pointer;
    border: none;
    background: transparent;
    color: #9ca3af;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
}

.action-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.action-icon:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.action-icon:focus-visible {
    outline: 2px solid rgba(239, 68, 68, 0.35);
    outline-offset: 2px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.add-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-size: 14px;
}

.add-btn:hover {
    background: #ecfdf3;
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background: var(--background);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    overflow: hidden;
    transition: width 0.3s;
}

body.editor-page .canvas-area {
    background: var(--background);
}

.canvas-card {
    background: #fff;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-header {
    height: 60px;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.badge-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.required-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-secondary);
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.required-toggle .checkbox-input {
    width: 14px;
    height: 14px;
}

.logic-pill {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.logic-pill.active {
    color: var(--primary);
    border-color: rgba(111, 207, 151, 0.35);
    background: #ecfdf3;
}

.logic-pill:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-type-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f0fdfa;
    /* Tealish default */
    border: 1px solid #ccfbf1;
    border-radius: 6px;
    color: #0f766e;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.canvas-body {
    flex: 1;
    padding: 60px 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.canvas-content {
    width: 100%;
    max-width: 680px;
}

/* Global Resets affecting contenteditable */
[contenteditable]:focus {
    outline: none;
}

.editable-title,
.editable-desc {
    background-color: transparent !important;
}

.editable-title *,
.editable-desc * {
    background-color: transparent !important;
}

/* Typography */
.editable-title {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
    line-height: 1.3;
    outline: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px;
    transition: all 0.2s;
    white-space: pre-wrap;
    /* Preserve line breaks */
}

.editable-title:hover {
    border-color: #e5e7eb;
}

.editable-title:focus {
    border-color: var(--primary);
    background: transparent !important;
}

.editable-desc {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.5;
    outline: none;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px;
    white-space: pre-wrap;
    /* Preserve line breaks */
    resize: none;
}

.editable-desc:focus {
    background: rgba(0, 0, 0, 0.02);
}

.canvas-input-preview {
    margin-top: 40px;
    pointer-events: none;
    /* Non-interactive in editor */
    max-width: 520px;
}

.canvas-input-preview.is-interactive {
    pointer-events: auto;
}

.canvas-input-preview input,
.canvas-input-preview textarea {
    width: 100%;
}

.choice-builder {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 560px;
}

.choice-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.choice-letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.choice-text {
    flex: 1;
    font-size: 16px;
    color: var(--text-main);
    outline: none;
}

.choice-remove {
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 6px;
}

.choice-remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.choice-add {
    display: flex;
    gap: 12px;
    align-items: center;
}

.choice-add .form-input {
    flex: 1;
}

.choice-empty {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 2px;
}

.image-choice-builder {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-choice-item {
    display: grid;
    grid-template-columns: 72px 1fr 32px;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.image-choice-thumb {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: #f3f4f6;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border);
}

.image-choice-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.image-choice-label {
    font-weight: 600;
    font-size: 14px;
}

.image-choice-remove {
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 6px;
}

.image-choice-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.image-choice-add {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.rating-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rating-dot {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f9fafb;
}

.message-preview {
    padding: 12px 16px;
    border: 1px dashed #cbd5f5;
    border-radius: 10px;
    color: var(--text-secondary);
    background: #f8fafc;
}

.terms-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #111827;
    color: #fff;
    padding: 12px 36px 14px 16px;
    border-radius: 10px;
    box-shadow: 0 12px 24px -16px rgba(15, 23, 42, 0.6);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 320px;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
}

.toast.info {
    background: #1f2937;
}

.toast.warning {
    background: #92400e;
}

.toast.success {
    background: #065f46;
}

.toast.error {
    background: #b91c1c;
}

.toast.hide {
    opacity: 0;
    transform: translateY(-6px);
}

.toast-message {
    display: block;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
    padding: 2px;
}

.toast-close:hover {
    opacity: 1;
}

.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    transform-origin: left;
    animation: toast-progress 3s linear forwards;
}

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Inline Text Toolbar */
.text-toolbar {
    position: fixed;
    z-index: 1500;
    display: flex;
    gap: 6px;
    background: #111827;
    color: #fff;
    padding: 6px 8px;
    border-radius: 8px;
    box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.6);
}

.text-toolbar.hidden {
    display: none;
}

.toolbar-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
}

.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.preview-btn-lg {
    background: #dc2626;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 999px;
    font-size: 17px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.2;
    max-width: 100%;
    text-align: center;
}

.preview-btn-edit {
    cursor: text;
    user-select: text;
}

.preview-btn-text {
    display: inline-block;
    white-space: pre-wrap;
    line-height: 1.2;
}

.preview-btn-text:focus {
    outline: none;
}

/* Floating Actions */
.floating-actions {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.float-btn {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    font-size: 18px;
    transition: all 0.2s;
}

.float-btn:hover {
    background: #f9fafb;
    color: var(--primary);
}

.float-btn.add-main {
    background: transparent;
    color: var(--primary);
    font-size: 24px;
    border: none;
}

.float-btn.add-main:hover {
    background: transparent;
    color: var(--primary-hover);
    transform: scale(1.1);
}

.help-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    cursor: pointer;
    border: none;
}

/* Properties Panel */
.properties-panel {
    border-left: 1px solid var(--border);
    border-right: none;
    width: 300px;
    /* Fixed width like sidebar */
}

.properties-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.properties-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.close-prop-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.properties-form {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.logic-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.logic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logic-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.logic-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.logic-edit-btn {
    justify-content: center;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

/* Ensure fonts are applied to inputs */
input,
textarea,
select,
button {
    font-family: var(--font-family);
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-main);
    transition: border-color 0.2s;
}

.form-input.font-select {
    padding: 10px 14px;
    font-size: 15px;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(111, 207, 151, 0.18);
}

/* File Upload (Viewer) */
.file-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 420px;
}

.file-upload-box {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.file-upload-box:hover {
    border-color: rgba(111, 207, 151, 0.6);
    background: #f3f4f6;
}

.file-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.file-upload-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(111, 207, 151, 0.12);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-upload-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.file-upload-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.file-upload-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.file-upload-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.file-upload-button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.file-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.logic-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2000;
    padding: 24px;
}

.logic-modal.hidden {
    display: none;
}

.logic-modal-card {
    width: 100%;
    max-width: 900px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    padding: 18px 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--border);
}

.logic-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.logic-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.logic-modal-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.logic-close-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.logic-modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logic-rule-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(200px, 1fr) 36px;
    gap: 10px;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
}

.logic-rule-row.has-error {
    border-color: #fecaca;
    background: #fef2f2;
}

.logic-rule-row .form-input.error {
    border-color: #f87171;
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.12);
}

.logic-rule-row .form-input {
    height: 40px;
    padding: 8px 12px;
    font-size: 14px;
    background: #fff;
    border-radius: 10px;
}

.logic-rule-actions {
    display: flex;
    justify-content: flex-end;
}

.logic-remove-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.logic-remove-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
}

.logic-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.logic-modal-body .logic-hint {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
}

.logic-modal-body .logic-edit-btn {
    width: 100%;
    justify-content: center;
    background: #f8fafc;
    border: 1px dashed var(--border);
    color: var(--text-main);
}

@media (max-width: 720px) {
    .logic-modal-card {
        max-width: 95vw;
    }

    .logic-rule-row {
        grid-template-columns: 1fr;
    }

    .logic-rule-actions {
        justify-content: flex-end;
    }
}

.share-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2000;
    padding: 24px;
}

.share-modal.hidden {
    display: none;
}

.share-modal-card {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    padding: 20px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.share-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.share-modal-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.share-close-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.share-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}

.share-input-row .form-input {
    flex: 1;
}

.share-modal-footnote {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Buttons */
.btn,
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.05s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 18px -12px rgba(39, 174, 96, 0.45);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: #fff;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled,
.btn-primary[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-input {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Modal Helpers */
.hidden {
    display: none !important;
}

/* Dropdown Menus */
.type-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    min-width: 220px;
    padding: 6px;
    animation: fadeIn 0.1s ease-out;
    max-height: 60vh;
    overflow-y: scroll;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #cbd5f5 transparent;
}

.type-dropdown::-webkit-scrollbar {
    width: 8px;
}

.type-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.type-dropdown::-webkit-scrollbar-thumb {
    background: #bfe8d3;
    border-radius: 999px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item.selected {
    background: #ecfdf3;
    color: var(--primary);
}

.dd-label {
    flex: 1;
}

.dd-check {
    font-size: 12px;
    color: var(--primary);
}

/* Authentication Layout */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px;
    font-family: var(--font-family);
    background: radial-gradient(1200px 600px at 15% -20%, #dff5ea 0%, #f4fbf7 45%, #ffffff 100%);
    position: relative;
    overflow: hidden;
}

.auth-container::before,
.auth-container::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.auth-container::before {
    width: 420px;
    height: 420px;
    top: -160px;
    right: -140px;
    background: radial-gradient(circle, rgba(111, 207, 151, 0.22) 0%, rgba(111, 207, 151, 0) 70%);
}

.auth-container::after {
    width: 320px;
    height: 320px;
    bottom: -120px;
    left: -80px;
    background: radial-gradient(circle, rgba(39, 174, 96, 0.18) 0%, rgba(39, 174, 96, 0) 70%);
}

.auth-box {
    background: var(--surface);
    padding: 44px 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px -24px rgba(15, 23, 42, 0.35), 0 8px 20px -12px rgba(15, 23, 42, 0.2);
    width: 100%;
    max-width: 420px;
    border: 1px solid #e6f2ea;
    position: relative;
    z-index: 1;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    margin-bottom: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.auth-logo-img {
    height: 52px;
    width: auto;
    display: block;
}

.auth-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-main);
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-box .form-input {
    background-color: #f9fafb;
    border-color: #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.auth-box .form-input:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(111, 207, 151, 0.25);
}

.auth-box .form-input::placeholder {
    color: #9ca3af;
}

.auth-box input:-webkit-autofill,
.auth-box input:-webkit-autofill:hover,
.auth-box input:-webkit-autofill:focus,
.auth-box input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-main);
    box-shadow: 0 0 0 1000px #f9fafb inset;
    transition: background-color 5000s ease-in-out 0s;
}

.auth-box .btn,
.auth-box .btn-primary {
    width: 100%;
    min-height: 48px;
    padding: 14px 18px;
    font-size: 16px;
    border-radius: 12px;
    display: flex;
    margin-top: 6px;
}

.auth-box .btn-primary {
    box-shadow: 0 10px 18px -12px rgba(39, 174, 96, 0.45);
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.confirm-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2100;
    padding: 24px;
}

.confirm-modal.hidden {
    display: none;
}

.confirm-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
    padding: 20px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid var(--border);
    position: relative;
}

.confirm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.confirm-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

.confirm-close-btn {
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.confirm-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.confirm-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-btn {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.confirm-btn.danger {
    background: #ef4444;
}

.media-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2000;
    padding: 24px;
}

.media-modal.hidden {
    display: none;
}

.media-modal-card {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.media-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.media-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.media-modal-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.media-close-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.media-tabs {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.media-tab {
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 4px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.media-tab.active {
    color: var(--text-main);
    border-bottom-color: var(--text-main);
}

.media-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 4px;
}

.media-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-panel.hidden {
    display: none;
}

.media-drop {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.media-drop input[type="file"] {
    display: none;
}

.media-drop-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.media-preview {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #f9fafb;
    color: var(--text-secondary);
    min-height: 120px;
    max-height: 260px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.media-preview img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.media-preview iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 10px;
}

.media-help {
    font-size: 12px;
    color: var(--text-secondary);
}

.media-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.media-remove-btn {
    margin-right: auto;
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.field-media {
    width: 100%;
    margin-bottom: 18px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
}

.field-media img,
.field-media iframe {
    width: 100%;
    max-width: 720px;
    margin-left: 0;
}

.field-media img {
    max-height: 320px;
    object-fit: contain;
    display: block;
    margin-right: auto;
}

.field-media iframe {
    max-height: 320px;
}

.media-frame {
    width: 100%;
    max-width: 720px;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f4f6;
    border: 1px solid var(--border);
    align-self: flex-start;
    margin-right: auto;
}

.media-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
}

.media-link:hover {
    text-decoration: underline;
}

.auth-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-link:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    display: none;
}

.alert-danger {
    background-color: #fef2f2;
    color: var(--danger);
    border: 1px solid #fee2e2;
}

.alert-success {
    background-color: #ecfdf3;
    color: var(--success);
    border: 1px solid #d1fae5;
}

@media (max-width: 480px) {
    .auth-box {
        padding: 32px 24px;
    }

    .auth-title {
        font-size: 20px;
    }
}


/* Options View Layout */
.options-view {
    display: block;
    flex: 1;
    background: #f9fafb;
    overflow-y: auto;
}

.options-content {
    flex: 1;
    overflow: visible;
    padding: 40px 60px;
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

.options-content.full-width {
    max-width: 920px;
}

.opt-section {
    margin-bottom: 40px;
}

.opt-section h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}

.opt-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.opt-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

.opt-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-text {
    width: 100px;
    font-family: monospace;
}

/* Range Slider */
.range-slider {
    width: 100%;
    accent-color: var(--primary);
}

/* Toggles / Switches */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.toggle-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.toggle-desc {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 400px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    -webkit-transform: translateX(22px);
    -ms-transform: translateX(22px);
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.badge-pro {
    background: #dcfce7;
    color: #15803d;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 6px;
    text-transform: uppercase;
}

/* Save Bar */
.save-bar {
    position: fixed;
    bottom: 0;
    left: 240px;
    /* Sidebar width */
    right: 0;
    background: white;
    padding: 16px 40px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.btn-sm-outline {
    background: white;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

/* Utility to toggle Views */
.hidden {
    display: none !important;
}
