@font-face { font-family: Poppins; font-weight: 400; font-display: swap; src: url(fonts/poppins-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Poppins; font-weight: 400; font-display: swap; src: url(fonts/poppins-400-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(fonts/poppins-600-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(fonts/poppins-600-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Poppins; font-weight: 700; font-display: swap; src: url(fonts/poppins-700-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Poppins; font-weight: 700; font-display: swap; src: url(fonts/poppins-700-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --cream: #FDF6EE;
  --parchment: #F5EDD8;
  --brown: #3D1F0A;
  --body: #5A3A1E;
  --gold: #C9A44A;
  --gold-dark: #B8902F;
  --line: #E6D7BC;
  --ok: #4C7A43;
  --bad: #B5432F;
  --warn: #C9861A;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--body);
  font: 400 17px/1.5 Poppins, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.top-seal { width: 56px; height: auto; flex: none; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dark); }
h1 { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 700; color: var(--brown); }

.step { display: flex; align-items: center; gap: 10px; margin: 24px 0 12px; font-size: 18px; font-weight: 600; color: var(--brown); }
.step span {
  display: grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; background: var(--brown); color: var(--cream); font-size: 15px;
}

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

.install { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; background: var(--parchment); }
.install p { margin: 0; flex: 1; font-size: 15px; line-height: 1.4; }
.install strong { color: var(--brown); }

.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.style-card {
  position: relative; display: block; cursor: pointer;
  background: #fff; border: 3px solid var(--line); border-radius: var(--radius);
  padding: 8px 8px 10px; text-align: center; transition: border-color .15s, transform .15s;
}
.style-card:active { transform: scale(.98); }
.style-card img { display: block; width: 100%; height: auto; border-radius: 10px; }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-name { display: block; margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--brown); line-height: 1.25; }
.style-card:has(input:checked) { border-color: var(--gold); box-shadow: 0 4px 14px rgba(201, 164, 74, .3); }
.style-card:has(input:checked)::after {
  content: "✓"; position: absolute; top: -10px; right: -10px;
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--gold); color: #fff; font-weight: 700; font-size: 16px;
}
.style-card:has(input:focus-visible) { outline: 3px solid var(--brown); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 20px; border: 0; border-radius: 14px;
  font: 600 17px/1.2 Poppins, system-ui, sans-serif; cursor: pointer;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn svg { width: 26px; height: 26px; fill: currentColor; flex: none; }
.btn-main { width: 100%; min-height: 64px; background: var(--brown); color: var(--cream); font-size: 19px; box-shadow: 0 6px 16px rgba(61, 31, 10, .25); }
.btn-ghost { background: transparent; color: var(--brown); border: 2px solid var(--line); }
.btn-ghost-light { background: rgba(255, 255, 255, .15); color: #fff; }
.btn-small { min-height: 44px; padding: 8px 18px; background: var(--brown); color: var(--cream); font-size: 15px; }
#pick-label { position: relative; overflow: hidden; }
#pick-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#pick-label.locked { opacity: .45; box-shadow: none; }
.style-card:has(input:disabled) { opacity: .6; }
.hint { margin: 8px 0 0; text-align: center; font-size: 14px; color: #8a6d4f; }

.status { margin-top: 24px; }
.status-head { display: flex; align-items: center; gap: 12px; }
.status-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--brown); line-height: 1.3; }
.status-sub { margin: 10px 0 0; font-size: 15px; }
.status-warn { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: #FFF4DC; font-size: 14px; color: #7a5410; }
.spinner {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--gold); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.done-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--ok); }
.done-mark svg { width: 22px; height: 22px; fill: #fff; }
.bar { height: 12px; margin-top: 14px; border-radius: 99px; background: var(--parchment); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-dark)); transition: width .3s; }
.actions { margin-top: 16px; display: grid; gap: 12px; }
.row { display: flex; gap: 12px; }
.row .btn { flex: 1; }
.saved-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: #EAF2E7; color: #2f5228; font-size: 15px; }
#stop, #retry { width: 100%; margin-top: 14px; }

.results { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.thumb {
  position: relative; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: #fff; aspect-ratio: 2 / 3; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.waiting { background: var(--parchment); }
.thumb.waiting::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .9s linear infinite;
}
.thumb.queued::after { animation: none; border-top-color: var(--line); }
.badge {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 4px 6px; border-radius: 8px;
  font-size: 12px; font-weight: 600; line-height: 1.25; color: #fff; text-align: center;
}
.badge.bad { background: var(--bad); }
.badge.warn { background: var(--warn); }
.thumb.failed { display: grid; place-items: center; padding: 8px 8px 40px; font-size: 12px; color: var(--body); text-align: center; word-break: break-all; }

.foot { margin-top: 32px; text-align: center; font-size: 13px; color: #8a6d4f; }
.foot p { margin: 0; }

.viewer {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
  background: rgba(20, 10, 2, .92); padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-bar { display: flex; gap: 10px; margin-top: 12px; }
.viewer-bar .btn { flex: 1; min-height: 56px; width: auto; }
