:root {
  --bg: #111310;
  --panel: #191b17;
  --panel-light: #20231d;
  --border: #30342b;
  --text: #f1f1e8;
  --muted: #93978a;
  --accent: #c8f169;
  --accent-dark: #a8d744;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, input, select {
  font: inherit;
}

button, select {
  cursor: pointer;
}

button:focus-visible, input:focus-visible, select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.topbar {
  min-height: 72px;
  padding: 0 6%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 19, 16, .95);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.7px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #15180f;
  background: var(--accent);
  border-radius: 10px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -2px;
  padding-right: 2px;
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

.back-link {
  color: #c7cabb;
  font-size: 13px;
}

.back-link:hover, .app-footer a:hover {
  color: var(--accent);
}

.app {
  width: min(1320px, 92%);
  margin: auto;
}

.intro {
  padding: 48px 0 32px;
}

.eyebrow, .section-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.5px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px #c8f16966;
}

.intro h1 {
  margin: 12px 0 8px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -2.8px;
}

.intro h1 span {
  color: var(--accent);
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-heading h2, .preview-top h2 {
  font-size: 18px;
  letter-spacing: -.5px;
  margin: 4px 0 0;
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
}

.upload-box {
  min-height: 174px;
  border: 1px dashed #515845;
  background: #1c2018;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}

.upload-box:hover, .upload-box.drag-over {
  border-color: var(--accent);
  background: #252b1c;
}

.upload-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #303a21;
  color: var(--accent);
  font-size: 28px;
  margin-bottom: 5px;
}

.upload-box strong {
  font-size: 13px;
}

.upload-box > span:not(.upload-icon) {
  color: var(--muted);
  font-size: 12px;
}

.upload-box u {
  color: var(--accent);
}

.upload-box small {
  margin-top: 7px;
  color: #74796b;
  font-size: 10px;
}

.file-details {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.file-thumb {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--panel-light);
  border-radius: 8px;
  color: var(--accent);
  font-size: 10px;
}

.file-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.file-text strong {
  font-size: 11px;
  overflow-wrap: anywhere;
}

.file-text span {
  font-size: 10px;
  color: var(--muted);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 5px;
}

.text-button:hover {
  color: var(--accent);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 25px 0;
}

.compact {
  margin-bottom: 17px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 13px 0 8px;
  color: #c8cbbb;
  font-size: 11px;
  font-weight: 650;
}

.select-control, .input-control {
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  color: var(--text);
  background: #12140f;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}

.select-control:focus, .input-control:focus {
  border-color: var(--accent);
}

.select-control option {
  background: #191b17;
  color: var(--text);
}

.dimension-grid {
  margin-top: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px minmax(0, 1fr);
  align-items: end;
  gap: 9px;
}

.dimension-grid > div:first-child,
.dimension-grid > div:last-of-type {
  min-width: 0;
}

.dimension-separator {
  padding-bottom: 12px;
  color: var(--muted);
  text-align: center;
}

.ratio-lock {
  grid-column: 1 / -1;
  justify-self: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  background: #12140f;
  color: var(--muted);
  font-size: 11px;
}

.ratio-lock.active {
  color: var(--accent);
  border-color: #586b36;
  background: #252c1c;
}

.crop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 13px;
}

.secondary-button {
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #20221d;
  color: #d5d8cb;
  font-size: 11px;
  transition: .2s;
}

.secondary-button:hover {
  border-color: #6a7b48;
  color: var(--accent);
}

.range-field {
  margin-top: 18px;
}

.range-field > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #d2d5c8;
}

output {
  color: var(--accent);
  font-size: 11px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 12px 0 0;
}

.preview-panel {
  position: sticky;
  top: 16px;
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.preview-status {
  padding: 6px 9px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 10px;
}

.preview-stage {
  min-height: 350px;
  padding: 20px;
  background-color: #12140f;
  background-image: linear-gradient(45deg, #1b1e18 25%, transparent 25%), linear-gradient(-45deg, #1b1e18 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1b1e18 75%), linear-gradient(-45deg, transparent 75%, #1b1e18 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.empty-preview {
  padding: 24px 10px;
  text-align: center;
}

.empty-art {
  position: relative;
  width: 90px;
  height: 90px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  border: 1px solid #3b4430;
  border-radius: 24px;
  color: var(--accent);
  background: #1c2116;
  font-size: 43px;
}

.empty-art i {
  position: absolute;
  top: -12px;
  right: -9px;
  color: #f0dca5;
  font-style: normal;
  font-size: 23px;
}

.empty-preview h3 {
  font-size: 14px;
  margin: 0 0 7px;
}

.empty-preview p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 8px 35px #0006;
}

.preview-meta {
  display: grid;
  grid-template-columns: 1fr 25px 1fr;
  align-items: center;
  gap: 8px;
  padding: 16px 0 0;
}

.preview-meta > div:not(.meta-arrow) {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.preview-meta span, .size-summary span {
  color: var(--muted);
  font-size: 10px;
}

.preview-meta strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.meta-arrow {
  color: var(--accent);
  text-align: center;
  font-size: 18px;
}

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: end;
}

.export-grid .field-label {
  min-height: 18px;
}

.size-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
  padding: 14px;
  background: #12140f;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.size-summary > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.size-summary strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.download-button {
  width: 100%;
  min-height: 50px;
  margin-top: 18px;
  padding: 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent);
  color: #171b10;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  transition: background .2s, transform .2s;
}

.download-button:not(:disabled):hover {
  background: #d8ff8d;
  transform: translateY(-1px);
}

.download-button span:last-child {
  font-size: 20px;
}

.privacy-note {
  margin: 13px 0 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
}

.error-message {
  color: #ff9e90;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.app-footer {
  margin: 35px 0 0;
  padding: 23px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
}

.small-brand {
  font-size: 14px;
}

.small-brand .brand-mark {
  width: 27px;
  height: 27px;
  font-size: 14px;
  border-radius: 8px;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-panel {
    position: static;
    grid-row: 1;
  }

  .controls {
    grid-row: 2;
  }

  .preview-stage {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 62px;
    padding: 0 5%;
  }

  .app {
    width: 92%;
  }

  .intro {
    padding: 35px 0 25px;
  }

  .intro h1 {
    letter-spacing: -1.8px;
  }

  .panel {
    padding: 17px;
    border-radius: 13px;
  }

  .preview-stage {
    min-height: 240px;
    padding: 12px;
  }

  #previewCanvas {
    max-height: 340px;
  }

  .export-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-footer {
    flex-wrap: wrap;
  }

  .app-footer > span {
    order: 3;
    width: 100%;
  }
}