/* Version: v4.5.0 | Updated: 2026-07-31 18:58 | Features: Applied direction rtl & text-align right to .ai-modal-card */
/* ============================================
   meta.fikra / ميتا.فكرة — Design Tokens
   ============================================ */
.mf-bar {
    --mf-h: 48px;
    --mf-bg: rgba(30, 30, 30, 0.98);
    --mf-border: rgba(68, 68, 68, 0.3);
    --mf-logo-color: #e2b714;
    --mf-dot-color: #e2b714;
    --mf-title-color: rgba(224, 224, 224, 0.6);
    --mf-theme-color: rgba(226, 183, 20, 0.35);
    --mf-theme-hover: rgba(226, 183, 20, 0.6);
    --mf-gold-dim: rgba(226, 183, 20, 0.1);
    --mf-help-color: rgba(226, 183, 20, 0.5);
    --mf-help-hover: rgba(226, 183, 20, 0.9);
    --mf-help-bg: rgba(226, 183, 20, 0.08);
    pointer-events: none;
}

.mf-logo {
    pointer-events: auto;
    color: #e2b714;
}

:root {
    --bg: #1e1e1e;
    --bg-panel: rgba(45, 45, 45, 0.98);
    --bg-input: rgba(45, 45, 45, 0.97);
    --bg-textarea: rgba(35, 35, 35, 0.6);
    --bg-btn: rgba(226, 183, 20, 0.1);
    --bg-btn-hover: rgba(226, 183, 20, 0.25);
    --bg-badge-view: rgba(68, 68, 68, 0.4);
    --bg-badge-edit: rgba(226, 183, 20, 0.15);
    --border-subtle: rgba(68, 68, 68, 0.5);
    --border-input: #e2b714;
    --border-textarea: rgba(68, 68, 68, 0.4);
    --border-textarea-focus: rgba(226, 183, 20, 0.5);
    --border-btn: rgba(68, 68, 68, 0.5);
    --text-primary: #e0e0e0;
    --text-secondary: #cccccc;
    --text-dim: #888888;
    --text-label: rgba(226, 183, 20, 0.85);
    --text-btn: #e2b714;
    --text-btn-hover: #f5d450;
    --text-badge-view: #888888;
    --text-badge-edit: #e2b714;
    --text-placeholder: rgba(136, 136, 136, 0.4);
    --header-color: rgba(224, 224, 224, 0.6);
    --help-btn-color: rgba(226, 183, 20, 0.6);
    --font: 'Tajawal', 'DM Sans', 'Noto Sans Arabic', sans-serif;
    --header-h: 48px;
    --input-h: 34px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 12px;
    --transition-fast: 0.15s ease;
    --transition-panel: 0.22s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    overflow: hidden;
    background: var(--bg);
    font-family: var(--font);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 500;
    color: var(--header-color);
    letter-spacing: 0.4px;
    z-index: 10;
    pointer-events: none;
    gap: 20px;
}

.help-btn {
    pointer-events: auto;
    color: var(--help-btn-color);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.help-btn:hover {
    color: rgba(100, 200, 150, 0.7);
    background: rgba(100, 200, 150, 0.08);
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    cursor: default;
}

#nodeInput {
    position: fixed;
    display: none;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 500;
    padding: 5px 14px;
    text-align: center;
    outline: none;
    min-width: 100px;
    max-width: 260px;
    height: var(--input-h);
    z-index: 20;
    box-shadow: 0 0 24px rgba(100, 200, 150, 0.08);
}

/* ============================================
     Left Context Box
     ============================================ */
.panel-toggle {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 12;
    background: var(--bg-panel);
    color: var(--text-btn);
    border: 1px solid var(--border-subtle);
    border-left: none;
    padding: 12px 8px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
}

.panel-toggle i {
    color: var(--text-btn);
    transition: transform 0.2s ease, color 0.2s ease;
}

.panel-toggle:hover {
    background: var(--bg-input);
    color: var(--text-btn-hover);
}

.panel-toggle:hover i {
    color: var(--text-btn-hover);
    transform: scale(1.15);
}

body.light-mode .panel-toggle {
    background: rgba(255, 255, 255, 0.9);
    color: rgba(20, 80, 60, 0.5);
    border-color: rgba(40, 80, 65, 0.15);
}

body.light-mode .panel-toggle:hover {
    background: rgba(255, 255, 255, 1);
    color: rgba(20, 120, 80, 0.8);
}

.context-box {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%) translateX(-100%);
    width: 320px;
    max-height: 70vh;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    z-index: 15;
    transition: transform var(--transition-panel);
}

.context-box.open {
    transform: translateY(-50%) translateX(0);
}

.cb-header {
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(80, 120, 100, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cb-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.8px;
    color: var(--text-label);
    text-transform: uppercase;
}

.cb-actions {
    display: flex;
    gap: 6px;
}

.cb-btn {
    background: var(--bg-btn);
    border: 1px solid var(--border-btn);
    border-radius: var(--radius-md);
    color: var(--text-btn);
    font-size: 13px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.cb-btn:hover {
    background: var(--bg-btn-hover);
    color: var(--text-btn-hover);
}

.cb-close {
    margin-left: 4px;
    color: rgba(200, 100, 100, 0.5);
}

.cb-close:hover {
    color: rgba(200, 100, 100, 0.9);
    background: rgba(200, 60, 60, 0.15);
}

.cb-textarea {
    flex: 1;
    margin: 10px 14px 14px;
    background: var(--bg-textarea);
    border: 1px solid var(--border-textarea);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    padding: 10px;
    resize: none;
    outline: none;
    line-height: 1.55;
    min-height: 0;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}

.cb-textarea:focus {
    border-color: var(--border-textarea-focus);
}

.cb-textarea.cb-disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.cb-textarea::placeholder {
    color: var(--text-placeholder);
}

/* ============================================
     Floating Note Post-It
     ============================================ */
.floating-note {
    position: fixed;
    display: none;
    bottom: 24px;
    right: 24px;
    width: 240px;
    min-height: 90px;
    max-height: 220px;
    background: var(--bg-panel);
    border: 1px solid var(--border-input);
    border-radius: 12px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 13px;
    padding: 10px 12px;
    resize: none;
    outline: none;
    z-index: 300;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform: translateY(5px);
    opacity: 0;
}

.floating-note.visible {
    transform: translateY(0);
    opacity: 1;
}

.floating-note::placeholder {
    color: var(--text-placeholder);
}



/* ============================================
     Mobile / Touch Adjustments
     ============================================ */
@media (max-width: 768px) {
    #modeBadge {
        display: none;
    }

    .context-box {
        width: 280px;
    }
}
/* ============================================
   Light Theme Variables (Overrides Dark)
   ============================================ */
   body.light-mode {
    --bg: #f4f4f4;
    --bg-panel: rgba(255, 255, 255, 0.95);
    --bg-input: rgba(255, 255, 255, 0.98);
    --bg-textarea: rgba(232, 232, 232, 0.6);
    --bg-btn: rgba(194, 141, 0, 0.08);
    --bg-btn-hover: rgba(194, 141, 0, 0.18);
    --bg-badge-view: rgba(204, 204, 204, 0.4);
    --bg-badge-edit: rgba(194, 141, 0, 0.12);
  
    --border-subtle: rgba(204, 204, 204, 0.6);
    --border-input: #c28d00;
    --border-textarea: rgba(204, 204, 204, 0.5);
    --border-textarea-focus: rgba(194, 141, 0, 0.4);
    --border-btn: rgba(204, 204, 204, 0.6);
  
    --text-primary: #404040;
    --text-secondary: #555555;
    --text-dim: #737373;
    --text-label: #c28d00;
    --text-btn: #c28d00;
    --text-btn-hover: #996e00;
    --text-badge-view: #737373;
    --text-badge-edit: #c28d00;
    --text-placeholder: rgba(115, 115, 115, 0.4);
  
    --header-color: rgba(64, 64, 64, 0.7);
    --help-btn-color: #c28d00;
  
    --barBg: 'rgba(255, 255, 255, 0.85)';
    --barBorder: 'rgba(204, 204, 204, 0.3)';
    --barText: 'rgba(64, 64, 64, 0.6)';
  }
  body.light-mode .panel-toggle {
    background: var(--bg-panel);
    color: var(--text-btn);
    border-color: var(--border-subtle);
  }
  
  body.light-mode .panel-toggle:hover {
    background: var(--bg-input);
    color: var(--text-btn-hover);
  }

/* ============================================
   Search Container & Overlay
   ============================================ */
.search-container {
    position: fixed;
    top: 104px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    width: 90%;
    max-width: 460px;
    pointer-events: auto;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 6px 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.2s ease;
}

.search-box:focus-within {
    border-color: var(--border-input);
    box-shadow: 0 4px 25px rgba(226, 183, 20, 0.25);
}

.search-icon {
    color: var(--text-label);
    font-size: 14px;
    margin-right: 10px;
}

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
}

#searchInput::placeholder {
    color: var(--text-placeholder);
}

.search-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-label);
    margin: 0 8px;
    white-space: nowrap;
}

.search-clear-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    transition: color 0.15s ease;
}

.search-clear-btn:hover {
    color: var(--text-primary);
}

/* ============================================
   Glassmorphic Node Hover Tooltip
   ============================================ */
.node-tooltip {
    position: fixed;
    display: none;
    max-width: 320px;
    background: var(--bg-panel);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity 0.15s ease;
}

.tooltip-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tooltip-tags {
    font-size: 10px;
    color: var(--text-label);
    font-weight: 500;
    margin-bottom: 4px;
}

.tooltip-note {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
}

/* ============================================
   Always-Visible Top Left Header Menu & Search
   ============================================ */
.top-left-menu {
    position: fixed;
    top: 56px;
    left: 18px;
    z-index: 130;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 5px 10px;
    border-radius: 24px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: auto;
}

.top-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--bg-btn);
    border: 1px solid var(--border-btn);
    border-radius: 50%;
    color: var(--text-btn);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.top-menu-btn:hover {
    background: var(--bg-btn-hover);
    color: var(--text-btn-hover);
    transform: scale(1.12);
}

.top-menu-divider {
    width: 1px;
    height: 18px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.search-box-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 4px 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search-box-inline:focus-within {
    border-color: #e2b714;
    box-shadow: 0 0 16px rgba(226, 183, 20, 0.45);
    background: rgba(226, 183, 20, 0.08);
}

.search-icon-inline {
    font-size: 12px;
    color: var(--text-secondary);
}

.search-box-inline input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    width: 210px;
}

.search-count-inline {
    font-size: 11px;
    color: #e2b714;
    font-weight: 700;
}

.search-clear-inline {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
}

/* ============================================
   Right Vertical Floating Side Toolbar
   ============================================ */
.side-action-bar {
    position: fixed;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    z-index: 130;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    padding: 8px 6px;
    border-radius: 24px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: auto;
}

.side-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-btn);
    border: 1px solid var(--border-btn);
    border-radius: 50%;
    color: var(--text-btn);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.side-btn:hover:not(:disabled) {
    background: var(--bg-btn-hover);
    color: var(--text-btn-hover);
    transform: scale(1.12);
}



.side-divider {
    width: 18px;
    height: 1px;
    background: var(--border-subtle);
    margin: 2px 0;
}

.tb-danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.tb-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* AI Button & Popovers */
.top-menu-btn.ai-btn-accent {
    color: #ffd700;
    background: linear-gradient(135deg, rgba(226, 183, 20, 0.25), rgba(255, 215, 0, 0.12));
    border: 1px solid rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.25);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.top-menu-btn.ai-btn-accent:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.4), rgba(226, 183, 20, 0.25));
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.6), 0 0 30px rgba(226, 183, 20, 0.3);
    transform: translateY(-1px) scale(1.06);
}
.top-menu-btn.ai-btn-accent i {
    animation: aiWandGlow 2.5s infinite ease-in-out;
}
@keyframes aiWandGlow {
    0%, 100% { filter: drop-shadow(0 0 2px #ffd700); transform: rotate(0deg) scale(1); }
    50% { filter: drop-shadow(0 0 8px #ffd700); transform: rotate(-10deg) scale(1.15); }
}

/* Samples Popover Menu (Attached Header Dropdown) */
.samples-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 2000;
    background: var(--mf-input-bg, #191924);
    border: 1px solid var(--mf-border, #272738);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(14px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 260px;
}
body.light .samples-popover {
    background: #ffffff;
    border-color: #e2e2ec;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}
.samples-title {
    font-size: 12px;
    font-weight: 700;
    color: #e2b714;
    padding: 6px 10px;
    border-bottom: 1px solid var(--mf-border, #272738);
    margin-bottom: 4px;
}
body.light .samples-title {
    border-bottom-color: #e2e2ec;
}
.sample-item-btn {
    background: transparent;
    border: none;
    color: var(--mf-text, #e2e2ec);
    padding: 9px 12px;
    border-radius: 8px;
    text-align: right;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease;
}
body.light .sample-item-btn {
    color: #1a1a26;
}
.sample-item-btn:hover {
    background: rgba(226, 183, 20, 0.15);
    color: #e2b714;
}

/* AI Generator Modal */
.ai-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ai-modal-card {
    direction: rtl;
    text-align: right;
    background: var(--bg-panel, rgba(30, 30, 30, 0.96));
    border: 1px solid rgba(226, 183, 20, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 20px rgba(226, 183, 20, 0.15);
    overflow: hidden;
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.ai-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}
.ai-modal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ai-engine-tag {
    background: rgba(226, 183, 20, 0.15);
    border: 1px solid rgba(226, 183, 20, 0.35);
    color: #ffd700;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ai-modal-desc {
    font-size: 13px;
    color: var(--text-dim, #a0a0a0);
    margin: 0;
    line-height: 1.5;
}
.ai-chips-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-dim, #888);
    margin-top: 4px;
}
.ai-close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim, #888);
    font-size: 20px;
    cursor: pointer;
}
.ai-close-btn:hover { color: #fff; }
.ai-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#aiPromptInput {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px;
    color: var(--text-primary, #e0e0e0);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    outline: none;
    direction: rtl;
    text-align: right;
}
#aiPromptInput:focus {
    border-color: #e2b714;
    box-shadow: 0 0 10px rgba(226, 183, 20, 0.2);
}
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ai-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}
.ai-chip:hover {
    border-color: #e2b714;
    color: #e2b714;
    background: rgba(226, 183, 20, 0.12);
}
.ai-submit-btn {
    background: linear-gradient(135deg, #e2b714, #c28d00);
    color: #121212;
    font-weight: bold;
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.ai-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(226, 183, 20, 0.4);
}
.ai-loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 12px;
    background: rgba(226, 183, 20, 0.05);
    border: 1px dashed rgba(226, 183, 20, 0.35);
    border-radius: 12px;
    text-align: center;
}
.ai-loading-spark-ring {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(226, 183, 20, 0.12);
    border: 1.5px solid rgba(226, 183, 20, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sparkPulse 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
}
.ai-spark-icon {
    font-size: 20px;
    color: #e2b714;
    animation: sparkRotate 3s infinite linear;
}
.ai-loading-status-text {
    color: #e2b714;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s ease-in-out;
}
.ai-loading-bar-track {
    width: 80%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
.ai-loading-bar-fill {
    width: 45%;
    height: 100%;
    background: linear-gradient(90deg, #e2b714, #f5d450);
    border-radius: 4px;
    position: absolute;
    animation: shimmerSlide 1.6s infinite ease-in-out;
}
@keyframes sparkPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(226, 183, 20, 0.3); }
    50% { transform: scale(1.1); box-shadow: 0 0 16px 4px rgba(226, 183, 20, 0.25); }
}
@keyframes sparkRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes shimmerSlide {
    0% { left: -45%; }
    100% { left: 100%; }
}
.ai-error-msg {
    color: #ef4444;
    font-size: 13px;
    background: rgba(239, 68, 68, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.ai-badge-soon {
    background: rgba(226, 183, 20, 0.2);
    color: #e2b714;
    border: 1px solid rgba(226, 183, 20, 0.4);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 6px;
}

.ai-coming-soon-banner {
    background: rgba(226, 183, 20, 0.08);
    border: 1px dashed rgba(226, 183, 20, 0.4);
    color: #e2b714;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   Scoped LTR Styling for English Mode
   ============================================ */
body.lang-en .hdr-dropdown-panel,
body.lang-en .samples-popover,
body.lang-en .ai-modal-card {
    direction: ltr;
    text-align: left;
}

body.lang-en .hdr-dropdown-panel .dropdown-item {
    flex-direction: row;
    justify-content: space-between;
}

body.lang-en .hdr-dropdown-panel .item-label,
body.lang-en .samples-popover .sample-item-btn {
    flex-direction: row;
    text-align: left;
}

body.lang-en .ai-modal-header {
    flex-direction: row;
}

body.lang-en .ai-modal-header-left {
    flex-direction: row;
}

body.lang-en .ai-chips {
    flex-direction: row;
}

body.lang-en #aiPromptInput {
    direction: ltr;
    text-align: left;
}

/* ============================================
   Mobile & Touch Screen Adaptations
   ============================================ */
@media (max-width: 768px) {
    .side-action-bar {
        top: auto;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        right: 50%;
        transform: translateX(50%);
        flex-direction: row;
        padding: 6px 12px;
        border-radius: 30px;
        gap: 8px;
        max-width: calc(100vw - 24px);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    }

    .side-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
        flex-shrink: 0;
    }

    .side-divider {
        width: 1px;
        height: 22px;
        margin: 0 3px;
    }

    #searchContainer {
        top: 60px;
        width: 94%;
    }

    #nodeInput {
        font-size: 16px !important;
    }

    .floating-note {
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        right: 50%;
        transform: translateX(50%);
        width: 90%;
        max-width: 380px;
        min-height: 90px;
        max-height: 220px;
        z-index: 500;
        font-size: 15px;
    }
}

@media (max-width: 540px) {
    .ai-modal-card {
        width: 94%;
        max-height: 86vh;
        margin: auto;
    }

    .ai-modal-body {
        padding: 14px;
        max-height: calc(86vh - 60px);
        overflow-y: auto;
    }

    .ai-chips {
        gap: 6px;
    }

    .ai-chip {
        padding: 5px 10px;
        font-size: 12px;
    }

    .samples-popover {
        position: fixed !important;
        top: 60px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 92% !important;
        max-width: 360px !important;
    }
}

/* ============================================
   Auth Modal & Cloud Drawer Styling
   ============================================ */
.auth-card {
    max-width: 420px;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    color: #e2b714;
    border-bottom-color: #e2b714;
}

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

.auth-form input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

.auth-form input:focus {
    border-color: #e2b714;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 16px 0 12px;
    color: var(--text-dim);
    font-size: 12px;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-subtle);
}

.auth-divider span {
    padding: 0 10px;
}

.cloud-drawer {
    position: fixed;
    top: 60px;
    left: 12px;
    width: 320px;
    max-height: calc(100vh - 80px);
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    z-index: 1000;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
    font-weight: 600;
    color: #e2b714;
}

.drawer-body {
    padding: 14px;
    overflow-y: auto;
    max-height: 480px;
}

.cloud-maps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cloud-map-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: background 0.15s ease;
}

.cloud-map-item:hover {
    background: rgba(226, 183, 20, 0.08);
}

.cloud-map-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cloud-map-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.cloud-map-date {
    font-size: 11px;
    color: var(--text-dim);
}

.cloud-map-actions {
    display: flex;
    gap: 6px;
}

.cloud-action-btn {
    padding: 4px 8px;
    background: var(--bg-btn);
    border: 1px solid var(--border-btn);
    border-radius: 6px;
    color: var(--text-btn);
    font-size: 12px;
    cursor: pointer;
}

.read-only-banner {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid #10b981;
    color: #10b981;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
}

.fork-btn {
    padding: 4px 10px;
    background: #10b981;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.user-acct-btn.logged-in {
    border-color: #e2b714 !important;
    color: #e2b714 !important;
    box-shadow: 0 0 10px rgba(226, 183, 20, 0.3);
}

/* ============================================
   Share Modal Styling
   ============================================ */
.share-card {
    max-width: 480px;
}

.share-url-box {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.share-url-box input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    color: #e2b714;
    font-family: monospace;
    font-size: 13px;
    outline: none;
}

.copy-btn {
    padding: 10px 18px;
    white-space: nowrap;
}

.share-toast {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    border-radius: 8px;
    color: #10b981;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.2s ease-in-out;
}

/* ============================================
   App Toast Notification
   ============================================ */
.app-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid var(--border-subtle);
    border-radius: 30px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(14px);
    animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.app-toast.success { border-color: #10b981; color: #10b981; }
.app-toast.error { border-color: #ef4444; color: #ef4444; }
.app-toast.info { border-color: #e2b714; color: #e2b714; }

@keyframes toastSlideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================
   Rich Article Reader & Split Editor Styling
   ============================================ */
.article-card {
    max-width: 860px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: rgba(28, 31, 44, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}

.article-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.article-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-close-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.article-close-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.read-status-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.read-status-pill.unread {
    background: rgba(226, 183, 20, 0.12);
    border-color: rgba(226, 183, 20, 0.4);
    color: #e2b714;
}

.read-status-pill.read {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #10b981;
}

.article-header-right {
    text-align: right;
}

.article-breadcrumb {
    color: #e2b714;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.article-title {
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.article-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(88vh - 170px);
}

.article-body-content {
    color: #e2e8f0;
    font-size: 16px;
    line-height: 1.8;
}

.article-body-content h1, .article-body-content h2, .article-body-content h3 {
    color: #ffffff;
    margin-top: 20px;
    margin-bottom: 10px;
}

.article-body-content p {
    margin-bottom: 16px;
}

.article-body-content code {
    background: rgba(0, 0, 0, 0.4);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    color: #e2b714;
}

.article-body-content pre {
    background: rgba(0, 0, 0, 0.5);
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.article-body-content img {
    max-width: 100%;
    border-radius: 10px;
    margin: 16px 0;
}

.article-body-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.article-body-content th, .article-body-content td {
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    text-align: right;
}

.article-body-content th {
    background: rgba(255, 255, 255, 0.05);
    color: #e2b714;
}

.article-empty-notice {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
}

.editor-formatting-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.fmt-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.fmt-btn:hover {
    background: rgba(226, 183, 20, 0.2);
    border-color: #e2b714;
    color: #e2b714;
    transform: translateY(-1px);
}

/* EasyMDE Dark Mode Customizations */
.EasyMDEContainer {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.3);
}

.EasyMDEContainer .editor-toolbar {
    background: rgba(15, 23, 42, 0.9) !important;
    border-color: var(--border-subtle) !important;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 8px;
}

.EasyMDEContainer .editor-toolbar button {
    color: var(--text-primary) !important;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    margin: 0 2px !important;
    transition: all 0.2s ease;
}

.EasyMDEContainer .editor-toolbar button:hover, 
.EasyMDEContainer .editor-toolbar button.active {
    background: rgba(226, 183, 20, 0.2) !important;
    border-color: #e2b714 !important;
    color: #e2b714 !important;
}

.EasyMDEContainer .editor-toolbar i.separator {
    border-left: 1px solid var(--border-subtle) !important;
    border-right: none !important;
    margin: 0 6px !important;
}

.EasyMDEContainer .CodeMirror {
    background: rgba(0, 0, 0, 0.35) !important;
    color: #e2e8f0 !important;
    border-color: var(--border-subtle) !important;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    font-family: inherit !important;
    font-size: 15px;
    line-height: 1.7;
    min-height: 320px;
    direction: rtl;
}

.EasyMDEContainer .editor-preview {
    background: rgba(24, 27, 38, 0.98) !important;
    color: #e2e8f0 !important;
    direction: rtl;
    text-align: right;
}

.editor-textarea:focus {
    border-color: #e2b714;
}

.preview-box {
    flex: 1;
    padding: 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow-y: auto;
}

.editor-actions-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.danger-btn {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid #ef4444 !important;
    color: #ef4444 !important;
}

.article-modal-footer {
    padding: 14px 28px 20px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.article-footer-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
}

.article-footer-hint {
    color: var(--text-dim);
    font-size: 12px;
    margin: 0 0 6px;
}

.article-footer-shortcut {
    color: var(--text-dim);
    font-size: 12px;
    margin: 0;
}

.article-footer-shortcut kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: #ffffff;
    font-family: inherit;
}

/* ============================================
   Integrated About Modal Styling
   ============================================ */
.about-card {
  width: 100%;
  max-width: 560px;
  background: rgba(30, 32, 44, 0.96);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 32px 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.about-card .card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  direction: rtl;
}

.about-card .brand-logo {
  font-size: 20px;
  font-weight: 700;
  color: #e2b714;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 2px;
}

.about-card .brand-logo .dot {
  color: var(--text-dim);
}

.about-card .lang-btn {
  background: rgba(226, 183, 20, 0.1);
  border: 1px solid rgba(226, 183, 20, 0.3);
  color: #e2b714;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.about-card .lang-btn:hover {
  background: rgba(226, 183, 20, 0.2);
}

.about-card .node-preview-wrapper {
  margin: 6px 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.about-card .breathing-node {
  width: 105px;
  height: 95px;
  background: rgba(45, 48, 64, 0.9);
  border: 2px solid #e2b714;
  border-radius: 50% 45% 55% 40% / 45% 50% 40% 55%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 0 25px rgba(226, 183, 20, 0.25);
  animation: organicBreath 6s ease-in-out infinite alternate;
}

.about-card .eye-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(26, 28, 38, 0.95);
  border: 1px solid rgba(220, 225, 235, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e2b714;
  font-size: 11px;
  margin-top: -12px;
  z-index: 2;
}

.about-card .content-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.about-card .content-wrapper.rtl {
  direction: rtl;
}

.about-card .content-wrapper.ltr {
  direction: ltr;
}

.about-card .title {
  font-size: 21px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 10px;
}

.about-card .description {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.about-card .divider {
  width: 100%;
  height: 1px;
  background: var(--border-subtle);
  margin-bottom: 16px;
}

.about-card .credits {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.about-card .credits strong {
  color: var(--text-primary);
  font-weight: 600;
}

.about-card .source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #e2b714;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.about-card .source-link:hover {
  opacity: 0.85;
  text-decoration: underline;
}