:root {
  color-scheme: light;
  --background: #fffaf4;
  --foreground: #201c19;
  --muted: #766f67;
  --surface: rgba(255, 252, 247, 0.78);
  --surface-strong: rgba(255, 252, 247, 0.92);
  --border: rgba(50, 43, 37, 0.1);
  --primary: #315f58;
  --primary-foreground: #fffaf4;
  --ring: rgba(49, 95, 88, 0.22);
  --shadow: 0 24px 70px rgba(30, 25, 20, 0.12);
  --radius: 22px;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

html {
  min-height: 100%;
  background-color: var(--background);
  background: var(--background);
}

body {
  min-height: 100dvh;
  min-height: 100svh;
  background-color: var(--background);
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

body.is-locked .app {
  visibility: hidden;
  pointer-events: none;
}

button {
  border: 0;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  min-height: 100dvh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  background: var(--background);
  background-color: var(--background);
  margin: 0 auto;
  padding:
    max(14px, calc(env(safe-area-inset-top) + 8px))
    10px
    max(10px, env(safe-area-inset-bottom));
}

@supports (-webkit-touch-callout: none) {
  .app {
    padding-top: max(14px, calc(env(safe-area-inset-top) + 8px));
  }
}

.round-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 18px;
  background: var(--surface-strong);
  color: var(--primary);
  cursor: pointer;
  box-shadow: none;
}

.deck {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.progress {
  width: calc(100% - 18px);
  height: 4px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(32, 28, 25, 0.08);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-content: stretch;
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 34px;
  background:
    linear-gradient(155deg, rgba(255, 253, 249, 0.82), rgba(255, 247, 236, 0.66)),
    var(--surface);
  box-shadow:
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.78),
    inset 0 0 0 1px rgba(50, 43, 37, 0.05),
    var(--shadow);
  backdrop-filter: blur(30px) saturate(1.35);
  -webkit-backdrop-filter: blur(30px) saturate(1.35);
  touch-action: pan-y;
  user-select: none;
  will-change: transform;
  animation: settle 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(50, 43, 37, 0.07);
  border-radius: 26px;
  pointer-events: none;
}

.card.dragging {
  cursor: grabbing;
  transition: none;
}

.card.from-right {
  animation-name: enter-right;
}

.card.from-left {
  animation-name: enter-left;
}

.card-media {
  height: min(42svh, 330px);
  overflow: hidden;
  background: rgba(49, 95, 88, 0.09);
}

.card-media img,
.card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-copy {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 8vw, 46px);
}

.card.has-media .card-copy {
  justify-content: flex-end;
}

.card-text {
  margin: 0;
}

.card-title {
  margin: 0 0 12px;
  color: var(--foreground);
  font-size: clamp(1.35rem, 5.8vw, 2.1rem);
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1;
  text-wrap: balance;
}

.card-text {
  color: var(--foreground);
  font-family: inherit;
  font-size: clamp(2.1rem, 10.4vw, 3.35rem);
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1.04;
  overflow-wrap: break-word;
  white-space: pre-line;
  word-break: normal;
}

.card-meta {
  margin: 16px 0 0;
  color: rgba(32, 28, 25, 0.66);
  font-size: 0.84rem;
  font-weight: 680;
  line-height: 1.35;
}

.card.is-memory {
  background: #201c19;
}

.card.is-memory::before {
  border-color: rgba(255, 255, 255, 0.16);
}

.card.is-memory .card-media {
  position: absolute;
  inset: 0;
  height: auto;
  background: #201c19;
}

.card.is-memory .card-copy {
  position: relative;
  z-index: 1;
  min-height: 100%;
  justify-content: flex-end;
  padding: clamp(20px, 6vw, 34px);
  background:
    linear-gradient(180deg, transparent 34%, rgba(10, 8, 6, 0.08) 50%, rgba(10, 8, 6, 0.78) 100%);
}

.card.is-memory .card-title,
.card.is-memory .card-text,
.card.is-memory .card-meta {
  color: #fffaf4;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.48);
}

.card.is-memory .card-text {
  max-width: 18rem;
  font-size: clamp(1.2rem, 5.2vw, 1.72rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.08;
}

.card.is-memory .card-meta {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(255, 250, 244, 0.2);
  border-radius: 999px;
  background: rgba(255, 250, 244, 0.13);
  padding: 8px 10px;
  color: rgba(255, 250, 244, 0.86);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.card.is-media-only .card-copy {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  gap: 8px;
  align-items: center;
  align-self: end;
  background: transparent;
  padding-top: 2px;
}

.round-button {
  width: 56px;
  height: 56px;
  color: var(--primary);
  font-size: 2.05rem;
  font-weight: 520;
  line-height: 1;
}

.round-button:disabled {
  opacity: 0.36;
}

.primary-button {
  min-height: 56px;
  border-radius: 18px;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 1.03rem;
  font-weight: 720;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: none;
}

.round-button,
.primary-button {
  transition:
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 180ms ease,
    background-color 180ms ease;
}

.round-button:active,
.primary-button:active {
  transform: scale(0.96);
}

.round-button:focus-visible,
.primary-button:focus-visible,
.card:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  transform: translateY(20px);
  border: 0;
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  color: var(--foreground);
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.launch-lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  min-width: 320px;
  min-height: 100dvh;
  min-height: 100svh;
  background:
    linear-gradient(160deg, rgba(255, 250, 244, 0.96), rgba(244, 251, 248, 0.92)),
    var(--background);
  color: var(--foreground);
  padding:
    max(22px, calc(env(safe-area-inset-top) + 14px))
    18px
    max(22px, calc(env(safe-area-inset-bottom) + 14px));
}

.launch-lock-panel {
  width: min(100%, 390px);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  padding: clamp(30px, 9vw, 44px);
  text-align: center;
}

.launch-lock h1 {
  margin: 0;
  color: var(--foreground);
  font-size: clamp(2.25rem, 12vw, 4rem);
  font-weight: 760;
  letter-spacing: 0;
  line-height: 0.95;
  text-wrap: balance;
}

.launch-lock p {
  margin: 16px 0 0;
  color: var(--foreground);
  font-size: clamp(1.08rem, 4.7vw, 1.35rem);
  font-weight: 680;
  line-height: 1.25;
}

.launch-lock-time {
  color: var(--muted) !important;
  font-size: 0.96rem !important;
  font-weight: 620 !important;
}

@keyframes settle {
  from {
    transform: translateY(12px) scale(0.982);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes enter-right {
  from {
    transform: translateX(34px) scale(0.985);
    opacity: 0;
  }

  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes enter-left {
  from {
    transform: translateX(-34px) scale(0.985);
    opacity: 0;
  }

  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@media (min-width: 760px) {
  .app {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .card-copy {
    padding: 36px;
  }
}

@media (max-width: 380px) {
  .app {
    padding-left: 9px;
    padding-right: 9px;
  }

  .card-copy {
    padding: 26px;
  }

  .card-text {
    font-size: clamp(1.9rem, 9.7vw, 2.86rem);
  }

  .controls {
    grid-template-columns: 52px 1fr 52px;
  }

  .round-button,
  .primary-button {
    min-height: 52px;
  }

  .round-button {
    width: 52px;
    height: 52px;
  }
}

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