:root {
  --font-head: 'Bree Serif', Georgia, serif;
  --font-brand: 'Dongle UI', system-ui, sans-serif;
  --font-body: 'Dongle UI', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bg: #f3efe8;
  --text: #1d1b18;
  --muted: #6d675e;
  --focus: #1d1b18;
  --paper: #f3efe8;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --paper: #1b1a18;
  --text: #fbf8f3;
  --muted: #a39b8f;
  --focus: #fbf8f3;
  color-scheme: dark;
}

:root[data-scene] { --muted: color-mix(in srgb, var(--text) 80%, var(--bg)); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1b1a18;
    --text: #f2ede5;
    --muted: #a39b8f;
    --focus: #f2ede5;
    --paper: #1b1a18;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

.scene {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 24px 16px;
  min-width: 0;
}

.scene > .envelope, .scene > .card { grid-area: 1 / 1; }

.scene .envelope {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.8s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.envelope:focus-visible { outline-offset: 8px; }

.ready .envelope { opacity: 1; transform: none; }

.ready .envelope.idle { animation: bob 3.6s ease-in-out 1s infinite; }

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}

.card {
  position: relative;
  display: block;
  width: min(86vw, 420px, calc((100dvh - 204px) * 5 / 7));
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  visibility: hidden;
}

.revealed .card { visibility: visible; }

.card { container-type: inline-size; transition: translate 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); }

.flip {
  position: absolute;
  inset: 0;
  display: block;
  transform: perspective(2200px) rotateY(0deg);
}

.face {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.12), 0 2px 6px rgb(0 0 0 / 0.08), 0 12px 24px -8px rgb(0 0 0 / 0.3);
  transition: box-shadow 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.face svg { display: block; width: 100%; height: 100%; }

.face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.3);
  opacity: 0;
  pointer-events: none;
}

.back {
  opacity: 0;
  transform: scaleX(-1);
  background: url(/kit/bg/paper-coldpress-white.jpg) center / cover, #fbfaf7;
}

.mark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4.5%;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 5.4cqi;
  letter-spacing: 0.02em;
  text-align: center;
  color: rgb(0 0 0 / 0.07);
  text-shadow: 0 -1px 0 rgb(255 255 255 / 0.95), 0 1.5px 1.5px rgb(0 0 0 / 0.26);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
}

.make-own { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; transition: background 0.2s ease, translate 0.2s ease; }

.make-mark { flex: none; width: 18px; height: 18px; translate: 0 0.065em; background: currentColor; -webkit-mask: url(/mark.svg) center / contain no-repeat; mask: url(/mark.svg) center / contain no-repeat; }

@media (hover: hover) {
  .make-own:hover { background: color-mix(in srgb, var(--text) 14%, transparent); translate: 0 -1px; }
}

.mark-sym { position: relative; flex: none; width: 1.18em; height: 1.18em; translate: 0 0.065em; }

.mark-sym i { position: absolute; inset: 0; -webkit-mask: url(/mark.svg) center / contain no-repeat; mask: url(/mark.svg) center / contain no-repeat; }

.mark-sym i:nth-child(1) { background: rgb(0 0 0 / 0.22); translate: 0 1.5px; }

.mark-sym i:nth-child(2) { background: rgb(255 255 255 / 0.95); translate: 0 -1px; }

.mark-sym i:nth-child(3) { background: rgb(0 0 0 / 0.07); }

.flipped .flip { transform: perspective(2200px) rotateY(-180deg); }

.flipped .front { opacity: 0; }

.flipped .back { opacity: 1; }

@media (hover: hover) {
  .hoverable .card:hover { translate: 0 -3px; }
  .hoverable .card:hover .face { box-shadow: 0 2px 2px rgb(0 0 0 / 0.1), 0 6px 14px rgb(0 0 0 / 0.1), 0 22px 40px -12px rgb(0 0 0 / 0.34); }
}

.cue { display: flex; align-items: center; justify-content: center; min-height: 40px; color: var(--muted); font-size: 14px; font-weight: 500; text-align: center; }

.cue-note { margin: 0; }

.cue-button { display: inline-flex; align-items: center; gap: 10px; padding: 0 4px 0 0; border: 0; border-radius: 999px; background: none; color: inherit; font: inherit; cursor: pointer; animation: cue-in 0.4s ease both; }

@keyframes cue-in { from { opacity: 0; translate: 0 4px; } }

.cue-ring { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); transition: background 0.2s ease, scale 0.2s ease; }

.cue-ring svg { grid-area: 1 / 1; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.6s cubic-bezier(0.45, 0.05, 0.2, 1); }

.cue-button:not([data-action='open']) .cue-open, .cue-button[data-action='open'] .cue-turn { display: none; }

.flipped .cue-turn { transform: scaleX(-1); }

@media (hover: hover) {
  .cue-button:hover { color: var(--text); }
  .cue-button:hover .cue-ring { background: color-mix(in srgb, var(--text) 14%, transparent); scale: 1.06; }
}

.cue-button:active .cue-ring { scale: 0.96; }

.missing .envelope, .missing .card { display: none; }

.owner {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--paper);
  font-size: 13px;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}

.owner-status { min-width: 0; margin-right: 6px; overflow: hidden; text-overflow: ellipsis; }

.owner > button, .owner-icon { flex: none; height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: color-mix(in srgb, var(--paper) 16%, transparent); color: inherit; font: inherit; font-weight: 600; cursor: pointer; }

.owner > button:hover, .owner-icon:hover, .owner-icon[aria-expanded='true'] { background: color-mix(in srgb, var(--paper) 28%, transparent); }

.owner-more { position: relative; display: flex; flex: none; }

.owner-icon { display: grid; place-items: center; width: 28px; padding: 0; background: none; }

.owner-icon svg { width: 16px; height: 16px; fill: currentColor; }

.owner-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: -6px;
  display: grid;
  min-width: 180px;
  padding: 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text) 94%, var(--paper));
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.22);
}

.owner-menu a, .owner-menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--paper); font: 500 14px/1.3 inherit; font-family: inherit; text-align: left; text-decoration: none; cursor: pointer; }

.owner-menu a:hover, .owner-menu button:hover { background: color-mix(in srgb, var(--paper) 14%, transparent); }

.owner-menu svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.owner-menu .danger-item { margin-top: 4px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--paper) 18%, transparent); border-radius: 0 0 8px 8px; color: #ee8a77; }

:root[data-theme='dark'] .owner-menu .danger-item { color: #a3392a; }

.ask { width: min(400px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 16px; background: var(--paper); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / 0.3); }

.ask::backdrop { background: rgb(20 18 15 / 0.5); }

.ask h2 { margin: 0; font: 400 21px/1.25 var(--font-head); }

.ask p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; text-wrap: pretty; }

.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.ask-actions button { padding: 9px 16px; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); border-radius: 999px; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

.ask-actions .danger { border-color: #a3392a; background: #a3392a; color: #fff; }

@media (max-width: 560px) {
  .owner { padding-left: 14px; }
}

.keep { margin-bottom: 14px; }

.keep-button { padding: 10px 20px; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); border-radius: 999px; background: none; color: var(--text); font-weight: 600; cursor: pointer; }

.keep-button:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }

.keep-done { color: var(--muted); font-size: 14px; }

.keep-done a { color: var(--text); }

.foot { padding: 20px 16px 28px; text-align: center; font-size: 13px; }

.foot .keep-done a { color: var(--muted); }

.embedded .foot { display: none; }

.embedded .card { width: min(86vw, 420px, calc((100dvh - 120px) * 5 / 7)); }

body:has(#keep:not([hidden])) .card { width: min(86vw, 420px, calc((100dvh - 262px) * 5 / 7)); }

.scene-fixed { background-attachment: fixed !important; }

.on-photo .cue-note:not(:empty), .on-photo .keep-done {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.14);
}

.on-photo .keep-button, .on-photo .make-own, .on-photo .cue-ring { background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 1px 3px rgb(0 0 0 / 0.14); }

.on-photo .cue-button { padding-right: 14px; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 1px 3px rgb(0 0 0 / 0.14); color: var(--text); }

.on-photo .cue-button .cue-ring { box-shadow: none; }

.on-photo .cue-button .cue-ring { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

@media (hover: hover) {
  .on-photo .make-own:hover, .on-photo .keep-button:hover { background: color-mix(in srgb, var(--paper) 92%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .envelope, .face { transition: none !important; }
  .ready .envelope.idle { animation: none; }
}

@media (pointer: coarse), (max-width: 600px) {
  :where(.cue-button, .make-own, .button) { position: relative; }
  :is(.cue-button, .make-own, .button)::after { content: ''; position: absolute; inset: min(0px, calc(50% - 22px)); }
}

.report-open { position: fixed; right: 16px; bottom: 16px; z-index: 5; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--text) 7%, transparent); color: color-mix(in srgb, var(--text) 62%, transparent); cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }

.report-open:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 12%, transparent); color: var(--text); }

.report-open:disabled { cursor: default; opacity: 0.6; }

.report-open.sent svg { fill: currentColor; }

.report-open svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.on-photo .report-open { background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

@media (max-width: 600px) {
  .report-open { right: 12px; bottom: calc(12px + var(--consent-space, 0px)); }
}

.report { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }

.report-reasons { display: grid; gap: 2px; margin: 16px 0 0; padding: 0; border: 0; }

.report-reasons label { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }

.report-reasons input { width: 18px; height: 18px; margin: 0; accent-color: var(--text); }

.report-field { display: grid; gap: 6px; margin-top: 14px; font-size: 14px; font-weight: 600; }

.report-field small { color: var(--muted); font-weight: 400; }

.report-field textarea, .report-field input { width: 100%; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--paper) 96%, var(--text)); color: var(--text); font: inherit; font-size: 16px; font-weight: 400; resize: vertical; }

.report-error { color: #b9432c !important; }

.report-error:empty { display: none; }

.report .ask-actions { flex-direction: row-reverse; justify-content: flex-start; }

.report .ask-actions button:disabled { opacity: 0.6; cursor: default; }

.report form.sending .report-step > :not(.ask-actions) { opacity: 0.55; transition: opacity 0.2s ease; }

.report .ask-actions .report-send:disabled { opacity: 1; }

.report-send { display: inline-flex; align-items: center; gap: 8px; }

.report-spin { display: none; width: 14px; height: 14px; border: 2px solid rgb(255 255 255 / 0.35); border-top-color: #fff; border-radius: 50%; animation: report-spin 0.7s linear infinite; }

.sending .report-spin { display: block; }

@keyframes report-spin { to { rotate: 360deg; } }

.report form { display: grid; }

.report-done { display: grid; align-content: center; justify-items: center; gap: 4px; padding: 12px 0 4px; text-align: center; animation: report-in 0.3s ease both; }

.report-done h2 { margin-top: 10px; outline: none; }

.report-done p { max-width: 30ch; margin-top: 4px; }

.report-tick { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: color-mix(in srgb, #2b6463 14%, transparent); color: #2b6463; }

.report-tick svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; animation: report-draw 0.4s 0.15s ease forwards; }

.report-close { margin-top: 20px; padding: 10px 28px; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); border-radius: 999px; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

@keyframes report-in { from { opacity: 0; translate: 0 6px; } }

@keyframes report-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .report-spin { animation-duration: 1.6s; }
  .report-done, .report-tick svg { animation: none; stroke-dashoffset: 0; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .report-tick { background: color-mix(in srgb, #8fd0cc 16%, transparent); color: #8fd0cc; }
}

:root[data-theme='dark'] .report-tick { background: color-mix(in srgb, #8fd0cc 16%, transparent); color: #8fd0cc; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
