:root {
  color-scheme: dark;
  --bg: #101010;
  --panel: #171717;
  --panel-raised: #1d1d1d;
  --control: #242424;
  --control-hover: #2c2c2c;
  --line: #2a2a2a;
  --line-bright: #3a3a3a;
  --text: #f1f1f1;
  --muted: #8e8e8e;
  --accent: #ff641e;
  --accent-dark: #1c0800;
  --danger: #ff695e;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-header {
  position: relative;
  z-index: 10;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-button--brand {
  width: auto;
  gap: 5px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}

.icon-button--brand svg {
  width: 16px;
  height: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-divider {
  width: 1px;
  height: 20px;
  margin: 0 5px;
  background: var(--line-bright);
}

.icon-action,
.zoom-button,
.tool-button,
.secondary-button,
.primary-button,
.text-button {
  border: 0;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, opacity 120ms ease, transform 120ms ease;
}

.icon-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  background: transparent;
}

.icon-action:hover:not(:disabled),
.zoom-button:hover,
.tool-button:hover {
  background: var(--control-hover);
}

.icon-action:disabled {
  cursor: default;
  opacity: 0.28;
}

.icon-action svg,
.tool-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.secondary-button,
.primary-button {
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 650;
}

.secondary-button {
  background: var(--control);
}

.secondary-button:hover {
  background: var(--control-hover);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  color: var(--accent-dark);
}

.primary-button:hover {
  background: #ff7c3f;
}

.primary-button:active,
.secondary-button:active,
.tool-button:active,
.icon-action:active {
  transform: translateY(1px);
}

.app-shell {
  height: calc(100% - 58px);
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 260px;
}

.panel {
  position: relative;
  z-index: 5;
  background: var(--panel);
}

.tools-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-right: 1px solid var(--line);
}

.tool-list,
.panel-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.tool-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.tool-button.is-active {
  background: var(--accent);
  color: var(--accent-dark);
}

.color-control {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.color-control::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
  pointer-events: none;
}

.color-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.color-swatch {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #f4f4f5;
}

.checker-toggle span {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #a8a8a8 25%, transparent 25%),
    linear-gradient(-45deg, #a8a8a8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #a8a8a8 75%),
    linear-gradient(-45deg, transparent 75%, #a8a8a8 75%);
  background-position: 0 0, 0 5px, 5px -5px, -5px 0;
  background-size: 10px 10px;
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 34px;
  background: #111;
}

.canvas-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 54px;
  background-image: radial-gradient(circle at center, #181818 0, #111 68%);
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.canvas-wrap {
  --canvas-bg: #f7f7f7;
  position: relative;
  flex: none;
  width: 576px;
  height: 576px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 0.45), 0 0 0 1px #000;
  background-color: var(--canvas-bg);
  background-image:
    linear-gradient(45deg, #d8d8d8 25%, transparent 25%),
    linear-gradient(-45deg, #d8d8d8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8d8d8 75%),
    linear-gradient(-45deg, transparent 75%, #d8d8d8 75%);
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  touch-action: none;
  user-select: none;
}

.canvas-wrap.is-dark-bg {
  --canvas-bg: #292929;
  background-image: none;
}

#paintCanvas,
.slice-guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#paintCanvas {
  cursor: none;
}

.slice-guides {
  overflow: visible;
  pointer-events: none;
}

.slice-guides path {
  fill: none;
  stroke: rgb(255 100 30 / 0.92);
  stroke-width: 1;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 2px rgb(255 100 30 / 0.35));
}

.slice-guides .tile-cell {
  fill: rgb(255 100 30 / 0.025);
  stroke: none;
}

.slice-guides .tile-cell:nth-child(even) {
  fill: rgb(255 100 30 / 0.055);
}

.slice-guides.is-hidden {
  display: none;
}

.cursor-preview {
  position: absolute;
  z-index: 4;
  display: none;
  box-sizing: border-box;
  border: 2px solid #fff;
  background: rgb(255 100 30 / 0.38);
  box-shadow:
    0 0 0 2px #111,
    inset 0 0 0 1px rgb(255 100 30 / 0.95);
  pointer-events: none;
}

.cursor-preview.is-visible {
  display: block;
}

.statusbar {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.intro-seo {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.intro-seo a {
  color: inherit;
}

.intro-seo a:hover {
  color: var(--accent);
}

.status-center {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-control {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 2px;
}

.zoom-control span {
  width: 44px;
  text-align: center;
}

.zoom-button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}

.settings-panel {
  overflow-y: auto;
  border-left: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.settings-section {
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-section h2 {
  margin: 0 0 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.color-section-title output {
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

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

.palette-color {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 5px;
  background: var(--swatch);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}

.palette-color:hover {
  z-index: 1;
  transform: scale(1.12);
}

.palette-color.is-active::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1.5px solid #fff;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.75);
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.text-button:hover {
  color: var(--accent);
}

.field-label {
  display: block;
  margin: 13px 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.input-with-suffix {
  height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--control);
}

.input-with-suffix:focus-within {
  border-color: var(--accent);
}

.input-with-suffix input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  padding: 0 2px 0 10px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.input-with-suffix span {
  padding-right: 10px;
  color: var(--muted);
  font-size: 11px;
}

.field-hint {
  margin: 7px 0 0;
  color: #666;
  font-size: 9px;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
}

.range-row output {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--range-fill, 50%), var(--line-bright) var(--range-fill, 50%));
}

input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  appearance: none;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line-bright);
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 15px;
  cursor: pointer;
}

.switch-row--compact {
  margin: 0 0 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.switch-row > span {
  min-width: 0;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 11px;
  font-weight: 600;
}

.switch-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  position: relative;
  width: 32px;
  height: 18px;
  flex: none;
  border-radius: 9px;
  background: var(--line-bright);
  transition: background 130ms ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #aaa;
  transition: transform 130ms ease, background 130ms ease;
}

.switch-row input:checked + i {
  background: var(--accent);
}

.switch-row input:checked + i::after {
  background: var(--accent-dark);
  transform: translateX(14px);
}

.switch-row input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.export-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 90px rgb(0 0 0 / 0.75);
}

.export-dialog::backdrop {
  background: rgb(0 0 0 / 0.7);
  backdrop-filter: blur(5px);
}

.export-dialog form {
  padding: 20px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
}

.dialog-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-header .icon-action {
  margin: -7px -7px 0 0;
}

.export-preview {
  height: 190px;
  display: grid;
  place-items: center;
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #202020;
  background-image:
    linear-gradient(45deg, #292929 25%, transparent 25%),
    linear-gradient(-45deg, #292929 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #292929 75%),
    linear-gradient(-45deg, transparent 75%, #292929 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.export-preview canvas {
  width: 156px;
  height: 156px;
  image-rendering: pixelated;
  box-shadow: 0 7px 22px rgb(0 0 0 / 0.35);
}

.export-fields {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
}

.export-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
}

.export-fields select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--control);
  color: var(--text);
  font-size: 11px;
}

.quality-field {
  grid-column: 1 / -1;
}

.quality-field > span {
  display: flex;
  justify-content: space-between;
}

.quality-field[hidden] {
  display: none;
}

.dialog-export {
  width: 100%;
  height: 40px;
  margin-top: 12px;
}

.dialog-export:first-of-type {
  margin-top: 20px;
}

.dialog-export span {
  opacity: 0.6;
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 48px;
  padding: 9px 13px;
  border: 1px solid var(--line-bright);
  border-radius: 7px;
  background: #202020;
  color: var(--text);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.4);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 800px) {
  .app-shell {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .settings-panel {
    position: fixed;
    z-index: 12;
    top: 58px;
    right: 0;
    bottom: 0;
    width: 240px;
    box-shadow: -10px 0 30px rgb(0 0 0 / 0.35);
  }

  .workspace {
    grid-column: 2;
  }

  .status-center {
    display: none;
  }

  .statusbar {
    grid-template-columns: 1fr auto 1fr;
  }

  .intro-seo {
    display: none;
  }
}

@media (max-width: 570px) {
  .settings-panel {
    display: none;
  }

  .app-shell {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .secondary-button,
  .header-divider {
    display: none;
  }

  .app-header {
    padding-inline: 12px;
  }

  .canvas-stage {
    padding: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
