:root {
    --bg-main: #0F172A;
    --bg-card: #1E293B;
    --bg-hover: #334155;
    --border-color: rgba(255, 255, 255, 0.08);
    --primary: #F46B9E;
    --primary-hover: #E05388;
    --accent: #38BDF8;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
    
    /* Refined Design Tokens */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(16px);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --gradient-primary: linear-gradient(135deg, #F46B9E 0%, #EC4899 50%, #A855F7 100%);
}

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

body {
    font-family: 'Assistant', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    direction: rtl;
}

/* Accessibility - Focus visible */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Base Layout */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 440px;
    min-width: 380px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 28px 24px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 10;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    position: relative;
}

/* Sidebar Gradient Overlay */
.sidebar::after {
    content: '';
    position: sticky;
    bottom: -28px; /* account for padding */
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, var(--bg-card) 10%, transparent);
    pointer-events: none;
    margin-top: auto;
    z-index: 5;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
    transition: background var(--transition-normal);
}
.sidebar:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

.app-header {
    margin-bottom: 20px;
}

.back-to-catalog-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 12px;
    padding: 6px 12px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 20px;
    width: fit-content;
    transition: all var(--transition-spring);
}

.back-to-catalog-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent);
    transform: translateX(3px);
}

.logo-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(244, 107, 158, 0.15);
    color: var(--primary);
    border: 1px solid rgba(244, 107, 158, 0.3);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    border-radius: 20px;
    margin-bottom: 8px;
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #FFFFFF;
}

.app-header .subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==========================================================================
   FORM CONTROLS & GLASSMORPHISM
   ========================================================================== */
.controls-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.control-group {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--transition-normal);
}

.control-group:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.control-group.highlight {
    position: relative;
    border-color: rgba(244, 107, 158, 0.3);
    background: rgba(244, 107, 158, 0.04);
}

.control-group.highlight:focus-within {
    border-color: transparent;
    background: linear-gradient(var(--bg-card), var(--bg-card)) padding-box, var(--gradient-primary) border-box;
    border: 1px solid transparent;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #E2E8F0;
}

.input-with-clear input {
    width: 100%;
    padding: 12px 16px;
    background: #0F172A;
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: #FFFFFF;
    font-size: 1.15rem;
    font-weight: 700;
    font-family: inherit;
    transition: all var(--transition-normal);
}

.input-with-clear input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 0 10px rgba(244,107,158,0.1), 0 0 0 3px rgba(244, 107, 158, 0.2);
}

.input-with-clear input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
    font-style: italic;
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.tag {
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 9px;
    border-radius: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tag:hover {
    background: var(--primary);
    color: #FFFFFF;
}

/* ==========================================================================
   RADIO GRID & CARDS
   ========================================================================== */
.radio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.radio-card {
    display: flex;
    flex-direction: column;
    background: #0F172A;
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px;
    cursor: pointer;
    transition: all var(--transition-spring);
    position: relative;
    overflow: hidden;
}

.radio-card input {
    position: absolute;
    opacity: 0;
}

.radio-card:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

.radio-card.active {
    border-color: var(--primary);
    background: rgba(244, 107, 158, 0.08);
    border-right: 3px solid var(--primary);
}

.radio-card.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    left: 8px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: bold;
}

.radio-title {
    font-weight: 700;
    font-size: 0.88rem;
}

.radio-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Fonts Preview */
.font-preview-fredoka { font-family: 'Fredoka', sans-serif; font-weight: 700; }
.font-preview-rubik { font-family: 'Rubik', sans-serif; font-weight: 800; }
.font-preview-secular { font-family: 'Secular One', sans-serif; }
.font-preview-suez { font-family: 'Suez One', serif; }
.font-preview-heebo { font-family: 'Heebo', sans-serif; font-weight: 800; }
.font-preview-assistant { font-family: 'Assistant', sans-serif; font-weight: 800; }
.font-preview-varela { font-family: 'Varela Round', sans-serif; }
.font-preview-alef { font-family: 'Alef', sans-serif; font-weight: 700; }
.font-preview-frank { font-family: 'Frank Ruhl Libre', serif; font-weight: 800; }
.font-preview-karantina { font-family: 'Karantina', sans-serif; font-weight: 700; font-size: 1.05rem; }
.font-preview-amatic { font-family: 'Amatic SC', cursive; font-weight: 700; font-size: 1.15rem; }

.font-grid-expanded {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
.font-grid-expanded::-webkit-scrollbar { width: 5px; }
.font-grid-expanded::-webkit-scrollbar-track { background: transparent; }
.font-grid-expanded::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ==========================================================================
   PILL SELECTOR
   ========================================================================== */
.pill-selector {
    display: flex;
    background: #0F172A;
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 4px;
}

.pill-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pill-btn.active {
    background: linear-gradient(180deg, var(--bg-card), rgba(30,41,59,0.8));
    color: #FFFFFF;
    box-shadow: var(--shadow-md);
}

.pill-btn:active {
    transform: scale(0.97);
}

.weight-selector .pill-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    gap: 1px;
}
.weight-selector .pill-btn span {
    font-size: 0.82rem;
}
.weight-selector .pill-btn small {
    font-size: 0.68rem;
    opacity: 0.65;
}
.weight-tag-badge {
    font-size: 0.72rem;
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

/* ==========================================================================
   ICON GRID
   ========================================================================== */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-height: 190px;
    overflow-y: auto;
    padding: 6px;
    background: #0B1120;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.icon-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: #111827;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}
.icon-card:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: #1E293B;
    transform: translateY(-1px);
}
.icon-card.active {
    border-color: var(--primary);
    background: rgba(244, 107, 158, 0.15);
    box-shadow: 0 0 10px rgba(244, 107, 158, 0.25);
}
.icon-emoji {
    font-size: 1.35rem;
    line-height: 1.2;
}
.icon-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 600;
}
.icon-card.active .icon-name {
    color: #FFFFFF;
}

/* ==========================================================================
   COLORS & SWATCHES
   ========================================================================== */
.colors-row {
    display: flex;
    gap: 16px;
}

.color-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0F172A;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}

.color-picker-wrap {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.color-picker-wrap:hover {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.color-picker-wrap input[type="color"] {
    border: none;
    width: 48px;
    height: 48px;
    cursor: pointer;
    background: none;
    transform: scale(1.5);
    transition: transform var(--transition-fast);
}

.theme-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.theme-chip {
    background: #0F172A;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-chip:hover {
    border-color: var(--accent);
    color: #FFFFFF;
}

.swatch-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #0F172A;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-spring);
}
.swatch-btn span {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
}
.swatch-btn:hover {
    border-color: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

/* ==========================================================================
   ADVANCED & SLIDERS
   ========================================================================== */
.advanced-panel summary {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    outline: none;
    user-select: none;
}

.advanced-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.slider-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    outline: none;
    accent-color: var(--accent);
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 6px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* ==========================================================================
   DOWNLOAD BUTTONS & GRID
   ========================================================================== */
.download-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px; /* Touch target */
}

.btn-primary {
    background: linear-gradient(135deg, #F46B9E, #EC4899);
    color: #FFFFFF;
    padding: 14px 20px;
    box-shadow: 0 4px 16px rgba(244, 107, 158, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 107, 158, 0.6);
}
.btn-primary:hover .btn-icon {
    transform: scale(1.1);
}
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
    transform: skewX(-20deg);
}
.btn-primary:hover::before {
    animation: shimmer 1.5s infinite;
}

.btn-lg {
    display: flex;
    align-items: center;
    text-align: right;
    gap: 14px;
}

.btn-icon {
    font-size: 1.6rem;
    transition: transform var(--transition-fast);
}

.btn-text {
    display: flex;
    flex-direction: column;
}

.btn-text strong {
    font-size: 1.05rem;
}

.btn-text small {
    font-size: 0.75rem;
    opacity: 0.85;
    font-weight: 400;
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-secondary {
    flex: 1;
    background: #0284C7;
    color: #FFFFFF;
    padding: 10px;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    background: #0369A1;
}

.btn-outline {
    flex: 1;
    background: transparent;
    border: 1.5px solid var(--glass-border);
    color: #FFFFFF;
    padding: 10px;
    font-size: 0.85rem;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
}

.download-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.download-grid .btn-download {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1.5px solid rgba(255,255,255,0.1);
    background: #0F172A;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
}

.btn-download:hover {
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-1px);
}

.btn-download.primary {
    background: linear-gradient(135deg, #F46B9E, #EC4899);
    border: none;
    color: white;
    box-shadow: 0 4px 16px rgba(244,107,158,0.35);
}

.btn-download.primary:hover {
    box-shadow: 0 6px 24px rgba(244,107,158,0.55);
    transform: translateY(-2px);
}

.btn-download.secondary {
    background: transparent;
    color: #CBD5E1;
}

.btn-download .btn-icon {
    font-size: 1.5rem;
}

.btn-download .btn-text {
    display: flex;
    flex-direction: column;
}

.btn-download .btn-text strong {
    font-size: 0.95rem;
    color: white;
}

.btn-download .btn-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==========================================================================
   VIEWPORT AREA
   ========================================================================== */
.viewport-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #1E293B 0%, #0F172A 100%);
    overflow: hidden;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.5); /* Vignette effect */
}

#canvas-container {
    width: 100%;
    height: 100%;
}

.viewport-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    left: 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.viewport-top-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    pointer-events: none;
    z-index: 10;
}

.viewport-bottom-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 30px;
    pointer-events: none;
    z-index: 10;
}

.status-indicator {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: breathe 2s ease-in-out infinite;
}

.status-indicator.loading .status-dot {
    background: #F59E0B;
    box-shadow: 0 0 8px #F59E0B;
    animation: pulse 1s infinite;
}

.view-actions {
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    color: #FFFFFF;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-spring);
}

.icon-btn:hover {
    background: var(--primary);
    transform: scale(1.08);
}

.icon-btn.active {
    background: var(--accent);
}

.icon-action-btn {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    pointer-events: auto;
}
.icon-action-btn:hover {
    background: var(--primary);
}

/* ==========================================================================
   MODEL STATS
   ========================================================================== */
.model-stats-card {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255,255,255,0.2); /* 3D highlight feel */
    padding: 10px 20px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-lg);
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.stat-label {
    color: var(--text-muted);
}

.stat-val {
    color: #FFFFFF;
    font-weight: 700;
}

.badge-manifold {
    background: rgba(16, 185, 129, 0.2);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.75rem;
}

.stat-pill {
    display: inline-flex;
    gap: 6px;
    font-size: 0.8rem;
    align-items: center;
}
.stat-pill.success {
    color: #10B981;
}
.stat-value {
    font-weight: 700;
    color: white;
}

/* ==========================================================================
   PROJECT TOOLBAR
   ========================================================================== */
.project-toolbar {
    display: flex;
    gap: 6px;
    background: #0B1120;
    border: 1px solid var(--glass-border);
    padding: 6px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

.btn-proj {
    flex: 1;
    background: #1E293B;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    padding: 8px 6px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-spring);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: inherit;
    white-space: nowrap;
    position: relative;
}
.btn-proj:not(:last-child)::after {
    content: '';
    position: absolute;
    left: -3px; /* RTL, so right side of next button theoretically */
    top: 20%;
    height: 60%;
    width: 1px;
    background: var(--glass-border);
}

.btn-proj:hover {
    background: rgba(244, 107, 158, 0.15);
    border-color: var(--primary);
    color: #FFFFFF;
    transform: translateY(-1px);
}
.btn-proj:hover i {
    animation: pulse 0.5s;
}

.btn-proj:active {
    transform: translateY(0);
}

/* ==========================================================================
   TOASTS & ALERTS
   ========================================================================== */
.drag-toast {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid var(--accent);
    color: #F8FAFC;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drag-info-banner {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px dashed rgba(56, 189, 248, 0.4);
    border-radius: 10px;
    font-size: 0.84rem;
    color: var(--accent);
    line-height: 1.45;
}

.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1.5px solid var(--accent);
    color: #FFFFFF;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.toast-notification.show {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-notification::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    width: 100%;
    animation: progress Shrink linear forwards;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

@keyframes breathe {
    0%, 100% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 4px #10B981; }
    50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 12px #10B981; }
}

@keyframes shimmer {
    100% { left: 100%; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 1200px) {
    .sidebar {
        width: 380px;
    }
}

@media (max-width: 900px) {
    .app-layout {
        flex-direction: column-reverse;
        transition: all 0.3s ease;
    }
    .sidebar {
        width: 100%;
        height: 50vh;
        min-width: unset;
    }
    .viewport-area {
        height: 50vh;
    }
    .btn {
        min-height: 48px; /* Larger touch targets */
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   ALLSVGICONS & KEYBOARD ICON PICKER MODAL
   ========================================================================== */
.btn-open-catalog {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #A5B4FC;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-open-catalog:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35) 0%, rgba(168, 85, 247, 0.35) 100%);
    border-color: #818CF8;
    color: #FFFFFF;
    transform: translateY(-1px);
}

.quick-icons-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px 2px;
}
.btn-quick-icon {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #E2E8F0;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.18s ease;
}
.btn-quick-icon svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}
.btn-quick-icon:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.6);
    color: #FFFFFF;
    transform: translateY(-1px);
}

/* Modal Window */
.custom-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 29, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.custom-modal-window {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(99, 102, 241, 0.15);
    width: 100%;
    max-width: 780px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px 24px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.modal-title-wrap h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #F8FAFC;
    margin-bottom: 4px;
}
.modal-title-wrap p {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.modal-title-wrap a {
    color: #818CF8;
    text-decoration: underline;
}
.modal-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #94A3B8;
    font-size: 1.4rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 24px;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.modal-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94A3B8;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.modal-tab-btn:hover {
    color: #F8FAFC;
    background: rgba(255, 255, 255, 0.04);
}
.modal-tab-btn.active {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.4);
    color: #818CF8;
}

.modal-tab-content {
    display: none;
    padding: 18px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-tab-content.active {
    display: block;
}

.modal-search-row {
    margin-bottom: 16px;
}
#icon-search-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #F8FAFC;
    font-size: 0.9rem;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s ease;
}
#icon-search-input:focus {
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.cat-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cat-pill {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #94A3B8;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    cursor: pointer;
    transition: all 0.18s ease;
}
.cat-pill:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.08);
}
.cat-pill.active {
    background: #6366F1;
    border-color: #6366F1;
    color: #FFFFFF;
    font-weight: 600;
}

.icons-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 10px;
    max-height: 48vh;
    overflow-y: auto;
    padding-right: 4px;
}
.icon-card {
    background: rgba(30, 41, 59, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}
.icon-card:hover {
    background: rgba(99, 102, 241, 0.16);
    border-color: rgba(99, 102, 241, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.3);
}
.icon-card svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    color: #E2E8F0;
    margin-bottom: 6px;
}
.icon-card .icon-title {
    font-size: 0.72rem;
    color: #CBD5E1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.icon-card .icon-tag {
    font-size: 0.64rem;
    color: #64748B;
    font-family: monospace;
    margin-top: 2px;
}

/* Paste SVG Tab */
.paste-svg-box textarea {
    width: 100%;
    padding: 12px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #F8FAFC;
    font-family: monospace;
    font-size: 0.82rem;
    resize: vertical;
    outline: none;
}
.paste-svg-box textarea:focus {
    border-color: #6366F1;
}
.paste-svg-preview-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
    background: rgba(15, 23, 42, 0.5);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.svg-preview-tile {
    width: 60px;
    height: 60px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.svg-preview-tile svg {
    width: 42px;
    height: 42px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    color: #38BDF8;
}
.paste-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.paste-actions input {
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #F8FAFC;
    font-size: 0.85rem;
}
.btn-apply-svg {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    border: none;
    color: #FFFFFF;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-apply-svg:hover {
    background: linear-gradient(135deg, #818CF8 0%, #6366F1 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
