/* Palette and shapes follow vitanovatherapy.com; the fonts are the site's own files */
@font-face { font-family: Outfit; font-weight: 300; font-display: swap; src: url(/assets/fonts/outfit-v15-latin-300.woff2) format('woff2'); }
@font-face { font-family: Outfit; font-weight: 400; font-display: swap; src: url(/assets/fonts/outfit-v15-latin-regular.woff2) format('woff2'); }
@font-face { font-family: Outfit; font-weight: 500; font-display: swap; src: url(/assets/fonts/outfit-v15-latin-500.woff2) format('woff2'); }
@font-face { font-family: 'Libre Baskerville'; font-weight: 400; font-display: swap; src: url(/assets/fonts/libre-baskerville-v24-latin-regular.woff2) format('woff2'); }

:root {
  --gold: hsl(38, 74%, 44%);
  --gold-deep: hsl(38, 90%, 25%);
  --gold-wash: hsla(38, 74%, 44%, .1);
  --ink: hsl(300, 3%, 29%);
  --ink-soft: hsla(300, 3%, 29%, .55);
  --cream: hsl(38, 100%, 98%);
  --sand: hsl(42, 61%, 90%);
  --rose: hsl(354, 70%, 48%);
  --roots: hsl(22, 42%, 31%);  /* ethnicity: ROOTS in config.js */
  /* third colour, an accent beside gold: the tools that change the selected person (gold adds people) */
  --accent: hsl(195, 48%, 33%);
  --accent-deep: hsl(195, 55%, 24%);
  --accent-edge: hsla(195, 48%, 33%, .3);
  --glass: #fff;  /* opaque: lines behind a bar never show through its choices */
  --edge: hsla(38, 74%, 44%, .14);
  --shadow: 0 10px 30px hsla(38, 74%, 44%, .14), 0 2px 8px hsla(300, 3%, 29%, .06);
  --shadow-sm: 0 3px 10px hsla(38, 74%, 44%, .16), 0 1px 3px hsla(300, 3%, 29%, .06);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(120% 90% at 50% 45%, #fff 0%, var(--cream) 60%);
  font-family: Outfit, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
button svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- canvas ---------- */
#stage {
  position: fixed; inset: 0; width: 100%; height: 100%;
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
#stage.panning { cursor: grabbing; }

.node { cursor: pointer; }
.node .shape { transition: stroke .25s; }
#stage.linking .node:hover .shape { stroke: var(--gold); stroke-width: 3; }
.node:hover .shape { stroke: var(--gold); }
.node:focus-visible .shape { stroke: var(--gold); stroke-width: 3; }
.node .name { transition: opacity .2s; }

.union { cursor: pointer; }
.union .kids, .union .line, .union .marks { pointer-events: none; }  /* only its hit path is pointed at */
.union .line, .union .marks { transition: stroke .25s; }
.union:hover .line, .union:hover .marks { stroke: var(--gold); }
.union:focus-visible .line, .union:focus-visible .marks { stroke: var(--gold); }
.union.friend { cursor: default; }
.union.friend:hover .line { stroke: hsl(300, 3%, 29%); }
/* a parental line: the line down to a child, from their first parents (drop) or a further set (link) */
.drop, .link { cursor: pointer; }
.link .line { transition: stroke .25s; }
.link:hover .line, .link.on .line { stroke: var(--gold); }
.link:focus-visible .line { stroke: var(--gold); }
.drop:hover, .link:hover .glow { stroke: hsla(38, 74%, 44%, .12); }
.drop:focus-visible { stroke: hsla(38, 74%, 44%, .55); }

.rel { cursor: pointer; }
.rel:hover .glow { stroke: hsla(38, 74%, 44%, .12); }
.rel:focus-visible .glow { stroke: hsla(38, 74%, 44%, .55); }
.rel.draft { opacity: .75; }
#stage.linking, #stage.linking .node { cursor: crosshair; }
#band { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 4 6; stroke-linecap: round; pointer-events: none; opacity: .7; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } }

.breath {
  fill: var(--gold); stroke: var(--gold); stroke-width: 1.5; fill-opacity: .6; opacity: 0;
  transform-box: fill-box; transform-origin: center;
  animation: breath 2.6s var(--ease) infinite;
  pointer-events: none;
}
.breath.late { animation-delay: 1.3s; }
@keyframes breath {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---------- hover hint ---------- */
#hint {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none;
  padding: 5px 11px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--edge); box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 12px; letter-spacing: .02em; color: var(--ink); white-space: nowrap;
  opacity: 0; transition: opacity .2s var(--ease);
}
#hint.show { opacity: 1; transition-delay: .25s; }

/* ---------- floating controls ---------- */
#ui { position: fixed; inset: 0; pointer-events: none; transition: opacity .25s; }
#ui.moving { opacity: 0; }
.slot { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.slot.top { z-index: 2; }
/* controls spring out of the person, and only appear once they are clear of it,
   so nothing is drawn over the person on the way; the ring just fades in where it is */
.fly { position: absolute; left: 0; top: 0; animation: fly .55s var(--spring) both, appear .35s cubic-bezier(.6, 0, .9, .4) both; }
.fly.fade { animation: appear .45s var(--ease) both; }
#ui.still .fly { animation: none; }
@keyframes fly { from { transform: translate(var(--fx), var(--fy)) scale(.2); } }
@keyframes appear { from { opacity: 0; } }

/* "+" buttons: add a relative in that direction */
.plus {
  position: absolute; left: -16px; top: -16px;
  width: 32px; height: 32px; padding: 0;
  border: 1.2px solid hsla(38, 74%, 44%, .5); border-radius: 50%;
  background: #fff; color: var(--gold);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center; cursor: pointer; pointer-events: auto;
  transition: background .2s, color .2s, opacity .3s, transform .35s var(--spring);
}
.plus:hover { background: var(--gold); color: #fff; transform: scale(1.08); }
/* while a tool's choices are out, the "+" step back (still there, still usable) */
#ui.hush .plus { opacity: .22; transform: scale(.8); }
#ui.hush .plus:hover { opacity: 1; transform: none; }
/* the "+" on each couple line, when which couple a child belongs to is asked */
#ui.hush .plus.pick { opacity: 1; transform: none; }
#ui.hush .plus.pick:hover { transform: scale(1.08); }
.plus svg { width: 16px; height: 16px; stroke-width: 2; }
.plus .lab {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 11px; letter-spacing: .04em; color: var(--ink-soft);
  white-space: nowrap; pointer-events: none;
}
.plus .lab.up { bottom: calc(100% + 5px); }
.plus .lab.down { top: calc(100% + 5px); }

/* small round tools that open on hover / tap */
.tool {
  --s: 30px;
  position: absolute; display: flex;
  min-width: var(--s); min-height: var(--s); border-radius: calc(var(--s) / 2);
  background: var(--glass); border: 1px solid var(--edge);
  box-shadow: var(--shadow-sm); pointer-events: auto;
}
.tool.right { left: calc(var(--s) / -2); }
.tool.left { right: calc(var(--s) / -2); flex-direction: row-reverse; }
.tool.down { top: calc(var(--s) / -2); align-items: flex-start; }
.tool.up { bottom: calc(var(--s) / -2); align-items: flex-end; }

.face {
  width: calc(var(--s) - 2px); height: calc(var(--s) - 2px); flex: none; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--ink-soft); display: grid; place-items: center; cursor: pointer;
  transition: color .2s, transform .35s var(--spring);
}
.face svg { width: 16px; height: 16px; }
.tool .face { color: var(--accent); }
.tool:hover .face { color: var(--accent-deep); }
.tool.danger:hover .face { color: var(--rose); }
.face:active { transform: scale(.85); }

.tip {
  align-self: center;
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  font-size: 12px; letter-spacing: .02em; color: var(--ink);
  transition: max-width .35s var(--ease), opacity .25s, padding .35s var(--ease);
}
.tool:hover .tip { max-width: 110px; opacity: 1; padding: 0 12px 0 1px; }
.tool.left:hover .tip { padding: 0 1px 0 12px; }
.tool.open .tip { display: none; }

.opts { display: none; align-items: center; gap: 2px; padding: 4px; }
.tool.open { border-radius: 20px; }
.tool.open .opts { display: flex; animation: unfold .45s var(--spring) both; }
.tool.right .opts { transform-origin: left center; }
.tool.left .opts { transform-origin: right center; }
#ui.kept .tool.open .opts { animation: none; }
@keyframes unfold { from { opacity: 0; transform: scale(.8); } }

.opt {
  width: 34px; height: 34px; padding: 0; flex: none;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-soft); display: grid; place-items: center; cursor: pointer;
  transition: background .2s, color .2s, transform .35s var(--spring);
}
.opt:hover { color: var(--gold); background: var(--gold-wash); }
.opt.on { color: var(--gold-deep); background: var(--sand); }
.opt:active { transform: scale(.88); }
.opt svg { width: 18px; height: 18px; }
.sep { width: 1px; height: 20px; margin: 0 4px; background: hsla(300, 3%, 29%, .12); flex: none; align-self: center; }

/* conditions: coloured chips, four to a row, each as wide as its word (the bloom gives the bar no
   width of its own, so "auto" columns would shrink to the chips' min-width); a chosen one is filled */
.tool.open .chips { display: grid; grid-template-columns: repeat(4, max-content); gap: 6px; padding: 8px; }
@media (max-width: 380px) {
  .tool.open .chips { grid-template-columns: repeat(2, max-content); }
}
.chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 52px; height: 30px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 15px;
  background: var(--soft); color: var(--solid);
  font-size: 12px; font-weight: 500; letter-spacing: .02em; white-space: nowrap;
  cursor: pointer;
  transition: background .25s, color .25s, border-color .25s, transform .35s var(--spring);
}
.chip:hover { border-color: var(--pastel); }
.chip.on { background: var(--solid); color: #fff; }
.chip:active { transform: scale(.9); }

/* ethnicity: the names in the family as chips, in small capitals as on the drawing, and a field for a new one */
.tool.open .opts.eths { flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px; }
.eths .names { display: grid; gap: 6px; }
.chip.eth {
  --soft: hsl(22, 30%, 95%); --solid: var(--roots); --pastel: hsl(22, 25%, 80%);
  min-width: 0; font-size: 13px; letter-spacing: .04em; font-variant: small-caps;
}
.chip.eth:disabled { opacity: .35; cursor: default; }
.chip.eth:disabled:hover { border-color: transparent; }
.eth { cursor: pointer; }

/* a short note about the person, typed in a one-line field that unfolds from its tool */
.tool.open .opts.note { padding: 4px; }
.note-edit, .eth-edit {
  width: 180px; height: 28px; padding: 0 12px;
  border: 0; outline: 0; border-radius: 14px;
  background: #fff; box-shadow: inset 0 0 0 1.2px hsla(38, 74%, 44%, .3);
  font: 400 13px Outfit, 'Segoe UI', system-ui, sans-serif; color: var(--ink);
  transition: box-shadow .25s;
}
.note-edit::placeholder, .eth-edit::placeholder { color: hsla(300, 3%, 29%, .32); }
.note-edit:focus, .eth-edit:focus { box-shadow: inset 0 0 0 1.5px hsla(38, 74%, 44%, .55); }
/* or typed right where its bubble is, the bubble's size at any zoom (--k), as wide as its words (--w) */
.node .note { cursor: text; }
.note-edit.in-place {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  width: calc(var(--w) * var(--k) * 1px); height: calc(15px * var(--k)); padding: 0;
  border-radius: calc(7.5px * var(--k)); font-size: calc(9.5px * var(--k)); text-align: center;
  box-shadow: inset 0 0 0 1.2px hsla(38, 74%, 44%, .55), 0 3px 12px hsla(38, 74%, 44%, .16);
}

/* one soft round haze under the whole bloom, the same size for everyone: the drawing behind it
   steps back, fading out with no edge; the person's symbol is drawn again on top of it */
.bloom {
  position: absolute; left: 0; top: 0; width: var(--d); height: var(--d);
  transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side,
    hsla(38, 100%, 99%, .8) 0%, hsla(38, 100%, 99%, .76) 62%, hsla(38, 90%, 97%, .45) 80%,
    hsla(38, 80%, 95%, .14) 92%, hsla(38, 80%, 95%, 0) 100%);
}
.self { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.fly.now { animation: none; }

/* the tools ride a fine ring close to the person, in the accent colour; the "+" sit farther out */
.ring {
  position: absolute; left: 0; top: 0; width: var(--d); height: var(--d);
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 1px solid hsla(195, 48%, 33%, .22); pointer-events: none;
}
.tool.moon { --s: 28px; background: #fff; border-color: var(--accent-edge); transition: background .25s, border-color .25s; }
.tool.moon .face svg { width: 15px; height: 15px; stroke-width: 1.8; }
.tool.moon:not(.open):hover { background: var(--accent); border-color: var(--accent); }
.tool.moon:not(.open):hover .face, .tool.moon:not(.open):hover .tip { color: #fff; }
.tool.moon.danger:hover { background: var(--rose); border-color: var(--rose); }
/* open: the tool itself is filled, its bar of choices stays light */
.tool.moon.open { background: var(--glass); border-color: var(--accent-edge); }
.tool.moon.open .face { background: var(--accent); color: #fff; }

/* fingers: larger targets */
@media (pointer: coarse) {
  .plus { width: 40px; height: 40px; left: -20px; top: -20px; }
  .tool { --s: 38px; }
  .tool.moon { --s: 38px; }
  .opt { width: 42px; height: 42px; }
  .chip { height: 38px; }
  .item { height: 42px; }
  .bin { width: 34px; height: 34px; }
  /* lines: a wider band to tap (drawing units, so it follows the zoom as the line does); no hover glow,
     which a finger would leave behind */
  .hit, .drop { stroke-width: 30px; }
  .drop:hover { stroke: transparent; }
  /* fields typed in 16px: iPhones zoom the whole page into a field with smaller letters */
  #ui .name-edit, #ui .note-edit, #ui .eth-edit, #key-sheet input { font-size: 16px; }
  /* a note typed in place is drawn at 16px and shrunk to its bubble's size (--t), so it looks as before */
  #ui .note-edit.in-place {
    --t: calc(9.5 * var(--k) / 16);
    width: calc(var(--w) * 16 / 9.5 * 1px); height: calc(15px * 16 / 9.5); border-radius: calc(7.5px * 16 / 9.5);
    transform: scale(var(--t)); transform-origin: 0 0;
    box-shadow: inset 0 0 0 calc(1.2px / var(--t)) hsla(38, 74%, 44%, .55), 0 calc(3px / var(--t)) calc(12px / var(--t)) hsla(38, 74%, 44%, .16);
  }
}

/* marker on a couple line: tap to choose partnered, married, or separated/divorced */
.couple {
  position: absolute; left: -14px; top: -14px;
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--edge); border-radius: 50%;
  background: #fff; color: var(--ink-soft); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; cursor: pointer; pointer-events: auto;
  transition: color .2s, transform .35s var(--spring);
}
@media (pointer: coarse) {
  .couple { width: 34px; height: 34px; left: -17px; top: -17px; }
}
.couple:hover { color: var(--gold); transform: scale(1.1); }
.couple svg { width: 18px; height: 9px; }

/* name, typed right under the person */
.name-edit {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  height: 26px; min-width: 64px; padding: 0 12px;
  border: 0; outline: 0; border-radius: 13px;
  background: hsla(0, 0%, 100%, .95);
  box-shadow: inset 0 0 0 1.2px var(--accent-edge);
  font: 400 13px Outfit, 'Segoe UI', system-ui, sans-serif; color: var(--ink); caret-color: var(--accent);
  text-align: center; pointer-events: auto;
  transition: box-shadow .25s;
}
.name-edit::placeholder { color: hsla(195, 30%, 33%, .4); }
.name-edit:focus { box-shadow: inset 0 0 0 1.5px hsla(195, 48%, 33%, .6), 0 4px 14px hsla(195, 48%, 33%, .12); }

/* bar under a selected couple line */
.bar {
  position: absolute; left: 0; top: 0; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px; padding: 5px;
  border-radius: 999px; background: var(--glass); border: 1px solid var(--edge);
  box-shadow: var(--shadow); pointer-events: auto; white-space: nowrap;
}
/* relationship names appear under icons on a narrow screen */
.bar.rels { width: max-content; max-width: calc(100vw - 24px); }
.bar .opt.named span { display: none; }
.bar .opt.wide { width: 48px; }
.bar .opt.wide svg { width: 28px; height: 14px; }
@media (max-width: 680px) {
  .bar.rels { display: grid; width: min(320px, calc(100vw - 24px)); grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: 22px; }
  .bar.rels .sep { display: none; }
  .bar.rels .opt.named { width: 100%; height: auto; min-height: 54px; padding: 6px 3px; display: flex; flex-direction: column; justify-content: center; gap: 3px; border-radius: 16px; }
  .bar.rels .opt.named span { display: block; color: var(--ink-soft); font-size: 10px; line-height: 1.1; text-align: center; white-space: normal; }
  .bar.rels .opt.named.on span { color: var(--gold-deep); }
}
.bar .add { width: auto; display: flex; gap: 4px; padding: 0 14px 0 10px; color: var(--gold); font-size: 12px; letter-spacing: .02em; }
.bar .add svg { width: 14px; height: 14px; stroke-width: 2; }

/* ---------- Vita Nova mark, top left ---------- */
/* a gold rectangle, as the menu button, the logo on it in its light colours as in the site's navbar */
.brand {
  position: fixed; left: 16px; top: 14px; z-index: 3;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 17px 9px 13px; border-radius: 16px;
  background: var(--gold); color: var(--cream); text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  transition: transform .4s var(--spring), box-shadow .25s;
}
.brand:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, .16); }
.brand svg { width: 19px; height: 29px; }
.brand span { font: 400 15px 'Libre Baskerville', Georgia, serif; letter-spacing: .01em; }
.vn-peach { fill: hsl(39, 92%, 73%); }
.vn-peach-line, .vn-sand-line { fill: none; stroke-width: 7; }
.vn-peach-line { stroke: hsl(39, 92%, 73%); }
.vn-sand-line { stroke: var(--sand); }

.privacy-link {
  position: fixed; right: 20px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 3;
  padding: 6px 8px; border-radius: 8px;
  background: var(--cream); color: var(--ink-soft);
  font-size: 12px; text-decoration: none;
}
.privacy-link:hover, .privacy-link:focus-visible { color: var(--gold); text-decoration: underline; }

/* ---------- pencil on the canvas ---------- */
#ink { pointer-events: none; }
#stage[data-pen="pencil"], #stage[data-pen="pencil"] * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15.2 4.8a2 2 0 0 1 2.8 0l1.2 1.2a2 2 0 0 1 0 2.8L9 19H5v-4z' stroke='%23fff' stroke-width='4'/%3E%3Cpath d='M15.2 4.8a2 2 0 0 1 2.8 0l1.2 1.2a2 2 0 0 1 0 2.8L9 19H5v-4zM13.5 6.5l4 4' stroke='%23915f2f' stroke-width='1.6'/%3E%3C/svg%3E") 5 19, crosshair;
}

.item.shake, .burger.shake, .choice.shake { animation: shake .4s ease; }

/* ---------- menu, top right: a gold round button like the site's ---------- */
.menu { position: fixed; right: 20px; top: 16px; z-index: 6; display: flex; flex-direction: column; align-items: flex-end; }
.burger {
  position: relative; width: 50px; height: 50px; padding: 0;
  border: 0; border-radius: 50%; background: var(--gold); color: var(--sand);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .35s var(--spring), background .25s;
}
.burger:hover { transform: scale(1.06); }
.burger:active { transform: scale(.95); }
.burger:focus-visible { outline: 2px solid hsla(300, 3%, 29%, .5); outline-offset: 2px; }
.burger svg { width: 22px; height: 22px; stroke-width: 2; overflow: visible; }
.burger path { transform-box: fill-box; transform-origin: center; transition: transform .45s var(--spring), opacity .2s; }
.menu.open .burger .l1 { transform: translateY(6px) rotate(45deg); }
.menu.open .burger .l2 { opacity: 0; transform: scaleX(.2); }
.menu.open .burger .l3 { transform: translateY(-6px) rotate(-45deg); }

.menu-list { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-top: 12px; pointer-events: none; }
/* one fixed width for every item, icons and words in one column: wide enough for the pencil with its
   bin beside it (also the larger bin for fingers), so nothing changes size when the bin appears */
.item {
  position: relative; display: flex; align-items: center; gap: 9px;
  width: 126px; height: 40px; padding: 0 18px 0 13px;
  border: 1px solid var(--edge); border-radius: 20px;
  background: #fff; color: var(--ink); box-shadow: var(--shadow-sm);
  font-size: 13px; letter-spacing: .03em; cursor: pointer;
  opacity: 0; transform: translateY(-14px) scale(.7); transform-origin: right center;
  transition: opacity .2s, transform .3s var(--ease), background .2s;
}
.item svg { width: 18px; height: 18px; color: var(--gold); }
.item:hover { background: var(--cream); }
.item:active { transform: scale(.95); }
/* the pencil, in line with the rest; its bubble holds its own bin */
.item.pen { padding: 0; gap: 0; }
.pen-tool {
  display: flex; flex: 1; align-items: center; gap: 9px; height: 100%; padding: 0 18px 0 13px;
  border: 0; border-radius: 20px; background: transparent; color: inherit;
  font: inherit; letter-spacing: inherit; cursor: pointer;
}
.pen-tool:has(+ .bin:not([hidden])) { padding-right: 8px; }
.bin {
  width: 30px; height: 30px; margin-right: 4px; padding: 0; flex: none;
  border: 1px solid var(--edge); border-radius: 50%; background: var(--cream);
  display: grid; place-items: center; cursor: pointer;
  animation: pop .45s var(--spring) both;
  transition: background .2s, border-color .2s, transform .35s var(--spring);
}
.item.pen .bin svg { width: 16px; height: 16px; color: var(--gold); }
.bin:hover { background: var(--rose); border-color: var(--rose); transform: scale(1.08); }
.item.pen .bin:hover svg { color: #fff; }
.bin:active { transform: scale(.92); }
/* pencil in hand */
.item.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.item.on svg { color: #fff; }
.item.on:hover { background: var(--gold-deep); }
.menu.open .menu-list { pointer-events: auto; }
.menu.open .item { opacity: 1; transform: none; transition: opacity .25s, transform .5s var(--spring), background .2s; }
.menu.open .item:nth-child(2) { transition-delay: .04s; }
.menu.open .item:nth-child(3) { transition-delay: .08s; }
.menu.open .item:nth-child(4) { transition-delay: .12s; }
.menu:not(.open) .item { visibility: hidden; transition: opacity .2s, transform .3s var(--ease), visibility 0s .3s; }

/* ---------- save sheet ---------- */
dialog.sheet {
  padding: 0; border: 1px solid var(--edge); border-radius: 26px;
  background: #fff; color: var(--ink); box-shadow: var(--shadow);
  max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px);
  overscroll-behavior: contain;
}
dialog.sheet[open] { animation: sheet .5s var(--spring) both; }
dialog.sheet.out { animation: sheet-out .16s var(--ease) both; }
dialog.sheet::backdrop { background: hsla(38, 60%, 94%, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: appear .3s both; }
dialog.sheet.out::backdrop { opacity: 0; transition: opacity .16s; }
@keyframes sheet { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes sheet-out { to { opacity: 0; transform: scale(.97); } }

/* save: three choices, wrapping cleanly on narrow phones */
.save .choices { display: grid; grid-template-columns: repeat(3, 150px); gap: 12px; padding: 14px; }
.choice {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 0; padding: 22px 12px 18px;
  border: 1px solid var(--edge); border-radius: 18px;
  background: hsl(40, 90%, 98%); color: var(--ink); cursor: pointer;
  transition: background .25s, transform .4s var(--spring), box-shadow .25s;
}
.choice:hover, .choice:focus-visible { background: var(--sand); transform: translateY(-2px); box-shadow: var(--shadow-sm); outline: none; }
.choice:active { transform: scale(.95); }
.choice svg { width: 30px; height: 30px; margin-bottom: 8px; color: var(--gold); stroke-width: 1.4; }
.choice b { font-weight: 500; font-size: 14px; letter-spacing: .03em; }
.choice small { font-size: 11.5px; color: var(--ink-soft); letter-spacing: .02em; }
.choice.busy svg { animation: busy 1s ease-in-out infinite; }
.pdf-warning { max-width: 430px; margin: 0 14px 14px; color: var(--ink-soft); font-size: 12px; line-height: 1.45; text-align: center; }
.pdf-warning[hidden] { display: none; }
@media (max-width: 520px) {
  .save .choices { grid-template-columns: repeat(2, minmax(0, 128px)); }
  .save .choice[data-save="file"] { grid-column: 1 / -1; }
}

@keyframes busy { 50% { transform: translateY(3px); opacity: .5; } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- password sheet: optional when saving (twice), asked when opening a locked file ---------- */
.key-form { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 260px; padding: 22px 20px 18px; }
.key-form .lock { width: 30px; height: 30px; margin-bottom: 4px; fill: none; stroke: var(--gold); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.key-form input {
  width: 100%; height: 38px; padding: 0 16px;
  border: 0; outline: 0; border-radius: 19px;
  background: hsl(40, 90%, 98%); box-shadow: inset 0 0 0 1.2px var(--edge);
  font: 400 14px Outfit, 'Segoe UI', system-ui, sans-serif; color: var(--ink); caret-color: var(--gold);
  text-align: center; letter-spacing: .04em;
  transition: box-shadow .25s;
}
.key-form input::placeholder { color: hsla(300, 3%, 29%, .38); letter-spacing: .02em; }
.key-form input:focus { box-shadow: inset 0 0 0 1.5px hsla(38, 74%, 44%, .55); }
.key-form input.shake { animation: shake .4s ease; }
.key-form .note { font-size: 11px; line-height: 1.5; color: var(--ink-soft); letter-spacing: .02em; text-align: center; }
.key-form .go {
  width: 44px; height: 44px; margin-top: 4px; padding: 0;
  border: 0; border-radius: 50%; background: var(--gold); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: transform .35s var(--spring), background .25s;
}
.key-form .go:hover { background: var(--gold-deep); transform: scale(1.06); }
.key-form .go:active { transform: scale(.94); }
.key-form .go.busy svg { animation: busy 1s ease-in-out infinite; }
/* opening: one field, no note */
.key.opening [name="again"], .key.opening .note { display: none; }
@media (max-width: 380px) { .key-form { width: 230px; } }
