:root {
  --bg: #ffffff;
  --text: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --accent: #0a84ff;
  --accent-text: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(0, 0, 0, 0.06);
  --fill: rgba(120, 120, 128, 0.12);
  --sheet: #ffffff;
  --separator: rgba(60, 60, 67, 0.18);
  --tile: #e5e5ea;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #ffffff;
    --secondary: rgba(235, 235, 245, 0.6);
    --glass: rgba(40, 40, 42, 0.72);
    --glass-border: rgba(255, 255, 255, 0.08);
    --fill: rgba(120, 120, 128, 0.24);
    --sheet: #1c1c1e;
    --separator: rgba(84, 84, 88, 0.6);
    --tile: #1c1c1e;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body.locked {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

.topfade {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(env(safe-area-inset-top) + 64px);
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 70%, transparent) 50%,
    transparent
  );
  opacity: 0;
  transition: opacity 0.2s;
}

body.scrolled .topfade {
  opacity: 1;
}

.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) max(16px, env(safe-area-inset-right)) 0
    max(16px, env(safe-area-inset-left));
  pointer-events: none;
}

.top > * {
  pointer-events: auto;
}

.spacer {
  flex: 1;
}

.pill {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  background: var(--glass);
  border: 0.5px solid var(--glass-border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  transition: transform 0.15s;
}

.pill:active,
.cta:active,
.option:active {
  transform: scale(0.96);
}

.pill.primary {
  background: var(--accent);
  color: var(--accent-text);
}

main {
  padding-bottom: calc(env(safe-area-inset-bottom) + 110px);
}

.hero {
  padding: calc(env(safe-area-inset-top) + 60px) max(16px, env(safe-area-inset-right)) 14px
    max(16px, env(safe-area-inset-left));
}

.hero h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.hero p {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--secondary);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (min-width: 1000px) {
  .grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--tile);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.tile img.loaded {
  opacity: 1;
}

.tile .check {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.tile .check svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  opacity: 0;
}

body.selecting .tile .check {
  display: flex;
}

.tile[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
}

.tile[aria-pressed="true"] .check {
  background: var(--accent);
  z-index: 1;
}

.tile[aria-pressed="true"] .check svg {
  opacity: 1;
}

.empty {
  padding: 80px 32px;
  text-align: center;
  color: var(--secondary);
  font-size: 17px;
  line-height: 1.4;
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  margin-bottom: 6px;
}

.bottom {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 11;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 16px)
    max(16px, env(safe-area-inset-left));
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.bottom > * {
  pointer-events: auto;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 24px rgba(10, 132, 255, 0.35);
  transition:
    transform 0.15s,
    opacity 0.2s;
}

.cta svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.cta:disabled {
  opacity: 0.4;
  box-shadow: none;
}

.cta.small {
  min-height: 46px;
  padding: 0 20px;
  font-size: 17px;
}

.cta.wide {
  width: 100%;
  margin-top: 8px;
}

.selbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  background: var(--glass);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

.selbar span {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.4);
  animation: fade 0.25s ease-out;
}

.sheet {
  position: fixed;
  z-index: 100001;
  left: 8px;
  right: 8px;
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 20px 12px;
  border-radius: 32px;
  background: var(--sheet);
  box-shadow: var(--shadow);
  animation: rise 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes rise {
  from {
    transform: translateY(110%);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet-backdrop {
    animation: none;
  }
}

.grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--separator);
  margin: 0 auto 14px;
}

.sheet h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}

.option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 10px;
  border-radius: 20px;
  background: var(--fill);
  text-align: left;
  border: 2px solid transparent;
  transition:
    transform 0.15s,
    border-color 0.15s;
}

.option[aria-pressed="true"] {
  border-color: var(--accent);
}

.radio {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--separator);
}

.option[aria-pressed="true"] .radio {
  border: 7px solid var(--accent);
}

.option-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-text strong {
  font-size: 17px;
}

.option-text small {
  font-size: 14px;
  color: var(--secondary);
  line-height: 1.3;
}

.size {
  font-size: 15px;
  color: var(--secondary);
  white-space: nowrap;
}

.status {
  margin: 4px 0 14px;
  text-align: center;
  font-size: 17px;
}

.hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 15px;
  color: var(--secondary);
}

.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--fill);
  overflow: hidden;
  margin-bottom: 8px;
}

.bar div {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.2s;
}

.done-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #34c759;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-icon svg {
  width: 34px;
  height: 34px;
  stroke-width: 3;
}

.link {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 14px;
  font-size: 17px;
  color: var(--accent);
}

.pswp {
  --pswp-bg: #000;
}

body.light-viewer .pswp {
  --pswp-bg: #fff;
}

.pswp__top-bar,
.pswp__counter,
.pswp__button--zoom,
.pswp__button--arrow--prev,
.pswp__button--arrow--next {
  display: none !important;
}

.vbar {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  transition: opacity 0.2s;
  pointer-events: none;
}

.vbar > * {
  pointer-events: auto;
}

.vbar.vtop {
  top: 0;
  padding-top: calc(env(safe-area-inset-top) + 8px);
}

.vbar.vbottom {
  bottom: 0;
  justify-content: center;
  padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
}

.pswp:not(.pswp--ui-visible) .vbar {
  opacity: 0;
}

.pswp:not(.pswp--ui-visible) .vbar > * {
  pointer-events: none;
}

.vtitle {
  flex: 1;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  line-height: 1.2;
  margin-right: 48px;
}

.vtitle strong {
  display: block;
  font-size: 16px;
}

.vtitle small {
  font-size: 13px;
  opacity: 0.85;
}

.round {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(60, 60, 60, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

.round svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.4;
}

.empty span {
  display: block;
}

.empty .cta {
  margin-top: 28px;
}

.actions {
  display: flex;
  gap: 10px;
  max-width: 520px;
}

.cta.glass {
  background: var(--glass);
  color: var(--text);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  padding: 0 22px;
}

.tile .duration {
  position: absolute;
  right: 6px;
  bottom: 5px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

body.selecting .tile .duration {
  left: 6px;
  right: auto;
}

.vslide {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: calc(env(safe-area-inset-top) + 64px) 0 calc(env(safe-area-inset-bottom) + 92px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vslide video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.toast {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 10px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--glass);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  cursor: pointer;
  animation: fade 0.25s ease-out;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid var(--fill);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.done-icon.warn {
  background: #ff9f0a;
}

.people {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 2px max(16px, env(safe-area-inset-left)) 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.people::-webkit-scrollbar {
  display: none;
}

.person {
  flex: none;
  width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--secondary);
  transition: transform 0.15s;
}

.person:active {
  transform: scale(0.94);
}

.person .avatar {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 3px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}

.person[aria-pressed="true"] .avatar {
  outline-color: var(--accent);
}

.person[aria-pressed="true"] span {
  color: var(--text);
  font-weight: 600;
}

.person.me .avatar {
  background: var(--accent);
  color: #fff;
}

.person.me .avatar svg {
  width: 30px;
  height: 30px;
}

.person.me span {
  color: var(--accent);
  font-weight: 600;
}

.filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  font-size: 17px;
  font-weight: 600;
}

.filterbar .pill {
  box-shadow: none;
  background: var(--fill);
  height: 36px;
  font-size: 15px;
}

.bar div.indeterminate {
  width: 35% !important;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(300%);
  }
}
