:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.24);
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --separator: rgba(60, 60, 67, 0.18);
  --accent: #5e5ce6;
  --danger: #ff3b30;
  --success: #34c759;
  --bar: rgba(242, 242, 247, 0.78);
  --radius: 22px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --separator: rgba(84, 84, 88, 0.6);
  --accent: #7d7aff;
  --bar: rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--label); }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  letter-spacing: -0.2px;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
svg { flex: none; }

.page { animation: enter 0.35s var(--ease); padding-bottom: max(28px, env(safe-area-inset-bottom)); }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.4px; margin: 6px 0 14px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 22px 0 10px; }
.section-head h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: 0.35px; }
.count { color: var(--label-2); font-size: 15px; }
.secondary { color: var(--label-2); }

.scroller {
  display: flex; gap: 14px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px;
  scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 0 16px;
}
.scroller::-webkit-scrollbar { display: none; }

.story { flex: none; width: 74px; background: none; border: 0; padding: 0; cursor: pointer; scroll-snap-align: start; text-align: center; }
.story-ring {
  width: 72px; height: 72px; border-radius: 50%; padding: 3px; margin: 0 auto;
  background: conic-gradient(from 210deg, #5e5ce6, #bf5af2, #ff375f, #ff9f0a, #5e5ce6);
  transition: transform 0.2s var(--ease);
}
.story.seen .story-ring { background: var(--fill-strong); }
.story-ring video, .story-ring img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid var(--bg); background: var(--fill);
}
.story span { display: block; font-size: 12px; margin-top: 6px; color: var(--label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story:active .story-ring { transform: scale(0.94); }

.chips { gap: 8px; margin-top: 4px; }
.chip {
  flex: none; height: 34px; padding: 0 15px; border: 0; border-radius: 17px; cursor: pointer;
  background: var(--fill); font-size: 15px; font-weight: 500; transition: background 0.2s, color 0.2s;
}
.chip.active { background: var(--label); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; margin-top: 14px; }
.card {
  position: relative; display: block; aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden;
  background: var(--fill); color: #fff; text-decoration: none; transform: translateZ(0);
  transition: transform 0.25s var(--ease);
}
.card:active { transform: scale(0.97); }
.card video, .card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card::after { content: ""; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(0, 0, 0, 0.62)); }
.card-copy { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 1; }
.card-copy h3 { font-size: 16px; line-height: 20px; font-weight: 600; margin: 0 0 8px; }
.meta { display: flex; justify-content: space-between; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-size: 14px; font-weight: 600;
}
.need { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; opacity: 0.9; }
.empty { text-align: center; padding: 40px 0; }

.nav { display: flex; align-items: center; height: 44px; margin: 0 -8px 6px; }
.nav-back { display: inline-flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 8px; }
.hero { width: 100%; aspect-ratio: 4 / 5; max-height: 46vh; object-fit: cover; border-radius: var(--radius); background: var(--fill); display: block; }
.title { font-size: 28px; line-height: 34px; font-weight: 700; margin: 16px 0 6px; letter-spacing: 0.36px; }

.group { background: var(--surface); border-radius: 14px; overflow: hidden; }
.group-header { font-size: 13px; text-transform: uppercase; color: var(--label-2); margin: 24px 16px 7px; }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; font-size: 15px; }
.row + .row { border-top: 0.5px solid var(--separator); margin-left: 16px; padding-left: 0; }
.row svg { color: var(--success); margin-top: 1px; }

.slot { margin-top: 18px; }
.slot-label { font-size: 15px; font-weight: 600; margin: 0 4px 8px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 168px; padding: 18px; border-radius: var(--radius); background: var(--surface); cursor: pointer;
  text-align: center; overflow: hidden; transition: transform 0.2s var(--ease);
}
.drop:active { transform: scale(0.98); }
.drop input { display: none; }
.drop-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--fill); color: var(--accent); }
.drop strong { color: var(--accent); font-weight: 600; }
.drop small { color: var(--label-2); font-size: 13px; }
.drop img.preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: enter 0.3s var(--ease); }
.drop .replace {
  position: absolute; right: 10px; bottom: 10px; z-index: 1; height: 30px; padding: 0 12px; border-radius: 15px;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 13px; display: inline-flex; align-items: center;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.error { color: var(--danger); font-size: 13px; margin: 6px 4px 0; }
.error:empty { display: none; }

.bar {
  position: sticky; bottom: 0; z-index: 5; margin: 20px -16px 0;
  padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.page.with-bar { padding-bottom: 0; }
.cta {
  width: 100%; height: 50px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600;
  transition: opacity 0.2s, transform 0.2s var(--ease);
}
.cta:active:not(:disabled) { transform: scale(0.98); }
.cta:disabled { background: var(--fill); color: var(--label-2); cursor: default; }
.cta.plain { background: var(--fill); color: var(--accent); margin-top: 10px; }
.note { text-align: center; font-size: 12px; color: var(--label-2); margin-top: 8px; }

.progress { padding-top: 5vh; }
.ring { width: 88px; height: 88px; margin: 0 auto 20px; display: block; }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--fill); }
.ring .spin { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 70 200; transform-origin: center; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress h2 { text-align: center; font-size: 22px; margin: 0 0 6px; }
.progress > p { text-align: center; margin: 0; }
.step { display: flex; align-items: center; gap: 12px; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: #fff; }
.step.done .dot { background: var(--success); }
.step.now .dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.step.todo { color: var(--label-2); }
.step.fail .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.45; } }
.result { width: 100%; border-radius: var(--radius); background: #000; display: block; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
