:root {
  --ink: #17211d;
  --muted: #59635f;
  --paper: #f7f5ed;
  --panel: #fffdf6;
  --line: #d9d0bf;
  --field: #e8f0df;
  --field-strong: #bfd6ae;
  --sky: #b8dbe8;
  --clay: #b9674b;
  --clay-dark: #8f4936;
  --shadow: 0 24px 70px rgba(45, 50, 38, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(184, 219, 232, 0.55), transparent 38%),
    linear-gradient(160deg, var(--paper) 0%, #eef2e6 55%, #f5eadf 100%);
  color: var(--ink);
  font-family: Avenir Next, Avenir, Trebuchet MS, Verdana, sans-serif;
}

body {
  min-height: 100%;
  margin: 0;
}

button,
a,
input {
  font: inherit;
}

button,
.download-link {
  min-height: 44px;
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 28px;
  align-items: stretch;
  padding: 24px 0 26px;
}

.hero-copy {
  min-height: 285px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 8px solid var(--clay);
  padding-left: clamp(20px, 4vw, 44px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--clay-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-family: Georgia, Cambria, Times New Roman, serif;
  font-size: clamp(3.2rem, 9vw, 7.6rem);
  line-height: 0.86;
  letter-spacing: 0;
}

.intro {
  max-width: 650px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.55;
}

.hero-panel,
.workspace,
.preview-card {
  border: 1px solid rgba(23, 33, 29, 0.12);
  background: rgba(255, 253, 246, 0.86);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 12px;
  align-content: center;
  padding: 18px;
  border-radius: 8px;
}

.guide-step {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.54);
}

.guide-step.active {
  background: var(--field);
  border-color: var(--field-strong);
}

.step-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.guide-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.workspace {
  border-radius: 8px;
  padding: clamp(14px, 3vw, 24px);
}

.controls-bar,
.action-row,
.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.controls-bar {
  margin-bottom: 16px;
}

.mode-button,
.primary-button,
.secondary-button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fffaf0;
  text-decoration: none;
  cursor: pointer;
}

.mode-button.active,
.primary-button {
  border-color: var(--clay-dark);
  background: var(--clay);
  color: white;
}

.primary-button:disabled,
.download-link.disabled {
  opacity: 0.46;
  cursor: not-allowed;
  pointer-events: none;
}

.secondary-button {
  background: transparent;
}

.input-pane {
  display: none;
}

.input-pane.active {
  display: block;
}

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

.drop-zone {
  min-height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  border: 2px dashed #a4b18d;
  border-radius: 8px;
  background:
    repeating-linear-gradient(135deg, rgba(184, 219, 232, 0.17) 0 10px, transparent 10px 20px),
    rgba(255, 255, 255, 0.44);
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  font-size: 1.18rem;
  font-weight: 800;
}

.drop-detail,
.camera-hint,
.status-strip,
.preview-card span {
  color: var(--muted);
}

.camera-tools {
  display: grid;
  gap: 12px;
}

#cameraPreview {
  width: 100%;
  max-height: 58vh;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #20302a;
  object-fit: contain;
}

.action-row {
  align-items: center;
  margin-top: 18px;
}

.status-strip {
  margin: 16px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--sky);
  background: rgba(184, 219, 232, 0.2);
}

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

.preview-card {
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
}

.preview-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.preview-card h2 {
  margin: 0;
  font-size: 1rem;
}

canvas {
  display: block;
  width: 100%;
  min-height: 210px;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, rgba(23, 33, 29, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(23, 33, 29, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(23, 33, 29, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(23, 33, 29, 0.08) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.result-card {
  outline: 2px solid rgba(185, 103, 75, 0.25);
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.warning-item {
  padding: 10px 12px;
  border-left: 4px solid var(--clay);
  background: rgba(185, 103, 75, 0.12);
  color: #663525;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 880px) {
  .hero,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: 220px;
  }

  .result-card {
    order: -1;
  }
}

@media (max-width: 620px) {
  .app-shell,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  .drop-grid {
    grid-template-columns: 1fr;
  }

  .action-row > *,
  .controls-bar > * {
    flex: 1 1 auto;
  }

  .preview-card header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}
