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

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.4);
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --bg-main: #0a0b14;
    --bg-card: linear-gradient(145deg, #12141f 0%, #1a1d2e 100%);
    --bg-elevated: linear-gradient(135deg, #1e2234 0%, #252940 100%);
    --bg-input: #1a1d2e;
    --border: #2d3348;
    --border-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px var(--primary-glow);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(ellipse at top, #1a1d2e 0%, var(--bg-main) 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0.5rem;
}

.header {
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow), var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--border-glow);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

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

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0.75rem;
    align-items: start;
}

.sidebar {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0.75rem;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(145deg, var(--border-glow), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    pointer-events: none;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-hover), var(--accent));
}

.control-section {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 0.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 0 3px var(--border-glow), 0 0 15px var(--primary-glow);
}

.form-control.textarea {
    resize: vertical;
    min-height: 60px;
}

.form-control.color-input {
    height: 36px;
    padding: 0.2rem;
    cursor: pointer;
}

.form-control.font-select {
    cursor: pointer;
}

.form-control.font-select option {
    padding: 0.5rem;
    font-size: 0.875rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.shape-selector {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem;
    background: var(--bg-input);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.shape-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.shape-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.shape-btn.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.size-control {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.size-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.size-btn:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.size-btn:active {
    transform: scale(0.92);
}

.size-input {
    flex: 1;
    text-align: center;
    font-weight: 600;
    cursor: default;
}

.preview-area {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1rem;
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-area::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    opacity: 0.1;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.label-preview {
    background: white;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.label-preview.square {
    border-radius: 8px;
}

.label-preview.circle {
    border-radius: 50%;
}

.label-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    text-align: center;
    gap: 0;
    padding: 5%;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

/* Absolutely positioned overlay for decorative borders (e.g., snowflakes) */
.border-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.preview-name {
    font-weight: 700;
    word-wrap: break-word;
    width: 90%;
    line-height: 1.2;
}

.preview-ingredients,
.preview-warnings,
.preview-business {
    word-wrap: break-word;
    width: 90%;
    white-space: pre-wrap;
    line-height: 1.2;
}

.preview-warnings {
    font-weight: 600;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0.5rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-radius: 6px;
    transition: var(--transition);
}

.preset-item:hover {
    background: var(--secondary);
}

.preset-info {
    flex: 1;
}

.preset-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.preset-date {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.preset-actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #10b981;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 2000;
}

.notification.show {
    transform: translateX(0);
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 968px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: none;
        order: 2;
    }

    .preview-area {
        order: 1;
        min-height: 400px;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 1rem;
    }

    .title {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
    }

    .sidebar {
        padding: 1rem;
    }

    .preview-area {
        padding: 1rem;
    }

    .preview-container {
        padding: 1rem;
    }

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

    .notification {
        right: 1rem;
        left: 1rem;
        top: 1rem;
    }

    .modal-content {
        max-width: 100%;
        margin: 1rem;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 0.5rem;
    }

    .btn {
        font-size: 0.8125rem;
        padding: 0.5rem 1rem;
    }
}
