* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    display: flex; height: 100vh; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px; color: #ddd; background: #1a1a1a;
}

#sidebar {
    width: 280px; background: #2a2a2a; padding: 12px;
    overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
    border-right: 1px solid #444; flex-shrink: 0;
}
#viewport { flex: 1; position: relative; }
#viewport canvas { display: block; width: 100%; height: 100%; }

#drop-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; color: #fff; font-size: 24px;
    pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
#drop-overlay.active { opacity: 1; }

h3 { color: #aaa; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.sep { height: 1px; background: #444; margin: 4px 0; }

label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
label span { white-space: nowrap; }
label .val { color: #8cf; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; cursor: pointer; }
label .val:hover { text-decoration: underline; }
.val-input {
    width: 52px; background: #333; border: 1px solid #6af; border-radius: 2px;
    color: #8cf; font-size: 12px; text-align: right; padding: 0 4px;
    font-variant-numeric: tabular-nums; outline: none;
}
input[type="range"] { flex: 1; accent-color: #6af; }
input[type="file"] { display: none; }
select {
    background: #333; color: #ddd; border: 1px solid #555;
    border-radius: 3px; padding: 3px 6px; font-size: 12px;
}

.btn {
    padding: 5px 10px; background: #444; border: 1px solid #555;
    border-radius: 3px; color: #ddd; cursor: pointer; font-size: 12px;
}
.btn:hover { background: #555; }
.btn.primary { background: #357; border-color: #468; }
.btn.danger { background: #733; border-color: #844; }
.btn.axis-x { background: #6b3000; border-color: #8a4500; color: #ffb380; }
.btn.axis-x:hover { background: #7d3a00; }
.btn.axis-y { background: #2a5200; border-color: #3a6a00; color: #b5ff80; }
.btn.axis-y:hover { background: #356200; }
.btn.axis-z { background: #003366; border-color: #004488; color: #80ccff; }
.btn.axis-z:hover { background: #004477; }

.mode-group { display: flex; gap: 4px; }
.mode-btn {
    flex: 1; padding: 6px; background: #333; border: 1px solid #555;
    border-radius: 3px; color: #aaa; cursor: pointer; text-align: center; font-size: 12px;
}
.mode-btn.active { background: #357; color: #fff; border-color: #68a; }

#patch-list { display: flex; flex-direction: column; gap: 2px; }
.patch-row {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 6px; border-radius: 3px; cursor: pointer;
}
.patch-row:hover { background: #383838; }
.patch-row.active { background: #2a3a4a; }
.patch-swatch { width: 16px; height: 16px; border-radius: 2px; flex-shrink: 0; }
.patch-info { flex: 1; font-size: 12px; }
.patch-count { color: #888; font-size: 11px; }

#status {
    color: #888; font-size: 11px; margin-top: auto;
    padding-top: 8px; border-top: 1px solid #444;
}

.row { display: flex; gap: 4px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

#toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #444; color: #eee; padding: 8px 18px; border-radius: 6px;
    font-size: 13px; opacity: 0; transition: opacity 0.2s;
    pointer-events: none; z-index: 200; white-space: nowrap;
}
#toast.show { opacity: 1; }
#toast.warning { background: #7a5a00; color: #ffe066; }

#no-mesh-msg {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: #666; font-size: 16px; user-select: none;
}
#no-mesh-msg p { margin: 8px 0; }
#no-mesh-msg .hint { font-size: 13px; color: #555; }

#loading-msg {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: #aaa; font-size: 18px; display: none;
}
#version {
    position: fixed; bottom: 6px; right: 10px;
    color: #555; font-size: 10px; pointer-events: none; z-index: 50;
}
