:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.6);
    --secondary: #ec4899;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --border-glass: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(255, 255, 255, 0.25);
    --bg-glass: rgba(20, 20, 35, 0.4);
    --bg-element: rgba(255, 255, 255, 0.06);
    --bg-element-hover: rgba(255, 255, 255, 0.1);
    --radius-xl: 32px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    /* Soft dark gradient with mesh colored orbs for genuine glass effect background */
    background-color: #080a14;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 50% 100%, rgba(56, 189, 248, 0.2) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Glass Panels Baseline */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 40px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

/* Header */
.top-nav-wrapper {
    width: 100%;
    padding: 0 1.5rem;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1060px;
    margin: 1.5rem auto 0;
    height: 60px;
    padding: 0 1.5rem;
    border-radius: 100px; /* Super pill looking */
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand i {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text-primary);
}

/* Boxed Layout Container */
.app-container {
    max-width: 1060px;
    width: 100%;
    margin: 1.5rem auto 1.5rem;
    height: calc(100vh - 110px);
    display: flex;
    gap: 1.5rem;
    padding: 0 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 360px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-highlight);
    border-radius: 4px;
}

/* Canvas Area */
.canvas-area {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
}

#previewArea {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.canvas-container {
    margin: 0 auto !important; /* Forces FabricJS container to center */
}

/* Elements Inside Glass Panels */
.upload-zone {
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-element);
    margin-bottom: 1.5rem;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    font-size: 1.8rem;
    color: var(--text-primary);
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.upload-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Tabs UI */
.tabs {
    display: flex;
    background: var(--bg-element);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-glass);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 0;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--bg-element-hover);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Tool Groups */
.tool-group {
    background: var(--bg-element);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tool-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Layer Items */
.layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-element);
    border: 1px solid var(--border-glass);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.layer-item:hover {
    background: var(--bg-element-hover);
}

.layer-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.layer-text {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Forms */
.control-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-select {
    width: 100%;
    background: var(--bg-element);
    border: 1px solid var(--border-glass);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.form-select:focus {
    border-color: var(--border-highlight);
    background: var(--bg-element-hover);
}

/* Custom Font Dropdown */
.custom-font-dropdown {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-font-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-element);
    border: 1px solid var(--border-glass);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-font-trigger:hover {
    background: var(--bg-element-hover);
    border-color: var(--border-highlight);
}

.custom-font-options {
    position: absolute;
    top: 105%;
    left: 0;
    right: 0;
    background: rgba(20, 20, 35, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.2s, transform 0.2s;
}

.custom-font-options.open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.custom-font-option {
    padding: 0.6rem 0.8rem;
    font-size: 1.1rem;
    color: white;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.custom-font-option:last-child {
    border-bottom: none;
}

.custom-font-option:hover {
    background: rgba(99, 102, 241, 0.2);
}

.custom-font-option-category {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.4rem 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-element);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 4px;
}

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

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-wrapper input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Range Slider iOS Style */
.range-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.range-val {
    font-size: 0.75rem;
    width: 35px;
    text-align: right;
    color: var(--text-primary);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.main-action {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1rem;
}

.btn-export {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.3);
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(236, 72, 153, 0.4);
}

/* Helper iOS Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-element);
    border: 1px solid var(--border-glass);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: #34d399; /* iOS green toggle */
    border-color: #34d399;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Custom Modal */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none; /* hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.custom-modal {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: var(--radius-xl);
}

.custom-modal-overlay.active .custom-modal {
    transform: scale(1);
}

.modal-title {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.modal-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

.btn-danger:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

