:root {
  --bg: #10120f;
  --panel: #191c17;
  --panel2: #20241d;
  --border: #30362b;
  --text: #f4f6ef;
  --muted: #a4aa9a;
  --accent: #b8f34a;
  --accent2: #b8f34a;
  --success: #b8f34a;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="checkbox"],
input[type="range"],
input[type="color"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 3px;
}

a {
  color: var(--accent2);
  text-decoration: none;
}

.topbar {
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 48px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: #131510;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
}

.brand strong {
  color: var(--accent);
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #161a10;
  background: var(--accent);
  font-weight: 800;
}

.back-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.back-link:hover {
  color: var(--accent);
}

.container {
  width: min(1440px, 100%);
  margin: auto;
  padding: 28px clamp(14px, 3vw, 38px) 60px;
}

.hero {
  padding: 24px 0 30px;
  max-width: 800px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.15;
  letter-spacing: -1.3px;
}

.hero p {
  max-width: 700px;
  color: var(--muted);
  font-size: 16px;
}

.privacy-note {
  display: inline-block;
  margin-top: 5px;
  padding: 8px 12px;
  border: 1px solid #40512a;
  border-radius: 10px;
  color: #cde9a7;
  background: #1a2113;
  font-size: 13px;
}

.upload-card {
  padding: 18px;
  margin-bottom: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.dropzone {
  min-height: 230px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border: 2px dashed #424a39;
  border-radius: 13px;
  background: #151811;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: #202719;
}

.dropzone strong {
  font-size: 20px;
}

.dropzone > span:not(.upload-icon):not(.primary-button) {
  color: var(--muted);
  font-size: 13px;
}

.upload-icon {
  font-size: 38px;
  color: var(--accent);
  line-height: 1;
}

#imageInput {
  display: none;
}

.workspace {
  margin-top: 32px;
}

.hidden {
  display: none !important;
}

.section-heading,
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 4px 0 18px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}

.controls-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.controls-panel {
  padding: 16px;
}

.control-group {
  padding: 0 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.control-group:last-child {
  border-bottom: 0;
}

.control-group h3,
.preview-heading h3 {
  margin: 0 0 13px;
  font-size: 15px;
}

label:not(.check-row):not(.dropzone) {
  display: block;
  margin: 12px 0 5px;
  color: #dce4d2;
  font-size: 12px;
  font-weight: 700;
}

input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #11130f;
  color: var(--text);
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #11130f;
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

output {
  color: var(--accent);
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  color: #dce4d2;
  font-size: 13px;
  cursor: pointer;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 4px;
  border-radius: 10px;
  background: #11130f;
}

.type-button {
  padding: 9px 5px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
}

.type-button.active {
  color: #161a10;
  background: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  transition: transform .15s, background .15s, border-color .15s;
}

.primary-button {
  color: #161a10;
  background: var(--accent);
}

.primary-button:hover {
  background: #9bd32d;
}

.secondary-button {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel2);
}

.secondary-button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(.98);
}

.large {
  min-height: 48px;
}

.full {
  width: 100%;
  margin-top: 10px;
}

.preview-panel {
  padding: 18px;
}

.preview-heading {
  margin-bottom: 15px;
}

.preview-heading h3 {
  margin-bottom: 2px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 20px;
  color: var(--accent);
  background: #1a2113;
  font-size: 11px;
}

.canvas-wrap {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: #151811;
  background-image:
    linear-gradient(45deg, #20241d 25%, transparent 25%),
    linear-gradient(-45deg, #20241d 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #20241d 75%),
    linear-gradient(-45deg, transparent 75%, #20241d 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  touch-action: pan-y;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.preview-actions button {
  flex: 1;
}

.file-info {
  margin-top: 13px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: #11130f;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.status-message {
  margin-top: 12px;
  font-size: 13px;
}

.status-message.error {
  color: #ff9999;
}

.status-message.success {
  color: var(--success);
}

.progress-area {
  margin-top: 15px;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 20px;
  background: #30362b;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9bd32d, #b8f34a);
  transition: width .2s;
}

.main-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.main-actions #processAll {
  grid-column: 1 / -1;
}

.results {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.result-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #151811;
}

.result-card img {
  width: 100%;
  height: 130px;
  display: block;
  object-fit: contain;
  border-radius: 7px;
  background: #20241d;
}

.result-card p {
  margin: 9px 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.result-card a {
  display: block;
  padding: 8px;
  border: 1px solid #40512a;
  border-radius: 8px;
  background: #1a2113;
  color: var(--accent);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.info-section {
  max-width: 800px;
  margin-top: 45px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.info-section h2 {
  font-size: 23px;
}

.info-section li {
  margin: 9px 0;
  color: #dce4d2;
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 22px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: 2;
  }

  .preview-panel {
    order: 1;
  }
}

@media (max-width: 520px) {
  .container {
    padding-top: 18px;
  }

  .topbar {
    min-height: 62px;
  }

  .brand {
    font-size: 16px;
  }

  .dropzone {
    min-height: 200px;
    padding: 18px;
  }

  .preview-panel,
  .controls-panel {
    padding: 12px;
  }

  .main-actions {
    grid-template-columns: 1fr;
  }

  .main-actions #processAll {
    grid-column: auto;
  }

  .section-heading {
    align-items: flex-start;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}