:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.06);
  --card2: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.64);
  --border: rgba(255, 255, 255, 0.12);
  --primary: #3b82f6;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans",
    "Liberation Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, rgba(59, 130, 246, 0.25), transparent 60%),
    radial-gradient(900px 600px at 85% 10%, rgba(16, 185, 129, 0.18), transparent 55%), var(--bg);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.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;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header__title {
  font-size: 16px;
  letter-spacing: 0.2px;
  font-weight: 650;
}

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

.layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  padding: 16px;
  max-width: 1280px;
  margin: 0 auto;
}

.layout--single {
  grid-template-columns: 1fr;
  max-width: 760px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

.tab--active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.form {
  padding: 14px;
}

.row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.row--stack {
  grid-auto-flow: row;
}

.row--inline {
  grid-auto-flow: column;
  align-items: center;
  grid-template-columns: 120px auto;
}

.row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.input,
.textarea,
.select {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(59, 130, 246, 0.75);
}

.textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.45;
}

.input--mini {
  width: 110px;
  font-family: var(--mono);
  padding: 10px 10px;
}

.select--mini {
  padding: 9px 10px;
  font-size: 12px;
}

.checkbox {
  width: 18px;
  height: 18px;
}

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

.grid--2 {
  grid-template-columns: 1fr 1fr;
}

.open-actions {
  margin-top: 4px;
  margin-bottom: 12px;
}

.open-hint {
  margin-top: 4px;
}

.grid-span-2 {
  grid-column: 1 / span 2;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  background: rgba(0, 0, 0, 0.22);
}

.btn--primary {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn--ghost {
  background: transparent;
}

.btn--block {
  width: 100%;
}

.btn:active {
  transform: translateY(1px);
}

.link {
  border: 0;
  background: transparent;
  color: rgba(147, 197, 253, 0.9);
  cursor: pointer;
  padding: 0;
  font-weight: 650;
}

.range {
  width: 100%;
}

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

.color {
  width: 46px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.22);
}

.preview {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding-right: 4px;
}

.preview__card {
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview__header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 6px;
}

.preview__title {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.preview__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.preview__body {
  padding: 14px;
}

.preview__imgWrap {
  display: grid;
  place-items: center;
  border-radius: 16px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

#previewImg {
  width: 100%;
  max-width: 340px;
  height: auto;
  image-rendering: pixelated;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.error {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: rgba(254, 226, 226, 0.95);
  font-size: 13px;
}

.history {
  display: grid;
  gap: 10px;
}

.history__item {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  padding: 10px 10px;
  display: grid;
  gap: 8px;
}

.history__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.history__name {
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__meta {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__actions {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.file {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(0, 0, 0, 0.14);
}

.file__btn {
  white-space: nowrap;
  padding: 9px 12px;
}

.file__name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

.progress {
  position: relative;
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.9), rgba(167, 139, 250, 0.9), rgba(251, 113, 133, 0.9));
  transition: width 160ms ease;
}

.progress__text {
  position: absolute;
  top: -20px;
  right: 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.progress--indeterminate .progress__bar {
  width: 100%;
  background-size: 160% 100%;
  animation: progressMove 1.2s linear infinite;
}

@keyframes progressMove {
  from {
    background-position: 0% 0%;
  }
  to {
    background-position: 160% 0%;
  }
}

.swatches {
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  padding: 10px 10px;
  display: grid;
  gap: 8px;
}

.swatch__chips {
  display: flex;
  gap: 8px;
}

.chip {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
  }

  .header__actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .layout {
    padding: 12px;
    gap: 12px;
  }

  .form {
    padding: 12px;
  }

  .grid--2 {
    grid-template-columns: 1fr;
  }

  .grid-span-2 {
    grid-column: auto;
  }

  .row--inline {
    grid-auto-flow: row;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .input,
  .textarea,
  .select {
    font-size: 16px;
  }

  .input--mini {
    width: 100%;
  }

  .btn {
    min-height: 44px;
  }

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

  #previewImg {
    max-width: 280px;
  }
}
