:root {
  --bg: #09090b;
  --panel: #09090b;
  --panel-muted: #a1a1aa;
  --panel-text: #fafafa;
  --accent: #f4f4f5;
  --input-bg: #18181b;
  --input-border: #27272a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 18% 8%, #13131a 0%, #0a0a0f 44%, var(--bg) 100%);
  color: #e4e4e7;
}

.layout {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
}

.panel {
  position: fixed;
  top: 0;
  left: 0;
  width: min(360px, 92vw);
  height: 100vh;
  z-index: 3;
  background: linear-gradient(180deg, #0c0c11 0%, var(--panel) 100%);
  color: var(--panel-text);
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid #27272a;
}

.panel h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 8px 0 18px;
  color: var(--panel-muted);
  font-size: 0.9rem;
}

section {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(24, 24, 27, 0.8);
  border: 1px solid #27272a;
}

section h2 {
  margin: 0 0 10px;
  font-size: 0.93rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d4d4d8;
}

label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 9px;
  color: #d4d4d8;
}

.label-head {
  display: block;
  margin-bottom: 2px;
}

.help-text {
  display: block;
  margin: 0 0 4px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #a1a1aa;
}

label .label-head + input,
label .label-head + textarea,
label .label-head + select {
  margin-top: 0;
}

.label-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid #3f3f46;
  background: #111114;
  color: #fafafa;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

input,
textarea,
select,
button {
  width: 100%;
  margin-top: 5px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: #f6fbff;
  padding: 7px 9px;
  font-size: 0.86rem;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 8px;
  border-radius: 999px;
  border: 1px solid #30303a;
  background: linear-gradient(90deg, #23232d 0%, #151521 100%);
  padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #d4d4d8;
  background: #f6fbff;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #d4d4d8;
  background: #f6fbff;
  cursor: pointer;
}

input[type="color"] {
  height: 37px;
  padding: 4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 10px;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #d4d4d8;
}

.check-row span {
  color: #d4d4d8;
  font-size: 0.82rem;
}

button {
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.07);
}

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

button.primary {
  background: linear-gradient(180deg, #ffffff 0%, var(--accent) 100%);
  border-color: #d4d4d8;
  color: #09090b;
  font-weight: 600;
}

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

.stage {
  position: fixed;
  inset: 0;
  display: block;
  padding: 0;
  background: #09090b;
  z-index: 1;
}

.canvas-wrap {
  width: 100vw;
  height: 100vh;
}

.canvas-side {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: min(310px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding-top: 0;
}

#view {
  display: block;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  background: #020617;
  box-shadow: none;
  border: none;
}

.status {
  min-height: 72px;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #e4e4e7;
  white-space: pre-line;
}

@media (max-width: 980px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .layout {
    width: 100%;
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }

  .stage {
    position: relative;
    inset: auto;
    z-index: 1;
    order: 2;
    background: #09090b;
  }

  .canvas-wrap {
    width: 100%;
    height: auto;
  }

  #view {
    width: 100%;
    height: 100dvh;
    min-height: 420px;
    max-height: none;
  }

  .panel {
    position: relative;
    top: auto;
    left: auto;
    z-index: 1;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 14px;
    border-right: none;
    border-top: 1px solid #27272a;
    order: 1;
  }

  .canvas-side {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    z-index: 1;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 12px 14px 14px;
  }

  .row {
    grid-template-columns: 1fr;
  }
}
