:root {
  --indigo: #3732A5;
  --magenta: #B41290;
  --blue: #1355F4;
  --sky: #3BA4F5;
  --orange-from: #F88641;
  --orange-to: #F26A1B;
  --ink: #1F2240;
  --muted: #4E5270;
  --card: #FFFFFF;
  --danger: #B3261E;
  --radius: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: linear-gradient(170deg, #C9DFF6 0%, #F4F6F6 52%, #F5D7C0 100%) fixed;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
}

.hero { text-align: center; padding: 8px 4px 20px; }
.eyebrow { margin: 0 0 6px; color: var(--magenta); font-weight: 600; font-size: 17px; }

h1, h2 { font-family: Montserrat, "Be Vietnam Pro", system-ui, sans-serif; margin: 0; }
h1 { color: var(--indigo); font-size: 30px; font-weight: 800; line-height: 1.22; }
h2 { color: var(--indigo); font-size: 24px; font-weight: 700; line-height: 1.3; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: 0 8px 24px rgba(55, 50, 165, .12);
}
.center { text-align: center; }
.lead { margin: 0 0 18px; font-size: 19px; }

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 60px;
  margin-top: 12px;
  padding: 12px 18px;
  border: 0;
  border-radius: 16px;
  font-family: Montserrat, "Be Vietnam Pro", system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .file-input:focus-visible + .btn { outline: 3px solid var(--sky); outline-offset: 2px; }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn-primary { color: #fff; background: linear-gradient(180deg, var(--orange-from), var(--orange-to)); box-shadow: 0 6px 16px rgba(242, 106, 27, .32); }
.btn-secondary { color: var(--indigo); background: #EEF1FD; }

.error { margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; color: var(--danger); background: #FDECEA; font-weight: 500; }
.privacy { margin: 16px 0 0; color: var(--muted); font-size: 16px; text-align: center; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 16px; }

.spinner {
  width: 52px;
  height: 52px;
  margin: 8px auto 16px;
  border: 5px solid #DDE3FA;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.section-title { margin: 26px 4px 4px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.tile {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #E7EAF6;
  cursor: pointer;
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.tile-wrap { position: relative; border-radius: 14px; }
.tile-wrap.is-selected { box-shadow: 0 0 0 4px var(--orange-to); }
.tile-wrap.is-selected .tile img { opacity: .78; }
.tile-check { position: absolute; top: 0; right: 0; display: flex; align-items: flex-start; justify-content: flex-end; width: 52px; height: 52px; padding: 7px; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tile-check span { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 2.5px solid #fff; border-radius: 50%; color: transparent; background: rgba(14, 16, 36, .5); font-size: 20px; font-weight: 700; line-height: 1; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.tile-check[aria-checked="true"] span { color: #fff; background: var(--orange-to); }
.tile-check:focus-visible { outline: 3px solid var(--sky); outline-offset: -3px; border-radius: 14px; }
.select-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 2px; }
.select-actions .btn { min-height: 54px; margin-top: 0; font-size: 17px; }
.select-actions .btn[disabled] { opacity: .5; cursor: default; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -6px 20px rgba(55, 50, 165, .2); }
.save-bar-inner { max-width: 688px; margin: 0 auto; }
.save-bar-row { display: flex; gap: 8px; }
.save-bar .btn { flex: 1; min-width: 0; min-height: 58px; margin-top: 0; font-size: 18px; }
.save-bar .save-stop { flex: 0 0 84px; font-size: 17px; }
body.has-save-bar .page { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: #0E1024;
}
.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  font-size: 17px;
}
.viewer-close { min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; color: #fff; background: rgba(255, 255, 255, .16); font: inherit; font-weight: 600; cursor: pointer; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; -webkit-touch-callout: default; }
.viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: 48px;
  height: 64px;
  margin-top: -32px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(14, 16, 36, .55);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
#viewer-prev { left: 6px; }
#viewer-next { right: 6px; }
.viewer-bottom { padding: 4px 16px calc(14px + env(safe-area-inset-bottom)); }
.viewer-hint { margin: 8px 0 0; color: #C8CCE6; font-size: 15px; text-align: center; }
.viewer-status { margin: 8px 0 0; color: #fff; font-size: 17px; font-weight: 500; text-align: center; }
.viewer-status.is-error { color: #FFB4AB; }
.save-status { margin: 0 0 8px; color: var(--indigo); font-size: 16px; font-weight: 500; line-height: 1.35; text-align: center; }
.save-status.is-error { color: var(--danger); }
