:root {
  --bg: #0b0c10;
  --panel: #11141a;
  --fg: #e6edf3;
  --muted: #93a1b3;
  --accent: #3ea6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, PingFang SC, Noto Sans CJK SC, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg);
  background: linear-gradient(180deg, #0b0c10, #0b0c10 60%, #0f1218);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 12, 16, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #1f2430;
}

.bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.bar label {
  font-size: 12px;
  color: var(--muted);
}

.bar button,
.bar input[type="file"]::file-selector-button {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid #222a36;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.bar button:hover,
.bar input[type="file"]::file-selector-button:hover {
  border-color: #2b3546;
}

.bar input[type="range"] {
  width: 200px;
}

.range-presets {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.range-presets button {
  padding: 5px 10px;
  font-size: 12px;
}

.zoom-readout {
  font-size: 12px;
  color: var(--muted);
  min-width: 88px;
}

.wrap {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  min-height: calc(100vh - 56px);
}

.side {
  border-right: 1px solid #1f2430;
  background: #0f1218;
  padding: 12px;
  overflow: auto;
  min-width: 0;
}

.side h3 {
  margin: 8px 0;
  font-size: 14px;
  color: var(--muted);
}

textarea {
  width: 100%;
  height: 260px;
  resize: vertical;
  background: #0b0f16;
  color: var(--fg);
  border: 1px solid #212a3a;
  border-radius: 12px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.hint {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed #2b3546;
  border-radius: 10px;
}

.hint-block + .hint-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(67, 84, 110, 0.45);
}

.hint-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #c6d4ef;
}

.hint ul {
  margin: 0;
  padding-left: 16px;
}

.hint li {
  margin-bottom: 6px;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #122035;
  color: #a7c7ff;
  font-size: 12px;
  margin-right: 6px;
}

.kbd {
  padding: 0 6px;
  border: 1px solid #2b3546;
  border-radius: 6px;
  font-size: 12px;
}

canvas {
  width: 100%;
  display: block;
  background: #0a0d12;
  cursor: default;
}

main {
  min-height: calc(100vh - 56px);
  min-width: 0;
  position: relative;
}

body.side-collapsed .wrap {
  grid-template-columns: 0 1fr;
}

body.side-collapsed .side {
  padding: 0;
  border-right: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.side-drawer {
  position: absolute;
  top: 12px;
  left: 0;
  z-index: 5;
  width: 28px;
  height: 56px;
  border: 1px solid #283349;
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: rgba(15, 18, 24, 0.92);
  color: #cfe1ff;
  cursor: pointer;
  display: block;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.side-drawer::before {
  content: '‹';
  display: block;
  font-size: 20px;
  line-height: 52px;
  text-align: center;
}

body.side-collapsed .side-drawer::before {
  content: '›';
}

#testBadge {
  position: fixed;
  right: 10px;
  bottom: 10px;
  background: #0f1218;
  border: 1px solid #283349;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: #a4c2ff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

#testPanel {
  position: fixed;
  right: 10px;
  bottom: 44px;
  width: 380px;
  max-height: 45vh;
  overflow: auto;
  background: #0f1218;
  border: 1px solid #283349;
  border-radius: 12px;
  display: none;
}

#testPanel h4 {
  margin: 10px;
  font-size: 13px;
  color: #c6d4ef;
}

#testPanel pre {
  margin: 0 10px 10px;
  padding: 10px;
  background: #0b0f16;
  color: #d7e3ff;
  border: 1px solid #1f2a3d;
  border-radius: 10px;
  white-space: pre-wrap;
}

#layerMenu {
  position: fixed;
  display: none;
  background: #0f1218;
  border: 1px solid #283349;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

#colorMenu {
  position: fixed;
  display: none;
  width: 228px;
  background: #0f1218;
  border: 1px solid #283349;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 21;
}

#colorMenu {
  position: fixed;
  display: none;
  width: 228px;
  background: #0f1218;
  border: 1px solid #283349;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  z-index: 21;
}

#layerMenu h5 {
  margin: 4px 6px 8px;
  font-size: 12px;
  color: #a4c2ff;
}

#colorMenu h5 {
  margin: 2px 2px 10px;
  font-size: 12px;
  color: #a4c2ff;
}

#colorMenu h5 {
  margin: 2px 2px 10px;
  font-size: 12px;
  color: #a4c2ff;
}

#layerMenu button {
  width: 180px;
  display: block;
  margin: 6px 0;
  background: #152033;
  color: #e6edf3;
  border: 1px solid #283349;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}

#colorMenu button {
  width: 100%;
  display: block;
  margin: 8px 0 0;
  background: #152033;
  color: #e6edf3;
  border: 1px solid #283349;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}

#colorMenu button {
  width: 100%;
  display: block;
  margin: 8px 0 0;
  background: #152033;
  color: #e6edf3;
  border: 1px solid #283349;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}

#layerMenu button.secondary {
  background: #101a2a;
  color: #cfe1ff;
}

#colorMenu button.secondary {
  background: #101a2a;
  color: #cfe1ff;
}

#colorMenu button.secondary {
  background: #101a2a;
  color: #cfe1ff;
}

#layerMenu button:hover {
  border-color: #34507a;
}

#colorMenu button:hover {
  border-color: #34507a;
}

#colorMenu button:hover {
  border-color: #34507a;
}

#layerMenu button.danger {
  background: #2a0e14;
  border-color: #5c1b24;
  color: #ffb4c0;
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  padding: 0;
}

.color-swatch:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  padding: 0;
}

.color-swatch:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

#toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 30;
  display: none;
  background: #0f1218;
  color: #cfe1ff;
  border: 1px solid #2b3d5c;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

@media (max-width: 960px) {
  .wrap {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .side {
    border-right: 0;
    border-bottom: 1px solid #1f2430;
  }

  main {
    min-height: 60vh;
  }
}
