:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #11171e;
  --panel-2: #172028;
  --line: #2b3742;
  --text: #f4f7f8;
  --muted: #9eaab3;
  --green: #53f4a7;
  --blue: #52b8ff;
  --amber: #f2c15c;
  --red: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 12%, rgba(83, 244, 167, 0.16), transparent 28rem),
    radial-gradient(circle at 88% 82%, rgba(82, 184, 255, 0.12), transparent 26rem),
    var(--bg);
  color: var(--text);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  background: #151d25;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #52616d;
  background: #1b2630;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: rgba(83, 244, 167, 0.55);
  background: #123626;
  color: #dffdec;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  width: 100vw;
  height: 100vh;
}

.toolbar {
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(17, 23, 30, 0.92);
  box-shadow: 0 0 36px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(83, 244, 167, 0.5);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 10px, rgba(83, 244, 167, 0.28) 11px, transparent 12px),
    linear-gradient(transparent 10px, rgba(82, 184, 255, 0.24) 11px, transparent 12px),
    #101820;
  background-size: 12px 12px;
  box-shadow: inset 0 0 0 5px rgba(83, 244, 167, 0.06);
}

h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.control-row,
.pattern-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.control-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: min(520px, calc(100% - 36px));
  color: #d9e1e4;
  pointer-events: none;
}

.hud span {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  padding: 7px 10px;
  background: rgba(8, 11, 15, 0.72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.hud strong {
  color: var(--green);
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(60vh, 1fr);
    min-height: 100vh;
    height: auto;
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }

  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage {
    height: calc(100vh - 260px);
    min-height: 420px;
  }
}

@media (max-width: 520px) {
  .control-grid,
  .control-row,
  .pattern-bar {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 1.1rem;
  }

  .stage {
    height: calc(100vh - 336px);
    min-height: 360px;
  }
}
