* { box-sizing: border-box; }
:root {
    --bg: #0f172a;
    --panel: #111827;
    --panel-2: #1f2937;
    --line: rgba(255,255,255,.08);
    --text: #f8fafc;
    --muted: #94a3b8;
    --primary: #14b8a6;
    --primary-dark: #0f766e;
    --secondary: #334155;
    --danger: #ef4444;
    --radius: 18px;
    --shadow: 0 20px 60px rgba(0,0,0,.35);
}
body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1e293b 0%, #0f172a 45%, #020617 100%);
    color: var(--text);
    min-height: 100vh;
}
.container {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto;
}
header, footer, .upload-section, .editor-section, .notification {
    backdrop-filter: blur(10px);
}
header, footer {
    background: rgba(17, 24, 39, .85);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
header { margin-bottom: 24px; }
footer { margin-top: 24px; color: var(--muted); }
h1 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 3.2rem); }
.subtitle { margin: 0; color: var(--muted); max-width: 70ch; }
.app-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.upload-section, .editor-section {
    background: rgba(17, 24, 39, .88);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.section-title i { color: var(--primary); font-size: 1.2rem; }
.section-title h2 { margin: 0; font-size: 1.3rem; }
.upload-area {
    border: 2px dashed rgba(20,184,166,.45);
    border-radius: 20px;
    padding: 32px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(20,184,166,.08), rgba(255,255,255,.02));
    cursor: pointer;
    transition: .2s ease;
}
.upload-area.dragover { transform: translateY(-1px); border-color: var(--primary); background: rgba(20,184,166,.12); }
.upload-icon { font-size: 2.6rem; color: var(--primary); margin-bottom: 12px; }
.upload-text h3 { margin: 0 0 6px; }
.upload-text p { margin: 0 0 18px; color: var(--muted); }
.btn {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #042f2e; }
.btn-primary:hover:not(:disabled) { background: #2dd4bf; }
.btn-secondary { background: var(--secondary); color: var(--text); }
.image-preview-container {
    position: relative;
    min-height: 360px;
    margin-top: 20px;
    border-radius: 20px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: conic-gradient(from 45deg, #1f2937 0 25%, #0f172a 0 50%, #1f2937 0 75%, #0f172a 0 100%);
    background-size: 28px 28px;
}
.result-panel.white-bg { background: #fff; }
.result-panel.gradient-bg { background: linear-gradient(135deg, #0ea5e9, #8b5cf6, #ec4899); }
.placeholder-image {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255,255,255,.25);
    font-size: 4rem;
}
.image-preview {
    position: relative;
    z-index: 2;
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.editor-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.control-group {
    background: rgba(255,255,255,.03);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
}
.control-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin-bottom: 12px;
}
.control-label i { color: var(--primary); }
.select-field, .color-field {
    width: 100%;
    min-height: 46px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(15,23,42,.95);
    color: var(--text);
    padding: 0 14px;
}
.color-field { padding: 6px; }
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
}
.toggle-switch {
    width: 62px;
    height: 34px;
    border-radius: 999px;
    background: #334155;
    border: 0;
    padding: 4px;
    position: relative;
}
.toggle-switch.active { background: var(--primary); }
.toggle-slider {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    display: block;
    transition: transform .2s ease;
}
.toggle-switch.active .toggle-slider { transform: translateX(28px); }
.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.helper-box {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(20,184,166,.08);
    border: 1px solid rgba(20,184,166,.24);
    color: #ccfbf1;
}
.helper-box p { margin: 0 0 10px; }
.helper-box p:last-child { margin-bottom: 0; }
.loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 14px;
    background: rgba(2,6,23,.74);
    z-index: 5;
}
.hidden { display: none; }
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.notification {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: rgba(17,24,39,.94);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: .25s ease;
}
.notification.show { opacity: 1; transform: translateY(0); }
.notification.error i { color: var(--danger); }
.notification.success i { color: var(--primary); }
code { background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) {
    .app-container { grid-template-columns: 1fr; }
    .editor-controls { grid-template-columns: 1fr; }
    .image-preview-container { min-height: 280px; }
}
