:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #0b0e12;
  color: #f7f9fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid #323a45;
  background: #1c232c;
  color: #f7f9fb;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  border-color: #6c7a89;
  background: #252e39;
}

button.primary {
  background: #f7f9fb;
  color: #07090c;
  border-color: #f7f9fb;
}

button.danger {
  color: #ff8b8b;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid #303943;
  background: #0f141a;
  color: #f7f9fb;
  border-radius: 5px;
  padding: 8px 10px;
}

input[type='color'] {
  padding: 3px;
}

label {
  display: grid;
  gap: 6px;
  color: #aeb8c5;
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 360px;
  height: 100vh;
}

.panel {
  min-width: 0;
  overflow: auto;
  border-color: #252d36;
  background: #10151c;
}

.panel.left {
  border-right: 1px solid #252d36;
}

.panel.right {
  border-left: 1px solid #252d36;
}

.panel-inner {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: #8c98a6;
  font-size: 13px;
}

.section {
  display: grid;
  gap: 12px;
}

.section-title {
  color: #e8edf2;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.grid-preset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-preset.active {
  border-color: #00f7ff;
  background: #12363c;
  color: #e8fdff;
  box-shadow: inset 0 0 0 1px #00f7ff;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid #303943;
  border-radius: 5px;
  padding: 8px 10px;
  background: #0f141a;
  color: #e8edf2;
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.check input {
  width: auto;
  min-height: auto;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: #07090d;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  border-bottom: 1px solid #252d36;
  background: #10151c;
}

.export-status {
  flex-basis: 100%;
  min-height: 18px;
  color: #8c98a6;
  font-size: 12px;
  font-weight: 760;
}

.topbar-title {
  min-width: 0;
  font-weight: 900;
}

.topbar-title small {
  display: block;
  color: #8c98a6;
  font-weight: 700;
}

.viewport {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  touch-action: none;
}

.canvas-wrap {
  display: grid;
  min-width: min-content;
  min-height: 100%;
  place-items: center;
}

.svg-host {
  background: #000;
  box-shadow: 0 0 0 1px #303943, 0 18px 50px rgba(0, 0, 0, 0.48);
  touch-action: none;
}

.svg-host svg {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
}

.zone-hit {
  cursor: move;
}

.resize-handle {
  cursor: grab;
}

.mobile-controls {
  display: grid;
  gap: 10px;
}

.pad-grid {
  display: grid;
  gap: 8px;
}

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

.size-pad {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.pad-grid button {
  min-height: 52px;
  padding: 0 8px;
  font-size: 14px;
}

.zone-list {
  display: grid;
  gap: 8px;
}

.zone-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  border: 1px solid #303943;
  border-radius: 6px;
  padding: 8px 10px;
  background: #0f141a;
  cursor: pointer;
}

.zone-item.active {
  border-color: #00f7ff;
  box-shadow: inset 0 0 0 1px #00f7ff;
}

.swatch {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 3px;
}

.zone-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-meta {
  color: #8c98a6;
  font-size: 12px;
  font-weight: 760;
}

.empty {
  color: #8c98a6;
  border: 1px dashed #303943;
  border-radius: 6px;
  padding: 14px;
}

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

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel.left,
  .panel.right {
    border: 0;
  }

  .panel {
    overflow: visible;
  }

  .stage {
    min-height: 64vh;
    order: -1;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .viewport {
    min-height: 56vh;
  }
}

@media (max-width: 560px) {
  .panel-inner,
  .viewport {
    padding: 12px;
  }

  .grid-2,
  .grid-3,
  .grid-preset-row,
  .toggle-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .button-row button {
    flex: 1 1 46%;
  }

  .stage {
    min-height: 72vh;
  }

  .viewport {
    min-height: 62vh;
    padding: 10px;
  }

  .topbar .button-row {
    width: 100%;
  }

  .topbar .button-row button {
    min-height: 48px;
  }

  .size-pad {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
