:root {
  color-scheme: light;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #e6f4f1;
  --accent: #14b8a6;
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #5b6b7f;
  --line: #e3e9ee;
  --bg: #f5f8f8;
  --card: #ffffff;
  --stage-0: #16a34a;
  --stage-1: #ca8a04;
  --stage-2: #ea580c;
  --stage-3: #dc2626;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3 { color: var(--ink); line-height: 1.3; margin: 0 0 .6em; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.75rem, 6vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 4.5vw, 1.75rem); }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand__mark { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); position: relative; flex: none; }
.brand__mark::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 7px; height: 8px;
  border: 2.5px solid #fff; border-bottom: 0; border-radius: 10px 10px 0 0;
}
.brand__name { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand__en { font-size: .72rem; font-weight: 700; color: var(--brand); letter-spacing: .08em; }
.model-status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); text-align: right; }
.model-status__dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.model-status[data-kind="busy"] .model-status__dot { background: var(--stage-1); animation: pulse 1.2s ease-in-out infinite; }
.model-status[data-kind="ok"] .model-status__dot { background: var(--stage-0); }
.model-status[data-kind="err"] { color: var(--stage-3); }
.model-status[data-kind="err"] .model-status__dot { background: var(--stage-3); }
@keyframes pulse { 50% { opacity: .35; } }

/* 화면 전환 */
main { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }
.screen { display: none; }
.screen.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1.5px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.btn:active { transform: scale(.98); }
.btn--lg { min-height: 56px; font-size: 1.05rem; padding: 0 26px; }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(15, 118, 110, .25); }
.btn--primary:hover { background: var(--brand-strong); }
.btn--ghost { background: #fff; color: var(--brand-strong); border-color: #b9dcd6; }
.btn--ghost:hover { background: var(--brand-soft); }
.btn:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.back {
  background: none; border: 0; padding: 6px 0; margin-bottom: 8px;
  color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer;
}
.back:hover { color: var(--brand); }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 8px; }
.actions .btn { width: 100%; }

/* 첫 화면 */
.hero { display: grid; gap: 20px; align-items: center; }
.eyebrow {
  display: inline-block; margin-bottom: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-size: .82rem; font-weight: 700;
}
.lead { color: var(--muted); font-size: 1.02rem; margin-bottom: 22px; }
.lead strong { color: var(--ink); }
.hero .btn { width: 100%; }
.privacy-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px; border-radius: var(--radius); background: var(--card);
  border: 1px solid #cfe7e2; box-shadow: var(--shadow);
}
.privacy-card__icon { width: 34px; height: 34px; flex: none; fill: var(--brand-soft); stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.privacy-card__title { font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.privacy-card__body { color: var(--muted); font-size: .92rem; margin: 0; }
.features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.features li {
  display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: start;
  padding: 16px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
}
.features svg { grid-row: span 2; width: 40px; height: 40px; padding: 8px; border-radius: 12px; background: var(--brand-soft); fill: none; stroke: var(--brand); stroke-width: 1.6; }
.features strong { color: var(--ink); }
.features span { color: var(--muted); font-size: .9rem; }

/* 촬영 가이드 */
.tips { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tips li { display: flex; gap: 14px; padding: 16px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.tips__no {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: .9rem;
}
.tips strong { color: var(--ink); }
.tips p { margin: 2px 0 0; color: var(--muted); font-size: .93rem; }
.note {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px;
  background: #fff8e6; border: 1px solid #f6e3b0; color: #6b4e00; font-size: .9rem;
}
.fineprint { color: var(--muted); font-size: .84rem; margin: 6px 0 0; text-align: center; }

/* 분석 중 */
.scan {
  position: relative; margin: 8px auto 16px; max-width: 420px; border-radius: var(--radius);
  overflow: hidden; background: #0b1220; box-shadow: var(--shadow);
}
.scan canvas { display: block; width: 100%; height: auto; opacity: .85; }
.scan__line {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%;
  background: linear-gradient(180deg, rgba(20, 184, 166, 0), rgba(20, 184, 166, .45), rgba(20, 184, 166, 0));
  animation: scan 1.4s ease-in-out infinite;
}
@keyframes scan { to { top: 100%; } }
.analyzing-text { text-align: center; font-weight: 700; color: var(--ink); }

/* 결과 */
.summary {
  padding: 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.summary__title { font-size: 1.15rem; font-weight: 800; color: var(--ink); margin: 0 0 6px; }
.summary__body { color: var(--muted); margin: 0; font-size: .93rem; }
.summary__list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.summary__list li { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; background: #f1f5f9; }

.result-grid { display: grid; gap: 16px; }
.viewer { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 12px; }
.photo { position: relative; margin: 0; border-radius: 12px; overflow: hidden; background: #0b1220; }
.photo canvas { display: block; width: 100%; height: auto; }
.photo .photo__heat { position: absolute; inset: 0; height: 100%; transition: opacity .2s; }
.photo.is-heat-off .photo__heat { opacity: 0; }
.viewer__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 12px 4px 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: .92rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .15s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: .5; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.legend i { width: 72px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, #2563eb, #facc15, #dc2626); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 4px; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.conditions { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; align-content: start; }
.cond { padding: 14px 16px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.cond__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cond__name { font-weight: 800; color: var(--ink); }
.cond__desc { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.badge {
  flex: none; padding: 3px 12px; border-radius: 999px; font-weight: 800; font-size: .88rem; color: #fff;
}
.badge[data-stage="0"] { background: var(--stage-0); }
.badge[data-stage="1"] { background: var(--stage-1); }
.badge[data-stage="2"] { background: var(--stage-2); }
.badge[data-stage="3"] { background: var(--stage-3); }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #eef2f6; margin: 10px 0 6px; gap: 2px; }
.bar span { display: block; height: 100%; min-width: 0; opacity: .35; }
.bar span.is-pick { opacity: 1; }
.bar span[data-stage="0"] { background: var(--stage-0); }
.bar span[data-stage="1"] { background: var(--stage-1); }
.bar span[data-stage="2"] { background: var(--stage-2); }
.bar span[data-stage="3"] { background: var(--stage-3); }
.cond__probs { display: grid; grid-template-columns: repeat(4, 1fr); font-size: .75rem; color: var(--muted); }
.cond__probs b { color: var(--ink); }

.about { margin-top: 18px; padding: 14px 16px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
.about summary { cursor: pointer; font-weight: 800; color: var(--ink); }
.about ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.about li + li { margin-top: 6px; }
.disclaimer {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: #f1f5f9;
  color: #334155; font-size: .88rem; border-left: 4px solid var(--brand);
}

.footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0 calc(20px + env(safe-area-inset-bottom)); }
.footer p { margin: 0 0 4px; color: var(--muted); font-size: .8rem; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 480px; margin: 0 auto; padding: 14px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 600; box-shadow: var(--shadow);
}

/* 넓은 화면(PC) */
@media (min-width: 760px) {
  main { padding-top: 40px; }
  .actions { flex-direction: row; justify-content: center; }
  .actions .btn { width: auto; min-width: 240px; }
  .hero .btn { width: auto; }
  .features { grid-template-columns: repeat(3, 1fr); }
  .features li { grid-template-columns: 1fr; row-gap: 8px; }
  .features svg { grid-row: auto; }
  .tips { grid-template-columns: 1fr 1fr; }
  #screen-guide, #screen-analyzing { max-width: 760px; margin: 0 auto; }
}
@media (min-width: 960px) {
  .hero { grid-template-columns: 1.25fr 1fr; gap: 40px; }
  .result-grid { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .viewer { position: sticky; top: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
