:root {
  color-scheme: dark;
  --bg: #0f1116;
  --panel: #181b22;
  --panel-2: #20242d;
  --line: #333946;
  --text: #f5f2ea;
  --muted: #a7adbb;
  --accent: #d8b45f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0f1116;
  color: var(--text);
  font-family:
    Inter, Pretendard, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

.topbar,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1;
}

h2 {
  font-size: 15px;
}

.primary-action,
.icon-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, var(--accent), white 18%);
  border-radius: 8px;
  background: var(--accent);
  color: #15120a;
  font-weight: 900;
  cursor: pointer;
}

.primary-action {
  gap: 9px;
  min-height: 44px;
  padding: 0 16px;
}

.icon-action {
  width: 34px;
  height: 34px;
  font-size: 22px;
}

.secondary-action {
  min-height: 38px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

.secondary-action.danger {
  border-color: rgb(255 120 120 / 0.35);
  color: #ffb7b7;
}

.stage-shell {
  display: grid;
  place-items: center;
  min-height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #151820 25%, transparent 25%),
    linear-gradient(-45deg, #151820 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151820 75%),
    linear-gradient(-45deg, transparent 75%, #151820 75%);
  background-color: #101219;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
  overflow: hidden;
  padding: 18px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 150px);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.45);
  cursor: grab;
}

canvas:active {
  cursor: grabbing;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  overflow: auto;
  max-height: calc(100vh - 44px);
  padding-right: 2px;
}

.panel-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 15px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

textarea {
  min-height: 74px;
  padding: 10px 11px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

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

input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  padding: 4px;
}

.file-drop {
  position: relative;
  grid-template-columns: 38px 1fr;
  align-items: center;
  min-height: 72px;
  border: 1px dashed color-mix(in srgb, var(--accent), white 12%);
  border-radius: 8px;
  background: #151820;
  padding: 13px;
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #16120a;
  font-size: 24px;
  font-weight: 900;
}

small {
  display: block;
  margin-top: 3px;
  color: #858c9a;
  font-size: 11px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12151b;
  padding: 4px;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent), transparent 45%);
}

.color-grid,
.number-grid,
.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.layer-list {
  display: grid;
  gap: 7px;
}

.layer-item {
  display: grid;
  grid-template-columns: 1fr 30px;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #151820;
  color: var(--text);
  padding: 4px 4px 4px 10px;
}

.layer-item.is-active {
  border-color: var(--accent);
  background: var(--panel-2);
}

.layer-select {
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.layer-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.08);
  color: var(--muted);
  cursor: pointer;
}

.layer-editor {
  display: grid;
  gap: 10px;
}

.editor-group {
  display: grid;
  gap: 10px;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.035);
  padding: 10px;
}

.editor-group h3 {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0;
}

.style-button-row {
  display: grid;
  grid-template-columns: 42px 42px 1fr;
  gap: 8px;
  align-items: end;
}

.mini-toggle {
  display: block;
  color: var(--text);
}

.mini-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mini-toggle span {
  display: grid;
  place-items: center;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  font-weight: 900;
  cursor: pointer;
}

.mini-toggle input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.toggle-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}

.toggle-row input {
  accent-color: var(--accent);
}

@media (max-width: 980px) {
  .studio {
    grid-template-columns: 1fr;
  }

  .panel {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .studio {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-action {
    width: 100%;
  }

  .stage-shell {
    min-height: 260px;
    padding: 10px;
  }
}
