:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-soft: #141414;
  --panel: rgba(16, 16, 16, 0.9);
  --panel-border: rgba(106, 106, 106, 0.28);
  --text: #e2e2e2;
  --muted: #9a9a9a;
  --accent: #55f2c4;
  --accent-2: #7aa6ff;
  --ring: rgba(255, 255, 255, 0.08);
  --ray: rgba(255, 255, 255, 0.12);
  --back-gap: 162px;
  --panel-base: 320px;
  --panel-scale: 0.75;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Helvetica", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, rgba(130, 130, 130, 0.2), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(190, 190, 190, 0.18), transparent 45%),
    var(--bg);
}

button,
input,
select,
textarea {
  font-family: "Helvetica", sans-serif;
}

#app {
  display: grid;
  grid-template-columns: calc(var(--panel-base) * var(--panel-scale)) 1fr;
  height: 100vh;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  overflow-y: auto;
  overflow-x: hidden;
}

.panel {
  scrollbar-width: none;
}

.panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.panel-inner {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transform: scale(var(--panel-scale));
  transform-origin: top left;
  width: calc(100% / var(--panel-scale));
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 9px;
}

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  margin-bottom: var(--back-gap);
  margin-left: -12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.back-arrow {
  display: block;
}

.back-link:hover {
  color: var(--text);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  width: max-content;
}

.title-mark {
  display: block;
  width: 66%;
  height: auto;
  margin-top: calc(var(--back-gap) * -0.5);
  margin-bottom: 18px;
}

.title {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

.block {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c9c9c9;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatches.empty {
  display: none;
}

.color-swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  cursor: pointer;
}

.color-swatch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="number"] {
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 14, 14, 0.8);
  color: var(--text);
  font-size: 14px;
}

input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 4px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 14, 14, 0.8);
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  height: 18px;
  cursor: pointer;
  --range-progress: 0%;
  --range-progress-px: 0px;
  --range-track-height: 6px;
  --range-fill-height: 2px;
  --range-track-color: rgba(255, 255, 255, 0.22);
  --range-fill-color: rgba(255, 255, 255, 0.55);
  --range-thumb-size: 12px;
  --range-track-radius: 999px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: var(--range-track-height);
  border-radius: var(--range-track-radius);
  background:
    linear-gradient(var(--range-fill-color), var(--range-fill-color))
      0 50% / var(--range-progress-px) var(--range-fill-height) no-repeat,
    linear-gradient(
        to right,
        transparent 0,
        transparent var(--range-progress-px),
        var(--range-track-color) var(--range-progress-px),
        var(--range-track-color) 100%
      )
      0 50% / 100% var(--range-track-height) no-repeat;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--range-thumb-size);
  height: var(--range-thumb-size);
  border-radius: 999px;
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.35);
  margin-top: calc((var(--range-track-height) - var(--range-thumb-size)) / 2);
}

input[type="range"]::-moz-range-track {
  height: var(--range-track-height);
  background:
    linear-gradient(var(--range-fill-color), var(--range-fill-color))
      0 50% / var(--range-progress-px) var(--range-fill-height) no-repeat,
    linear-gradient(
        to right,
        transparent 0,
        transparent var(--range-progress-px),
        var(--range-track-color) var(--range-progress-px),
        var(--range-track-color) 100%
      )
      0 50% / 100% var(--range-track-height) no-repeat;
  border-radius: var(--range-track-radius);
}

input[type="range"]::-moz-range-progress {
  height: var(--range-fill-height);
  background: transparent;
  border-radius: var(--range-track-radius);
}

input[type="range"]::-moz-range-thumb {
  width: var(--range-thumb-size);
  height: var(--range-thumb-size);
  border-radius: 999px;
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

select {
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 14, 14, 0.8);
  color: var(--text);
  font-size: 14px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #9a9a9a;
}

input:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button {
  padding: 10px 12px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 20, 20, 0.85);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.15s ease, border 0.15s ease, background 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
}

button.primary {
  background: linear-gradient(135deg, rgba(180, 180, 180, 0.22), rgba(110, 110, 110, 0.18));
  border-color: rgba(200, 200, 200, 0.35);
}

.ghost {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.15);
  font-size: 12px;
  padding: 6px 10px;
}

.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.tool {
  flex: 1 1 80px;
}

.tool.active {
  border-color: rgba(85, 242, 196, 0.6);
  background: rgba(85, 242, 196, 0.12);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-lock {
  position: relative;
  padding: 4px 6px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 20, 20, 0.85);
}

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

.lock-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  opacity: 0.7;
}

.toggle-lock input:checked + .lock-icon {
  opacity: 1;
}

.toggle-lock input:disabled + .lock-icon {
  opacity: 0.35;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.grid-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.layer-item {
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(18, 18, 18, 0.6);
  font-size: 12px;
  color: var(--muted);
  cursor: grab;
}

.layer-item.layer-grid {
  cursor: pointer;
}

.layer-item.layer-grid.draggable {
  cursor: grab;
}

.layer-item.layer-grid.draggable:active {
  cursor: grabbing;
}

.layer-item:active {
  cursor: grabbing;
}

.layer-item + .layer-item {
  margin-top: 8px;
}

.layer-item.stacked-start {
  border-bottom-width: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.layer-item.stacked-middle {
  margin-top: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  border-radius: 0;
}

.layer-item.stacked-end {
  margin-top: 0;
  border-top-width: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.layer-item.active {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.layer-item.group-active {
  border-color: rgba(255, 255, 255, 0.22);
}


.layer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.layer-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}

.layer-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.layer-title {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-meta {
  font-size: 11px;
  color: var(--muted);
}

.layer-delete {
  padding: 6px 8px;
  font-size: 11px;
}

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

.layer-actions button {
  padding: 6px 8px;
  font-size: 11px;
}

.layer-item.dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.layer-item.drag-over-top {
  border-top-color: rgba(255, 255, 255, 0.45);
  border-top-width: 1px;
}

.layer-item.drag-over-bottom {
  border-bottom-color: rgba(255, 255, 255, 0.45);
  border-bottom-width: 1px;
}

.layer-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.layer-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 2px;
}

.grid-item {
  padding: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(18, 18, 18, 0.6);
  font-size: 12px;
  color: var(--muted);
}

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

.grid-item.active {
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.grid-item button {
  padding: 6px 8px;
  font-size: 11px;
}

.repeat-wedges,
.repeat-wedge-strips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 6px;
}

.repeat-wedge-strips {
  margin-top: 6px;
}

.wedge-button {
  padding: 6px 0;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 18, 18, 0.6);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: border 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.wedge-button.active {
  border-color: rgba(85, 242, 196, 0.55);
  color: var(--text);
  background: rgba(85, 242, 196, 0.12);
}

.wedge-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wedge-strip {
  position: relative;
  height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.075s ease;
}

.wedge-strip::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  border-radius: 2px;
  background: var(--strip-color, rgba(255, 255, 255, 0.12));
  transform: translateY(-50%);
  transition: background 0.075s ease;
}

.wedge-strip[data-state="some"] {
  --strip-color: rgba(85, 242, 196, 0.5);
}

.wedge-strip[data-state="some"]:hover:not([data-suppress-hover="true"]),
.wedge-strip[data-state="some"]:active:not([data-suppress-hover="true"]),
.wedge-strip[data-state="none"]:hover:not([data-suppress-hover="true"]),
.wedge-strip[data-state="none"]:active:not([data-suppress-hover="true"]) {
  --strip-color: rgba(85, 242, 196, 1);
}

.wedge-strip[data-state="all"] {
  --strip-color: rgba(85, 242, 196, 1);
}

.wedge-strip[data-state="all"]:hover:not([data-suppress-hover="true"]),
.wedge-strip[data-state="all"]:active:not([data-suppress-hover="true"]) {
  --strip-color: rgba(255, 255, 255, 0.12);
}

.wedge-strip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wedge-strip[data-state="none"] {
  --strip-color: rgba(255, 255, 255, 0.12);
}

.stage {
  position: relative;
  overflow: hidden;
}

.new-doc-warning {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8;
}

.new-doc-warning.visible {
  display: flex;
}

.new-doc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
}

.new-doc-dialog {
  position: relative;
  z-index: 1;
  padding: 20px 24px;
  text-align: center;
  max-width: 320px;
}

.new-doc-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(250, 250, 250, 0.95);
  mix-blend-mode: screen;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.25);
  margin-bottom: 6px;
}

.new-doc-copy {
  font-size: 12px;
  color: rgba(235, 235, 235, 0.9);
  mix-blend-mode: screen;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.2);
  margin-bottom: 14px;
}

.new-doc-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.new-doc-cancel {
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--muted);
}

.new-doc-cancel:hover {
  transform: none;
  color: var(--text);
}

#context-menu {
  position: absolute;
  z-index: 10;
  min-width: 180px;
  padding: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 16, 16, 0.95);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

#context-menu.visible {
  display: flex;
}

.context-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.context-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 12px;
}

.context-menu button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 2px;
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
}

.context-menu button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  bottom: 20px;
  left: 20px;
  padding: 12px 14px;
  border-radius: 2px;
  background: rgba(16, 16, 16, 0.7);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.fps-counter {
  position: absolute;
  right: 16px;
  bottom: 16px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 5;
}
