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

:root {
  --bg: #ebeae6;
  --bg-deep: #e0dfd9;
  --surface: #f7f6f2;
  --ink: #1c1c1a;
  --muted: #6a6a64;
  --line: #cfcfc8;
  --line-soft: #dddcd6;
  --accent: #1f6b4a;
  --accent-hover: #175539;
  --accent-soft: #d8ebe2;
  --warn-bg: #f0e6c8;
  --warn-ink: #5c4a18;
  --focus: #1f6b4a;
  --radius: 0;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
}

html {
  color-scheme: light;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ——— Header ——— */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
}

.logo-mark {
  width: 12px;
  height: 12px;
  background: var(--accent);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.file-name {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
  max-width: min(42vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name:not([hidden]):not(:empty) {
  display: block;
}

/* ——— Hero / drop zone ——— */

.drop-zone {
  /* Size to the card only — a tall wrapper was keeping :hover alive above/below */
  margin: auto;
  width: min(920px, calc(100% - 2.5rem));
  cursor: pointer;
  outline: none;
  animation: rise-in 0.7s var(--ease) both;
}

.drop-zone:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.hero {
  width: 100%;
  padding: 3.5rem 2rem 4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}

.hero::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.45s var(--ease);
}

.drop-zone:hover .hero,
.drop-zone.drag-over .hero {
  border-color: var(--accent);
  background: #fafaf7;
}

.drop-zone:hover .hero::before,
.drop-zone.drag-over .hero::before {
  transform: scaleY(1);
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.hero-line {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.hero-sub {
  max-width: 28rem;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 2.25rem;
}

.drop-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line-soft);
}

.drop-cta {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--surface);
  background: var(--accent);
  padding: 0.75rem 1.35rem;
  border: 1px solid var(--accent);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.drop-zone:hover .drop-cta,
.drop-zone.drag-over .drop-cta {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.drop-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Compact drop zone after file load */

.drop-zone.compact {
  width: min(1400px, calc(100% - 2.5rem));
  margin: 1rem auto 0;
  animation: none;
}

.drop-zone.compact .hero {
  width: 100%;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.drop-zone.compact .hero::before {
  width: 4px;
  transform: scaleY(1);
}

.drop-zone.compact .hero-brand,
.drop-zone.compact .hero-line,
.drop-zone.compact .hero-sub {
  display: none;
}

.drop-zone.compact .drop-content {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0;
  border-top: none;
  width: 100%;
}

.drop-zone.compact .drop-cta {
  font-size: 0.8125rem;
  padding: 0.45rem 0.9rem;
}

.drop-zone.compact .drop-hint {
  display: none;
}

/* ——— Workspace ——— */

.workspace {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1px;
  width: min(1400px, calc(100% - 2.5rem));
  margin: 1rem auto 2rem;
  background: var(--line);
  border: 1px solid var(--line);
  animation: rise-in 0.45s var(--ease) both;
}

.workspace.hidden {
  display: none;
}

.options-panel,
.preview-panel {
  background: var(--surface);
}

.options-panel {
  padding: 1.35rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.panel-header {
  margin-bottom: 1.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-scope .btn-text {
  margin-top: 0.55rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
}

.switch-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-track {
  display: block;
  position: relative;
  box-sizing: border-box;
  width: 40px;
  height: 22px;
  background: var(--line);
  border: none;
  transition: background 0.15s ease;
  pointer-events: none;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  background: var(--surface);
  transition: transform 0.15s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-text {
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover {
  color: var(--ink);
}

.btn-text[hidden] {
  display: none;
}

.option-group {
  margin-bottom: 1.15rem;
  border: none;
}

.option-group legend {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Segmented controls */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  background: var(--bg);
}

.seg-item {
  position: relative;
  cursor: pointer;
}

.seg-item input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.seg-item span {
  display: block;
  text-align: center;
  padding: 0.45rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-item:last-child span {
  border-right: none;
}

.seg-item:hover span {
  color: var(--ink);
}

.seg-item input:checked + span {
  background: var(--ink);
  color: var(--surface);
}

.seg-item input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* Sliders */

.slider-group label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: default;
  margin-bottom: 0.45rem;
}

.slider-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.slider-value {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 1.5rem;
  text-align: right;
}

.option-group input[type="range"] {
  width: 100%;
  height: 2px;
  appearance: none;
  background: var(--line);
  outline: none;
  cursor: pointer;
}

.option-group input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--ink);
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}

.option-group input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--ink);
  border: none;
  border-radius: 0;
  cursor: pointer;
}

.option-group input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.15);
}

.option-group input[type="range"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.slider-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Fine tune — collapsed by default */

.fine-tune {
  margin: 0.25rem 0 1rem;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.75rem;
}

.fine-tune summary {
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  transition: color 0.15s ease;
}

.fine-tune summary::-webkit-details-marker {
  display: none;
}

.fine-tune summary::before {
  content: '';
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s var(--ease);
}

.fine-tune[open] summary::before {
  transform: rotate(45deg);
}

.fine-tune summary:hover {
  color: var(--ink);
}

.fine-tune[open] summary {
  margin-bottom: 1rem;
  color: var(--ink);
}

.fine-tune .option-group {
  margin-bottom: 1rem;
}

/* Actions */

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1rem;
}

.btn {
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 0;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #f7f6f2;
}

.btn-primary:hover:not(:disabled) {
  background: var(--ink);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-icon:hover:not(:disabled) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.btn-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.progress-container {
  margin-top: 1rem;
}

.progress-bar-track {
  height: 2px;
  background: var(--line-soft);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}

.progress-bar-track.visible,
.progress-container:has(.progress-text:not(:empty)) .progress-bar-track {
  opacity: 1;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.4rem;
  min-height: 1.2em;
}

/* Preview */

.preview-panel {
  padding: 1.25rem 1.35rem 1.5rem;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.preview-stats {
  display: flex;
  gap: 1.25rem;
  font-size: 0.8rem;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mode-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--bg);
  color: var(--ink);
}

.mode-vector {
  background: var(--accent-soft);
  color: var(--accent);
}

.mode-raster {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.preview-stage {
  position: relative;
  min-height: 280px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
  padding: 0.5rem 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.loading-overlay.hidden {
  display: none;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 1.1rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: min(300px, 90%);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.loading-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.loading-detail {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.2em;
}

.loading-bar-track {
  width: 100%;
  height: 2px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 0.35rem;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skeleton-label {
  height: 8px;
  width: 40px;
  margin: 0 auto;
  background: var(--bg-deep);
}

.skeleton-page {
  height: min(42vh, 320px);
  border: 1px solid var(--line);
  background: var(--bg);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.preview-card h3 {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.preview-canvas {
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: auto;
  max-height: 70vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0.75rem;
  min-height: 120px;
}

.preview-canvas canvas {
  max-width: 100%;
  height: auto;
  display: block;
  animation: fade-page 0.35s var(--ease) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-page {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 900px) {
  .header {
    padding: 0.85rem 1rem;
  }

  .drop-zone,
  .drop-zone.compact,
  .workspace {
    width: calc(100% - 1.5rem);
  }

  .hero {
    padding: 2.5rem 1.35rem 2.75rem;
  }

  .workspace {
    grid-template-columns: 1fr;
    margin-bottom: 1.5rem;
  }

  .options-panel {
    border-bottom: 1px solid var(--line);
  }

  .preview-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
