:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --text: #0f172a;
  --muted: #5b6472;
  --border: #d9e2ec;
  --accent: #1d4ed8;
  --accent-strong: #163ea8;
  --danger: #b42318;
  --shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.site-header {
  margin-bottom: 24px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 0.95rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 24px;
}

.hero {
  grid-column: 1 / -1;
  padding: 28px 4px 2px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
  font-weight: 700;
}

.hero h1 {
  max-width: 14ch;
  font-size: clamp(2.2rem, 4.2vw, 3.8rem);
  line-height: 1.02;
}

.hero-copy {
  margin-top: 16px;
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.uploader-card,
.controls-card {
  display: grid;
  gap: 20px;
}

.preview-card {
  grid-row: span 2;
}

.dropzone {
  min-height: 260px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 12px;
  padding: 28px;
  border: 1.5px dashed #b8c7d9;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfdff 0%, #f6f9fc 100%);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: var(--accent);
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.dropzone-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f172a, #334155);
  color: #ffffff;
  font-size: 0.96rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.dropzone h2,
.section-head h2 {
  font-size: 1.08rem;
}

.dropzone p,
.section-head p,
.muted {
  color: var(--muted);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.meta-box {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.meta-label {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.meta-value {
  word-break: break-word;
}

.section-head {
  display: grid;
  gap: 6px;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.size-pill {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.size-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.size-pill.is-selected {
  background: #eff6ff;
  border-color: #90b4ff;
  color: var(--accent-strong);
}

.button-row {
  display: flex;
  gap: 12px;
}

.button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #ffffff;
}

.button-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
}

.status {
  min-height: 24px;
  line-height: 1.5;
}

.export-preview-head {
  margin-top: 4px;
}

.export-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.export-preview-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.export-preview-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.export-preview-canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(45deg, rgba(15, 23, 42, 0.04) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.04) 75%),
    linear-gradient(45deg, rgba(15, 23, 42, 0.04) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.04) 75%),
    #ffffff;
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.export-preview-canvas {
  width: min(84px, 100%);
  height: auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.export-preview-empty {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-subtle);
}

.preview-stage {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(45deg, rgba(15, 23, 42, 0.04) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.04) 75%),
    linear-gradient(45deg, rgba(15, 23, 42, 0.04) 25%, transparent 25%, transparent 75%, rgba(15, 23, 42, 0.04) 75%),
    #f8fafc;
  background-size: 28px 28px;
  background-position: 0 0, 14px 14px;
}

#previewImage {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}

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

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

  .preview-card {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1120px);
    padding-top: 20px;
  }

  .card {
    padding: 20px;
  }

  .hero {
    padding: 12px 2px 0;
  }

  .hero h1 {
    max-width: none;
  }

  .dropzone {
    justify-items: center;
    text-align: center;
  }

  .meta-grid,
  .size-grid,
  .button-row,
  .export-preview-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
  }

  .preview-stage {
    min-height: 300px;
  }
}
