:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #1f1b16;
  --muted: #6b6258;
  --line: #e8dfd3;
  --accent: #c8502e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e2;
  --ok: #2f7a4b;
  --ok-soft: #e4f3ea;
  --warn: #8a5a00;
  --warn-soft: #fdf1d8;
  --radius: 16px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 18px 64px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 30px; }
h2 { font-size: 22px; margin-top: 28px; }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
small { display: block; font-size: 14px; opacity: .8; font-weight: 400; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 8px; }
.brand { font-family: var(--serif); font-weight: 600; color: var(--ink); text-decoration: none; font-size: 18px; }
.back { color: var(--ink); text-decoration: none; font-size: 16px; padding: 10px 0; }

.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: 36px; }
.lead { color: var(--muted); font-size: 18px; }
.step { color: var(--accent); font-weight: 600; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.card.soft { background: var(--accent-soft); border-color: transparent; }
.card.ok { background: var(--ok-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }

.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; min-height: 54px; margin: 10px 0; padding: 12px 18px;
  font: 600 17px/1.25 var(--sans); color: var(--ink); text-align: center; text-decoration: none;
  background: var(--card); border: 2px solid var(--ink); border-radius: 14px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 72px; font-size: 19px; }
.btn.ghost { border-color: var(--line); font-weight: 500; }
.btn.small { min-height: 44px; font-size: 15px; margin: 6px 0; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.985); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; padding: 8px 0; cursor: pointer; }

.howto { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.howto li { counter-increment: s; position: relative; padding: 0 0 14px 44px; }
.howto li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center;
}

.price-note { color: var(--muted); font-size: 15px; text-align: center; }

/* recorder */
.rec-live { text-align: center; }
.timer { font: 600 44px/1 var(--sans); font-variant-numeric: tabular-nums; margin: 18px 0 6px; }
.limit { color: var(--muted); font-size: 15px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #d62d20; margin-right: 8px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.meter { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 14px 0; }
.meter > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s; }
.progress { height: 8px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 12px 0; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
video, audio { width: 100%; border-radius: 12px; }
video { background: #000; max-height: 60vh; }
video.mirror { transform: scaleX(-1); }

details.alt { margin-top: 8px; }
details.alt summary { cursor: pointer; color: var(--muted); padding: 10px 0; font-size: 15px; }

.error h3 { color: #a2361a; }
.error ol { padding-left: 20px; margin: 8px 0 12px; }
.error li { margin-bottom: 6px; }
.diag { font: 12px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); word-break: break-word; margin-top: 10px; }

textarea, input[type=text], input[type=password] {
  width: 100%; font: 17px/1.4 var(--sans); padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 12px; font: 14px var(--sans); color: var(--ink); cursor: pointer; }

.quote { font-family: var(--serif); font-size: 20px; border-left: 4px solid var(--accent); padding: 4px 0 4px 14px; margin: 12px 0; white-space: pre-wrap; }

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.steps .ic { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; border: 2px solid var(--line); color: var(--muted); }
.steps .done .ic { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps .now .ic { border-color: var(--accent); color: var(--accent); }
.steps .done b, .steps .now b { color: var(--ink); }
.steps b { color: var(--muted); }

.amount { font: 700 48px/1 var(--sans); text-align: center; margin: 6px 0; }
.paysteps { padding-left: 22px; margin: 12px 0; }
.paysteps li { margin-bottom: 14px; }
.code { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg); border: 2px dashed var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 6px; font: 700 20px ui-monospace, Menlo, monospace; letter-spacing: .03em; }
.code button { font: 600 15px var(--sans); border: 0; background: var(--ink); color: #fff; border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.fine { font-size: 14px; color: var(--muted); }

.list { list-style: none; padding: 0; margin: 0; }
.list li a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.hot { background: var(--accent-soft); color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 10; max-width: 90vw; }
.center { text-align: center; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* "You've got a keepsake" envelope */
.welcome { text-align: center; padding-top: 36px; }
.welcome .step { font-size: 16px; margin-top: 8px; }
.envelope { position: relative; width: 220px; height: 150px; margin: 40px auto 28px; animation: bob 2.4s ease-in-out infinite; }
.env-back, .env-front, .env-flap, .env-letter { position: absolute; left: 0; right: 0; }
.env-back { inset: 0; background: #b8462a; border-radius: 10px; }
.env-letter {
  left: 14px; right: 14px; top: 10px; height: 120px; background: #fff; border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); display: grid; place-items: center; color: var(--accent); font-size: 34px;
  transition: transform .7s cubic-bezier(.2,.8,.2,1) .35s; z-index: 1; opacity: 0;
}
.env-front {
  inset: 0; z-index: 2; border-radius: 10px;
  background: linear-gradient(to top right, var(--accent) 50%, transparent 50.5%) left / 50.5% 100% no-repeat,
              linear-gradient(to top left, #d65d3a 50%, transparent 50.5%) right / 50.5% 100% no-repeat;
}
.env-flap {
  top: 0; height: 95px; z-index: 3; transform-origin: top center; transition: transform .45s ease-in, z-index 0s .25s;
  background: linear-gradient(to bottom right, #e06a46 50%, transparent 50.5%) left / 50.5% 100% no-repeat,
              linear-gradient(to bottom left, #e06a46 50%, transparent 50.5%) right / 50.5% 100% no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.15));
}
.envelope.open { animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-letter { transform: translateY(-70px); opacity: 1; }
.env-seal { position: absolute; left: 50%; top: 78px; width: 34px; height: 34px; margin-left: -17px; border-radius: 50%; background: #fff; color: var(--accent); display: grid; place-items: center; font-size: 18px; z-index: 4; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: opacity .2s; }
.envelope.open .env-seal { opacity: 0; }
.envelope::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  transform: translate(-50%, -50%) scale(0); box-shadow: 0 0 0 0 rgba(200,80,46,.35); pointer-events: none;
}
.envelope.open::after { animation: ring 1s ease-out .3s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-1.5deg); } }
@keyframes ring { from { transform: translate(-50%,-50%) scale(1); box-shadow: 0 0 0 0 rgba(200,80,46,.45); } to { transform: translate(-50%,-50%) scale(1); box-shadow: 0 0 0 140px rgba(200,80,46,0); } }
@media (prefers-reduced-motion: reduce) { .envelope, .envelope * { animation: none !important; transition: none !important; } }

/* person folders */
.folder-line { font-size: 15px; color: var(--muted); margin: 4px 0 12px; }
.folder-line .linkbtn { font-size: 15px; padding: 4px 0; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.folderbox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin: 10px 0; }
.folderbox summary { display: flex; justify-content: space-between; align-items: center; min-height: 52px; cursor: pointer; font-weight: 600; font-size: 18px; list-style: none; }
.folderbox summary::-webkit-details-marker { display: none; }
.folderbox summary::after { content: '▾'; color: var(--muted); margin-left: 8px; transition: transform .2s; }
.folderbox:not([open]) summary::after { transform: rotate(-90deg); }
.folderbox summary span:first-child { flex: 1; }
.folderbox .count { font-size: 14px; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 10px; }
.folderbox.loose { background: transparent; }
.folderbox .list li:last-child a { border-bottom: 0; }
.ktitle { display: flex; flex-direction: column; min-width: 0; }
.ktitle small { color: var(--muted); font-size: 13px; }
[data-renamebox] { margin: 6px 0 12px; }
