:root {
  --red: #b01e2d;
  --red-dark: #8f1824;
  --red-tint: #fbeef0;
  --ink: #16181b;
  --muted: #646b74;
  --line: #dfe2e6;
  --bg: #f4f5f7;
  --card: #ffffff;
  --green: #1f7a3d;
  --green-tint: #e8f4ec;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.wordmark { height: 34px; width: auto; display: block; }
.app-label { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--muted); }
.back {
  border: 0; background: none; padding: 6px; margin-left: -6px;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.back svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.back:active { background: var(--bg); }

.demo-banner {
  background: #fff4d6; color: #6b5200; text-align: center;
  font-size: 13px; font-weight: 600; padding: 6px 12px;
}

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 20px 16px 24px; }
.screen.center { text-align: center; padding-top: 48px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
.step { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--red); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); margin: 0 0 16px; }
.small { font-size: 13px; }
.warn { color: var(--red-dark); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; min-height: 56px; padding: 0 20px;
  border-radius: var(--radius); border: 0; cursor: pointer;
  font: inherit; font-size: 18px; font-weight: 650;
}
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 2px 6px rgba(176, 30, 45, 0.25); }
.btn.primary:active { background: var(--red-dark); }
.btn.primary:disabled { background: #e2e4e7; color: #8a9199; box-shadow: none; cursor: default; }
.btn.secondary { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
#scrSignin .btn { max-width: 320px; margin: 24px auto 0; }
.link {
  background: none; border: 0; padding: 4px 2px; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--red); text-decoration: none;
}

/* ---------- step 1 ---------- */
.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 132px; margin: 8px 0 18px; padding: 20px;
  border: 2px dashed #d9a1a8; border-radius: var(--radius);
  background: var(--red-tint); color: var(--red);
  font-size: 19px; font-weight: 650; cursor: pointer;
}
.dropzone.compact { min-height: 64px; font-size: 17px; }
.dropzone:active { background: #f6dfe2; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-plus {
  width: 36px; height: 36px; border-radius: 50%; background: var(--red); color: #fff;
  display: grid; place-items: center; font-size: 26px; line-height: 1; font-weight: 500;
}
.grid-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 600; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e7e9ec; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .badge {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; font-weight: 600;
}
.tile .remove {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 18px; line-height: 30px; cursor: pointer;
}

/* ---------- step 2 ---------- */
.field { border: 0; padding: 0; margin: 0 0 22px; }
h1 + .field { margin-top: 18px; }
.field > label, .field > legend { display: block; font-weight: 650; margin-bottom: 8px; padding: 0; }
.opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="search"] {
  width: 100%; min-height: 52px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--card);
  font: inherit; font-size: 17px; color: var(--ink); -webkit-appearance: none; appearance: none;
}
input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(176, 30, 45, 0.12); }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  min-height: 52px; padding: 8px 10px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--card);
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); text-align: center;
}
.chip[aria-checked="true"] { border-color: var(--red); background: var(--red-tint); color: var(--red-dark); }
.results { list-style: none; margin: 6px 0 0; padding: 0; background: var(--card); border-radius: 12px; overflow: hidden; }
.results:empty { display: none; }
.results li { border: 1px solid var(--line); border-top: 0; }
.results li:first-child { border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.results li:last-child { border-radius: 0 0 12px 12px; }
.results button {
  display: block; width: 100%; text-align: left; padding: 12px 14px; min-height: 56px;
  border: 0; background: none; font: inherit; cursor: pointer;
}
.results button:active { background: var(--bg); }
.results strong { display: block; font-size: 16px; }
.results span { font-size: 13px; color: var(--muted); }
#repHint { margin: 6px 0 0; }
.rep-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1.5px solid #9fcfb0; background: var(--green-tint); border-radius: 12px;
}
.check { width: 32px; height: 32px; border-radius: 50%; background: var(--green); flex: none; display: grid; place-items: center; }
.check svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.rep-text { flex: 1; min-width: 0; }
.rep-text strong, .rep-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-text span { margin: 0; }

/* ---------- uploading ---------- */
.bar { height: 10px; border-radius: 99px; background: #e2e4e7; overflow: hidden; margin: 8px 0 6px; }
.bar-fill { height: 100%; width: 0; background: var(--red); transition: width 0.3s ease; }
.uplist { list-style: none; margin: 16px 0 0; padding: 0; }
.uplist li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 6px;
  background: var(--card); border-radius: 10px; font-size: 14px;
}
.uplist .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uplist .st { font-weight: 600; color: var(--muted); flex: none; }
.uplist .st.ok { color: var(--green); }
.uplist .st.bad { color: var(--red); }

/* ---------- done ---------- */
.done-mark { width: 84px; height: 84px; border-radius: 50%; background: var(--green); margin: 0 auto 18px; display: grid; place-items: center; }
.done-mark svg { width: 46px; height: 46px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#doneCount { font-size: 17px; margin: 0 0 4px; }
#doneLink { display: inline-block; margin-top: 4px; }

/* ---------- bottom bar ---------- */
.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 12px 16px calc(8px + var(--safe-b));
}
.actionbar > * { max-width: 528px; margin-left: auto; margin-right: auto; }
.actionbar .btn + .btn { margin-top: 8px; }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin: 0 auto 8px; }
.hint:empty { display: none; }
.foot { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: #8a9199; margin: 8px auto 0; }
.foot .link { font-size: 11.5px; padding: 2px; }

/* ---------- loading ---------- */
.spinner { width: 36px; height: 36px; margin: 40px auto; border-radius: 50%; border: 4px solid #e2e4e7; border-top-color: var(--red); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .bar-fill { transition: none; }
}
