@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=DM+Sans:wght@300;400;500&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f0f;
  --surface: #191919;
  --surface2: #222222;
  --border: #2e2e2e;
  --text: #f0ede6;
  --muted: #6b6b6b;
  --accent: #c8f04a;
  --accent-dim: #a8cc32;
}

/* ─── Layout ─────────────────────────────────── */

html,
body {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

@media (max-width: 680px) {
  html {
    overflow-y: auto;
  }
  body {
    overflow-x: hidden;
    overflow-y: visible;
    align-items: center;
    padding: 1rem 1.25rem;
    min-height: unset;
    width: 100%;
    box-sizing: border-box;
  }

  header {
    margin-bottom: 1.25rem;
  }
}

.container {
  width: 100%;
  max-width: 640px;
}

.container.has-image {
  max-width: 920px;
}

/* ─── Header ─────────────────────────────────── */

header {
  margin-bottom: 2rem;
}

header h1 {
  font-family: 'DM Mono', monospace;
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

header p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 6px;
  font-family: 'DM Mono', monospace;
  font-weight: 300;
}

/* ─── Drop zone ──────────────────────────────── */

#drop-zone {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: clamp(1.75rem, 5vh, 3rem) 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(200, 240, 74, 0.04);
}

#drop-zone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

#drop-zone svg {
  display: block;
  margin: 0 auto 1.25rem;
  color: var(--accent);
  opacity: 0.8;
  width: 52px;
  height: 52px;
}

.title-logo {
  display: inline-block;
  width: 15px;
  height: 15px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
  opacity: 0.6;
}

#drop-zone p {
  font-size: 1rem;
  color: var(--muted);
}

#drop-zone span {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--border);
  display: block;
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ─── Controls ───────────────────────────────── */

#controls {
  display: none;
}

#controls.active {
  display: grid;
  grid-template-columns: 1fr 360px;
  column-gap: 2.5rem;
  align-items: start;
}

/* Right-side panel stacks vertically */
#controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

/* ─── File bar ───────────────────────────────── */

.file-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.file-bar svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.file-bar .file-name {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-bar .file-dims {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.change-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.change-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

/* ─── Slider ─────────────────────────────────── */

.slider-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.slider-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.slider-readout {
  font-family: 'DM Mono', monospace;
  font-size: 2rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}

.slider-readout span {
  font-size: 1rem;
  font-weight: 300;
  color: var(--muted);
}

input[type='range'] {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type='range']::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.slider-track-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--border);
  margin-top: 4px;
}

/* ─── Dimensions ─────────────────────────────── */

.dims-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.dim-box {
  text-align: center;
}

.dim-box .dim-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.dim-box .dim-val {
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
  color: var(--text);
}

.dim-box.new .dim-val {
  color: var(--accent);
}

.dim-editable {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
}

.dim-input {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
  width: 5ch;
  text-align: center;
  padding: 0;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
  appearance: textfield;
}

.dim-input::-webkit-outer-spin-button,
.dim-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dim-input:focus {
  border-bottom-color: var(--accent);
}

.dim-input::placeholder {
  color: var(--muted);
}

.dim-input.over-limit {
  color: #ff6b6b;
  border-bottom-color: #ff6b6b;
}

.dim-sep,
.dim-unit {
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
  color: var(--accent);
  pointer-events: none;
}

.size-hint {
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 10px;
}

/* ─── Format selector ────────────────────────── */

.format-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.format-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.format-btns {
  display: flex;
  gap: 8px;
}

.fmt-btn {
  flex: 1;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fmt-btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.fmt-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 240, 74, 0.06);
}

/* ─── Download button ────────────────────────── */

#download-btn {
  width: 100%;
  padding: 15px;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#download-btn:hover {
  background: var(--accent-dim);
}

#download-btn:active {
  transform: scale(0.99);
}

#download-btn:disabled {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: not-allowed;
  transform: none;
}

/* ─── Footer caption ─────────────────────────── */

footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ─── Uplift banner ──────────────────────────── */

#uplift-banner {
  display: block;
  margin-top: 1rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.2s, background 0.2s;
}

#uplift-banner:hover {
  border-color: #444;
  background: var(--surface);
}

#uplift-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#uplift-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#uplift-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

#uplift-body {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 300;
  opacity: 0.75;
}

#uplift-cta {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}


/* ─── Loading state ──────────────────────────────── */

#loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 3rem 2rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

#loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loading-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* ─── Preview canvas ─────────────────────────────── */

#preview-wrap {
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 220px;
  min-width: 0;
}

.has-image #preview-wrap {
  max-height: none;
  align-self: stretch;
  min-height: 300px;
}

#preview-canvas {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.has-image #preview-canvas {
  max-height: 100%;
}

/* ─── Controls staggered entrance ────────────────── */

#preview-wrap,
#controls-panel > * {
  opacity: 0;
  transition: opacity 0.35s ease;
}

#controls.ready #preview-wrap,
#controls.ready #controls-panel > * {
  opacity: 1;
}

#controls.ready #preview-wrap                    { transition-delay: 0ms;   }
#controls.ready #controls-panel > *:nth-child(1) { transition-delay: 50ms;  }
#controls.ready #controls-panel > *:nth-child(2) { transition-delay: 100ms; }
#controls.ready #controls-panel > *:nth-child(3) { transition-delay: 150ms; }
#controls.ready #controls-panel > *:nth-child(4) { transition-delay: 200ms; }

/* ─── Responsive: single column on small screens ─── */

@media (max-width: 680px) {
  .container,
  .container.has-image {
    max-width: 100%;
  }
  #controls.active {
    grid-template-columns: 1fr;
    column-gap: 0;
  }
  .has-image #preview-wrap {
    max-height: 220px;
    min-height: unset;
  }
  .has-image #preview-canvas {
    max-height: 220px;
  }
}

/* ─── Download section ───────────────────────────── */

#download-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── Footer ─────────────────────────────────────── */

.site-footer {
  width: 100%;
  margin-top: 2rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.02em;
}