html, body { height: 100%; overflow: hidden; }

#field { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#brand {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); margin-right: -.2em; z-index: 3;   /* margin offsets the trailing letter-spacing so the text is truly centred */
  font-size: 15px; letter-spacing: .2em; color: var(--ink-dim); user-select: none; -webkit-user-select: none;
}
#released {
  position: fixed; top: 22px; right: 62px; z-index: 3;
  font-size: 13px; color: var(--ink-dim); letter-spacing: .04em;
  opacity: 0; transition: opacity 1s; pointer-events: none;
}
#released.on { opacity: 1; }
@media (max-width: 520px) { #released { top: 46px; right: auto; left: 50%; transform: translateX(-50%); white-space: nowrap; } }   /* no room beside the centred brand */

#empty {
  position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 8px;
  pointer-events: none; color: var(--ink-dim); opacity: 0; transition: opacity 1.2s; padding: 0 24px;
}
#empty.on { opacity: 1; }
#empty b { font-weight: 500; font-size: 20px; color: var(--ink); opacity: .8; }

/* quick add */
#add {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 32px));
  padding: 7px; border-radius: 28px;   /* = half the collapsed height, so a full pill */
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: background .3s, border-color .3s, border-radius .35s cubic-bezier(.2, .85, .25, 1);
}
#add.open { background: rgba(20, 24, 50, .72); border-color: rgba(255, 255, 255, .22); border-radius: 34px; }
#add .add-row { display: flex; gap: 8px; align-items: center; padding-left: 18px; cursor: text; }
#addInput { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); font: inherit; font-size: 16px; }
#add input::placeholder { color: var(--ink-dim); }
#add .add-row button {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; font-size: 22px; line-height: 1;
  background: rgba(255, 255, 255, .13); transition: background .2s, transform .2s;
}
#add .add-row button:hover { background: rgba(255, 255, 255, .24); transform: scale(1.06); }
#add .opts {
  display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden;
  transition: grid-template-rows .35s cubic-bezier(.2, .85, .25, 1), opacity .25s, visibility 0s .35s;
}
#add.open .opts { grid-template-rows: 1fr; opacity: 1; visibility: visible; transition-delay: 0s; }
#add .opts-in { overflow: hidden; min-height: 0; }
#add .opts-body { display: grid; gap: 12px; padding: 14px 15px 8px; }
#add .chip, #add .seg button { font-size: 13px; }
#add .chip, #add .seg button { padding: 6px 12px; }
@media (prefers-reduced-motion: reduce) { #add .opts { transition: none; } }

/* first-run walkthrough: the coach bar takes the add bar's place until it is over */
#coach {
  position: fixed; z-index: 11; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 32px)); display: flex; gap: 14px; align-items: center;
  padding: 14px 14px 14px 22px; border-radius: 28px; font-size: 14px; line-height: 1.45;
  background: rgba(20, 24, 50, .82); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .6s, transform .6s;
}
#coach.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#coachText { flex: 1; display: grid; gap: 2px; }
#coachText > * { animation: coachIn .6s both; }
#coachText b { font-weight: 600; font-size: 15px; }
#coachText span { color: var(--ink-dim); }
#coachSkip { flex: none; background: none; border: 0; padding: 8px 10px; color: var(--ink-dim); font-size: 13px; }
#coachSkip:hover { color: var(--ink); }
@keyframes coachIn { from { opacity: 0; transform: translateY(4px); } }
body.touring #add { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
body.touring #overlay { padding-bottom: 130px; }       /* keep the card clear of the coach bar */
body.touring #card { max-height: calc(100dvh - 170px); }
#add { transition: background .3s, border-color .3s, border-radius .35s cubic-bezier(.2, .85, .25, 1), opacity .8s, transform .8s; }
#add.nudge { animation: nudge 1.6s ease-out 2; }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px rgba(185, 166, 255, .22), 0 0 40px rgba(185, 166, 255, .35); } }
@media (prefers-reduced-motion: reduce) { #coachText > *, #add.nudge { animation: none; } }

/* toast */
#toast {
  position: fixed; z-index: 12; left: 50%; bottom: calc(250px + env(safe-area-inset-bottom));   /* clear of the add bar even when its options are open */
  width: max-content; max-width: calc(100vw - 32px);
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  display: flex; gap: 14px; align-items: center; padding: 10px 18px; border-radius: 22px;
  background: rgba(20, 24, 50, .85); border: 1px solid var(--glass-line); font-size: 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: opacity .5s, transform .5s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; padding: 0; color: #b7c4ff; text-decoration: underline; text-underline-offset: 3px; }

/* the expanded blob */
#overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: rgba(6, 9, 20, 0); transition: background .5s;
}
#overlay[hidden] { display: none; }
#overlay.show { background: rgba(6, 9, 20, .6); }
#card {
  --h: 220;
  position: relative; width: min(460px, 100%); max-height: calc(100dvh - 40px); overflow: auto;
  border-radius: 36px; padding: 30px 28px 22px;
  background: linear-gradient(160deg, hsla(var(--h), 48%, 28%, .95), hsla(calc(var(--h) + 18), 40%, 15%, .97));
  border: 1px solid hsla(var(--h), 70%, 78%, .22);
  box-shadow: 0 30px 100px rgba(0, 0, 0, .5), 0 0 150px hsla(var(--h), 80%, 60%, .22);
  transition: --h .7s ease;
}
#card .inner { display: grid; gap: 14px; }
#closeBtn {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .1); font-size: 20px; line-height: 1; color: var(--ink-dim);
}
#closeBtn:hover { background: rgba(255, 255, 255, .2); color: var(--ink); }
#fTitle {
  width: 100%; background: none; border: 0; border-bottom: 1px solid rgba(255, 255, 255, .15); outline: 0;
  color: var(--ink); font-family: inherit; font-size: 25px; font-weight: 600; line-height: 1.25;
  padding: 2px 30px 10px 0; resize: none; overflow: hidden; display: block;
}
#fTitle:focus { border-bottom-color: rgba(255, 255, 255, .4); }
#status { font-size: 13px; letter-spacing: .03em; color: hsl(var(--h) 85% 82%); margin-top: -6px; }
#fNotes {
  width: 100%; min-height: 84px; resize: vertical; background: rgba(0, 0, 0, .16);
  border: 1px solid transparent; border-radius: 18px; outline: 0; padding: 12px 14px;
  color: var(--ink); font: inherit; font-size: 15px; line-height: 1.5;
}
#fNotes:focus { border-color: rgba(255, 255, 255, .22); }
#card ::placeholder { color: rgba(233, 236, 248, .38); }
.label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: -6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .seg button {
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; transition: background .2s, border-color .2s;
}
.chip:hover, .seg button:hover { background: rgba(255, 255, 255, .13); }
.chip.on, .seg button.on { background: rgba(255, 255, 255, .24); border-color: rgba(255, 255, 255, .5); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; }
.actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.ghost { background: none; border: 0; color: var(--ink-dim); padding: 10px 6px; font-size: 14px; }
.ghost:hover { color: var(--ink); }
.primary {
  border: 0; border-radius: 999px; padding: 12px 26px; font-weight: 600; font-size: 15px;
  background: hsl(var(--h) 75% 80%); color: #15122b; transition: transform .2s, background .7s;
}
.primary:hover { transform: scale(1.04); }

.sr { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
