:root {
  --bg: #0f141b;
  --panel: #161d26;
  --panel-2: #1e2732;
  --line: #2b3644;
  --text: #e7edf4;
  --muted: #93a1b3;
  --accent: #4da3ff;
  --warn: #ffb020;
  --bad: #ff5a52;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

#app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  height: 100vh;
}

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
}

#panel { border-right: none; border-left: 1px solid var(--line); }

h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.sub { margin: 2px 0 16px; color: var(--muted); font-size: 12px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.count { color: var(--muted); font-weight: 400; font-size: 12px; }

section { margin-bottom: 20px; }

.seg { display: flex; gap: 6px; }
.seg button, .row button, .grid button {
  flex: 1 1 auto;
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.seg button:hover, .row button:hover, .grid button:hover { border-color: var(--accent); }
.seg button.active, .grid button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

.row { display: flex; gap: 6px; margin-top: 8px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid button { padding: 6px 8px; font-size: 13px; text-align: left; }

.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: #ffffff; }
.swatch[data-color="#d01012"] { background: #d01012; }
.swatch[data-color="#0055bf"] { background: #0055bf; }
.swatch[data-color="#f5cd2f"] { background: #f5cd2f; }
.swatch[data-color="#237841"] { background: #237841; }
.swatch[data-color="#f4f4f4"] { background: #f4f4f4; }
.swatch[data-color="#1b2a34"] { background: #1b2a34; }
.swatch[data-color="#a0a5a9"] { background: #a0a5a9; }
.swatch[data-color="#6c6e68"] { background: #6c6e68; }
.swatch[data-color="#fe8a18"] { background: #fe8a18; }
.swatch[data-color="#bbe90b"] { background: #bbe90b; }
.swatch[data-color="#e4cd9e"] { background: #e4cd9e; }
.swatch[data-color="#582a12"] { background: #582a12; }
.swatch[data-color="#0a3463"] { background: #0a3463; }
.swatch[data-color="#e4adc8"] { background: #e4adc8; }

.field { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.field input {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  background: #0d1218;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}
.row .field { flex: 1 1 0; margin-bottom: 0; }

#stage { position: relative; overflow: hidden; background: #dbeafe; }
#view-root { position: absolute; inset: 0; }
#view-root canvas { display: block; width: 100%; height: 100%; }

#hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(15, 20, 27, 0.82);
  color: #fff;
  font-size: 12px;
}

#banner {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(15, 20, 27, 0.88);
  color: #fff;
  font-size: 12px;
}

#toast {
  position: absolute;
  right: 12px;
  top: 12px;
  max-width: 50%;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 176, 32, 0.95);
  color: #1b1200;
  font-size: 12px;
}

.files { list-style: none; margin: 8px 0 0; padding: 0; }
.files button {
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  margin-bottom: 4px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.files button:hover { border-color: var(--accent); }

.notfound { max-width: 520px; margin: 12vh auto; padding: 24px; text-align: center; }
.notfound h1 { font-size: 56px; margin: 0 0 8px; }
.notfound a { color: var(--accent); }

@media (max-width: 1100px) {
  #app { grid-template-columns: 240px minmax(0, 1fr) 280px; }
}
