:root {
  --bg: #f6f4ef;
  --paper: #ffffff;
  --ink: #1b1d22;
  --muted: #646a73;
  --line: #e2ded5;
  --accent: #1f4fd1;
  --accent-ink: #ffffff;
  --ok: #1f8a4c;
  --warn: #c27a00;
  --fail: #c62e2e;
  --radius: 14px;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); letter-spacing: -0.02em; margin: 0 0 0.4em; }
h2 { font-size: 1.05rem; margin: 0 0 0.6em; }
p { line-height: 1.55; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem); border-bottom: 1px solid var(--line); background: var(--paper);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem; }
.logo { width: 20px; height: 26px; border: 2.5px solid var(--accent); border-radius: 4px; position: relative; }
.logo::after { content: ''; position: absolute; left: 50%; top: 4px; width: 8px; height: 10px; transform: translateX(-50%); border-radius: 50%; background: var(--accent); }
.steps { display: flex; gap: 0.25rem; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.steps li { padding: 0.35rem 0.7rem; border-radius: 99px; color: var(--muted); white-space: nowrap; }
.steps li::before { content: attr(data-step) '. '; }
.steps li.active { background: var(--ink); color: #fff; }
.steps li.done { color: var(--ok); }
@media (max-width: 640px) { .steps li:not(.active) { display: none; } }

main { max-width: 1120px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 2.5rem); }
.lead { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }
.fineprint { color: var(--muted); font-size: 0.82rem; max-width: 70ch; margin-top: 2rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card {
  text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem; cursor: pointer; font: inherit; color: inherit; display: flex; gap: 1rem; align-items: flex-start;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .mini { flex: none; background: #fbfaf7; border: 1px solid var(--line); border-radius: 4px; }
.card h3 { margin: 0 0 0.3rem; font-size: 1.02rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.card .tag { display: inline-block; margin-top: 0.5rem; font-size: 0.75rem; font-weight: 700; color: var(--accent); }

.btn {
  font: inherit; font-weight: 700; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink);
  border-radius: 99px; padding: 0.65rem 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost.light { color: #fff; }
.btn.big { padding: 0.9rem 1.4rem; font-size: 1rem; width: 100%; }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn:disabled { opacity: .5; cursor: default; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.source-buttons { display: grid; gap: 0.75rem; max-width: 420px; }
.mobile-only { display: none; }
@media (pointer: coarse) { .mobile-only { display: inline-flex; } }
.hint { color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.tips { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.tips ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.55rem; font-size: 0.92rem; line-height: 1.45; }

.camera { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 78vh; margin-bottom: 1rem; }
.camera video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camera .guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-feedback {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff;
  padding: 0.45rem 0.9rem; border-radius: 99px; font-weight: 700; font-size: 0.92rem; white-space: nowrap;
}
.cam-feedback.good { background: var(--ok); }
.cam-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 6rem; font-weight: 800; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,.5); }
.cam-bar { position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 1rem; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.3); cursor: pointer; }
.shutter:active { background: #fff; }
.timer { color: #fff; font-weight: 700; display: flex; gap: .3rem; align-items: center; }

.editor { display: grid; grid-template-columns: minmax(240px, 380px) minmax(0, 1fr); gap: 2rem; align-items: start; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }
.preview-wrap { position: sticky; top: 80px; }
@media (max-width: 760px) { .preview-wrap { position: static; max-width: 300px; margin: 0 auto; } }
.preview { position: relative; box-shadow: 0 10px 30px rgba(0,0,0,.12); background: #fff; line-height: 0; }
.preview canvas { width: 100%; height: auto; display: block; }
.preview .guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.size-label { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 0.3rem 0 0; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.9rem; margin: 0.5rem 0; line-height: 1.4; }
.check input { margin-top: 0.2rem; }

.panel { display: grid; gap: 1rem; }
.summary { border-radius: var(--radius); padding: 1rem 1.2rem; font-weight: 700; display: flex; gap: .8rem; align-items: center; }
.summary.ok { background: #e3f3e9; color: var(--ok); }
.summary.warn { background: #fbf0dc; color: var(--warn); }
.summary.fail { background: #fbe4e4; color: var(--fail); }
.summary small { display: block; font-weight: 500; color: var(--ink); opacity: .8; }
.report { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.report li { display: grid; grid-template-columns: 22px 1fr; gap: 0.6rem; padding: 0.65rem 1rem; border-top: 1px solid var(--line); font-size: 0.9rem; }
.report li:first-child { border-top: 0; }
.report .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; }
.report .ok .dot { background: var(--ok); }
.report .warn .dot { background: var(--warn); }
.report .fail .dot { background: var(--fail); }
.report .val { color: var(--muted); font-size: 0.82rem; }
.report .tip { font-size: 0.84rem; margin-top: 0.15rem; }
.report .fail .tip { color: var(--fail); }
.report .warn .tip { color: var(--warn); }

.group { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1.1rem; }
.group summary { font-weight: 700; cursor: pointer; }
.group[open] summary { margin-bottom: 0.6rem; }
.slider { display: grid; grid-template-columns: 9.5rem 1fr 3.8rem; align-items: center; gap: 0.6rem; font-size: 0.88rem; margin: 0.35rem 0; }
.slider output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); }
@media (max-width: 420px) { .slider { grid-template-columns: 1fr 3.5rem; } .slider label { grid-column: 1 / -1; } }
.radio-row { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: 0.9rem; }
.warn-box { background: #fbf0dc; color: #7a4d00; border-radius: 10px; padding: 0.6rem 0.8rem; font-size: 0.84rem; line-height: 1.45; }

.nav { display: flex; justify-content: space-between; margin-top: 2rem; gap: 1rem; }
.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; max-width: 420px; }
.field label { font-weight: 700; font-size: 0.9rem; }
.field select, .field input { font: inherit; padding: 0.6rem 0.8rem; border-radius: 10px; border: 1.5px solid var(--line); background: var(--paper); }
.actions { display: grid; gap: 0.6rem; max-width: 420px; margin: 1.2rem 0 0.5rem; }
.info-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-top: 1.2rem; font-size: 0.9rem; max-width: 520px; }
.info-box ol { margin: 0.5rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.3rem; }
.sheet-preview { display: flex; justify-content: center; }
.sheet-preview svg { width: 100%; max-width: 380px; height: auto; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.12); }

.overlay { position: fixed; inset: 0; background: rgba(246,244,239,.86); display: grid; place-content: center; justify-items: center; gap: 1rem; z-index: 50; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dialog { background: var(--paper); border-radius: var(--radius); padding: 1.5rem; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.2); display: grid; gap: 1rem; }
.dialog p { margin: 0; }
