* {
    box-sizing: border-box;
}

:root {
    --bg: #111214;
    --panel: #191b1f;
    --panel-2: #202329;
    --border: #30343b;
    --text: #e7e9ec;
    --muted: #858b95;
    --accent: #7aa2ff;
    --node: #25282e;
    --socket: #d7dbe2;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
    font: inherit;
}

button,
select {
    border: 1px solid var(--border);
    background: #202329;
    color: var(--text);
    border-radius: 4px;
    padding: 5px 8px;
}

button {
    cursor: pointer;
}

button:hover {
    border-color: #555c68;
}

.topbar {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: #15171a;
}

.topbar strong {
    font-size: 14px;
    margin-right: 8px;
}

.muted {
    color: var(--muted);
}

.toolbar,
.preview-tools {
    display: flex;
    align-items: center;
    gap: 7px;
}

.toolbar label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

.workspace {
    height: calc(100vh - 48px);
    display: grid;
    grid-template-columns: 360px 1fr 260px;
}

.preview-panel,
.graph-panel,
.inspector-panel {
    min-width: 0;
    background: var(--panel);
}

.preview-panel {
    border-right: 1px solid var(--border);
}

.inspector-panel {
    border-left: 1px solid var(--border);
}

.panel-title {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    color: #cfd3d9;
}

.panel-title.small {
    height: 30px;
    font-size: 12px;
}

#preview {
    height: 55%;
    min-height: 260px;
}

.texture-preview {
    border-top: 1px solid var(--border);
    padding-bottom: 10px;
}

#texture-canvas {
    display: block;
    width: min(280px, calc(100% - 20px));
    aspect-ratio: 1;
    image-rendering: pixelated;
    margin: 10px auto;
    border: 1px solid var(--border);
    background-color: #111;
    background-image:
        linear-gradient(45deg, #191b1f 25%, transparent 25%),
        linear-gradient(-45deg, #191b1f 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #191b1f 75%),
        linear-gradient(-45deg, transparent 75%, #191b1f 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

#graph {
    position: relative;
    width: 100%;
    height: calc(100% - 38px);
    overflow: hidden;
    background-color: #141619;
    background-image:
        radial-gradient(#2c3036 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: grab;
}

#graph.dragging {
    cursor: grabbing;
}

#connections {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

#graph-content {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
}

.node {
    position: absolute;
    width: 190px;
    min-height: 80px;
    border: 1px solid #3a3f47;
    border-radius: 6px;
    background: var(--node);
    box-shadow: 0 6px 18px #0005;
    user-select: none;
}

.node.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px #7aa2ff44, 0 8px 22px #0008;
}

.node-header {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: #2c3037;
    border-radius: 5px 5px 0 0;
    cursor: move;
}

.node-title {
    font-weight: 600;
}

.node-body {
    padding: 7px 8px;
    position: relative;
}

.socket-row {
    height: 22px;
    display: flex;
    align-items: center;
    position: relative;
}

.socket {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--socket);
    border: 1px solid #111;
    cursor: crosshair;
    flex: 0 0 auto;
}

.socket.output {
    margin-left: auto;
}

.socket.input {
    margin-right: 7px;
}

.socket-label {
    color: #b9bec7;
}

.node-control {
    width: 100%;
    margin: 3px 0;
}

.node input[type="number"],
.node input[type="text"] {
    width: 70px;
    border: 1px solid var(--border);
    background: #17191c;
    color: var(--text);
    border-radius: 3px;
    padding: 2px 4px;
}

.node input[type="color"] {
    width: 42px;
    height: 22px;
    padding: 0;
    border: 0;
    background: transparent;
}

.node select {
    width: 100%;
    padding: 3px;
}

.inspector-empty {
    color: var(--muted);
    padding: 12px;
}

.inspector {
    padding: 12px;
}

.inspector h3 {
    margin: 0 0 12px;
    font-size: 14px;
}

.field {
    margin-bottom: 12px;
}

.field label {
    display: block;
    margin-bottom: 4px;
    color: #aeb4bd;
}

.field input,
.field select {
    width: 100%;
}

.palette-row {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-bottom: 5px;
}

.palette-row input[type="color"] {
    width: 42px;
    height: 28px;
}

.node-menu {
    position: fixed;
    z-index: 20;
    width: 180px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #202329;
    box-shadow: 0 10px 30px #0009;
}

.node-menu button {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
}

.hidden {
    display: none;
}

.empty-hint {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    color: #555b65;
    pointer-events: none;
}

.check {
    color: var(--muted);
}

.check input {
    vertical-align: middle;
}
