:root {
  color-scheme: light;
  --bg: #f3efe6;
  --bg-strong: #e6dfd1;
  --ink: #1d1a14;
  --muted: #645f52;
  --accent: #9f2f17;
  --accent-strong: #7a1f0d;
  --line: rgba(29, 26, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.72), rgba(255,255,255,0) 38%),
    linear-gradient(180deg, #ece5d7 0%, #f5f1e8 100%);
}

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

.intro-band,
.pad-band {
  display: grid;
  gap: 16px;
  align-items: stretch;
}

.intro-band {
  grid-template-columns: 1.5fr 1fr;
  margin-bottom: 16px;
}

.intro-copy,
.result-strip,
.pad-stage,
.insight-panel {
  background: rgba(247, 244, 238, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.intro-copy {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.intro-text {
  margin: 12px 0 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.result-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 20px;
}

.result-main strong,
.result-score strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
}

.result-label,
.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.pad-band {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
}

.pad-stage,
.insight-panel {
  padding: 16px;
}

.paper-frame {
  position: relative;
  min-height: 64vh;
  border: 1px solid rgba(29, 26, 20, 0.1);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.38), rgba(255,255,255,0.2)),
    repeating-linear-gradient(
      0deg,
      rgba(140, 126, 98, 0.06) 0,
      rgba(140, 126, 98, 0.06) 1px,
      transparent 1px,
      transparent 28px
    ),
    linear-gradient(180deg, #f8f5ee 0%, #efe7d7 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

#draw-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.actions-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

button {
  appearance: none;
  border: 1px solid rgba(29, 26, 20, 0.14);
  border-radius: 8px;
  background: #f6f2eb;
  color: var(--ink);
  padding: 14px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(29, 26, 20, 0.26);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff5ef;
}

button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.status-text {
  margin: 12px 0 0;
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.insight-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.preview-block,
.candidates-block {
  display: grid;
  gap: 10px;
}

#preview-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(29, 26, 20, 0.12);
  background: #f0ece3;
}

#candidate-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
}

#candidate-list li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(29, 26, 20, 0.08);
}

#candidate-list li:last-child {
  border-bottom: none;
}

@media (max-width: 920px) {
  body {
    background:
      radial-gradient(circle at top left, rgba(255,255,255,0.68), rgba(255,255,255,0) 42%),
      linear-gradient(180deg, #ece5d7 0%, #f5f1e8 100%);
  }

  .intro-band,
  .pad-band {
    grid-template-columns: 1fr;
  }

  .paper-frame {
    min-height: 58vh;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 12px, 100%);
    padding: 6px 0 18px;
  }

  .intro-copy,
  .result-strip,
  .pad-stage,
  .insight-panel {
    padding: 12px;
  }

  .actions-row {
    grid-template-columns: 1fr;
  }

  .result-strip {
    grid-template-columns: 1fr 1fr;
  }

  .pad-stage,
  .insight-panel {
    gap: 12px;
  }

  .paper-frame {
    min-height: 56vh;
    border-radius: 8px;
  }

  h1 {
    font-size: clamp(28px, 9vw, 40px);
  }

  .intro-text {
    font-size: 15px;
  }

  button {
    min-height: 48px;
    padding: 13px 12px;
  }

  #preview-image {
    aspect-ratio: 4 / 3;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: calc(100vw - 8px);
  }

  .intro-band,
  .pad-band {
    gap: 10px;
  }

  .paper-frame {
    min-height: 60vh;
  }

  .result-main strong,
  .result-score strong {
    font-size: 26px;
  }
}
