:root {
  --white: #ffffff;
  --black: #000000;
  --gray-1: #f5f5f7;  /* fills */
  --gray-2: #e5e5ea;  /* hairlines */
  --gray-3: #86868b;  /* secondary text */
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 28px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--white);
  color: var(--black);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.15s ease, background 0.2s ease, color 0.2s ease;
}

/* Every button shrinks a little while it's held down, then springs back. */
button:not(:disabled):active {
  transform: scale(0.94);
  transition-duration: 0.08s;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}

@media (hover: hover) {
  .tab:not(.is-active):hover { background: var(--gray-2); }
  .btn:hover { opacity: 0.85; }
  .round:not(:disabled):hover { transform: scale(1.06); }
  .board-list button:hover,
  .grid .remove:hover { color: var(--black); }
}

/* Top bar: the name with small tab buttons beside it */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  flex-wrap: wrap; /* on very narrow phones the tabs drop under the name */
  row-gap: 8px;
}

.logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tab {
  border: 0;
  background: var(--gray-1);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.tab.is-active {
  background: var(--black);
  color: var(--white);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

.badge.bump { animation: bump 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.view { display: none; }
.view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: view-in 0.25s ease;
}

h2 {
  margin: 12px 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.muted { color: var(--gray-3); margin-top: 0; }

/* Swipe view: the photo takes up all the space left under the top bar */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.deck {
  position: absolute;
  inset: 0;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-1);
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  will-change: transform;
  transform-origin: 50% 90%;
}

.card:not(.is-dragging) { transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.card.is-dragging { cursor: grabbing; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08); }
.card.is-leaving { transition: transform 0.35s ease, opacity 0.35s ease; pointer-events: none; }

/* The next photos wait just behind the top one and grow into place. */
.card[data-depth="1"] { transform: scale(0.96); }
.card[data-depth="2"] { transform: scale(0.92); }

.card > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* While a photo loads, the card shimmers and the photo fades in when ready. */
.card.is-loading {
  background: linear-gradient(100deg, var(--gray-1) 40%, var(--white) 50%, var(--gray-1) 60%) 0 0 / 250% 100%;
  animation: shimmer 1.3s linear infinite;
}

.card.is-loading > img { opacity: 0; }

/* Emoji badge that fades in as you drag */
.stamp {
  position: absolute;
  top: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  background: var(--white);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  font-size: 44px;
  line-height: 44px;
}

.stamp-like { left: 24px; }
.stamp-nope { right: 24px; }

/* Status (loading, empty, error) */
.status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px 24px 120px;
  color: var(--gray-3);
  font-weight: 600;
}

.status[hidden] { display: none; }
.status p { margin: 0; max-width: 280px; }

/* Button bar floating over the bottom of the photo */
.controls {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.round {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  background: var(--white);
  display: grid;
  place-items: center;
  padding: 0;
}

.round.undo {
  width: 46px;
  height: 46px;
  background: transparent;
}

.round:not(:disabled):active { transform: scale(0.86); }
.round:disabled { opacity: 0.35; cursor: default; }

.emoji {
  display: inline-block;
  font-size: 28px;
  line-height: 32px;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.round.undo .emoji { font-size: 22px; line-height: 26px; }

/* Played when a swipe or undo happens, whether from a button, a key or a drag. */
.round.pop { animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }
.round.pop .emoji { animation: pop-icon 0.4s ease; }
.round.rewind .emoji { animation: rewind 0.45s cubic-bezier(0.3, 1.2, 0.5, 1); }

/* Text buttons */
.btn {
  border: 0;
  background: var(--black);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
}

.btn.ghost {
  background: var(--gray-1);
  color: var(--black);
}

/* Liked grid */
.liked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.empty { color: var(--gray-3); font-weight: 500; }

.grid {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.grid li {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--gray-1);
  animation: item-in 0.3s ease;
}

.grid li.is-removing,
.board-list li.is-removing {
  animation: item-out 0.22s ease forwards;
  pointer-events: none;
}

.grid .open:active { transform: scale(0.97); }
.grid .open:active img { opacity: 0.85; }

.grid .open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
}

.grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.grid .remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
  color: var(--black);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* Full-screen photo viewer */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 20px 20px;
  animation: fade-in 0.2s ease;
}

.viewer[hidden] { display: none; }
.viewer.is-closing { animation: fade-out 0.18s ease forwards; }
.viewer img { animation: zoom-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }

.viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 20px;
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* Pop-up message */
.toast {
  position: fixed;
  left: 50%;
  top: calc(72px + env(safe-area-inset-top)); /* just under the top bar, over the photo */
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--black);
  color: var(--white);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translate(-50%, -16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}


.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.toast-action {
  border: 0;
  background: none;
  color: var(--white);
  font-weight: 700;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  to { opacity: 0; }
}

@keyframes zoom-in {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes pop-icon {
  0% { transform: scale(1); }
  35% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes rewind {
  0% { transform: translateX(0); }
  40% { transform: translateX(-7px) scale(1.1); }
  100% { transform: translateX(0); }
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.6); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

@keyframes item-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes item-out {
  to { opacity: 0; transform: scale(0.9); }
}

@keyframes highlight {
  from { background: var(--gray-2); }
  to { background: transparent; }
}

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

/* Boards */
.add-board {
  display: flex;
  gap: 8px;
}

.add-board[hidden] { display: none; }

.add-board input {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--gray-1);
  color: var(--black);
  font: inherit;
  font-size: 15px;
  outline: none;
}

.add-board input:focus { box-shadow: 0 0 0 2px var(--black); }

.form-error { color: var(--black); font-weight: 600; margin: 8px 0 0; font-size: 14px; }

.shake { animation: shake 0.4s ease; }

.static-note {
  background: var(--gray-1);
  border-radius: 16px;
  padding: 4px 18px;
  font-size: 15px;
}

.static-note a { color: var(--black); font-weight: 700; }

/* Grouped list, like iOS settings */
.board-list {
  list-style: none;
  padding: 0;
  margin: 20px 0;
  border: 1px solid var(--gray-2);
  border-radius: 16px;
  overflow: hidden;
}

.board-list:empty { display: none; }

.board-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.board-list li + li { border-top: 1px solid var(--gray-2); }
.board-list li.is-new { animation: highlight 1.2s ease; }

.board-list .board-error {
  display: block;
  color: var(--gray-3);
  font-size: 13px;
  font-weight: 500;
}

.board-list button {
  border: 0;
  background: transparent;
  color: var(--gray-3);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
}

.board-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
  font-weight: 600;
}

@media (max-width: 380px) {
  .logo { font-size: 20px; }
  .tab { padding: 6px 9px; font-size: 12px; }
  .topbar { gap: 8px; }
}
