:root {
  --bg: #0f141b;
  --panel: #1a2430;
  --panel-hi: #223040;
  --text: #e8eef6;
  --muted: #9aabbe;
  --accent: #4ac6b7;
  --accent-2: #f4ac45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Tahoma", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, #26384b 0%, var(--bg) 45%), #0b1015;
}

.app-shell {
  min-height: 100vh;
  padding: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(120deg, #16212d, #1f2e3f);
  border: 1px solid #2f445d;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.topbar h1 {
  margin: 0;
  letter-spacing: 0.03em;
}

.topbar p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

button, select, input[type="color"], input[type="number"], input[type="range"] {
  background: #0f1a25;
  color: var(--text);
  border: 1px solid #38506b;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr 360px;
  gap: 1rem;
  align-items: start;
}

#layers-panel {
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}

.panel,
.canvas-panel {
  background: color-mix(in srgb, var(--panel) 85%, #000 15%);
  border: 1px solid #2a3d55;
  border-radius: 12px;
  padding: 0.9rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.6rem;
}

.panel label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.panel label input,
.panel label select {
  display: block;
  margin-top: 0.2rem;
  width: 100%;
}

.range-with-value {
  display: grid;
  grid-template-columns: 1fr 84px;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.2rem;
}

.range-with-value input {
  margin-top: 0;
}

.canvas-panel {
  display: flex;
  flex-direction: column;
}

.canvas-wrap {
  flex: 1;
  min-height: 320px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #111;
  border: 1px solid #374a62;
  position: relative;
  overflow: auto;
}

.canvas-wrap.checker {
  background-image:
    linear-gradient(45deg, #242424 25%, transparent 25%),
    linear-gradient(-45deg, #242424 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #242424 75%),
    linear-gradient(-45deg, transparent 75%, #242424 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#preview {
  image-rendering: pixelated;
  border-radius: 4px;
}

.status-bar {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-debug {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  opacity: 0.9;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-list {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.layer-card {
  border: 1px solid #38506b;
  background: #131d28;
  border-radius: 10px;
  padding: 0.55rem;
}

.layer-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 0.4rem;
}

.layer-name-input {
  width: 100%;
  min-width: 0;
}

.layer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.layer-header-actions button {
  padding: 0.2rem 0.45rem;
  font-size: 0.78rem;
}

.layer-card.collapsed header {
  margin-bottom: 0;
}

.layer-card.collapsed .layer-grid {
  display: none;
}

.layer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.layer-grid label {
  margin: 0;
  font-size: 0.85rem;
}

.layer-grid .full {
  grid-column: 1 / -1;
}

.stop-row {
  display: grid;
  grid-template-columns: 1fr 90px auto;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    min-height: 420px;
  }
}
