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

:root {
  --bg: #f4f0eb;
  --ink: #111;
  --accent: #ff3300;
  --muted: #888;
  --card-bg: #fff;
  --border: #ddd;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  padding: 20px 32px;
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
}

.logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--accent);
  font-style: italic;
}

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px 40px;
  gap: 48px;
}

/* ── Hero ── */
.hero {
  text-align: center;
}

h1 {
  font-size: clamp(48px, 10vw, 96px);
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  color: var(--ink);
}

.subtitle {
  margin-top: 16px;
  font-size: 18px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Upload ── */
.upload-section {
  width: 100%;
  max-width: 560px;
}

.drop-zone {
  border: 3px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: #fff5f3;
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 32px;
}

.ruler-icon {
  font-size: 48px;
  line-height: 1;
}

.drop-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 8px;
}

.drop-sub {
  color: var(--muted);
  font-size: 14px;
}

.btn-upload {
  margin-top: 4px;
  padding: 12px 28px;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-upload:hover {
  background: var(--accent);
}

.drop-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Loading ── */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-msg {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

/* ── Result ── */
.result-section {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.result-label {
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.5px;
}

.result-label em {
  font-style: normal;
  color: var(--accent);
}

.comparison {
  display: flex;
  gap: 16px;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}

.comparison-card {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.comparison-card img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 480px;
  object-fit: contain;
  background: #f8f8f8;
}

.card-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
}

.after-tag {
  background: var(--accent);
}

.comparison-arrow {
  font-size: 28px;
  color: var(--muted);
  flex-shrink: 0;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-share {
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-share:hover {
  opacity: 0.85;
}

.btn-another {
  padding: 12px 32px;
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-another:hover {
  background: var(--ink);
  color: #fff;
}

/* ── Error ── */
.error-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.error-msg {
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  max-width: 480px;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  main {
    padding: 40px 16px 32px;
    gap: 36px;
  }
  .comparison-arrow {
    transform: rotate(90deg);
  }
}
