/* Bloom Camera Roll Sorter: ink, Bloom yellow, forest green. */
:root {
  --ink: #111311;
  --ink-2: #191c19;
  --ink-3: #222622;
  --ink-4: #2c312c;
  --line: rgba(245, 242, 231, 0.10);
  --line-2: rgba(245, 242, 231, 0.18);
  --cream: #F5F2E7;
  --body: #CFD2CA;
  --muted: #8E948C;
  --yellow: #FFD400;
  --yellow-soft: rgba(255, 212, 0, 0.14);
  --green: #105732;
  --green-2: #17703F;
  --green-hi: #2FA463;
  --danger: #FF8A5C;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: 'Anton', 'Impact', 'Arial Narrow', sans-serif;
  --sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); pointer-events: none; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  padding: calc(var(--safe-t) + 8px) 18px calc(var(--safe-b) + 14px);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(16, 87, 50, 0.35), transparent 60%),
    var(--ink);
}
.screen.active { display: flex; animation: screenIn .35s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
body.show-stats .screen { padding-top: calc(var(--safe-t) + 86px); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px 18px; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 58px; gap: 10px; }
.topbar-title { font: 700 18px/1.2 var(--sans); text-align: center; flex: 1; }
.logo { width: 118px; height: auto; }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--ink-2); display: grid; place-items: center; color: var(--cream); }
.icon-btn:active { background: var(--ink-3); }
.icon-btn-spacer { width: 48px; }

/* ---------- Type ---------- */
.kicker { margin: 0 0 10px; color: var(--yellow); font: 600 13px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; }
.display { margin: 0; font: 400 clamp(44px, 13.5vw, 62px)/0.98 var(--display); text-transform: uppercase; letter-spacing: .005em; }
.display-sm { margin: 0; font: 400 34px/1 var(--display); text-transform: uppercase; }
.accent { display: block; margin-top: 6px; font: italic 600 .62em/1.1 var(--serif); color: var(--yellow); text-transform: none; letter-spacing: 0; }
.display-sm .accent { font-size: 24px; }
.lead { color: var(--body); font-size: 17px; margin: 16px 0 0; }
.h2 { margin: 0 0 6px; font: 700 20px/1.25 var(--sans); }
.muted { color: var(--muted); margin: 0 0 12px; }
.small { font-size: 14px; }
.center { text-align: center; }
.note { color: var(--muted); font-size: 14px; text-align: center; margin: 4px 0 0; }
.warn { color: var(--yellow); font-size: 14px; margin: 12px 0 0; }
code { background: var(--ink-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px; border-radius: 999px; border: 0;
  font: 700 17px/1 var(--sans); text-decoration: none; user-select: none;
  transition: transform .12s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--yellow); color: var(--ink); font-weight: 800; box-shadow: 0 10px 30px -10px rgba(255, 212, 0, .55); }
.btn-green { background: var(--green); color: var(--cream); }
.btn-secondary { background: transparent; color: var(--cream); border: 1.5px solid var(--line-2); }
.btn-ghost { background: var(--ink-3); color: var(--cream); min-height: 46px; font-weight: 600; font-size: 15px; }
.btn-lg { min-height: 58px; width: 100%; font-size: 18px; }
.btn-xl { min-height: 68px; width: 100%; font-size: 21px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; font-size: 15px; padding: 14px; min-height: 48px; }
.link.center { display: block; margin: 8px auto 0; }

.chip {
  display: inline-flex; align-items: center; gap: 10px; align-self: center;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--ink-2); color: var(--body); font-size: 15px;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.chip.on .dot { background: var(--green-hi); box-shadow: 0 0 0 4px rgba(47, 164, 99, .2); }

.pill { display: inline-flex; align-items: center; flex: none; white-space: nowrap; height: 30px; padding: 0 14px; border-radius: 999px; background: var(--yellow); color: var(--ink); font: 800 14px/1 var(--sans); letter-spacing: .02em; }

/* ---------- Home ---------- */
.home-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; position: relative; }
.hero-tiles { position: relative; left: 50%; width: 0; height: 104px; margin-bottom: 28px; flex: none; }
.hero-tiles i {
  position: absolute; left: 0; top: 0; width: 58px; height: 58px; border-radius: 14px;
  transform: translate(calc(var(--x) - 29px), calc(var(--y) + 44px)) rotate(var(--r));
  animation: floaty 4.2s ease-in-out var(--d) infinite;
  border: 2px solid rgba(245, 242, 231, .85);
  background: linear-gradient(140deg, var(--yellow), #e0b800);
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .7);
}
.hero-tiles i:nth-child(2n) { background: linear-gradient(140deg, var(--green-2), var(--green)); }
.hero-tiles i:nth-child(3) { background: linear-gradient(140deg, #2a2f2a, #1a1d1a); }
@keyframes floaty { 50% { translate: 0 -10px; } }
.home-actions { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }

/* ---------- Destination ---------- */
.picked-summary { margin: 4px 0 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--ink-2); border: 1px solid var(--line); color: var(--body); font-size: 15px; }
.picked-summary b { color: var(--cream); }
.panel { padding: 18px; border-radius: var(--radius); background: var(--ink-2); border: 1px solid var(--line); margin-bottom: 14px; }
.panel .btn-lg { margin-top: 6px; }
.warn-panel { border-color: rgba(255, 212, 0, .4); background: rgba(255, 212, 0, .06); }
.warn-panel p { margin: 0 0 12px; color: var(--body); }
.who { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.dest-card {
  width: 100%; text-align: left; display: grid; gap: 4px; padding: 18px; margin-bottom: 14px;
  border-radius: var(--radius); border: 1.5px solid var(--line-2); background: var(--ink-2);
}
.dest-card.is-primary { border-color: var(--yellow); background: linear-gradient(160deg, rgba(255, 212, 0, .12), rgba(255, 212, 0, .02)); }
.dest-label { color: var(--muted); font-size: 14px; }
.dest-card strong { font-size: 21px; line-height: 1.2; }
.dest-go { justify-self: start; margin-top: 8px; height: 40px; padding: 0 18px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--yellow); color: var(--ink); font-weight: 800; }
.label { margin: 22px 0 8px; color: var(--yellow); font: 600 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; }
.panel .label { margin-top: 0; }
.row { display: flex; gap: 10px; }
.input {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 14px;
  border: 1.5px solid var(--line-2); background: var(--ink); font-size: 16px;
}
.input:focus, textarea:focus { outline: none; border-color: var(--yellow); }
.recent-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--ink-2); text-align: left; min-height: 56px; }
.recent-item svg { color: var(--yellow); flex: none; }
.recent-item span { flex: 1; font-weight: 500; }

/* ---------- Live counters ---------- */
.stats {
  position: fixed; z-index: 30; left: 12px; right: 12px; top: calc(var(--safe-t) + 10px);
  display: none; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
body.show-stats .stats { display: grid; }
.stat { background: rgba(25, 28, 25, .92); border: 1px solid var(--line); border-radius: 14px; padding: 9px 4px 8px; text-align: center; }
.stat b { display: block; font: 400 26px/1 var(--display); color: var(--cream); font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 4px; font: 600 10.5px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat:first-child { background: var(--yellow); border-color: var(--yellow); }
.stat:first-child b, .stat:first-child span { color: var(--ink); }
.stat b.bump { animation: bump .28s ease; }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ---------- Sorting ---------- */
#sort { padding-left: 12px; padding-right: 12px; }
.sort-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px 0; }
.sort-phase { color: var(--body); font-size: 14px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-zone { flex: 1; min-height: 210px; position: relative; display: grid; place-items: center; }
.swirl { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; position: relative; z-index: 5; }
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 5px 8px;
  padding: 7px 9px 8px 7px; border-radius: 13px; background: var(--ink-2); border: 1px solid var(--line);
  overflow: hidden; transition: border-color .3s, background .3s;
}
.card .thumb { width: 30px; height: 30px; border-radius: 8px; background: var(--ink-4) center/cover no-repeat; }
.card .count { font: 400 22px/1 var(--display); color: var(--cream); text-align: right; font-variant-numeric: tabular-nums; }
.card .name { grid-column: 1 / -1; min-height: 2.3em; font: 500 11.5px/1.15 var(--sans); color: var(--body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.special { border-color: rgba(255, 212, 0, .35); }
.card.special .count { color: var(--yellow); }
.card.hit { animation: hit .45s ease; }
@keyframes hit { 30% { background: var(--green); border-color: var(--green-hi); transform: scale(1.04); } }
.card.special.hit { animation-name: hitY; }
@keyframes hitY { 30% { background: rgba(255, 212, 0, .2); border-color: var(--yellow); transform: scale(1.04); } }
.progress { height: 6px; border-radius: 99px; background: var(--ink-3); margin-top: 12px; overflow: hidden; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green-hi), var(--yellow)); border-radius: 99px; transition: width .3s ease; }

.model-load { text-align: center; max-width: 290px; z-index: 25; position: relative; }
.model-load-title { font-weight: 700; font-size: 18px; margin: 14px 0 6px; }
.ring { position: relative; width: 130px; height: 130px; margin: 0 auto; }
.ring svg, .big-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track, .big-ring .track { fill: none; stroke: var(--ink-3); stroke-width: 10; }
.ring .fill, .big-ring .fill { fill: none; stroke: var(--yellow); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .3s; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 400 34px/1 var(--display); }

/* ---------- Review ---------- */
.review-head { padding: 4px 0 12px; }
.review-head .muted { margin: 8px 0 0; }
.review-scroll { padding-bottom: 24px; }
.review-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rcard { text-align: left; padding: 8px 8px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--ink-2); display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.rcard:active { transform: scale(.98); }
.rcard.special { border-color: rgba(255, 212, 0, .5); background: linear-gradient(170deg, rgba(255, 212, 0, .09), var(--ink-2) 60%); }
.rcard.empty { opacity: .45; }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: var(--ink-3); }
.mosaic i { background: var(--ink-4) center/cover no-repeat; }
.mosaic.one { grid-template-columns: 1fr; }
.mosaic.two { grid-template-rows: 1fr; }
.mosaic.three i:first-child { grid-row: span 2; }
.rcard .rname { font: 600 14px/1.2 var(--sans); padding: 0 4px; }
.rcard .rcount { font: 400 26px/1 var(--display); padding: 0 4px; }
.rcard.special .rcount { color: var(--yellow); }
.rcard .rsub { font-size: 12px; color: var(--muted); padding: 0 4px; margin-top: -4px; }
.cta-bar { margin: 0 -18px; padding: 14px 18px 0; border-top: 1px solid var(--line); background: linear-gradient(180deg, rgba(17, 19, 17, .9), var(--ink)); }
.cta-summary { margin: 0 0 10px; text-align: center; font-size: 14px; color: var(--body); }

/* ---------- Upload ---------- */
.upload-body { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding-top: 16px; }
.big-ring { position: relative; width: min(64vw, 250px); aspect-ratio: 1; margin: 0 auto 6px; }
.big-ring .track, .big-ring .fill { stroke-width: 14; }
.big-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.big-ring-text b { font: 400 58px/1 var(--display); }
.big-ring-text span { color: var(--body); font-size: 15px; margin-top: 6px; }
.up-bytes { text-align: center; margin: 0; font-weight: 700; font-size: 18px; }
.up-eta { text-align: center; margin: 0 0 6px; color: var(--yellow); font-weight: 600; }
.now-card { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius); background: var(--ink-2); border: 1px solid var(--line); }
.now-card img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--ink-3); flex: none; }
.now-card div { min-width: 0; }
.up-name { margin: 0 0 4px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-card .muted { margin: 0; }
.keep-open { margin: 10px 0 4px; }

/* ---------- Done ---------- */
.done-body { display: flex; flex-direction: column; gap: 12px; align-items: stretch; justify-content: center; text-align: center; }
.done-check { display: grid; place-items: center; margin-bottom: 8px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.done-body .lead { margin: 4px 0 10px; }
#done-failures { text-align: left; }

/* ---------- Sheets ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  max-height: 86vh; display: flex; flex-direction: column;
  padding: 8px 18px calc(var(--safe-b) + 16px);
  background: var(--ink-2); border-top: 1px solid var(--line-2); border-radius: 24px 24px 0 0;
  animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet-tall { height: 86vh; }
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 2px auto 12px; flex: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sheet-head .muted { margin: 0; }
.sheet-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 2px 18px 8px; }
.sheet-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--ink-3); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .badge { position: absolute; left: 5px; bottom: 5px; padding: 3px 7px; border-radius: 99px; background: rgba(17, 19, 17, .82); font: 600 11px/1.2 var(--sans); color: var(--cream); max-width: calc(100% - 10px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tile .vid { position: absolute; right: 5px; top: 5px; width: 24px; height: 24px; border-radius: 50%; background: rgba(17, 19, 17, .8); display: grid; place-items: center; }
.tile.sel { outline: 3px solid var(--yellow); outline-offset: -3px; }
.tile.sel::after { content: '✓'; position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 50%; background: var(--yellow); color: var(--ink); font-weight: 900; display: grid; place-items: center; font-size: 14px; }
#cat-more { width: 100%; margin-top: 10px; }
.select-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.select-bar span { font-weight: 600; }

.move-preview { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.move-preview img { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; background: var(--ink-3); flex: none; }
.move-preview .muted { margin: 0; overflow-wrap: anywhere; }
.move-preview > div { min-width: 0; }
.move-list { display: grid; gap: 8px; }
.move-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--ink-3); text-align: left; font-weight: 600; font-size: 16px; }
.move-opt.current { border-color: var(--yellow); color: var(--yellow); }
.move-opt.suggested::after { content: 'Suggested'; font: 600 11px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: var(--yellow); padding: 5px 8px; border-radius: 99px; }
.move-opt small { color: var(--muted); font-weight: 400; }

.confirm-body { color: var(--body); margin: 4px 0 16px; }
.confirm-body p { margin: 0 0 10px; }
.confirm-actions { display: grid; gap: 10px; }

/* Settings */
.settings .label:first-child { margin-top: 4px; }
.cat-row { padding: 12px; border-radius: 14px; background: var(--ink-3); border: 1px solid var(--line); margin-bottom: 8px; }
.cat-row .input { width: 100%; height: 48px; background: var(--ink-2); }
.cat-bar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.hint-toggle { flex: 1; text-align: left; height: 40px; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 14px; }
.hint-toggle::before { content: '▸ '; }
.hint-toggle[aria-expanded="true"]::before { content: '▾ '; }
.mini { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink-2); display: grid; place-items: center; flex: none; color: var(--body); font-size: 15px; }
.mini:disabled { opacity: .3; }
.cat-row textarea { width: 100%; margin-top: 8px; min-height: 110px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--ink-2); font-size: 16px; line-height: 1.4; resize: vertical; }
.settings .btn-secondary, .settings .btn-ghost { width: 100%; margin-top: 8px; }
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input { flex: 1; accent-color: var(--yellow); height: 32px; }
.slider-row span { min-width: 52px; text-align: right; font-weight: 700; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--ink-3); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--body); font-weight: 600; }
.seg button.on { background: var(--yellow); color: var(--ink); }
.about { margin-top: 18px; }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 16px;
  background: var(--cream); color: var(--ink); font-weight: 600; font-size: 15px; text-align: center;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8); animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

@media (min-height: 800px) {
  .card .thumb { width: 34px; height: 34px; }
  .card .count { font-size: 24px; }
}
@media (max-height: 700px) {
  .card { grid-template-columns: auto 1fr auto; gap: 6px; }
  .card .thumb { width: 26px; height: 26px; }
  .card .name { grid-column: 2; grid-row: 1; min-height: 0; font-size: 10.5px; }
  .card .count { grid-column: 3; font-size: 18px; }
  .cloud-zone { min-height: 150px; }
  .stat b { font-size: 21px; }
}
@media (min-width: 600px) {
  .screen { padding-left: max(18px, calc(50% - 260px)); padding-right: max(18px, calc(50% - 260px)); }
  #sort { padding-left: max(12px, calc(50% - 260px)); padding-right: max(12px, calc(50% - 260px)); }
  .stats { left: max(12px, calc(50% - 260px)); right: max(12px, calc(50% - 260px)); }
  .sheet { left: max(0px, calc(50% - 280px)); right: max(0px, calc(50% - 280px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
