:root {
    --bg: #07090b;
    --panel: #0c0f12;
    --panel-2: #12171b;
    --panel-3: #192026;
    --line: #293139;
    --line-strong: #46515c;
    --text: #f4f5f2;
    --muted: #c2c8c9;
    --dim: #7d878d;
    --canvas: #0e1114;
    --surface-hover: #1c2329;
    --left-rail-width: 250px;
    --right-rail-width: 286px;
    --font-ui: "Pixelify Sans", "Segoe UI", sans-serif;
}

*,
*::before,
*::after { letter-spacing: 0 !important; }

body,
button,
input,
select,
textarea { font-family: var(--font-ui); }

body { background: #050709; font-size: 13px; }
.app { position: relative; background: var(--bg); }

.left-panel,
.right-panel,
.import-card .modal-body,
.export-card .modal-body,
.context-toolbar {
    scrollbar-color: auto;
    scrollbar-width: auto;
}

@supports not selector(::-webkit-scrollbar) {
    .left-panel,
    .right-panel,
    .import-card .modal-body,
    .export-card .modal-body,
    .context-toolbar {
        scrollbar-color: #46515c #080b0d;
        scrollbar-width: thin;
    }
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: #050709;
    border: 1px solid #1d242a;
}

*::-webkit-scrollbar-thumb {
    min-height: 32px;
    background: #313a42;
    border: 2px solid #050709;
    border-radius: 0;
    box-shadow: inset 2px 0 0 var(--green), inset -1px 0 0 #171c20;
}

*::-webkit-scrollbar-thumb:hover {
    background: #46515c;
    box-shadow: inset 3px 0 0 var(--green), inset -1px 0 0 #171c20;
}

*::-webkit-scrollbar-thumb:active { background: var(--green); box-shadow: none; }
*::-webkit-scrollbar-button,
*::-webkit-scrollbar-button:single-button { display: none; width: 0; height: 0; background: transparent; }
*::-webkit-scrollbar-corner { background: #050709; }

.left-panel,
.right-panel,
.import-card .modal-body,
.export-card .modal-body,
.context-toolbar {
    scrollbar-gutter: stable;
}

@media (min-width: 901px) {
    .app { grid-template-columns: var(--left-rail-width) minmax(420px, 1fr) var(--right-rail-width); }
}

.header,
.left-panel,
.right-panel,
.footer { background: var(--panel); }

.header { border-color: var(--line); box-shadow: 0 2px 0 #050709; }
.header h1 { font-family: var(--font-ui); font-size: 19px; }
.header .subtitle { color: var(--dim); font-size: 12px; }

.rail-group {
    background: #0f1316;
    border-color: var(--line);
    box-shadow: inset 3px 0 0 var(--group-accent), 0 1px 0 #050709;
}

.rail-heading {
    min-height: 38px;
    background: #090c0f;
    border-color: var(--line);
    font-family: var(--font-ui);
    font-size: 13px;
}

.rail-heading i { font-size: 18px; }
.panel-section { border-color: #22292f; }
.panel-label { color: #d2d5d3; font-size: 12px; }
.panel-label i { flex: 0 0 auto; font-size: 16px; }
.project-group .source-panel .panel-label i { color: var(--blue); }

button,
select,
input[type="number"],
.brush-value,
.stat-box,
.upload-zone,
.modal-card,
.modal-choice,
.source-import,
.primary-mode,
.advanced-tools,
.context-toolbar,
.transform-gizmo,
.object-row,
.object-empty,
.inspector-details,
.texture-mode,
.texture-mode-panel { border-radius: 0 !important; }

button,
summary,
.upload-zone { transition: color 80ms linear, background-color 80ms linear, border-color 80ms linear, transform 60ms linear; }
button:active:not(:disabled) { transform: translateY(1px); }

button:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
.panel-resizer:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

.header-action,
.info-toggle,
.grid-size-btn,
.pixel-size-btn,
.view-btn,
.toggle-btn,
.tool-action,
.context-btn,
.gizmo-mode,
.tool-jump,
.tool-btn {
    min-width: 0;
    color: var(--muted);
    background: var(--panel-2);
    border-color: var(--line);
    font-family: var(--font-ui);
    font-size: 12px;
}

button > i { flex: 0 0 auto; font-size: 16px; }
button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.source-import,
.primary-mode,
.advanced-tools,
.object-row,
.object-empty,
.texture-mode-panel { background: var(--panel-2); border-color: var(--line); }

.source-import small,
.primary-mode span,
.edit-help,
.object-empty,
.source-mode-head small,
.modal-choice small { color: #929ca0; }

.grid-size-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pixel-filter-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.pixel-filter-row .pixel-size-btn { min-height: 46px; padding: 4px 2px; flex-direction: column; gap: 2px; font-size: 10px; }
.pixel-filter-row .pixel-size-btn i { font-size: 15px; }
.tool-actions { gap: 5px; }
.tool-actions .tool-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.brush-row .tool-action { display: inline-grid; place-items: center; }

.primary-mode { background: #102019; border-color: #315544; }
.primary-mode strong { font-family: var(--font-ui); font-size: 13px; }
.primary-mode span { font-size: 11px; }
.advanced-tools summary { font-size: 12px; }
.edit-help { font-size: 10px; }

.active-tool-readout {
    --active-tool-color: var(--green);
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 48px;
    margin-bottom: 6px;
    padding: 7px 9px;
    color: var(--active-tool-color);
    background: #09110e;
    border: 1px solid color-mix(in srgb, var(--active-tool-color) 42%, #1d2429);
    box-shadow: inset 3px 0 0 var(--active-tool-color);
}

.active-tool-readout > i { flex: 0 0 auto; font-size: 22px; }
.active-tool-readout span { display: grid; gap: 2px; min-width: 0; }
.active-tool-readout small { color: var(--dim); font-size: 9px; text-transform: uppercase; }
.active-tool-readout strong { overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.editor-tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-bottom: 10px; }
.editor-tool-grid .tool-btn { position: relative; min-height: 38px; justify-content: flex-start; padding: 6px 9px; border-color: var(--line); }
.editor-tool-grid .primary-tool { grid-column: 1 / -1; min-height: 44px; }
.editor-tool-grid .tool-btn.active { border-color: currentColor; box-shadow: inset 3px 0 0 currentColor, inset 0 0 0 1px #050709; }
.editor-tool-grid .tool-btn.active::after { content: "✓"; position: absolute; top: 4px; right: 6px; font-size: 10px; font-weight: 900; }
.editor-tool-grid .tool-btn[data-tool="select"] i,
.editor-tool-grid .tool-btn[data-tool="voxel-add"] i { color: var(--green); }
.editor-tool-grid .tool-btn[data-tool="rotate"] i { color: var(--blue); }
.editor-tool-grid .tool-btn[data-tool="paint"] i,
.editor-tool-grid .tool-btn[data-tool="voxel-remove"] i { color: var(--red); }
.editor-tool-grid .tool-btn[data-tool="eraser"] i { color: var(--orange); }
.editor-tool-grid .tool-btn[data-tool="picker"] i { color: var(--cyan); }
.editor-tool-grid .tool-btn[data-tool="bucket"] i { color: var(--yellow); }

.tool-subhead { display: flex; align-items: center; gap: 5px; margin: 9px 0 5px; color: var(--dim); font-size: 10px; text-transform: uppercase; }
.tool-subhead i { color: var(--green); font-size: 14px; }
.edit-group .brush-row,
.edit-group .tool-actions,
.edit-group .slice-row { display: grid; }
.edit-group .slice-status { display: block; }

.context-toolbar {
    max-width: min(820px, calc(100vw - var(--left-rail-width) - var(--right-rail-width) - 34px));
    padding: 5px;
    gap: 5px;
    overflow: hidden;
    background: #0d1215;
    border: 1px solid var(--line-strong);
    box-shadow: 3px 3px 0 #050709;
}

.context-title { font-family: var(--font-ui); font-size: 12px; }
.transform-gizmo { background: #090d0f; border: 1px solid var(--line); }

.toggle-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.toggle-btn { width: 100%; justify-content: center; padding-inline: 7px; }
#toggle-outer-outline { grid-column: 1 / -1; }
.view-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.view-btn { padding-inline: 4px; }

.slider-row { display: grid; grid-template-columns: auto minmax(70px, 1fr) auto; }
input[type="range"] {
    width: 100%;
    height: 16px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track { height: 5px; background: #293139; border: 1px solid #46515c; }
input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; appearance: none; -webkit-appearance: none; background: var(--yellow); border: 2px solid #0a0d0f; border-radius: 0; }
input[type="range"]::-moz-range-track { height: 4px; background: #293139; border: 1px solid #46515c; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--yellow); border: 2px solid #0a0d0f; border-radius: 0; }

select,
input[type="number"] { color: var(--text); background: #090d10; border: 1px solid var(--line-strong); }
.color-input { background: #090d10; }

.modal-backdrop { background: rgba(2, 4, 5, .88); }
.modal-card { background: #0c1013; border: 1px solid var(--line-strong); box-shadow: 8px 8px 0 #020304; }
.modal-head { background: #080b0d; border-color: var(--line); }
.modal-head strong { font-family: var(--font-ui); font-size: 14px; }
.modal-body { background: #0c1013; }
.upload-zone { background: #0a0e11; }
.upload-zone:hover { background: #11191a; }

.export-card { width: min(860px, calc(100vw - 28px)); }
.export-card .modal-body { max-height: min(82vh, 760px); overflow-y: auto; }
.export-body {
    display: grid;
    grid-template-columns: 256px minmax(280px, 1fr);
    gap: 12px;
}

.export-preview-wrap {
    display: grid;
    align-content: start;
    gap: 7px;
}

.export-preview-wrap canvas {
    width: 100%;
    aspect-ratio: 1;
    background: #070a0c;
    border: 1px solid var(--line-strong);
    image-rendering: pixelated;
}

.export-preview-wrap > span { color: var(--dim); font-size: 11px; text-align: center; }
.export-settings { display: grid; align-content: start; gap: 10px; }
.export-pixel-summary {
    display: grid;
    gap: 5px;
    padding: 9px;
    background: #080b0d;
    border: 1px solid var(--line);
    box-shadow: inset 3px 0 0 var(--green);
}

.export-pixel-summary > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--dim);
    font-size: 11px;
}

.export-pixel-summary strong { color: var(--text); font-weight: 700; text-align: right; }
.export-pixel-summary small { padding-top: 5px; color: #91a09b; border-top: 1px solid #1d2429; font-size: 10px; line-height: 1.35; }
.control-note { display: flex; align-items: flex-start; gap: 6px; margin-top: 7px; color: var(--dim); font-size: 10px; line-height: 1.35; }
.control-note i { flex: 0 0 auto; margin-top: 1px; color: var(--yellow); font-size: 14px; }
.export-control { display: grid; gap: 6px; }
.export-control > label,
.export-control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.export-control label i,
.export-control-label i { color: var(--cyan); font-size: 16px; }
.export-control output { margin-left: auto; color: var(--cyan); }
.export-control select { width: 100%; min-height: 36px; padding: 6px 9px; }
.export-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.export-direction {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    background: var(--panel-2);
    border: 1px solid var(--line);
    font-size: 12px;
}

.export-direction.active { color: #08282a; background: var(--cyan); border-color: var(--cyan); }
.export-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.export-checks label {
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    color: var(--muted);
    background: #0a0e11;
    border: 1px solid var(--line);
    font-size: 12px;
    cursor: pointer;
}

.export-checks input { width: 14px; height: 14px; accent-color: var(--cyan); }
.export-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.export-actions button {
    min-height: 56px;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--muted);
    background: var(--panel-2);
    border: 1px solid var(--line);
    text-align: left;
}

.export-actions button:hover { color: var(--text); background: var(--surface-hover); border-color: var(--cyan); }
.export-actions button > i { color: var(--cyan); font-size: 21px; }
.export-actions strong,
.export-actions small { display: block; }
.export-actions strong { color: var(--text); font-size: 12px; text-transform: uppercase; }
.export-actions small { margin-top: 3px; color: var(--dim); font-size: 10px; }
.export-actions button:disabled { opacity: .42; cursor: wait; }
.export-status { grid-column: 1 / -1; min-height: 18px; color: var(--cyan); }
.export-status.error { color: var(--red); }
.export-card.busy .export-preview-wrap { opacity: .65; }

.footer { color: var(--dim); border-color: var(--line); font-size: 10px; }
.footer span { display: inline-flex; align-items: center; gap: 5px; }
.footer i { color: var(--muted); font-size: 14px; }
.footer kbd { color: var(--text); background: #161c20; border-color: var(--line-strong); font-family: var(--font-ui); }

.panel-resizer {
    position: absolute;
    z-index: 40;
    top: 58px;
    bottom: 34px;
    width: 9px;
    cursor: col-resize;
    touch-action: none;
}

.panel-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    width: 1px;
    background: var(--line);
    transition: background-color 80ms linear, box-shadow 80ms linear;
}

.panel-resizer::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 3px;
    z-index: 1;
    width: 3px;
    height: 30px;
    background: repeating-linear-gradient(to bottom, var(--line-strong) 0 3px, transparent 3px 6px);
    transform: translateY(-50%);
}

.panel-resizer:hover::after,
.panel-resizer:focus-visible::after,
.is-resizing-panel .panel-resizer::after { background: var(--cyan); box-shadow: 0 0 0 1px #16363a; }
.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.is-resizing-panel .panel-resizer::before { background: repeating-linear-gradient(to bottom, var(--cyan) 0 3px, transparent 3px 6px); }
.panel-resizer-left { left: calc(var(--left-rail-width) - 4px); }
.panel-resizer-right { right: calc(var(--right-rail-width) - 4px); }
.is-resizing-panel { cursor: col-resize; user-select: none; }

@media (max-width: 900px) {
    .panel-resizer { display: none; }
    .context-toolbar { max-width: calc(100vw - 275px); }
}

@media (max-width: 560px) {
    .header h1 { font-size: 15px; }
    .header .subtitle { display: none; }
    .project-actions { display: flex; }
    .project-actions .header-action { width: 34px; padding: 0; justify-content: center; }
    .project-actions .header-action span { display: none; }
    .rail-heading { font-size: 11px; }
    .panel-label { font-size: 10px; }
    .toggle-row { grid-template-columns: 1fr; }
    .context-toolbar { max-width: calc(100vw - 84px); }
    .export-body { grid-template-columns: 1fr; }
    .export-preview-wrap { width: min(220px, 100%); justify-self: center; }
    .export-actions { grid-template-columns: 1fr; }
}
