:root {
    --bg-color:      #0f172a;
    --surface:       #1e293b;
    --primary:       #3b82f6;
    --primary-hover: #2563eb;
    --text-primary:  #f8fafc;
    --text-secondary:#94a3b8;
    --border:        #334155;
    --danger:        #ef4444;
    --success:       #22c55e;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(59,130,246,.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139,92,246,.15),  transparent 25%);
}

.app-container {
    width: 100%;
    max-width: 1400px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ===== HEADER ===== */
header {
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: .5rem;
}
header p { color: var(--text-secondary); font-size: 1.1rem; }

.header-clear-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.header-clear-btn:hover {
    background: rgba(239,68,68,0.25);
    border-color: rgba(239,68,68,0.5);
}

/* ===== SEO BADGES ===== */
.seo-badges { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    background: rgba(59,130,246,.12);
    border: 1px solid rgba(59,130,246,.3);
    color: #93c5fd;
    font-size: .8rem; font-weight: 600;
    padding: .3rem .75rem;
    border-radius: 999px;
    white-space: nowrap;
    transition: background .2s, border-color .2s;
}
.badge:hover { background: rgba(59,130,246,.22); border-color: rgba(59,130,246,.6); }

/* ===== MAIN LAYOUT ===== */
main { display: flex; gap: 2rem; align-items: flex-start; flex-wrap: wrap; }

/* ===== SIDEBAR ===== */
.sidebar {
    flex: 1; min-width: 350px; max-width: 450px;
    background: rgba(30,41,59,.7);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.1);
}

.sets-container {
    display: flex; flex-direction: column; gap: 1rem;
    margin-bottom: 1rem;
    max-height: 55vh; overflow-y: auto; padding-right: .5rem;
}
.sets-container::-webkit-scrollbar { width: 6px; }
.sets-container::-webkit-scrollbar-track { background: rgba(0,0,0,.1); }
.sets-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ===== SET CARD ===== */
.set-card {
    background: rgba(15,23,42,.6);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 1rem; cursor: pointer;
    transition: all .2s; position: relative;
    display: flex; flex-direction: column; gap: .8rem;
}
.set-card:hover  { border-color: rgba(59,130,246,.3); }
.set-card.active { border-color: var(--primary); box-shadow: 0 0 10px rgba(59,130,246,.2); background: rgba(30,41,59,.9); }

.set-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }

.set-name {
    cursor: text; border-bottom: 1px dashed transparent;
    padding: 2px 4px; border-radius: 4px;
    transition: border-color .2s, background .2s;
    flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.set-name:hover { border-bottom-color: var(--primary); background: rgba(59,130,246,.08); }

.set-name-input {
    background: transparent; border: none; border-bottom: 2px solid var(--primary);
    color: var(--text-primary); font-family: 'Inter',sans-serif;
    font-size: 1rem; font-weight: 600; outline: none;
    flex: 1; min-width: 0; padding: 2px 4px; width: 100%;
}

.remove-set-btn {
    background: transparent; color: var(--danger); border: none;
    cursor: pointer; font-size: 1.2rem; padding: 0 .5rem; font-weight: bold;
    transition: transform .1s;
}
.remove-set-btn:hover { transform: scale(1.2); }

/* ===== CONTROLS ===== */
.control-group { display: flex; flex-direction: column; gap: .4rem; }
.control-group label,
.ctrl-label {
    font-weight: 600; font-size: .82rem; color: var(--text-secondary);
    display: flex; justify-content: space-between; align-items: center;
}
.val-lbl { color: var(--primary); font-weight: 700; }

/* Dark select */
.dark-select {
    width: 100%;
    background: rgba(15,23,42,.8);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .75rem;
    font-family: 'Inter',sans-serif;
    font-size: .85rem;
    cursor: pointer;
    outline: none;
    transition: border-color .2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}
.dark-select:hover, .dark-select:focus { border-color: var(--primary); }

/* Styled range */
.styled-range {
    width: 100%; -webkit-appearance: none; appearance: none;
    height: 4px; border-radius: 999px;
    background: var(--border); outline: none; cursor: pointer;
}
.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--primary);
    border: 2px solid var(--bg-color);
    box-shadow: 0 0 4px rgba(59,130,246,.5);
    transition: transform .1s;
}
.styled-range::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Set controls section */
.set-controls { background: rgba(0,0,0,.2); border-radius: 8px; padding: .75rem; gap: .5rem; }

/* File drop zone */
.file-drop-zone {
    border: 2px dashed var(--border); border-radius: 8px;
    padding: 1rem; text-align: center; cursor: pointer;
    transition: all .2s; background: rgba(15,23,42,.5);
}
.file-drop-zone.active-zone { border-color: var(--primary); background: rgba(59,130,246,.08); }
.file-drop-zone:hover       { border-color: var(--primary); background: rgba(59,130,246,.08); }
.file-drop-zone.dragging    {
    border-color: var(--success);
    background: rgba(34,197,94,.1);
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(34,197,94,.2);
}
.placeholder-text { color: var(--text-secondary); font-size: .85rem; pointer-events: none; }

.banner-preview { display: flex; gap: .5rem; flex-wrap: wrap; max-height: 80px; overflow-y: auto; margin-top: .2rem; }
.preview-thumb  { width: 36px; height: 36px; object-fit: contain; background: #000; border-radius: 4px; border: 1px solid var(--border); }

/* Zone info */
.active-zone-info { background: rgba(15,23,42,.5); padding: 1rem; border-radius: 8px; margin-bottom: 1rem; }
.instruction-text { font-size: .8rem; color: var(--text-secondary); line-height: 1.4; }
.coordinates {
    background: #000; padding: .75rem; border-radius: 6px;
    font-family: monospace; color: #60a5fa; font-size: .85rem; line-height: 1.5;
}

/* Live Preview Toggle */
.toggle-label {
    display: flex !important; flex-direction: row !important;
    align-items: center; gap: .6rem;
    cursor: pointer; font-size: .85rem !important; color: var(--text-secondary) !important;
    margin-top: .4rem;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
    width: 36px; height: 20px; background: var(--border);
    border-radius: 999px; position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle-thumb {
    position: absolute; top: 3px; left: 3px;
    width: 14px; height: 14px; background: #fff;
    border-radius: 50%; transition: transform .2s;
}
.toggle-label input:checked + .toggle-track { background: var(--primary); }
.toggle-label input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

/* ===== BUTTONS ===== */
.primary-btn {
    background: var(--primary); color: #fff;
    border: none; border-radius: 8px; padding: 1rem;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background .2s, transform .1s; width: 100%;
}
.primary-btn:hover:not(:disabled)  { background: var(--primary-hover); transform: translateY(-2px); }
.primary-btn:active:not(:disabled) { transform: translateY(0); }
.primary-btn:disabled { background: var(--border); color: var(--text-secondary); cursor: not-allowed; opacity: .7; }

.secondary-btn {
    background: transparent; color: var(--primary);
    border: 2px dashed var(--primary); border-radius: 8px;
    padding: 1rem; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all .2s; width: 100%; margin-bottom: 1rem;
}
.secondary-btn:hover { background: rgba(59,130,246,.1); }

/* Result individual download button */
.result-dl-btn {
    display: block; text-align: center;
    background: rgba(59,130,246,.15); color: #93c5fd;
    border: 1px solid rgba(59,130,246,.3);
    border-radius: 6px; padding: .4rem;
    font-size: .8rem; font-weight: 600; text-decoration: none;
    transition: background .2s;
}
.result-dl-btn:hover { background: rgba(59,130,246,.3); }

/* ===== CANVAS AREA ===== */
.canvas-container {
    flex: 2; min-width: 0;
    background: rgba(30,41,59,.7);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px; padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.1);
    display: flex; flex-direction: column; align-items: center;
    overflow: auto;
}

/* Canvas toolbar */
.canvas-toolbar {
    display: flex; align-items: center; gap: .6rem;
    width: 100%; margin-bottom: 1rem;
    flex-wrap: wrap;
}
.toolbar-spacer { flex: 1; }

.tool-btn {
    background: rgba(30,41,59,.9);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px; padding: .4rem .9rem;
    font-size: .82rem; font-weight: 600; cursor: pointer;
    transition: all .2s; white-space: nowrap;
}
.tool-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--text-primary); }
.tool-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Canvas mode toggle group */
.canvas-mode-group {
    display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.canvas-mode-group .mode-btn {
    border-radius: 0; border: none; border-right: 1px solid var(--border);
    padding: .4rem .85rem;
}
.canvas-mode-group .mode-btn:last-child { border-right: none; }
.canvas-mode-group .mode-btn.active-mode {
    background: rgba(59,130,246,.25); color: #93c5fd;
    border-color: transparent;
}
/* Cursor reflects the active canvas mode */
canvas.mode-move { cursor: grab !important; }
canvas.mode-move:active { cursor: grabbing !important; }

.zoom-badge {
    background: rgba(59,130,246,.15);
    border: 1px solid rgba(59,130,246,.3);
    color: #93c5fd; font-size: .82rem; font-weight: 700;
    padding: .35rem .75rem; border-radius: 999px;
    min-width: 52px; text-align: center;
}

.canvas-placeholder { color: var(--text-secondary); font-size: 1.1rem; padding: 4rem; text-align: center; }
.canvas-wrapper {
    position: relative; max-width: 100%;
    transform-origin: top center;
    transition: transform .15s;
}

canvas {
    max-width: 100%; height: auto;
    border-radius: 4px; cursor: crosshair; display: block;
    box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}

/* ===== SEO CONTENT SECTION ===== */
.seo-content {
    background: rgba(30,41,59,.5);
    border: 1px solid var(--border);
    border-radius: 16px; padding: 2rem;
    color: var(--text-secondary); line-height: 1.8;
    display: flex; flex-direction: column; gap: 1.2rem;
}
.seo-content h2 {
    font-size: 1.5rem; font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.seo-content h3 { font-size: 1.1rem; font-weight: 600; color: #93c5fd; margin-top: .5rem; }
.seo-content p  { font-size: .95rem; }
.seo-content strong { color: var(--text-primary); }
.seo-content ul, .seo-content ol {
    padding-left: 1.5rem; display: flex; flex-direction: column; gap: .4rem; font-size: .95rem;
}
.seo-content li { line-height: 1.6; }

/* ===== KEYBOARD SHORTCUTS MODAL ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15,23,42,0.8); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
}
.modal-content {
    background: rgba(30,41,59,0.95); border: 1px solid var(--border);
    border-radius: 16px; padding: 2rem; width: 90%; max-width: 400px;
    position: relative; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.modal-close {
    position: absolute; top: 1rem; right: 1rem;
    background: transparent; color: var(--text-secondary); border: none;
    font-size: 1.5rem; cursor: pointer; transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }
.modal-content h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; color: var(--text-primary); text-align: center;}
.shortcuts-list { display: flex; flex-direction: column; gap: 1rem; }
.shortcut-item {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.shortcut-item:last-child { border-bottom: none; padding-bottom: 0; }
.shortcut-item span { color: var(--text-secondary); font-size: 0.95rem; }
kbd {
    background: rgba(15,23,42,1); border: 1px solid var(--border);
    border-radius: 4px; padding: 0.2rem 0.5rem;
    font-family: monospace; font-size: 0.85rem; color: #93c5fd;
    box-shadow: 0 2px 0 var(--border);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    main { flex-direction: column; }
    .sidebar { max-width: 100%; min-width: 0; }
    header h1 { font-size: 1.8rem; }
}

/* ===== HOW-TO SECTION ===== */
.how-to-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideDownFade 0.5s ease-out forwards;
}

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

.how-to-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.how-to-header .close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.how-to-header .close-btn:hover {
    color: var(--danger);
}

.how-to-steps {
    display: flex;
    gap: 1.5rem;
}

.step-card {
    flex: 1;
    background: rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease-out forwards;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.step-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.step-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.75rem;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.step-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #e2e8f0;
}

.step-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

@keyframes slideDownFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .how-to-steps {
        flex-direction: column;
    }
}
