:root {
  color-scheme: dark;
  --panel: rgba(10, 13, 17, 0.9);
  --panel-border: rgba(59, 130, 246, 0.22);
  --muted: #a7b2c4;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --danger: #f27568;
  --stage: #050607;
  --ink: #edf3f2;
  --button-text-size: 12px;
  --button-text-weight: 800;
  --uv-editor-width: 50vw;
  --range-track: #303a45;
  --range-fill: #70a7ff;
  --range-thumb: #f7f8fb;
  --scrollbar-track: #121a24;
  --scrollbar-thumb: #6fa7fb;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--stage);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

.icon-sprite {
  display: none;
}

.app-shell {
  width: 100%;
  height: 100%;
}

.topbar {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: grid;
  width: min(312px, calc(100vw - var(--uv-editor-width) - 36px));
  max-height: calc(100vh - 36px);
  gap: 12px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.028));
  box-shadow: none;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
}

.topbar::-webkit-scrollbar {
  width: 18px;
  height: 18px;
}

.topbar::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--scrollbar-track);
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.18);
}

.topbar::-webkit-scrollbar-thumb {
  min-height: 72px;
  border: 6px solid var(--scrollbar-track);
  border-radius: 999px;
  background: var(--scrollbar-thumb);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  color: #f7fbff;
  font-size: 18px;
  font-weight: 760;
  line-height: 1;
  text-align: center;
}

.brand-logo {
  display: block;
  width: min(100%, 275px);
  height: auto;
  max-height: 73px;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(94, 216, 255, 0.22);
  border-radius: 12px;
  background:
    linear-gradient(rgba(59, 130, 246, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.22) 1px, transparent 1px),
    linear-gradient(180deg, rgba(8, 13, 19, 0.86), rgba(5, 8, 13, 0.72));
  background-size: 11px 11px, 11px 11px, auto;
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.55);
}

.brand-mark::before {
  left: 9px;
  right: 9px;
  top: 20px;
  height: 2px;
}

.brand-mark::after {
  top: 9px;
  bottom: 9px;
  left: 20px;
  width: 2px;
}

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

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

.divider {
  grid-column: 1 / -1;
  height: 1px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.1);
}

.icon-button,
.text-button,
.field.compact input,
.field.compact select,
.field.name-field input,
.field.checker-field select {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #eef6f3;
  font-size: var(--button-text-size);
  font-weight: var(--button-text-weight);
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.icon-button {
  display: inline-grid;
  width: 100%;
  min-width: 0;
  height: 38px;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.text-button {
  display: inline-flex;
  width: auto;
  min-width: 64px;
  height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
}

.icon-button:hover,
.text-button:hover,
.field.compact input:hover,
.field.compact select:hover,
.field.name-field input:hover,
.field.checker-field select:hover {
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(59, 130, 246, 0.22);
  color: #edf6ff;
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

.icon-button:focus-visible,
.text-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid rgba(112, 167, 255, 0.48);
  outline-offset: 2px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.icon-button.is-active,
.text-button.is-active {
  border-color: rgba(59, 130, 246, 0.78);
  background: rgba(59, 130, 246, 0.3);
  color: #edf6ff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.rotate-button {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.atlas-tools .rotate-button {
  flex-basis: 82px;
  width: 82px;
  min-width: 82px;
}

.icon-button.rotate-button svg {
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  stroke-width: 1.65;
}

.icon-button.rotate-button span {
  color: currentColor;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.field {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 38px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.field.compact {
  grid-column: span 2;
}

.field.compact input,
.field.compact select,
.field.name-field input,
.field.checker-field select,
.export-field .icon-button {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #eef6f3;
  text-align: center;
}

.field.compact select,
.field.checker-field select {
  appearance: none;
  -webkit-appearance: none;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
  background:
    linear-gradient(45deg, transparent 50%, #a7b2c4 50%) calc(100% - 13px) 16px / 5px 5px no-repeat,
    linear-gradient(135deg, #a7b2c4 50%, transparent 50%) calc(100% - 8px) 16px / 5px 5px no-repeat,
    rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.field.compact select:hover,
.field.checker-field select:hover {
  background:
    linear-gradient(45deg, transparent 50%, #edf6ff 50%) calc(100% - 13px) 16px / 5px 5px no-repeat,
    linear-gradient(135deg, #edf6ff 50%, transparent 50%) calc(100% - 8px) 16px / 5px 5px no-repeat,
    rgba(59, 130, 246, 0.22);
}

.field.compact select option,
.field.checker-field select option {
  background: #101827;
  color: #edf6ff;
}

.field.name-field,
.field.checker-field,
.field.size-field,
.export-field {
  height: auto;
  grid-template-columns: minmax(92px, 140px);
  grid-template-rows: auto 38px;
  min-width: 140px;
  align-items: stretch;
  gap: 5px;
}

.field.name-field span,
.field.checker-field span,
.field.size-field span,
.export-field span,
.slider-field > span:first-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.field.name-field input {
  height: 38px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #eef6f3;
}

.field.checker-field {
  grid-template-columns: minmax(96px, 118px);
  min-width: 118px;
}

.field.size-field {
  grid-template-columns: minmax(92px, 116px);
}

.export-field {
  width: 64px;
  grid-template-columns: 64px;
  min-width: 64px;
}

.atlas-tools .export-field .icon-button {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
}

.atlas-tools .export-field:hover .icon-button,
.atlas-tools .export-field:focus-within .icon-button,
.atlas-tools .export-field .icon-button:hover {
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(59, 130, 246, 0.22);
  color: #edf6ff;
  transform: translateY(-1px);
}

.about-button {
  display: inline-flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  color: #c7d2e1;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.about-button:hover {
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(59, 130, 246, 0.22);
  color: #edf6ff;
  transform: translateY(-1px);
}

.about-button:active {
  transform: translateY(0);
}

.about-button:focus-visible {
  outline: 2px solid rgba(112, 167, 255, 0.48);
  outline-offset: 2px;
}

.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 12, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.about-overlay[hidden] {
  display: none;
}

.about-dialog {
  display: grid;
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(111, 167, 251, 0.32);
  border-radius: 12px;
  background: rgba(10, 13, 17, 0.98);
  box-shadow: 0 28px 74px rgba(0, 0, 0, 0.56);
}

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
}

.about-header h2 {
  margin: 0;
  color: #edf6ff;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.15;
}

.about-close {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  color: #edf6ff;
  font-size: 24px;
  line-height: 1;
}

.about-body {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

.about-lead,
.about-credit {
  margin: 0;
  color: #dce7f3;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.55;
}

.about-credit {
  margin-top: 12px;
  color: var(--muted);
}

.about-credit a,
.about-notes a {
  color: #70a7ff;
  text-decoration: none;
}

.about-credit a:hover,
.about-notes a:hover {
  color: #9bc3ff;
  text-decoration: underline;
}

.about-notes {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: #dce7f3;
  font-size: 13px;
  line-height: 1.55;
}

.about-notes h1,
.about-notes h2,
.about-notes h3 {
  margin: 18px 0 8px;
  color: #edf6ff;
  line-height: 1.2;
}

.about-notes h1:first-child,
.about-notes h2:first-child,
.about-notes h3:first-child {
  margin-top: 0;
}

.about-notes h1 {
  font-size: 19px;
}

.about-notes h2 {
  font-size: 16px;
}

.about-notes h3 {
  color: #c9d8e7;
  font-size: 14px;
}

.about-notes ul {
  display: grid;
  gap: 7px;
  margin: 8px 0 0;
  padding-left: 20px;
}

.about-notes p {
  margin: 8px 0;
}

.workspace {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-columns: minmax(320px, calc(100vw - var(--uv-editor-width))) var(--uv-editor-width);
  gap: 0;
}

.source-pane {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 1fr;
  background: var(--stage);
}

.atlas-pane {
  position: relative;
  z-index: 3;
  display: block;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--panel-border);
  background: rgba(7, 10, 14, 0.96);
  box-shadow: -20px 0 54px rgba(0, 0, 0, 0.38);
}

.atlas-floating-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  left: 18px;
  z-index: 6;
  display: grid;
  max-height: calc(100% - 36px);
  gap: 12px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.028));
  box-shadow: none;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
  -webkit-backdrop-filter: blur(14px) saturate(1.08);
  backdrop-filter: blur(14px) saturate(1.08);
}

.atlas-floating-panel::-webkit-scrollbar {
  width: 18px;
  height: 18px;
}

.atlas-floating-panel::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--scrollbar-track);
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.18);
}

.atlas-floating-panel::-webkit-scrollbar-thumb {
  min-height: 72px;
  border: 6px solid var(--scrollbar-track);
  border-radius: 999px;
  background: var(--scrollbar-thumb);
}

.atlas-pane .pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.atlas-pane .pane-header h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: #edf6ff;
  font-size: 16px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.atlas-pane .pane-header span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.atlas-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  padding-bottom: 2px;
}

.atlas-tools .icon-button {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
}

.atlas-tools .text-button {
  flex: 0 0 auto;
}

.atlas-title-tools,
.atlas-edit-tools,
.atlas-right-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
  min-width: 0;
}

.atlas-title-tools {
  align-items: flex-end;
  flex: 0 1 auto;
}

.atlas-edit-tools {
  flex: 1 1 492px;
}

.atlas-right-tools {
  flex: 1 1 520px;
  justify-content: flex-end;
  margin-left: auto;
}

.atlas-tools .field.compact {
  flex: 0 1 116px;
  grid-column: auto;
  min-width: 92px;
}

.slider-field {
  display: grid;
  grid-template-columns: minmax(150px, 210px);
  grid-template-rows: auto 38px;
  align-items: stretch;
  gap: 5px;
  height: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.slider-control {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 30px;
  align-items: center;
  gap: 8px;
  height: 38px;
}

.slider-field input[type="range"] {
  --range-progress: 0%;
  width: 100%;
  height: 32px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  -moz-appearance: none;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.slider-field input[type="range"]:focus {
  outline: none;
}

.slider-field input[type="range"]:focus-visible {
  outline: 2px solid rgba(112, 167, 255, 0.48);
  outline-offset: 2px;
}

.slider-field input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--range-fill) 0 var(--range-progress),
    var(--range-track) var(--range-progress) 100%
  );
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  -webkit-appearance: none;
  background: var(--range-thumb);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.22);
}

.slider-field input[type="range"]::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--range-track);
}

.slider-field input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--range-fill);
}

.slider-field input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 50%;
  background: var(--range-thumb);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.22);
}

.slider-field input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.slider-field output {
  color: #edf6ff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.canvas-menu {
  position: fixed;
  z-index: 20;
  min-width: 150px;
  padding: 6px;
  border: 1px solid rgba(59, 130, 246, 0.38);
  border-radius: 8px;
  background: rgba(14, 18, 22, 0.98);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.canvas-menu[hidden] {
  display: none;
}

.canvas-menu button {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #eef6f3;
  cursor: pointer;
  font-size: var(--button-text-size);
  font-weight: var(--button-text-weight);
  padding: 0 10px;
  text-align: left;
}

.canvas-menu button:hover,
.canvas-menu button:focus-visible {
  background: rgba(59, 130, 246, 0.22);
  outline: none;
}

.canvas-menu svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  touch-action: none;
}

#sourceCanvas {
  background: var(--stage);
  cursor: crosshair;
}

#atlasCanvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--stage);
  cursor: default;
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell,
  .workspace {
    height: auto;
    min-height: 100%;
  }

  .topbar {
    position: static;
    width: auto;
    max-height: none;
    margin: 10px;
    padding: 12px;
    grid-template-columns: 1fr;
    border-radius: 16px;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(520px, 62vh) minmax(620px, 78vh);
    padding: 0 10px 10px;
  }

  .atlas-pane {
    border: 1px solid var(--panel-border);
    border-radius: 0;
    box-shadow: none;
  }

  .atlas-floating-panel {
    top: 10px;
    right: 10px;
    left: 10px;
    max-height: calc(100% - 20px);
    padding: 12px;
    border-radius: 16px;
  }

  .atlas-tools .icon-button {
    flex-basis: 56px;
    width: 56px;
    min-width: 56px;
  }

  .atlas-title-tools,
  .atlas-edit-tools,
  .atlas-right-tools {
    flex-basis: 100%;
    margin-left: 0;
  }
}
