/* ============================================================
   Darksteady Texture Atlas Gen — Style Sheet
   Design System: Neon Dark (matches Audio Trimmer PRO / Image Converter PRO)
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --bg-color: #0a0a0a;
    --surface-color: #141414;
    --surface-light: #222;
    --primary-color: #a3ff00;
    --primary-glow: rgba(163, 255, 0, 0.4);
    --danger-color: #ff4444;
    --text-color: #ffffff;
    --text-muted: #888899;
    --border-color: #333;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --accent: var(--primary-color);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
    min-height: 100vh;
    background-image: radial-gradient(
        circle at 50% 0%,
        rgba(163, 255, 0, 0.08) 0%,
        transparent 70%
    );
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- App Container --- */
.app-container {
    width: 100%;
    max-width: 1560px;
    padding: 2.5rem;
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 32px;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(163, 255, 0, 0.1);
    margin: 2rem;
}

/* --- Header --- */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -1px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge {
    font-size: 1rem;
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 800;
    box-shadow: 0 0 15px var(--primary-glow);
    line-height: 1.4;
}

.highlight {
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--primary-glow);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
    margin-top: 0.4rem;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* ============================================================
   Buttons (shared)
   ============================================================ */
.btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-color);
    outline: none;
    font-family: 'Outfit', sans-serif;
}

.btn-small {
    padding: 0.4rem;
    border-radius: 8px;
    background: var(--surface-light);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

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

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

.btn-primary {
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.9rem;
    gap: 0.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

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

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(163, 255, 0, 0.1);
}

.btn-danger-subtle-outline:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.15);
}

/* ============================================================
   Form controls (shared pattern)
   ============================================================ */
.pro-select {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888899' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.2rem;
    width: 100%;
}

.pro-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(163, 255, 0, 0.15);
}

.pro-select option {
    background: var(--surface-color);
    color: var(--text-color);
}

.pro-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pro-col > label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-light);
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.input-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(163, 255, 0, 0.1);
}

.input-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    user-select: none;
}

.size-input,
.filename-input {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    outline: none;
    font-variant-numeric: tabular-nums;
}

.size-input {
    width: 64px;
}

.filename-input {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.7rem 1rem;
    border-radius: 12px;
    width: 100%;
}

.filename-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(163, 255, 0, 0.15);
}

.filename-input::placeholder {
    color: var(--text-muted);
}

.pro-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    user-select: none;
}

.pro-checkbox:hover {
    color: var(--text-color);
}

.pro-checkbox input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
    background: transparent;
}

.pro-checkbox input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-glow);
}

.pro-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 5px;
    width: 4px;
    height: 9px;
    border: solid var(--bg-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* --- Pro Slider --- */
.pro-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    height: 4px;
    cursor: pointer;
}

.pro-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
}

.pro-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px var(--primary-glow);
    border: none;
}

.pro-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    border: none;
}

.pro-slider::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
    border: none;
}

/* --- Format Toggle --- */
.format-toggle {
    display: flex;
    background: var(--surface-light);
    border-radius: 12px;
    overflow: hidden;
    padding: 4px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.format-toggle input {
    display: none;
}

.format-toggle label {
    padding: 0.7rem 1.1rem;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: var(--transition);
    color: var(--text-muted);
}

.format-toggle input:checked + label {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- Count Badge --- */
.count-badge {
    font-size: 0.75rem;
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 800;
    min-width: 24px;
    text-align: center;
    display: inline-block;
    line-height: 1.4;
}

.format-tag {
    font-size: 0.75rem;
    background: rgba(163, 255, 0, 0.15);
    color: var(--primary-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.info-text {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.info-text svg {
    opacity: 0.6;
}

/* ============================================================
   Drop Zone (shared)
   ============================================================ */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(163, 255, 0, 0.05);
    box-shadow: 0 0 40px rgba(163, 255, 0, 0.1) inset;
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    pointer-events: none;
}

.drop-content p {
    font-size: 1.1rem;
    font-weight: 600;
}

.drop-content svg {
    color: var(--primary-color);
    filter: drop-shadow(0 0 15px var(--primary-glow));
    transition: var(--transition);
}

.drop-zone:hover .drop-content svg {
    transform: translateY(-8px) scale(1.08);
}

.drop-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* ============================================================
   SETUP SCREEN
   ============================================================ */
.setup-screen {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease;
}

.setup-block {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.setup-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.setup-block-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.setup-step {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--bg-color);
    font-weight: 800;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
}

.setup-block-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.setup-block-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.4;
}

.setup-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.setup-row.tight {
    gap: 0.5rem;
}

.dim-x {
    color: var(--text-muted);
    font-weight: 700;
}

.setup-dilate-check {
    margin-left: auto;
}

.custom-layer-row {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.custom-layer-row .filename-input {
    flex-grow: 1;
}

.custom-layer-row .btn-secondary {
    flex-shrink: 0;
    white-space: nowrap;
}

/* --- Chips (layer type selection) --- */
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.chip {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.6rem 1.1rem;
    border-radius: 30px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    padding-left: 1.8rem;
}

.chip::before {
    content: '';
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.4;
    transition: var(--transition);
}

.chip:hover {
    color: var(--text-color);
    border-color: var(--accent);
}

.chip.active {
    background: color-mix(in srgb, var(--accent) 15%, var(--surface-light));
    border-color: var(--accent);
    color: var(--text-color);
    box-shadow: 0 0 15px color-mix(in srgb, var(--accent) 30%, transparent);
}

.chip.active::before {
    opacity: 1;
    box-shadow: 0 0 8px var(--accent);
}

/* --- Preset cards --- */
.preset-card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
}

.preset-card {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: 'Outfit', sans-serif;
}

.preset-card:hover {
    border-color: rgba(163, 255, 0, 0.4);
}

.preset-card.active {
    border-color: var(--primary-color);
    background: rgba(163, 255, 0, 0.08);
    box-shadow: 0 0 15px rgba(163, 255, 0, 0.12);
}

.preset-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
}

.preset-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.setup-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* ============================================================
   EDITOR LAYOUT
   ============================================================ */
.editor {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    position: relative;
    align-items: flex-start;
    animation: fadeIn 0.4s ease;
}

/* --- Sidebar --- */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--surface-color);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-actions {
    display: flex;
    gap: 0.4rem;
}

/* --- Layer List --- */
.layer-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.3rem;
}

.layer-list::-webkit-scrollbar { width: 6px; }
.layer-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.layer-list { scrollbar-width: thin; scrollbar-color: var(--border-color) transparent; }

.layer-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.7rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-light);
    border: 1px solid transparent;
    animation: fileItemIn 0.25s ease both;
}

.layer-item:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.layer-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent);
    background: color-mix(in srgb, var(--accent) 8%, var(--surface-light));
}

.layer-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    flex-shrink: 0;
}

.layer-item .layer-dot {
    background: var(--accent);
}

.layer-name {
    flex-grow: 1;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-fill-badge {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.layer-item.active .layer-fill-badge {
    color: var(--accent);
}

.layer-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border-radius: 6px;
    opacity: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.layer-item:hover .layer-remove {
    opacity: 1;
}

.layer-remove:hover {
    color: var(--danger-color);
    background: rgba(255, 68, 68, 0.1);
}

.btn-add-layer {
    width: 100%;
    border-radius: 12px;
    gap: 0.5rem;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- Sidebar Settings (collapsible) --- */
.sidebar-settings {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
    margin-top: 0.3rem;
}

.sidebar-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.sidebar-settings-header h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
}

.sidebar-settings-header .chevron {
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-settings.collapsed .chevron {
    transform: rotate(-90deg);
}

.atlas-settings-body {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin-top: 1rem;
    overflow: hidden;
}

.sidebar-settings.collapsed .atlas-settings-body {
    display: none;
}

/* ============================================================
   MAIN EDITOR / ATLAS WORKSPACE
   ============================================================ */
.main-editor {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.layer-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0.9rem 1.3rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.active-layer-info {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-weight: 700;
    font-size: 1.05rem;
}

.normal-invert-row {
    font-size: 0.85rem;
}

.atlas-workspace {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Interactive Grid --- */
#atlas-grid {
    display: grid;
    gap: 3px;
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    background:
        repeating-conic-gradient(
            rgba(255, 255, 255, 0.03) 0% 25%,
            transparent 0% 50%
        ) 50% / 20px 20px;
    border-radius: 16px;
    padding: 3px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.5);
}

.grid-cell {
    position: relative;
    background: var(--surface-light);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-cell:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(163, 255, 0, 0.15);
    z-index: 2;
}

.grid-cell.filled {
    border-color: rgba(163, 255, 0, 0.35);
}

.grid-cell.drag-over {
    border-color: var(--primary-color);
    background: rgba(163, 255, 0, 0.12);
}

.grid-cell-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.grid-cell-empty-icon {
    color: var(--border-color);
    transition: var(--transition);
}

.grid-cell:hover .grid-cell-empty-icon {
    color: var(--primary-color);
}

.grid-cell-coord {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    pointer-events: none;
}

.grid-cell-model-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: rgba(10, 10, 10, 0.75);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.grid-cell-clear {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(10, 10, 10, 0.8);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    cursor: pointer;
}

.grid-cell:hover .grid-cell-clear {
    opacity: 1;
}

.grid-cell-clear:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
    background: rgba(255, 68, 68, 0.15);
}

/* --- Atlas full preview panel --- */
.atlas-preview-panel {
    background: var(--surface-light);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preview-wrapper {
    width: 100%;
    height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    background:
        repeating-conic-gradient(
            rgba(255, 255, 255, 0.03) 0% 25%,
            transparent 0% 50%
        ) 50% / 20px 20px;
}

.atlas-preview-wrapper {
    overflow: auto;
}

.atlas-preview-wrapper canvas {
    border-radius: 4px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.preview-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.image-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.zoom-panel {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-muted);
}

.zoom-panel .pro-slider {
    width: 120px;
}

.zoom-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: right;
}

/* ============================================================
   EXPORT PANEL
   ============================================================ */
.pro-export-panel {
    background: var(--surface-color);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pro-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    align-items: end;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.export-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    align-self: center;
}

.export-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* --- Progress Bar --- */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
}

.progress-info span:first-child { color: var(--text-muted); }
.progress-info span:last-child { color: var(--primary-color); }

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--surface-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #c8ff50);
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

#loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* ============================================================
   CELL MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    width: 100%;
    max-width: 560px;
    max-height: 88vh;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 1.8rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(163, 255, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1.3rem;
}

.modal-card::-webkit-scrollbar { width: 6px; }
.modal-card::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-header h3 span {
    color: var(--primary-color);
}

.modal-dropzone {
    padding: 2rem 1.5rem;
}

/* --- Assignment list --- */
.assign-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.assign-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem;
    border-radius: 12px;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    animation: fileItemIn 0.2s ease both;
}

.assign-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
}

.assign-info {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.assign-filename {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assign-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.assign-meta.auto-detected {
    color: var(--primary-color);
}

.assign-select {
    width: 150px;
    flex-shrink: 0;
    padding: 0.45rem 1.8rem 0.45rem 0.7rem;
    font-size: 0.78rem;
}

.assign-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    padding: 4px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}

.assign-remove:hover {
    color: var(--danger-color);
    background: rgba(255, 68, 68, 0.1);
}

.model-preview-wrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #050505;
}

#modal-model-preview {
    width: 100%;
    height: 220px;
    display: block;
    cursor: grab;
}

#modal-model-preview:active {
    cursor: grabbing;
}

.model-preview-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(10, 10, 10, 0.6);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    pointer-events: none;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.modal-footer-right {
    display: flex;
    gap: 0.8rem;
}

/* ============================================================
   Keyframes
   ============================================================ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@keyframes fileItemIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1300px) {
    .preset-card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1100px) {
    .editor {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
    }
    .layer-list {
        max-height: 220px;
    }
    .setup-grid-2 {
        grid-template-columns: 1fr;
    }
    .pro-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .app-container {
        padding: 1.2rem;
        border-radius: 20px;
        margin: 1rem;
    }
    h1 {
        font-size: 1.6rem;
    }
    .preset-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .setup-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }
    .modal-footer-right {
        justify-content: stretch;
    }
    .modal-footer-right .btn {
        flex: 1;
    }
    .preview-wrapper {
        height: 240px;
    }
}
