:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg: #0f172a;
    --panel: #1e293b;
    --surface: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #475569;
    --danger: #ef4444;
    --success: #10b981;
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 15px;
    display: flex;
    gap: 20px;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

/* Layout */
.col {
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-radius: 12px;
    background: var(--panel);
    padding: 20px;
    width: 380px;
    flex-shrink: 0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.main {
    flex: 1;
    background: #020617;
    border-radius: 12px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border);
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 20px 20px;
}

.scroll-y {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface) var(--bg);
}

h2 {
    margin: 0 0 10px 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    border-bottom: 2px solid var(--surface);
    padding-bottom: 10px;
}

h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 15px 0 8px 0;
}

/* Controls */
label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

select,
input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    color: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

select:focus,
input:focus {
    border-color: var(--primary);
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-group {
    flex: 1;
}

button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button:hover {
    background: #475569;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

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

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

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

.btn-dl {
    background: #d97706;
    color: white;
}

.btn-icon {
    padding: 4px;
    min-width: 24px;
    height: 24px;
}

/* Mode Switcher */
.mode-switch {
    display: flex;
    background: var(--surface);
    border-radius: 6px;
    padding: 2px;
    margin-bottom: 10px;
}

.mode-opt {
    flex: 1;
    text-align: center;
    padding: 6px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-muted);
    transition: 0.2s;
}

.mode-opt.active {
    background: var(--primary);
    color: white;
    font-weight: bold;
}

#animSettings {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: none;
    margin-top: 10px;
}

/* File List */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--surface);
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid transparent;
}

.file-thumb {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-details {
    flex: 1;
    overflow: hidden;
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Order Input Style */
.order-input {
    width: 40px !important;
    padding: 2px 4px !important;
    text-align: center;
    background: #0f172a;
    border: 1px solid var(--border);
    margin-right: 2px;
    height: 22px;
}

/* Preview */
#preview-wrap {
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
}

#preview-box {
    position: relative;
    background-color: #000;
    width: 100px;
    height: 100px;
    overflow: hidden;
    transition: width 0.3s, height 0.3s;
}

#bg-layer,
#slots-layer,
#stickers-layer {
    position: absolute;
    inset: 0;
}

#bg-layer {
    background-size: cover;
    background-position: center;
    pointer-events: none;
}

#slots-layer {
    z-index: 10;
    pointer-events: none;
}

#stickers-layer {
    z-index: 20;
    pointer-events: none;
}

.preview-slot {
    position: absolute;
    background: rgba(255, 255, 255, 0.03);
    box-sizing: border-box;
    overflow: hidden;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    pointer-events: auto;
    cursor: grab;
}

.preview-slot.selected {
    border: 2px solid #facc15;
    z-index: 50;
    background: rgba(250, 204, 21, 0.05);
}

.preview-slot img {
    position: absolute;
    transform-origin: center center;
    user-select: none;
    pointer-events: none;
}

.preview-sticker {
    position: absolute;
    cursor: grab;
    pointer-events: auto;
    border: 1px solid transparent;
    user-select: none;
}

.preview-sticker.selected {
    border: 2px solid #3b82f6;
    z-index: 100;
}

.preview-sticker img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
}

.slot-toolbar {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, 0.95);
    padding: 6px;
    border-radius: 12px;
    display: flex;
    gap: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(8px);
}

.slot-toolbar.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.btn-tool {
    background: transparent;
    color: #e2e8f0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 16px;
    padding: 0;
}

.btn-tool:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: scale(1.1);
}

.divider {
    width: 1px;
    background: var(--border);
    margin: 0 4px;
    height: 24px;
    align-self: center;
}

textarea {
    width: 100%;
    flex: 1;
    background: #020617;
    color: #a5f3fc;
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 11px;
    resize: none;
    transition: background 0.1s;
}

textarea.updating {
    background: #0f172a;
}

.badge-cache {
    font-size: 11px;
    color: var(--success);
    padding: 8px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 6px;
    display: none;
    margin-bottom: 10px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

input[type="file"] {
    display: none !important;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    background: rgba(255, 255, 255, 0.02);
}

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