body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
}

#ui {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(20, 22, 26, 0.92);
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid #2a2f36;
    width: 300px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    box-sizing: border-box;
    font-size: 12px;
    color: #d8dbe0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

#ui h1 {
    margin: 0 0 14px 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: #f0f2f5;
}

.ui-section {
    margin-bottom: 6px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid #2a2f36;
    border-radius: 6px;
}

.ui-section[open] {
    background: rgba(255, 255, 255, 0.03);
    padding-bottom: 10px;
}

.ui-section > summary {
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #6ea8ff;
    padding: 4px 0;
    margin: 0;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ui-section > summary::-webkit-details-marker {
    display: none;
}

.ui-section > summary::before {
    content: '▶';
    font-size: 8px;
    color: #6ea8ff;
    transition: transform 0.12s ease;
    display: inline-block;
}

.ui-section[open] > summary::before {
    transform: rotate(90deg);
}

.ui-section[open] > summary {
    margin-bottom: 10px;
}

.ui-section > summary:hover {
    color: #9dc5ff;
}

.mesh-info-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-fallback {
    font-size: 10px;
    color: #7a8088;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 10px 0 4px;
    border-top: 1px dashed #2a2f36;
    padding-top: 8px;
}

/* Preview embed: no chrome at all, canvas fills the frame. */
body.preview-mode #ui {
    display: none;
}
body.preview-mode #canvas {
    width: 100vw;
    height: 100vh;
    cursor: grab;
}
body.preview-mode #canvas:active {
    cursor: grabbing;
}

.hint {
    font-size: 10px;
    color: #6a7078;
    line-height: 1.4;
    margin: 4px 0 2px;
}

/* Canvas highlight while an archive is dragged over it. */
#canvas.drag-over {
    outline: 2px dashed #4a90d9;
    outline-offset: -6px;
}

.preset-current {
    font-size: 10px;
    color: #7fd18a;
    margin: -4px 0 0;
    padding: 0 2px;
    word-break: break-all;
    min-height: 12px;
}
.preset-current.loading {
    color: #ffc35a;
}
.preset-current.error {
    color: #ff9999;
}

.mesh-info-list:empty {
    display: none;
}

#ui label {
    display: block;
    font-size: 11px;
    margin: 8px 0 4px;
    color: #a8adb5;
}

#ui label:first-child {
    margin-top: 0;
}

.slider-label {
    display: flex !important;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 10px;
}

.slider-val {
    color: #e8ecf1;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    font-size: 11px;
}

#ui input[type="file"] {
    display: block;
    width: 100%;
    color: #d8dbe0;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 11px;
    box-sizing: border-box;
}

#ui input[type="file"]::file-selector-button {
    background: #2a2f36;
    color: #e8ecf1;
    border: 1px solid #3a4048;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-right: 8px;
}

#ui input[type="file"]::file-selector-button:hover {
    background: #363c44;
}

#ui input[type="file"]:disabled {
    cursor: not-allowed;
    color: #555;
}

#ui select {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    background: #2a2f36;
    color: #e8ecf1;
    border: 1px solid #3a4048;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 11px;
    box-sizing: border-box;
}

#ui select:disabled {
    background: #22262b;
    color: #555;
}

#ui input[type="range"] {
    width: 100%;
    margin: 0 0 4px;
    accent-color: #6ea8ff;
    box-sizing: border-box;
}

#ui button {
    background: #2a2f36;
    color: #e8ecf1;
    border: 1px solid #3a4048;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    display: block;
    width: 100%;
    margin-bottom: 6px;
    transition: background 0.12s;
}

#ui button:hover:not(:disabled) {
    background: #363c44;
    border-color: #4a515a;
}

#ui button.active {
    background: #2a6dd9;
    color: #fff;
    border-color: #4585ff;
}

#ui button:disabled {
    background: #22262b;
    color: #555;
    border-color: #2a2f36;
    cursor: not-allowed;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

#ui .button-row button {
    margin: 0;
    padding: 4px 8px;
    font-size: 11px;
    flex: 1 1 60px;
    width: auto;
    min-width: 60px;
    display: inline-block;
}

.inline-check {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    margin: 0 !important;
    padding: 4px 6px;
    background: #2a2f36;
    border: 1px solid #3a4048;
    border-radius: 4px;
    font-size: 11px;
    color: #d8dbe0;
    cursor: pointer;
}

.inline-check input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

#status {
    font-size: 11px;
    color: #c5cbd3;
    margin: 0 0 10px 0;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    border-left: 2px solid #6ea8ff;
    line-height: 1.3;
}

.mesh-info-list {
    font-size: 11px;
    color: #d8dbe0;
}

.mesh-info-list > div {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #2a2f36;
    border-radius: 6px;
    word-break: break-all;
}

.mesh-info-list strong {
    color: #e8ecf1;
    font-weight: 600;
    font-size: 12px;
}

.mesh-vflip-button {
    background: #2a2f36;
    color: #d8dbe0;
    border: 1px solid #3a4048;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    margin: 6px 6px 0 0;
    display: inline-block;
}

.mesh-vflip-button:hover {
    background: #363c44;
}

.texture-picker {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tex-missing {
    color: #ff9999;
    font-size: 10px;
}

.tex-loaded {
    color: #7fd18a;
    font-size: 10px;
}

.tex-button {
    background: #2a2f36;
    color: #e8ecf1;
    border: 1px solid #3a4048;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    display: inline-block;
}

.tex-button:hover {
    background: #363c44;
}

#texturePreview {
    margin-bottom: 8px;
}

#texturePreview img {
    max-width: 100%;
    max-height: 180px;
    border: 1px solid #2a2f36;
    border-radius: 4px;
    background: #222;
}

#texturePreview .preview-label {
    font-size: 10px;
    color: #a8adb5;
    margin-bottom: 4px;
}

#canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* Sidebar scrollbar */
#ui::-webkit-scrollbar {
    width: 8px;
}
#ui::-webkit-scrollbar-track {
    background: transparent;
}
#ui::-webkit-scrollbar-thumb {
    background: #3a4048;
    border-radius: 4px;
}
#ui::-webkit-scrollbar-thumb:hover {
    background: #4a515a;
}
