:root {
  color-scheme: dark;
  --bg: #0d1118;
  --panel: #172233;
  --card: #263243;
  --card-border: #42536b;
  --control: #334257;
  --control-hover: #40536d;
  --text: #f8fafc;
  --muted: #aab2c0;
  --accent: #2dd4bf;
  --accent-dark: #0f766e;
  --warn: #f97316;
}

* {
  box-sizing: border-box;
}

button,
.button,
.tool-button,
.part-button,
.mockup-link,
select,
input[type="file"],
input[type="range"],
.picker-radio,
.picker-close,
.color-swatch,
.hue-canvas,
.sv-canvas {
  cursor: pointer;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

body {
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(520px, 1fr) 350px;
  width: 100vw;
  height: 100vh;
  min-width: 1120px;
}

.library {
  background: var(--panel);
  padding: 18px 14px;
  overflow-y: auto;
}

.controls {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  padding: 18px 14px 10px;
  overflow: hidden;
}

.library {
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.controls { border-left: 1px solid rgba(255, 255, 255, 0.04); }

.panel-title {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.panel-title strong {
  font-size: 20px;
  letter-spacing: 0;
}

.panel-title span,
.card h2,
.seo-link {
  color: #c8d1df;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.search {
  width: 100%;
  height: 38px;
  margin-bottom: 14px;
  padding: 0 12px;
  color: var(--text);
  background: #111827;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
}

.mockup-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.mockup-link {
  display: block;
  min-height: 39px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: #111822;
  font-size: 13px;
  line-height: 1.15;
  text-decoration: none;
}

.mockup-link:hover {
  background: #1b2635;
  border-color: var(--card-border);
}

.mockup-link.active {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #0d1118;
  background-size: 64px 64px;
  overflow: hidden;
}

.seo-copy {
  max-width: 980px;
  padding: 18px 28px 0;
}

.seo-copy h1 {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.25;
}

.seo-copy p {
  margin: 0;
  color: var(--muted);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 0;
  overflow: visible;
}

.canvas-stack {
  position: relative;
  display: grid;
  place-items: center;
  overflow: visible;
}

#stageCanvas {
  max-width: 100%;
  max-height: 100%;
  background: #ffffff;
  border: 10px solid #141922;
  box-shadow: 0 0 0 1px #334155;
  cursor: grab;
  touch-action: none;
}

#transformCanvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

#stageCanvas.dragging,
#transformCanvas.dragging {
  cursor: grabbing;
}

.controls-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
}

.control-section {
  margin-bottom: 14px;
}

.control-section > h2,
.project-card > h2,
.card h2,
.export-panel > h2 {
  margin: 0 0 10px;
  color: #c8d1df;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
}

.card,
.project-card {
  padding: 12px 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 11px;
}

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

.project-card > h2 {
  grid-column: 1 / -1;
  margin-bottom: 2px;
}

.project-action {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  font: inherit;
}

.project-action:disabled {
  opacity: 1;
}

.project-action img {
  display: block;
  width: 28px;
  height: 22px;
  object-fit: contain;
}

.project-action span:last-child {
  font-size: 12px;
}

.project-icon {
  color: #dbe7f5;
  font-size: 22px;
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  color: var(--text);
  background: var(--control);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

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

.button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button.primary {
  gap: 8px;
  min-height: 42px;
  margin-bottom: 10px;
  background: #27b7b8;
  border-color: #27b7b8;
  font-weight: 600;
}

.upload-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.design-list {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

.design-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.78fr) minmax(132px, 1.22fr) 32px;
  gap: 6px;
  align-items: stretch;
  padding: 4px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  background: var(--control);
  cursor: pointer;
}

.design-select,
.design-remove {
  border: 1px solid var(--card-border);
  color: var(--text);
  background: var(--control);
  font: inherit;
  cursor: pointer;
}

.design-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 58px;
  justify-items: center;
  min-width: 0;
  min-height: 70px;
  padding: 5px 6px;
  border-radius: 8px;
  border-color: transparent;
  background: transparent;
  text-align: center;
}

.design-thumbnail {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 1px solid #5b6d86;
  border-radius: 7px;
  background: #25354a;
}

.design-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.design-info {
  display: grid;
  gap: 1px;
  min-width: 0;
  width: 100%;
  justify-items: center;
}

.design-info strong {
  color: #f8fafc;
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.design-info > span {
  overflow: hidden;
  color: #aeb9c8;
  width: 100%;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-row.active {
  background: #8fa1b3;
  border-color: #a8b8cc;
}

.design-row.active .design-thumbnail {
  border-color: var(--accent);
}

.design-controls {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 4px 0 3px;
  min-width: 0;
}

.design-opacity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  row-gap: 4px;
  column-gap: 5px;
  min-width: 0;
  color: #dbe7f5;
  font-size: 10px;
}

.design-opacity input {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  height: 5px;
  margin: 2px 0 0;
}

.design-opacity output {
  color: #ffffff;
  font-size: 10px;
}

.design-opacity > span:first-child,
.design-blend > span {
  font-size: 11px;
  font-weight: 700;
}

.design-blend {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-top: 1px;
  color: #dbe7f5;
  font-size: 10px;
}

.design-blend select {
  width: 100%;
  min-width: 0;
  height: 22px;
  padding: 0 4px;
  border: 1px solid var(--card-border);
  border-radius: 5px;
  color: var(--text);
  background: var(--control);
  font: inherit;
  font-size: 10px;
}

.design-remove:hover {
  background: var(--control-hover);
}

.design-select:hover,
.design-row.active .design-select:hover {
  background: transparent;
}

.design-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  align-self: center;
  justify-self: center;
  padding: 0;
  border-radius: 6px;
  color: #ff9e9e;
  font-family: Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.button.accent {
  background: var(--warn);
  border-color: var(--warn);
  font-weight: 700;
}

.button.muted {
  color: #c2cad6;
}

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

.tool-card {
  padding: 8px 10px;
}

.tool-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: auto;
  flex: 1 1 0;
  height: 42px;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px 4px 5px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text);
  background: var(--control);
  font: inherit;
  cursor: pointer;
}

.tool-button:disabled {
  color: #7f8b9d;
  cursor: pointer;
}

.tool-button img {
  display: block;
  width: 13px;
  height: 17px;
  object-fit: contain;
  margin-top: 0;
}

.tool-button span:last-child {
  font-size: inherit;
  line-height: 14px;
}

.range-row,
.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 6px;
}

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

select {
  min-width: 148px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  color: var(--text);
  background: #202b3c;
  outline: none;
}

.background-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.background-action {
  display: grid;
  place-items: center;
  height: 58px;
  padding: 7px 4px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  color: var(--text);
  background: var(--control);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.background-action span:last-child {
  font-size: 12px;
}

.background-action img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.color-parts {
  display: grid;
  gap: 8px;
}

.part-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 4px 0 10px;
  border: 2px solid #a8b8cc;
  border-radius: 8px;
  color: #ffffff;
  background: #8fa1b3;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.part-button .color-swatch {
  display: block;
  width: 30px;
  height: 30px;
  justify-self: end;
  border: 2px solid #dbe5f1;
  border-radius: 8px;
  background: #ffffff;
}

.part-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-button input {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

#clearBackgroundBtn {
  gap: 8px;
}

#clearBackgroundBtn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.export-panel {
  padding-top: 10px;
  background: var(--panel);
}

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

.export-row select {
  width: 100%;
  min-width: 0;
  text-align: center;
  border: 1px solid var(--card-border);
  background: var(--control);
}

.export-progress {
  position: relative;
  display: none;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #263243;
}

.export-progress.visible {
  display: block;
}

.export-progress span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -35%;
  width: 35%;
  border-radius: inherit;
  background: var(--accent);
  animation: export-progress-slide 0.9s ease-in-out infinite;
}

@keyframes export-progress-slide {
  0% { left: -35%; }
  100% { left: 100%; }
}

.color-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
  background: rgba(0, 0, 0, 0.34);
}

.color-picker-dialog {
  position: fixed;
  width: 528px;
  height: 359px;
  background: #555555;
  border: 1px solid #202020;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.color-picker-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 10px;
  color: #f8fafc;
  background: #17202a;
  font-size: 13px;
  cursor: move;
  user-select: none;
}

.picker-close {
  width: 26px;
  height: 26px;
  border: 0;
  color: #f8fafc;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.color-picker-body {
  position: relative;
  width: 528px;
  height: 327px;
  background: #555555;
}

.sv-canvas {
  position: absolute;
  left: 8px;
  top: 28px;
  width: 256px;
  height: 256px;
  cursor: crosshair;
}

.hue-wrap {
  position: absolute;
  left: 266px;
  top: 20px;
  width: 36px;
  height: 272px;
  cursor: ns-resize;
  touch-action: none;
}

.hue-canvas {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 20px;
  height: 256px;
  cursor: ns-resize;
}

.hue-arrow {
  position: absolute;
  width: 0;
  height: 0;
  transform: translateY(-50%);
  cursor: ns-resize;
}

.hue-arrow.left {
  left: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 7px solid #ffffff;
  filter: drop-shadow(0 0 0 #1f1f1f);
}

.hue-arrow.right {
  right: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 7px solid #ffffff;
  filter: drop-shadow(0 0 0 #1f1f1f);
}

.sv-indicator {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000000;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hue-indicator {
  position: absolute;
  left: 8px;
  width: 20px;
  height: 0;
  transform: translateY(-50%);
  pointer-events: none;
}

.picker-label {
  position: absolute;
  color: #ffffff;
  font-size: 12px;
  line-height: 18px;
}

.swatch-label {
  left: 308px;
  width: 60px;
  text-align: center;
}

.new-label {
  top: 8px;
}

.current-label {
  top: 99px;
}

.split-swatch {
  position: absolute;
  left: 308px;
  top: 29px;
  width: 60px;
  height: 68px;
  border: 1px solid #6f6f6f;
  border-radius: 0;
  overflow: hidden;
}

.new-swatch,
.current-swatch {
  width: 100%;
  height: 50%;
}

.picker-field {
  position: absolute;
  height: 22px;
  color: #ffffff;
  font-size: 12px;
  line-height: 18px;
}

.picker-field span {
  position: absolute;
  left: 20px;
  top: 0;
  width: 20px;
}

.picker-field.right-field span {
  left: 20px;
}

.picker-field.cmyk-field span {
  left: 23px;
}

.picker-field input,
.hex-field input {
  position: absolute;
  top: -2px;
  left: 45px;
  width: 36px;
  height: 22px;
  padding: 0 4px;
  border: 0;
  outline: 1px solid #5f5f5f;
  border-radius: 0;
  color: #ffffff;
  background: #4a4a4a;
  font: inherit;
  text-align: center;
}

.picker-field.right-field input {
  left: 43px;
}

.picker-field input:focus,
.hex-field input:focus {
  outline-color: #7a7a7a;
}

.picker-field input[readonly] {
  cursor: default;
}

.picker-field em {
  position: absolute;
  left: 86px;
  top: 0;
  width: 20px;
  font-style: normal;
}

.picker-radio {
  position: absolute;
  left: 0;
  top: 3px;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
}

.picker-radio::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid #d7d7d7;
  border-radius: 50%;
}

.picker-radio.selected::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f2f2f2;
}

.hex-field {
  position: absolute;
  left: 308px;
  top: 294px;
  width: 98px;
  height: 22px;
  color: #ffffff;
  font-size: 12px;
}

.hex-field b {
  position: absolute;
  left: 0;
  top: 0;
  width: 16px;
  height: 18px;
  font-weight: 400;
  line-height: 18px;
  text-align: center;
}

.hex-field input {
  left: 18px;
  width: 80px;
  text-align: left;
}

.picker-actions {
  position: absolute;
  left: 390px;
  top: 34px;
  display: grid;
  gap: 10px;
}

.picker-actions button {
  width: 114px;
  height: 25px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  color: #ffffff;
  background: #464646;
  font: inherit;
  cursor: pointer;
}

.picker-actions button:hover {
  background: #535353;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(430px, 1fr) 310px;
    min-width: 960px;
  }
}
