Booking calendar
The scheduler behind every “Book a 15 min call” button on joinstarlight.com: a host card, a month calendar and the day’s free times, with a details step and a confirmation.
Build a React 19 + TypeScript component called BookingCalendar: a dark meeting scheduler with a host card, a month calendar and the chosen day's free times, then a details form and a "You're booked." card.
Constraints
- One .tsx file, "use client", imports from react only, icons inlined as SVG, no date library. All CSS in a template string rendered as <style href="ui-booking-calendar" precedence="ui">, every class prefixed "sb-". Default export, no required props; optional host name (default "Alex Rivera"), title ("Intro call"), description, duration, location, avatar and logo URLs (both empty by default), accent ("r, g, b", default "139, 92, 246"), the availability rules below, and onBook(booking).
- The root fills its parent (width/height 100%, overflow hidden, isolation isolate, background #0b0d12) and scrolls inside an inner wrapper if its frame is short. Respond to its own width with container queries, never the window. Render the inner content only on the client (useSyncExternalStore), since it depends on the clock and the visitor's time zone.
- Font: var(--font-google-sans-flex, "Google Sans Flex"), system-ui, sans-serif. Tokens: card #0D1219, border #1E2125, muted well #191E24, muted text #989EA4, hover #1D232B, page #0A0E12, focus #60A5FA.
Availability
- Host in America/Los_Angeles, Monday–Friday 09:00–17:00, 15-minute meetings starting every 15 minutes, at least 240 minutes' notice, up to 60 days ahead. Convert each host day to UTC with Intl.DateTimeFormat.formatToParts (correct across DST), then group the instants by date in the visitor's zone.
- Open on the current month, or the next one if the current month has no free days left.
Layout
- Page: max-width 896px, padding 40px 16px. One column below 680px; from 680px a 300px host column beside the rest; from 840px the rest splits into the calendar and a 232px times column. Gaps 24px, items aligned to the top.
Host card (radius 12, 1px border, padding 20)
- 40px round avatar (the host's initial, 16px semibold white, on the accent when there's no photo) with an optional 20px round logo badge at its bottom-right (1px white/10 border). Beside it the host name (12px muted) over the title (16px semibold, line-height 1.25). Then the description (14px muted), and rows with 16px icons, gap 8, 6px apart: "15 min" (clock), the location (video), and the visitor's zone as an unstyled select of every IANA zone with underscores shown as spaces. On the details step the select becomes plain text and a row with the chosen date and time (calendar icon) folds open above it.
Calendar card (padding 16)
- Header: "November 2026" (16px semibold) and two 36px round ghost buttons with 16px chevrons; previous is disabled at 50% on the current month.
- Weekday letters S M T W T F S (12px muted), then always six rows of seven square days, gap 4. Unavailable days are plain text at 40% muted (30% outside the month). Available days are buttons, 14px medium, radius 10; the selected one fills with the accent (radius 6, fade 0.22s) and its number turns white.
Times
- Before a date: "Select a date to see times." 14px muted, 24px from the top.
- After: a card headed "Mon, Nov 23" (14px semibold) with a 12h/24h segmented toggle (11px medium, muted well, the active half an accent pill that slides). Times are 36px pills, 14px medium, background #0A0E12, ring 0 0 0 1px white/8, 6px apart: one column of 200px pills scrolling at 420px when beside the calendar, two columns otherwise. Picking one fills it with the accent.
- Next (36px accent pill): when the frame is 980px or wider, the card widens from 232px to 312px past its column and Next pops in beside the chosen pill (scale .9 → 1). Narrower, Next fills a sticky bar under the times that folds open.
- Days and pills share a hover glow: a 1px conic border in the accent (accent at 0°, clear 90°–270°) whose start angle sweeps 0 → 360° over 1s ease-out-cubic (a registered @property), plus a radial wash of the accent at 10% under the pointer. Fade both out over .3s on leave.
Details and confirmation
- Replaces the calendar and times: "Confirm your details" (18px semibold), then floating-label fields in 52px wells (radius 16, #191E24 at 60%) with a white light under the pointer and a 2px rainbow conic ring on focus: "Your name *", "Email *", and a 96px "Anything else? (optional)" textarea whose placeholder reads "Share anything that will help prepare for the meeting." Back (ghost; hover tints with the accent at 12%) and "Confirm booking" (accent, spinner while submitting).
- Booking never calls a server: after a 0.9s pause it calls onBook and shows the confirmation. Missing name or email shows a white toast at the bottom: "Name and email are required", with a pink gradient swatch and a close button, gone after 4s.
- Then a centred 512px card: a green (#22C55E) circle and tick that draw themselves, "You're booked." (24px bold), "This is a demo, so nothing was booked and no email went to {email}.", rows for the title "with {host}" and the full date and time with the zone, and Reschedule, Cancel and Add to calendar (downloads an .ics) as 12px muted links.
Motion
- Transforms spring (0.3s, bounce 0.18, as a CSS linear() curve); opacity fades over 0.22s cubic-bezier(.22,1,.36,1). Swaps wait for the old piece to leave: the month sweeps 16px the way you paged (its title 10px), the times card and the panels rise 10px in and lift 10px out. Columns arrive 14px up, 0.13s apart; times stagger in 20ms apart.
- prefers-reduced-motion: fades only, no sweeps, no glow rotation, the tick already drawn.
Behaviour
- Real buttons with aria-pressed for days, times and the toggle, labelled month arrows, visible focus rings; hover effects only where (hover: hover). Clear every timer on unmount."use client";
/*
* BookingCalendar: the scheduler from Starlight (joinstarlight.com), the one every "Book a 15 min call" button
* opens in a modal. A host card on the left, a month calendar, and the free times for the day you pick. Pick a
* time, press Next, fill in your name and email, and it "books", ending on the "You're booked." card. Nothing
* leaves the browser: booking only calls `onBook`, so wire that to your own API to make it real.
*
* This is Starlight's own booking page, rewritten to run alone: the availability that the site fetches from
* its API is worked out here from the same rules (weekdays 9 to 5 in the host's time zone, 15-minute starts,
* 4 hours' notice, 60 days ahead), and booking calls `onBook` instead of the server.
*
* How it works
* - Times are real instants. Each host workday is converted from the host's zone to UTC with Intl (no date
* library), then grouped by day in the visitor's zone, so changing the time zone in the host card moves
* times across midnight the way the live page does. 12h or 24h follows the visitor's locale until toggled.
* - Columns: host, calendar, times. They follow the component's own width (container queries): one column
* below 680 px, the host beside the rest from 680, all three from 840. With 980 px or more the times card
* widens 80 px past its column to put Next beside the chosen time, as on the site; narrower, Next drops
* into a bar under the times, which is what the site does on phones.
* - Motion follows the site's one rule: what moves or resizes springs (0.3 s, bounce 0.18, sampled into a
* CSS linear() curve), what only fades takes the 0.22 s curve. Swaps wait for the old piece to leave first
* (the month sweeps the way you paged, the times card trades places), and columns arrive 0.13 s apart.
* - Days and times carry Starlight's card glow: on hover a 1 px conic border in the event's accent sweeps
* once around in 1 s and a soft light follows the pointer. All CSS (a registered --angle and two custom
* properties written on pointermove), so hovering never re-renders.
* - With reduced motion, things fade in place instead of travelling, and the glow doesn't sweep.
*
* Usage
* <div style={{ height: 720 }}>
* <BookingCalendar onBook={(booking) => console.log(booking)} />
* </div>
*
* <BookingCalendar hostName="Ada" title="Discovery call" durationMinutes={30} accent="16, 185, 129" />
*
* Requirements: React 19 (for the hoisted <style>), no other dependencies, a browser with container queries.
* Pass `avatarUrl` for a host photo and `logoUrl` for a company badge on it (square, 160 px and 80 px are
* plenty); without a photo it shows the host's initial on the accent. Set in Google Sans Flex when the
* page provides `--font-google-sans-flex`, else the system sans. Icons are Starlight's own (Iconly and
* Heroicons), inlined. It scrolls inside itself if its frame is shorter than its content.
*/
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
import type { CSSProperties, PointerEvent as ReactPointerEvent, ReactNode, RefObject } from "react";
/* ------------------------------------------------------------------ props */
export type Booking = {
/** Start, as an ISO string in UTC. */
startUtc: string;
endUtc: string;
name: string;
email: string;
notes: string;
/** The zone the visitor booked in, e.g. "America/New_York". */
timeZone: string;
};
export type BookingCalendarProps = {
hostName?: string;
title?: string;
description?: string;
durationMinutes?: number;
/** Shown beside the video icon. */
location?: string;
avatarUrl?: string;
logoUrl?: string;
/** The event's accent as an "r, g, b" triple. Starlight's palette: blue 59, 130, 246 · violet 139, 92, 246 · emerald 16, 185, 129. */
accent?: string;
/** The host's zone; the hours below are in it. */
hostTimeZone?: string;
/** Days the host takes calls, 0 = Sunday. */
workdays?: number[];
/** "HH:MM", 24-hour. */
dayStart?: string;
dayEnd?: string;
/** Minutes between possible start times. */
intervalMinutes?: number;
/** How soon the first time can be. */
minNoticeMinutes?: number;
/** How far ahead times are offered. */
futureLimitDays?: number;
/** Called when the visitor confirms. The demo then shows the confirmation card. */
onBook?: (booking: Booking) => void;
};
const DEFAULTS = {
hostName: "Alex Rivera",
title: "Intro call",
description: "A quick 15-minute call to get to know each other, talk through what you're working on, and see whether we're a good fit.",
durationMinutes: 15,
location: "Google Meet",
avatarUrl: "",
logoUrl: "",
accent: "139, 92, 246",
hostTimeZone: "America/Los_Angeles",
workdays: [1, 2, 3, 4, 5],
dayStart: "09:00",
dayEnd: "17:00",
intervalMinutes: 15,
minNoticeMinutes: 240,
futureLimitDays: 60,
};
type Settings = typeof DEFAULTS & { onBook?: (booking: Booking) => void };
/* ------------------------------------------------------------------ layout and motion */
/** Root widths (px) where the times sit beside the calendar, and where the times card has room to widen. */
const THREE_COLUMNS = 840;
const OVERHANG = 980;
/** Card padding (2 x 16) + the 200px time pills; the open state adds the gap and Next beside them. */
const SLOT_CARD_WIDTH = 232;
const SLOT_CARD_WIDTH_OPEN = 312;
/** Swaps wait for the leaving piece: the spring's 0.3 s for anything that moves, the 0.22 s fade otherwise. */
const MOVE_MS = 300;
const FADE_MS = 220;
/** Motion's spring { duration: 0.3, bounce: 0.18 } as a CSS linear() curve: damping 0.82, settled at 0.3 s. */
const SPRING = (() => {
const zeta = 0.82;
const omega = Math.log(1000) / (zeta * 0.3);
const damped = omega * Math.sqrt(1 - zeta * zeta);
const points: string[] = [];
for (let i = 0; i <= 40; i++) {
const t = (i / 40) * 0.3;
const x = 1 - Math.exp(-zeta * omega * t) * (Math.cos(damped * t) + ((zeta * omega) / damped) * Math.sin(damped * t));
points.push(i === 40 ? "1" : x.toFixed(4));
}
return `linear(${points.join(", ")})`;
})();
/* ------------------------------------------------------------------ dates and time zones */
const pad = (n: number) => String(n).padStart(2, "0");
/** "yyyy-MM-dd" of a local Date. */
const localKey = (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
const parseKey = (key: string) => {
const [y, m, d] = key.split("-").map(Number);
return new Date(y, m - 1, d || 1);
};
const toMinutes = (hhmm: string) => {
const [h, m] = hhmm.split(":").map(Number);
return h * 60 + (m || 0);
};
const formatters = new Map<string, Intl.DateTimeFormat>();
function zoned(ms: number, timeZone: string) {
let f = formatters.get(timeZone);
if (!f) {
f = new Intl.DateTimeFormat("en-US", {
timeZone,
hourCycle: "h23",
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
});
formatters.set(timeZone, f);
}
const p: Record<string, number> = {};
for (const { type, value } of f.formatToParts(ms)) p[type] = Number(value);
return { y: p.year, m: p.month, d: p.day, h: p.hour % 24, min: p.minute };
}
/** The UTC instant of a wall-clock time in a zone (two passes, so a DST change on that day lands right). */
function zonedToUtc(y: number, m: number, d: number, minutes: number, timeZone: string) {
const wall = Date.UTC(y, m - 1, d, 0, minutes);
const offset = (ms: number) => {
const p = zoned(ms, timeZone);
return Date.UTC(p.y, p.m - 1, p.d, p.h, p.min) - Math.floor(ms / 60000) * 60000;
};
return wall - offset(wall - offset(wall));
}
type Rules = Pick<Settings, "hostTimeZone" | "workdays" | "dayStart" | "dayEnd" | "durationMinutes" | "intervalMinutes" | "minNoticeMinutes" | "futureLimitDays">;
/** Every free start time, grouped by day ("yyyy-MM-dd") in the visitor's zone. */
function buildSlots(now: number, viewerZone: string, s: Rules) {
const byDay = new Map<string, number[]>();
const earliest = now + s.minNoticeMinutes * 60_000;
const latest = now + s.futureLimitDays * 86_400_000;
const start = toMinutes(s.dayStart);
const end = toMinutes(s.dayEnd);
const today = zoned(now, s.hostTimeZone);
for (let i = 0; i <= s.futureLimitDays + 1; i++) {
const day = new Date(Date.UTC(today.y, today.m - 1, today.d + i));
if (!s.workdays.includes(day.getUTCDay())) continue;
// Clocks change in the small hours, never inside a working day: one conversion per day is exact.
const opens = zonedToUtc(day.getUTCFullYear(), day.getUTCMonth() + 1, day.getUTCDate(), start, s.hostTimeZone);
for (let t = start; t + s.durationMinutes <= end; t += s.intervalMinutes) {
const at = opens + (t - start) * 60_000;
if (at < earliest || at > latest) continue;
const p = zoned(at, viewerZone);
const key = `${p.y}-${pad(p.m)}-${pad(p.d)}`;
const list = byDay.get(key);
if (list) list.push(at);
else byDay.set(key, [at]);
}
}
return byDay;
}
/** Always six rows, so the calendar keeps one height across every month. */
function monthGrid(month: Date) {
const lead = month.getDay();
return Array.from({ length: 42 }, (_, i) => new Date(month.getFullYear(), month.getMonth(), 1 - lead + i));
}
function monthHasTimes(slots: Map<string, number[]>, month: Date, today: Date) {
for (const d of monthGrid(month)) {
if (d.getMonth() === month.getMonth() && d >= today && slots.get(localKey(d))?.length) return true;
}
return false;
}
const monthTitle = (month: Date) => month.toLocaleDateString("en-US", { month: "long", year: "numeric" });
// "America/Los_Angeles" -> "America/Los Angeles"
const formatZone = (zone: string) => zone.replace(/_/g, " ");
/* ------------------------------------------------------------------ small hooks */
const noopSubscribe = () => () => {};
/** The root's width, kept current by a ResizeObserver; 0 until it has been measured. */
function useWidth(ref: RefObject<HTMLDivElement | null>) {
const subscribe = useCallback(
(onChange: () => void) => {
const el = ref.current;
if (!el) return () => {};
const observer = new ResizeObserver(onChange);
observer.observe(el);
return () => observer.disconnect();
},
[ref],
);
return useSyncExternalStore(subscribe, () => ref.current?.clientWidth ?? 0, () => 0);
}
/**
* AnimatePresence's mode="wait", for one keyed slot: when `key` changes, the old content stays up, marked
* as leaving, for `exitMs(oldKey)`; then the new key takes its place and plays its entrance. The first key
* shows without one.
*/
function useSwap(key: string, exitMs: (leaving: string) => number) {
const [shown, setShown] = useState(key);
const [swapped, setSwapped] = useState(false);
const leaving = key !== shown;
const ms = leaving ? exitMs(shown) : 0;
useEffect(() => {
if (!leaving) return;
const timer = setTimeout(() => {
setShown(key);
setSwapped(true);
}, ms);
return () => clearTimeout(timer);
}, [leaving, key, ms]);
return { shown, leaving, entering: swapped && !leaving };
}
/** Writes the pointer's position inside the element to --mx / --my for the glow. No re-render. */
function trackPointer(e: ReactPointerEvent<HTMLElement>) {
const r = e.currentTarget.getBoundingClientRect();
e.currentTarget.style.setProperty("--mx", `${((e.clientX - r.left) / r.width) * 100}%`);
e.currentTarget.style.setProperty("--my", `${((e.clientY - r.top) / r.height) * 100}%`);
}
function trackField(e: ReactPointerEvent<HTMLElement>) {
const r = e.currentTarget.getBoundingClientRect();
e.currentTarget.style.setProperty("--gx", `${e.clientX - r.left}px`);
e.currentTarget.style.setProperty("--gy", `${e.clientY - r.top}px`);
}
const vars = (v: Record<string, string | number>) => v as CSSProperties;
/* ------------------------------------------------------------------ component */
export default function BookingCalendar(props: BookingCalendarProps) {
const rootRef = useRef<HTMLDivElement>(null);
// Times depend on "now" and the visitor's zone, which a server render can't know: render the frame on the
// server and everything inside it on the client only.
const mounted = useSyncExternalStore(noopSubscribe, () => true, () => false);
return (
<div ref={rootRef} className="sb" style={vars({ "--sb-accent": props.accent ?? DEFAULTS.accent })}>
<style href="ui-booking-calendar" precedence="ui">
{css}
</style>
{mounted && <Scheduler settings={{ ...DEFAULTS, ...stripUndefined(props) }} rootRef={rootRef} />}
</div>
);
}
function stripUndefined<T extends object>(o: T): Partial<T> {
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as Partial<T>;
}
type Panel = "pick" | "form" | "done";
type Toast = { id: number; text: string };
function Scheduler({ settings: s, rootRef }: { settings: Settings; rootRef: RefObject<HTMLDivElement | null> }) {
const width = useWidth(rootRef);
const threeColumns = width >= THREE_COLUMNS;
const overhang = width >= OVERHANG;
const [now] = useState(() => Date.now());
const [tz, setTz] = useState(() => Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC");
const [zones] = useState<string[]>(() =>
typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : [],
);
// Matches the visitor's regional clock until they flip the toggle.
const [hour12, setHour12] = useState(
() => new Intl.DateTimeFormat(undefined, { hour: "numeric" }).resolvedOptions().hour12 ?? true,
);
// The availability rules by value, so a parent re-rendering with a fresh `workdays` array costs nothing.
const rules = JSON.stringify([s.hostTimeZone, s.workdays, s.dayStart, s.dayEnd, s.durationMinutes, s.intervalMinutes, s.minNoticeMinutes, s.futureLimitDays]);
const slots = useMemo(() => {
const [hostTimeZone, workdays, dayStart, dayEnd, durationMinutes, intervalMinutes, minNoticeMinutes, futureLimitDays] = JSON.parse(rules);
return buildSlots(now, tz, { hostTimeZone, workdays, dayStart, dayEnd, durationMinutes, intervalMinutes, minNoticeMinutes, futureLimitDays });
}, [now, tz, rules]);
const today = useMemo(() => {
const d = new Date(now);
d.setHours(0, 0, 0, 0);
return d;
}, [now]);
// A short window often has nothing left this month, and an all-grey month reads as "fully booked": on
// the first render only, an empty current month moves on to the next one.
const [view, setView] = useState(() => {
const first = new Date(today.getFullYear(), today.getMonth(), 1);
return monthHasTimes(slots, first, today) ? first : new Date(today.getFullYear(), today.getMonth() + 1, 1);
});
const [monthDir, setMonthDir] = useState(1);
const goToMonth = (delta: number) => {
setMonthDir(delta);
setView(new Date(view.getFullYear(), view.getMonth() + delta, 1));
};
const [dateKey, setDateKey] = useState<string | null>(null);
const [slot, setSlot] = useState<number | null>(null);
const [leavingSlot, setLeavingSlot] = useState<number | null>(null);
const [panel, setPanel] = useState<Panel>("pick");
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [notes, setNotes] = useState("");
const [submitting, setSubmitting] = useState(false);
const [booked, setBooked] = useState<Booking | null>(null);
const [toast, setToast] = useState<Toast | null>(null);
useEffect(() => {
if (leavingSlot === null) return;
const timer = setTimeout(() => setLeavingSlot(null), MOVE_MS);
return () => clearTimeout(timer);
}, [leavingSlot]);
useEffect(() => {
if (!toast) return;
const timer = setTimeout(() => setToast(null), 4000);
return () => clearTimeout(timer);
}, [toast]);
useEffect(() => {
if (!submitting) return;
// Stands in for the POST to the booking API.
const timer = setTimeout(() => {
if (slot === null) return;
const booking: Booking = {
startUtc: new Date(slot).toISOString(),
endUtc: new Date(slot + s.durationMinutes * 60_000).toISOString(),
name: name.trim(),
email: email.trim(),
notes: notes.trim(),
timeZone: tz,
};
s.onBook?.(booking);
setBooked(booking);
setSubmitting(false);
setPanel("done");
}, 900);
return () => clearTimeout(timer);
}, [submitting, slot, name, email, notes, tz, s]);
const pickDate = (key: string) => {
setDateKey(key);
setSlot(null);
setLeavingSlot(null);
};
const pickSlot = (at: number) => {
if (slot !== null && slot !== at) setLeavingSlot(slot);
setSlot(at);
};
const submit = () => {
if (slot === null || submitting) return;
if (!name.trim() || !email.trim()) {
setToast({ id: Date.now(), text: "Name and email are required" });
return;
}
setToast(null);
setSubmitting(true);
};
const startOver = (clearForm: boolean) => {
setPanel("pick");
setDateKey(null);
setSlot(null);
if (clearForm) {
setName("");
setEmail("");
setNotes("");
}
};
const top = useSwap(panel === "done" ? "done" : "book", () => MOVE_MS);
const onForm = panel !== "pick" && slot !== null;
return (
<>
<div className="sb-scroll">
<div className="sb-page">
{top.shown === "done" && booked ? (
<div
key="done"
className={top.leaving ? "sb-out" : "sb-in"}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
<Confirmed booking={booked} settings={s} hour12={hour12} onReschedule={() => startOver(false)} onCancel={() => startOver(true)} />
</div>
) : (
<div
key="book"
className={`sb-grid${top.leaving ? " sb-out" : ""}`}
style={vars({ "--sb-oy": "-10px" })}
>
<div className="sb-in" style={vars({ "--sb-dy": "14px" })}>
<HostCard
settings={s}
slotDate={onForm ? slot : null}
tz={tz}
hour12={hour12}
zones={zones}
onTzChange={onForm ? undefined : setTz}
/>
</div>
<BookPanels
panelKey={panel === "pick" ? "pick" : "form"}
pick={
<>
<div className="sb-in" style={vars({ "--sb-dy": "14px", "--sb-delay": "0.13s" })}>
<CalendarCard
view={view}
monthDir={monthDir}
today={today}
slots={slots}
selected={dateKey}
onMonth={goToMonth}
onPick={pickDate}
/>
</div>
<div className="sb-times-col sb-in" style={vars({ "--sb-dy": "14px", "--sb-delay": "0.26s" })}>
<TimesColumn
dateKey={dateKey}
slots={slots}
slot={slot}
leavingSlot={leavingSlot}
tz={tz}
hour12={hour12}
onHour12={setHour12}
threeColumns={threeColumns}
overhang={overhang}
onPick={pickSlot}
onNext={() => setPanel("form")}
/>
</div>
</>
}
form={
<ConfirmForm
name={name}
email={email}
notes={notes}
onName={setName}
onEmail={setEmail}
onNotes={setNotes}
submitting={submitting}
onBack={() => setPanel("pick")}
onSubmit={submit}
/>
}
/>
</div>
)}
</div>
</div>
{toast && (
<div key={toast.id} className="sb-toast" role="status">
<span className="sb-swatch" aria-hidden />
<span className="sb-toast-title">{toast.text}</span>
<button type="button" className="sb-toast-close" aria-label="Dismiss notification" onClick={() => setToast(null)}>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" aria-hidden>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</div>
)}
</>
);
}
/** The calendar + times pair and the details form trade places: the old one lifts away, then the new one rises. */
function BookPanels({ panelKey, pick, form }: { panelKey: "pick" | "form"; pick: ReactNode; form: ReactNode }) {
const swap = useSwap(panelKey, () => MOVE_MS);
if (swap.shown === "form") {
return (
<div
key="form"
className={swap.leaving ? "sb-out" : swap.entering ? "sb-in" : undefined}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
{form}
</div>
);
}
return (
<div key="pick" className={`sb-pick${swap.leaving ? " sb-out" : ""}`} style={vars({ "--sb-oy": "-10px" })}>
{pick}
</div>
);
}
/* ------------------------------------------------------------------ host card */
function HostCard({
settings: s,
slotDate,
tz,
hour12,
zones,
onTzChange,
}: {
settings: Settings;
slotDate: number | null;
tz: string;
hour12: boolean;
zones: string[];
onTzChange?: (zone: string) => void;
}) {
const [avatarFailed, setAvatarFailed] = useState(false);
const options = zones.includes(tz) ? zones : [tz, ...zones];
// Keeps the last chosen time on screen while its row folds away.
const [shownSlot, setShownSlot] = useState(slotDate);
if (slotDate !== null && slotDate !== shownSlot) setShownSlot(slotDate);
return (
<div className="sb-host">
<div className="sb-host-head">
<span className="sb-avatar-wrap">
<span className="sb-avatar">
{s.avatarUrl && !avatarFailed ? (
<img src={s.avatarUrl} alt="" onError={() => setAvatarFailed(true)} />
) : (
<span>{(s.hostName || "?")[0].toUpperCase()}</span>
)}
</span>
{s.logoUrl && (
<span className="sb-badge">
<img src={s.logoUrl} alt="" />
</span>
)}
</span>
<div>
<p className="sb-host-name">{s.hostName}</p>
<h2 className="sb-host-title">{s.title}</h2>
</div>
</div>
{s.description && <p className="sb-host-desc">{s.description}</p>}
<div className="sb-host-row">
<ClockIcon /> {s.durationMinutes} min
</div>
{s.location && (
<div className="sb-host-row">
<VideoIcon /> {s.location}
</div>
)}
<div className="sb-reveal" data-open={slotDate !== null ? "" : undefined}>
<div>
<span className="sb-host-row">
<CalendarIcon />
{shownSlot !== null &&
new Date(shownSlot).toLocaleString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
hour: "numeric",
minute: "2-digit",
hour12,
timeZone: tz,
})}
</span>
</div>
</div>
<div className="sb-host-row sb-host-tz">
<EarthIcon />
{onTzChange ? (
<select value={tz} onChange={(e) => onTzChange(e.target.value)} aria-label="Time zone">
{options.map((zone) => (
<option key={zone} value={zone}>
{formatZone(zone)}
</option>
))}
</select>
) : (
<span>{formatZone(tz)}</span>
)}
</div>
</div>
);
}
/* ------------------------------------------------------------------ calendar */
function CalendarCard({
view,
monthDir,
today,
slots,
selected,
onMonth,
onPick,
}: {
view: Date;
monthDir: number;
today: Date;
slots: Map<string, number[]>;
selected: string | null;
onMonth: (delta: number) => void;
onPick: (key: string) => void;
}) {
const swap = useSwap(localKey(view), () => MOVE_MS);
const month = parseKey(swap.shown);
const days = monthGrid(month);
const motionClass = swap.leaving ? "sb-out" : swap.entering ? "sb-in" : undefined;
const isCurrentMonth = view.getFullYear() === today.getFullYear() && view.getMonth() === today.getMonth();
return (
<div className="sb-card sb-cal">
<div className="sb-cal-head">
<div className="sb-month" aria-live="polite">
{/* The invisible copy sizes the box to the month being shown; the animated title sits over it. */}
<span className="sb-month-size" aria-hidden>
{monthTitle(view)}
</span>
<h3
key={swap.shown}
className={`sb-month-title${motionClass ? ` ${motionClass}` : ""}`}
style={vars({ "--sb-dx": `${monthDir * 10}px`, "--sb-ox": `${monthDir * -10}px` })}
>
{monthTitle(month)}
</h3>
</div>
<div className="sb-nav">
<button type="button" className="sb-icon-btn" onClick={() => onMonth(-1)} disabled={isCurrentMonth} aria-label="Previous month">
<ChevronLeftIcon />
</button>
<button type="button" className="sb-icon-btn" onClick={() => onMonth(1)} aria-label="Next month">
<ChevronRightIcon />
</button>
</div>
</div>
<div className="sb-dow" aria-hidden>
{["S", "M", "T", "W", "T", "F", "S"].map((d, i) => (
<div key={i}>{d}</div>
))}
</div>
<div
key={swap.shown}
className={`sb-days${motionClass ? ` ${motionClass}` : ""}`}
style={vars({ "--sb-dx": `${monthDir * 16}px`, "--sb-ox": `${monthDir * -16}px` })}
>
{days.map((d) => {
const key = localKey(d);
const inMonth = d.getMonth() === month.getMonth();
const available = inMonth && d >= today && (slots.get(key)?.length ?? 0) > 0;
if (!available) {
return (
<div key={key} className={`sb-day${inMonth ? "" : " sb-day-out"}`}>
{d.getDate()}
</div>
);
}
const isSelected = selected === key;
return (
<button
key={key}
type="button"
className="sb-day sb-glow"
aria-pressed={isSelected}
aria-label={d.toLocaleDateString("en-US", { weekday: "long", month: "long", day: "numeric" })}
onPointerMove={trackPointer}
onClick={() => onPick(key)}
>
<Glow />
<span className="sb-fill" aria-hidden />
<span className="sb-lbl">{d.getDate()}</span>
</button>
);
})}
</div>
</div>
);
}
/** Starlight's card glow: a conic border that sweeps once around on hover, and a light under the pointer. */
function Glow() {
return (
<>
<span className="sb-ring" aria-hidden />
<span className="sb-wash" aria-hidden />
</>
);
}
/* ------------------------------------------------------------------ times */
function TimesColumn({
dateKey,
slots,
slot,
leavingSlot,
tz,
hour12,
onHour12,
threeColumns,
overhang,
onPick,
onNext,
}: {
dateKey: string | null;
slots: Map<string, number[]>;
slot: number | null;
leavingSlot: number | null;
tz: string;
hour12: boolean;
onHour12: (hour12: boolean) => void;
threeColumns: boolean;
overhang: boolean;
onPick: (at: number) => void;
onNext: () => void;
}) {
const swap = useSwap(dateKey ?? "empty", (leaving) => (leaving === "empty" ? FADE_MS : MOVE_MS));
if (swap.shown === "empty") {
return (
<div key="empty" className={`sb-empty${swap.leaving ? " sb-fade-out" : ""}`}>
Select a date to see times.
</div>
);
}
const times = slots.get(swap.shown) ?? [];
const chosen = swap.leaving ? null : slot;
const inlineNext = threeColumns && overhang;
const label = (at: number) => new Date(at).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", hour12, timeZone: tz });
return (
<div
key={swap.shown}
className={swap.leaving ? "sb-out" : "sb-in"}
style={vars({ "--sb-dy": "10px", "--sb-oy": "-10px" })}
>
{/* Beside the calendar with room to spare, the card hugs the times, then widens past its column to make
room for Next. The pills are a fixed width, so only the card moves. Otherwise it fills its column
and Next rides a bar under the times. */}
<div
className="sb-times"
style={{ width: inlineNext ? (chosen !== null ? SLOT_CARD_WIDTH_OPEN : SLOT_CARD_WIDTH) : "100%" }}
>
<div className="sb-card sb-times-card">
<div className="sb-times-head">
<h3>{parseKey(swap.shown).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" })}</h3>
<TimeFormatToggle hour12={hour12} onChange={onHour12} />
</div>
<div className="sb-slots" role="group" aria-label="Available times">
{times.map((at, i) => {
const selected = chosen === at;
const next = inlineNext && (selected || leavingSlot === at);
return (
<div key={at} className="sb-slot-row sb-in" style={vars({ "--sb-dy": "6px", "--sb-delay": `${i * 0.02}s` })}>
<button
type="button"
className="sb-slot sb-glow"
aria-pressed={selected}
onPointerMove={trackPointer}
onClick={() => onPick(at)}
>
<Glow />
<span className="sb-fill" aria-hidden />
<span className="sb-lbl">{label(at)}</span>
</button>
{next && (
<div className={selected ? "sb-pop-in" : "sb-pop-out"}>
<button type="button" className="sb-btn sb-btn-accent" onClick={onNext} tabIndex={selected ? 0 : -1}>
Next
</button>
</div>
)}
</div>
);
})}
</div>
{!inlineNext && (
<div className="sb-bar" data-open={chosen !== null ? "" : undefined} inert={chosen === null}>
<div>
<div className="sb-bar-pad">
<button type="button" className="sb-btn sb-btn-accent sb-btn-block" onClick={onNext}>
Next
</button>
</div>
</div>
</div>
)}
</div>
</div>
</div>
);
}
/** Segmented 12h / 24h switch. The accent fill slides from one half to the other. */
function TimeFormatToggle({ hour12, onChange }: { hour12: boolean; onChange: (hour12: boolean) => void }) {
const refs = useRef<(HTMLButtonElement | null)[]>([]);
const [pill, setPill] = useState<{ x: number; w: number; ready: boolean } | null>(null);
useLayoutEffect(() => {
const el = refs.current[hour12 ? 0 : 1];
if (!el) return;
setPill((prev) => ({ x: el.offsetLeft, w: el.offsetWidth, ready: prev !== null }));
}, [hour12]);
return (
<div role="group" aria-label="Time format" className="sb-fmt">
{pill && (
<span
className="sb-fmt-pill"
data-ready={pill.ready ? "" : undefined}
style={{ transform: `translateX(${pill.x}px)`, width: pill.w }}
aria-hidden
/>
)}
{([true, false] as const).map((is12, i) => (
<button
key={String(is12)}
ref={(el) => {
refs.current[i] = el;
}}
type="button"
aria-pressed={hour12 === is12}
onClick={() => onChange(is12)}
>
{is12 ? "12h" : "24h"}
</button>
))}
</div>
);
}
/* ------------------------------------------------------------------ details form */
function ConfirmForm({
name,
email,
notes,
onName,
onEmail,
onNotes,
submitting,
onBack,
onSubmit,
}: {
name: string;
email: string;
notes: string;
onName: (v: string) => void;
onEmail: (v: string) => void;
onNotes: (v: string) => void;
submitting: boolean;
onBack: () => void;
onSubmit: () => void;
}) {
return (
<form
className="sb-card sb-form"
noValidate
onSubmit={(e) => {
e.preventDefault();
onSubmit();
}}
>
<h2>Confirm your details</h2>
<div className="sb-fields">
<Field label="Your name *" value={name} onChange={onName} disabled={submitting} autoComplete="name" />
<Field label="Email *" type="email" value={email} onChange={onEmail} disabled={submitting} autoComplete="email" />
<Field
label="Anything else? (optional)"
multiline
value={notes}
onChange={onNotes}
disabled={submitting}
placeholder="Share anything that will help prepare for the meeting."
/>
</div>
<div className="sb-actions">
<button type="button" className="sb-btn sb-btn-ghost" onClick={onBack} disabled={submitting}>
Back
</button>
<button type="submit" className="sb-btn sb-btn-accent" disabled={submitting}>
{submitting && <Spinner />}
Confirm booking
</button>
</div>
</form>
);
}
/** Starlight's floating-label field: a grey well, a light under the pointer, and a rainbow ring on focus. */
function Field({
label,
value,
onChange,
multiline,
...rest
}: {
label: string;
value: string;
onChange: (v: string) => void;
multiline?: boolean;
type?: string;
disabled?: boolean;
autoComplete?: string;
placeholder?: string;
}) {
const id = `sb-${label.replace(/\W+/g, "-").toLowerCase()}`;
const control = multiline ? (
<textarea id={id} rows={2} value={value} onChange={(e) => onChange(e.target.value)} placeholder={rest.placeholder ?? " "} disabled={rest.disabled} />
) : (
<input id={id} value={value} onChange={(e) => onChange(e.target.value)} placeholder=" " {...rest} />
);
return (
<div className={`sb-field${multiline ? " sb-field-multi" : ""}`} onPointerMove={trackField}>
<span className="sb-field-light" aria-hidden />
<span className="sb-field-ring" aria-hidden />
{control}
<label htmlFor={id}>{label}</label>
</div>
);
}
/* ------------------------------------------------------------------ confirmation */
function Confirmed({
booking,
settings: s,
hour12,
onReschedule,
onCancel,
}: {
booking: Booking;
settings: Settings;
hour12: boolean;
onReschedule: () => void;
onCancel: () => void;
}) {
const when = new Date(booking.startUtc).toLocaleString("en-US", {
weekday: "long",
month: "long",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "2-digit",
hour12,
timeZone: booking.timeZone,
});
const addToCalendar = () => {
const stamp = (iso: string) => iso.replace(/[-:]/g, "").replace(/\.\d{3}/, "");
const text = (v: string) => v.replace(/[\\;,]/g, (c) => `\\${c}`).replace(/\n/g, "\\n");
const ics = [
"BEGIN:VCALENDAR",
"VERSION:2.0",
"PRODID:-//Booking calendar//EN",
"METHOD:PUBLISH",
"BEGIN:VEVENT",
`UID:${stamp(booking.startUtc)}-${Math.random().toString(36).slice(2)}@booking-calendar`,
`DTSTAMP:${stamp(new Date().toISOString())}`,
`DTSTART:${stamp(booking.startUtc)}`,
`DTEND:${stamp(booking.endUtc)}`,
`SUMMARY:${text(`${s.title} with ${s.hostName}`)}`,
`LOCATION:${text(s.location)}`,
"END:VEVENT",
"END:VCALENDAR",
].join("\r\n");
const url = URL.createObjectURL(new Blob([ics], { type: "text/calendar" }));
const a = document.createElement("a");
a.href = url;
a.download = `${s.title.toLowerCase().replace(/\W+/g, "-")}.ics`;
a.click();
setTimeout(() => URL.revokeObjectURL(url), 1000);
};
return (
<div className="sb-card sb-done">
<div className="sb-check">
<svg viewBox="0 0 80 80" fill="none" aria-hidden>
<circle cx="40" cy="40" r="34" pathLength={1} />
<path d="M26.5 41.5 35.5 50.5 54 31" pathLength={1} />
</svg>
</div>
<h2>You're booked.</h2>
<p className="sb-done-sub">This is a demo, so nothing was booked and no email went to {booking.email}.</p>
<div className="sb-done-rows">
<div className="sb-done-row">
<CalendarDaysIcon />
<div>
<p>{s.title}</p>
<p>with {s.hostName}</p>
</div>
</div>
<div className="sb-done-row">
<ClockIcon />
<div>
<p>{when}</p>
<p>{booking.timeZone}</p>
</div>
</div>
</div>
<div className="sb-done-links">
<button type="button" onClick={onReschedule}>
<FlipBackwardIcon />
Reschedule
</button>
<button type="button" onClick={onCancel}>
<RemoveCircleIcon />
Cancel
</button>
<button type="button" onClick={addToCalendar}>
<CalendarAddIcon />
Add to calendar
</button>
</div>
</div>
);
}
/* ------------------------------------------------------------------ icons (Iconly, Heroicons) */
const stroke = { stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" } as const;
function Icon({ children }: { children: ReactNode }) {
return (
<svg viewBox="0 0 24 24" fill="none" aria-hidden>
{children}
</svg>
);
}
function ClockIcon() {
return (
<Icon>
<path
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
d="M12 3.75C7.44329 3.75 3.75 7.44329 3.75 12C3.75 16.5558 7.44335 20.25 12 20.25C16.5567 20.25 20.25 16.5558 20.25 12C20.25 7.44329 16.5567 3.75 12 3.75ZM2.25 12C2.25 6.61487 6.61487 2.25 12 2.25C17.3851 2.25 21.75 6.61487 21.75 12C21.75 17.3841 17.3852 21.75 12 21.75C6.61481 21.75 2.25 17.3841 2.25 12Z"
/>
<path
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
d="M11.6719 7.82617C12.0861 7.82617 12.4219 8.16196 12.4219 8.57617V12.2488L15.2314 13.9278C15.587 14.1403 15.703 14.6008 15.4905 14.9564C15.278 15.3119 14.8175 15.4279 14.4619 15.2154L11.2871 13.3181C11.0606 13.1827 10.9219 12.9383 10.9219 12.6743V8.57617C10.9219 8.16196 11.2577 7.82617 11.6719 7.82617Z"
/>
</Icon>
);
}
function VideoIcon() {
return (
<Icon>
<path {...stroke} d="M16.1515 9.67278C17.9896 8.21564 20.4563 6.80611 20.9229 7.31087C21.6943 8.13945 21.6277 16.0252 20.9229 16.7775C20.4943 17.2442 18.0086 15.8347 16.1515 14.3871" />
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M2.5144 12.037C2.5144 6.84461 4.23917 5.11414 9.41536 5.11414C14.5906 5.11414 16.3154 6.84461 16.3154 12.037C16.3154 17.2284 14.5906 18.9599 9.41536 18.9599C4.23917 18.9599 2.5144 17.2284 2.5144 12.037Z" />
</Icon>
);
}
function EarthIcon() {
return (
<Icon>
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M12 21C7.02908 21 3 16.9709 3 12C3 7.02908 7.02908 3 12 3C16.9709 3 21 7.02908 21 12C21 16.9709 16.9709 21 12 21Z" />
<path {...stroke} d="M17.3835 19.0977C17.3835 19.0977 15.2059 13.0954 21 11.9998" />
<path {...stroke} d="M20.1123 8.08805C19.1763 8.02286 17.4717 8.30308 14.9711 10.1011C11.9938 12.2456 11.3098 7.71346 12.2555 3.01302" />
<path {...stroke} d="M11.5945 21C11.5945 21 12.2075 18.4635 10.4532 17.0916C8.69895 15.7206 7.38835 15.8209 7.17041 14.0773C6.95246 12.3337 9.10468 12.0409 7.53041 9.44595C6.49127 7.73254 5.31787 6.66032 5.36165 5.95103" />
</Icon>
);
}
function CalendarIcon() {
return (
<Icon>
<path {...stroke} fillRule="evenodd" clipRule="evenodd" d="M2.74976 12.7756C2.74976 5.81959 5.06876 3.50159 12.0238 3.50159C18.9798 3.50159 21.2988 5.81959 21.2988 12.7756C21.2988 19.7316 18.9798 22.0496 12.0238 22.0496C5.06876 22.0496 2.74976 19.7316 2.74976 12.7756Z" />
<path {...stroke} d="M3.02515 9.32397H21.0331M16.4285 13.261H16.4375M12.0291 13.261H12.0381M7.62135 13.261H7.63035M16.4285 17.1129H16.4375M12.0291 17.1129H12.0381M7.62135 17.1129H7.63035M16.033 2.05005V5.31205M8.02466 2.05005V5.31205" />
</Icon>
);
}
function CalendarDaysIcon() {
return (
<Icon>
<g transform="translate(3, 2)" {...stroke}>
<path d="M0.09264 7.40426H17.91659M13.44207 11.30969H13.45134M9.00461 11.30969H9.01388M4.55789 11.30969H4.56716M13.44207 15.19622H13.45134M9.00461 15.19622H9.01388M4.55789 15.19622H4.56716M13.04372 0V3.29078M4.96551 0V3.29078" />
<path d="M13.2382655,1.57919622 L4.77096342,1.57919622 C1.83427331,1.57919622 0,3.21513002 0,6.22222222 L0,15.2718676 C0,18.3262411 1.83427331,20 4.77096342,20 L13.2290015,20 C16.1749556,20 18,18.3546099 18,15.3475177 L18,6.22222222 C18.0092289,3.21513002 16.1842196,1.57919622 13.2382655,1.57919622 Z" />
</g>
</Icon>
);
}
function FlipBackwardIcon() {
return (
<Icon>
<path {...stroke} d="M7.49049 13.0022C6.12748 11.6392 5.36301 10.8745 4 9.51145C5.36301 8.14844 6.12748 7.38449 7.49049 6.02148" />
<path {...stroke} d="M4 9.51099H15.7664C18.1046 9.51099 19.9997 11.4061 19.9997 13.7443C19.9997 16.0826 18.1046 17.9784 15.7664 17.9784H12.2824" />
</Icon>
);
}
function RemoveCircleIcon() {
return (
<Icon>
<path {...stroke} d="M21 12C21 7.02908 16.9709 3 12 3C7.02908 3 3 7.02908 3 12C3 16.9699 7.02908 21 12 21C16.9709 21 21 16.9699 21 12Z" />
<path {...stroke} d="M14.3304 9.66646L9.66792 14.329M14.3363 14.3353L9.66602 9.66504" />
</Icon>
);
}
function CalendarAddIcon() {
return (
<Icon>
<path {...stroke} d="M5.14567 8.28468C4.94095 6.9535 5.92558 5.74707 7.21675 5.74707H17.3368C18.3669 5.74707 19.2446 6.52808 19.4079 7.59009L20.9728 17.7657C21.1776 19.0969 20.1929 20.3033 18.9017 20.3033H8.78169C7.7516 20.3033 6.87394 19.5223 6.71061 18.4603L5.14567 8.28468Z" />
<path {...stroke} d="M10.2006 5.74707H6.66304C5.63295 5.74707 4.75529 6.52808 4.59196 7.59009L3.02702 17.7657C2.82229 19.0969 3.80693 20.3033 5.0981 20.3033H8.36228" />
<path {...stroke} d="M13.0593 10.8833V16.2578M15.7466 13.5706H10.3721" />
<path {...stroke} d="M9.02471 7.5044C9.21547 7.73453 9.34107 7.69894 9.59094 7.69894C10.2426 7.69894 10.7709 6.78153 10.7709 5.64985C10.7709 4.51817 10.2426 3.60076 9.59094 3.60076C9.2432 3.60076 9.03968 3.64146 8.82373 4.0571" />
<path {...stroke} d="M14.9334 7.5044C15.1242 7.73453 15.2498 7.69894 15.4996 7.69894C16.1513 7.69894 16.6795 6.78153 16.6795 5.64985C16.6795 4.51817 16.1513 3.60076 15.4996 3.60076C15.1519 3.60076 14.9484 3.64146 14.7324 4.0571" />
</Icon>
);
}
function ChevronLeftIcon() {
return (
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden>
<path fillRule="evenodd" clipRule="evenodd" d="M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z" />
</svg>
);
}
function ChevronRightIcon() {
return (
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden>
<path fillRule="evenodd" clipRule="evenodd" d="M16.28 11.47a.75.75 0 0 1 0 1.06l-7.5 7.5a.75.75 0 0 1-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 0 1 1.06-1.06l7.5 7.5Z" />
</svg>
);
}
function Spinner() {
return (
<svg className="sb-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" role="status" aria-label="Loading">
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
);
}
/* ------------------------------------------------------------------ styles */
// Starlight's dark booking theme. Its HSL tokens, as hex: card #0D1219, border #1E2125, muted #191E24,
// muted text #989EA4, hover #1D232B, page #0A0E12; the modal it opens in is #0B0D12.
const css = `
@property --sb-a{syntax:"<angle>";inherits:false;initial-value:0deg}
.sb{--sb-card:#0d1219;--sb-border:#1e2125;--sb-muted:#191e24;--sb-muted-fg:#989ea4;--sb-hover:#1d232b;--sb-page:#0a0e12;--sb-ring:#60a5fa;--sb-spring:${SPRING};--sb-fade:cubic-bezier(.22,1,.36,1);--sb-colors:cubic-bezier(.4,0,.2,1);position:relative;width:100%;height:100%;overflow:hidden;isolation:isolate;container:sb/inline-size;background:#0b0d12;color:#fff;color-scheme:dark;font-family:var(--font-google-sans-flex,"Google Sans Flex"),system-ui,sans-serif;font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility;-webkit-tap-highlight-color:transparent}
/* Resets carry no specificity (:where), so every sb- class below wins over them. */
:where(.sb) *,:where(.sb) *::before,:where(.sb) *::after{box-sizing:border-box}
:where(.sb) :where(h2,h3,p){margin:0;font:inherit}
:where(.sb) :where(button,input,textarea,select){font:inherit;color:inherit;letter-spacing:inherit;margin:0}
:where(.sb) :where(button){background:none;border:0;padding:0;cursor:pointer;text-align:inherit}
:where(.sb) :where(button:disabled){cursor:default}
:where(.sb) :where(svg){display:block;flex-shrink:0}
:where(.sb) :where(img){display:block}
:where(.sb) :where(a){color:inherit}
:where(.sb) :focus-visible{outline:1.5px solid var(--sb-ring);outline-offset:1px}
.sb-scroll{height:100%;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--sb-border) transparent}
.sb-page{max-width:896px;margin:0 auto;padding:40px 16px}
.sb-grid,.sb-pick{display:grid;gap:24px;align-items:start}
@container sb (min-width:680px){.sb-grid{grid-template-columns:300px minmax(0,1fr)}}
@container sb (min-width:840px){.sb-pick{grid-template-columns:minmax(0,1fr) 232px}}
.sb-card{border-radius:12px;border:1px solid var(--sb-border);background:var(--sb-card);color:#fafafa}
/* host */
.sb-host{position:relative;padding:20px;color:#fafafa}
.sb-host::before{content:"";position:absolute;inset:0;border-radius:12px;border:1px solid var(--sb-border);background:var(--sb-card);z-index:-1}
.sb-host-head{display:flex;align-items:center;gap:12px;margin-bottom:12px}
.sb-avatar-wrap{position:relative;flex-shrink:0}
.sb-avatar{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:9999px;overflow:hidden;background:rgb(var(--sb-accent));color:#fff;font-size:16px;font-weight:600}
.sb-avatar img{width:100%;height:100%;object-fit:cover}
.sb-badge{position:absolute;right:-2px;bottom:-2px;display:flex;align-items:center;justify-content:center;width:20px;height:20px;overflow:hidden;border-radius:9999px;border:1px solid rgba(255,255,255,.1);background:var(--sb-page)}
.sb-badge img{width:100%;height:100%;border-radius:9999px;object-fit:contain}
.sb-host-name{font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-host-title{font-weight:600;line-height:1.25}
.sb-host-desc{font-size:14px;line-height:20px;color:var(--sb-muted-fg);margin-bottom:12px}
.sb-host-row{display:flex;align-items:center;gap:8px;margin-bottom:6px;font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-host-row svg{width:16px;height:16px}
.sb-host-tz{align-items:flex-start;margin-bottom:0}
.sb-host-tz svg{margin-top:2px}
.sb-host-tz select{width:100%;min-width:0;padding:0;border:0;border-bottom:1px solid transparent;border-radius:0;background:transparent;font-size:14px;line-height:20px;cursor:pointer;-webkit-appearance:none;appearance:none;outline:none}
.sb-host-tz select:focus-visible{border-bottom-color:var(--sb-muted-fg)}
.sb-host-tz option{background:var(--sb-card);color:#fafafa}
.sb-reveal{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows .22s var(--sb-fade),opacity .22s var(--sb-fade)}
.sb-reveal[data-open]{grid-template-rows:1fr;opacity:1}
.sb-reveal>div{min-height:0;overflow:hidden}
/* calendar */
.sb-cal{padding:16px}
.sb-cal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.sb-month{position:relative;height:24px;overflow:hidden;flex-shrink:0;font-weight:600;line-height:24px;white-space:nowrap}
.sb-month-size{visibility:hidden}
.sb-month-title{position:absolute;inset:0}
.sb-nav{display:flex;align-items:center;gap:4px}
.sb-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:9999px;transition:color .15s var(--sb-colors),background-color .15s var(--sb-colors)}
.sb-icon-btn svg{width:16px;height:16px}
.sb-icon-btn:disabled{opacity:.5;pointer-events:none}
@media (hover:hover){.sb-icon-btn:hover{background:var(--sb-hover);color:#f2f2f2}}
.sb-dow{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));margin-bottom:8px;font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-dow div{padding:4px 0;text-align:center}
.sb-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.sb-day{aspect-ratio:1;display:flex;align-items:center;justify-content:center;font-size:14px;line-height:20px;color:rgba(152,158,164,.4)}
.sb-day.sb-day-out{color:rgba(152,158,164,.3)}
button.sb-day{position:relative;overflow:hidden;border-radius:10px;font-weight:500;color:#fafafa}
/* card glow, shared by days and time pills */
.sb-ring{position:absolute;inset:0;z-index:1;padding:1px;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .3s ease-out,--sb-a 0s;background:conic-gradient(from var(--sb-a),rgb(var(--sb-accent)) 0deg,transparent 90deg,transparent 270deg,rgb(var(--sb-accent)) 360deg);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}
.sb-wash{position:absolute;inset:0;z-index:0;pointer-events:none;opacity:0;transition:opacity .3s ease-out;background:radial-gradient(circle at var(--mx,50%) var(--my,50%),rgba(var(--sb-accent),.1) 0%,rgba(255,255,255,0) 90%)}
@media (hover:hover){
.sb-glow:hover>.sb-ring{opacity:1;--sb-a:360deg;transition:opacity 0s,--sb-a 1s cubic-bezier(.33,1,.68,1)}
.sb-glow:hover>.sb-wash{opacity:1}
}
.sb-fill{position:absolute;inset:0;z-index:2;border-radius:6px;background:rgb(var(--sb-accent));opacity:0;transition:opacity .22s var(--sb-fade)}
.sb-slot .sb-fill{border-radius:9999px}
.sb-glow[aria-pressed=true]>.sb-fill{opacity:1}
.sb-lbl{position:relative;z-index:10;transition:color .2s var(--sb-colors)}
.sb-glow[aria-pressed=true]>.sb-lbl{color:#fff}
/* times */
.sb-times-col{min-width:0}
.sb-empty{padding-top:24px;font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-times{transition:width .3s var(--sb-spring)}
.sb-times-card{padding:16px}
.sb-times-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:12px}
.sb-times-head h3{font-size:14px;line-height:20px;font-weight:600}
.sb-slots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:4px;margin:-4px}
@container sb (min-width:840px){.sb-slots{grid-template-columns:minmax(0,1fr);max-height:420px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--sb-border) transparent}}
.sb-slot-row{display:flex;align-items:center;gap:8px;min-width:0}
.sb-slot{position:relative;overflow:hidden;width:100%;height:36px;padding:0 16px;border-radius:9999px;font-size:14px;line-height:20px;font-weight:500;text-align:center;background:var(--sb-page);box-shadow:0 0 0 1px rgba(255,255,255,.08)}
@container sb (min-width:840px){.sb-slot{width:200px;flex-shrink:0}}
.sb-fmt{position:relative;display:flex;flex-shrink:0;align-items:center;padding:2px;border-radius:9999px;background:rgba(25,30,36,.6);font-size:11px;font-weight:500}
.sb-fmt button{position:relative;z-index:1;padding:2px 8px;border-radius:9999px;color:var(--sb-muted-fg);transition:color .15s var(--sb-colors)}
.sb-fmt button[aria-pressed=true]{color:#fff}
@media (hover:hover){.sb-fmt button[aria-pressed=false]:hover{color:#fff}}
.sb-fmt-pill{position:absolute;top:2px;bottom:2px;left:0;border-radius:9999px;background:rgb(var(--sb-accent))}
.sb-fmt-pill[data-ready]{transition:transform .3s var(--sb-spring),width .3s var(--sb-spring)}
.sb-bar{position:sticky;bottom:0;z-index:20;display:grid;grid-template-rows:0fr;margin:0 -16px;border-radius:0 0 11px 11px;background:var(--sb-card);opacity:0;transition:grid-template-rows .22s var(--sb-fade),opacity .22s var(--sb-fade),margin-bottom .22s var(--sb-fade)}
.sb-bar[data-open]{grid-template-rows:1fr;margin-bottom:-16px;opacity:1}
.sb-bar>div{min-height:0;overflow:hidden}
.sb-bar-pad{padding:12px 16px 16px}
/* buttons */
.sb-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:36px;padding:8px 16px;border-radius:9999px;white-space:nowrap;font-size:14px;line-height:20px;font-weight:500}
.sb-btn:disabled{opacity:.5;pointer-events:none}
.sb-btn-block{width:100%}
.sb-btn-accent{background:rgb(var(--sb-accent));color:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);transition:filter .15s var(--sb-colors),opacity .15s var(--sb-colors)}
.sb-btn-ghost{transition:color .15s var(--sb-colors),background-color .15s var(--sb-colors)}
@media (hover:hover){
.sb-btn-accent:hover{filter:brightness(.95)}
.sb-btn-ghost:hover{background:rgba(var(--sb-accent),.12);color:rgb(var(--sb-accent))}
}
.sb-spin{width:16px;height:16px;margin-right:8px;animation:sb-spin 1s linear infinite}
@keyframes sb-spin{to{rotate:360deg}}
/* details form */
.sb-form{padding:24px}
.sb-form h2{margin-bottom:16px;font-size:18px;line-height:28px;font-weight:600}
.sb-fields{display:flex;flex-direction:column;gap:16px}
.sb-field{position:relative;isolation:isolate;height:52px;border:1px solid transparent;border-radius:16px;background:rgba(25,30,36,.6)}
.sb-field:has(:disabled){opacity:.5;cursor:not-allowed}
.sb-field-light{position:absolute;inset:0;z-index:1;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .2s ease-out;background-image:radial-gradient(140px at var(--gx,50%) var(--gy,50%),rgba(255,255,255,.1) 0%,transparent 60%),radial-gradient(168px at var(--gx,50%) var(--gy,50%),rgba(255,255,255,.05),transparent 70%)}
@media (hover:hover){.sb-field:hover>.sb-field-light{opacity:1}}
.sb-field-ring{position:absolute;inset:0;z-index:3;padding:2px;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity .15s ease-out;background-image:conic-gradient(#f28a00,#f6b300,#f4d21a,#6fd34a,#16c7d9,#1a9dff,#1f5bff,#6b2bd9,#d834b7,#f04a9b,#f28a00);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}
.sb-field:focus-within>.sb-field-ring{opacity:1}
.sb-field input,.sb-field textarea{position:relative;z-index:2;display:block;width:100%;border:0;border-radius:inherit;background:transparent;font-size:16px;line-height:20px;outline:none}
.sb-field input{height:100%;padding:18px 20px 4px}
.sb-field :is(input,textarea)::placeholder{color:transparent}
.sb-field :is(input,textarea):focus::placeholder{color:var(--sb-muted-fg)}
.sb-field label{position:absolute;left:20px;top:50%;z-index:3;translate:0 -50%;font-size:14px;line-height:20px;color:var(--sb-muted-fg);pointer-events:none;transition:all .15s var(--sb-colors)}
.sb-field input:is(:focus,:not(:placeholder-shown),:autofill)+label{top:.85rem;font-size:11px}
.sb-field-multi{display:flex;height:auto;min-height:96px;overflow:hidden;padding-top:24px;cursor:text}
.sb-field-multi textarea{flex:1;min-height:0;padding:0 16px 8px;border-radius:0;resize:none}
.sb-field-multi label{left:16px;top:16px;translate:none}
.sb-field-multi textarea:is(:focus,:not(:placeholder-shown))+label{top:6px;font-size:11px}
@container sb (min-width:680px){.sb-field :is(input,textarea){font-size:14px}}
.sb-actions{display:flex;justify-content:space-between;margin-top:24px}
/* confirmation */
.sb-done{max-width:512px;margin:0 auto;padding:32px;text-align:center}
.sb-check{display:flex;justify-content:center;margin-bottom:16px}
.sb-check svg{width:80px;height:80px;stroke:#22c55e;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;animation:sb-fade-in .22s var(--sb-fade) .12s both,sb-pop .3s var(--sb-spring) .12s both}
.sb-check circle{stroke-dasharray:1;stroke-dashoffset:1;rotate:-90deg;transform-origin:center;animation:sb-draw .6s cubic-bezier(.65,0,.35,1) .2s forwards}
.sb-check path{stroke-dasharray:1;stroke-dashoffset:1;animation:sb-draw .35s cubic-bezier(.65,0,.35,1) .7s forwards}
@keyframes sb-draw{to{stroke-dashoffset:0}}
@keyframes sb-pop{from{scale:.7}}
.sb-done h2{margin-bottom:8px;font-size:24px;line-height:32px;font-weight:700}
.sb-done-sub{margin-bottom:24px;font-size:14px;line-height:20px;color:var(--sb-muted-fg);overflow-wrap:anywhere}
.sb-done-rows{display:flex;flex-direction:column;gap:12px;padding-top:24px;border-top:1px solid rgba(30,33,37,.6);text-align:left}
.sb-done-row{display:flex;align-items:flex-start;gap:12px}
.sb-done-row svg{width:20px;height:20px;margin-top:2px;color:var(--sb-muted-fg)}
.sb-done-row p:first-child{font-weight:500}
.sb-done-row p+p{font-size:14px;line-height:20px;color:var(--sb-muted-fg)}
.sb-done-links{display:flex;flex-wrap:wrap;justify-content:center;gap:16px;margin-top:24px;padding-top:24px;border-top:1px solid rgba(30,33,37,.6);font-size:12px;line-height:16px;color:var(--sb-muted-fg)}
.sb-done-links button{display:inline-flex;align-items:center;gap:6px;transition:color .15s var(--sb-colors)}
.sb-done-links svg{width:16px;height:16px}
@media (hover:hover){.sb-done-links button:hover{color:#fff}}
/* footer */
/* toast */
.sb-toast{position:absolute;left:50%;bottom:24px;z-index:50;display:flex;align-items:center;gap:12px;width:min(400px,calc(100% - 32px));padding:12px;translate:-50% 0;border:1px solid hsl(0 0% 91%);border-radius:20px;background:#fff;color:#020817;font-size:13px;box-shadow:0 1px 2px rgb(17 17 34/.04),0 4px 10px -2px rgb(17 17 34/.06),0 14px 28px -8px rgb(17 17 34/.1),0 30px 56px -16px rgb(17 17 34/.14);animation:sb-fade-in .4s ease both,sb-toast .4s cubic-bezier(.21,1.02,.73,1) both}
@keyframes sb-toast{from{translate:-50% calc(100% + 24px)}}
.sb-swatch{flex-shrink:0;align-self:stretch;width:56px;min-height:40px;margin:-10px 0 -10px -10px;border-radius:18px;box-shadow:inset 0 0 0 1px rgb(0 0 0/.04);background-image:linear-gradient(135deg,hsl(2 85% 91%) 0%,hsl(350 78% 89%) 34%,hsl(336 72% 88%) 68%,hsl(20 85% 90%) 100%)}
.sb-toast-title{flex:1;min-width:0;font-size:14px;line-height:1.35;font-weight:600}
.sb-toast-close{display:flex;flex-shrink:0;align-items:center;justify-content:center;width:28px;height:28px;border:1px solid hsl(0 0% 91%)!important;border-radius:999px;background:hsl(0 0% 97%)!important;color:hsl(0 0% 46%)!important}
@media (hover:hover){.sb-toast-close:hover{background:hsl(0 0% 93.5%)!important;border-color:hsl(0 0% 84%)!important;color:hsl(0 0% 16%)!important}}
/* enter and leave: transforms spring, opacity fades */
@keyframes sb-fade-in{from{opacity:0}}
@keyframes sb-fade-out{to{opacity:0}}
@keyframes sb-move-in{from{translate:var(--sb-dx,0px) var(--sb-dy,0px)}}
@keyframes sb-move-out{to{translate:var(--sb-ox,0px) var(--sb-oy,0px)}}
@keyframes sb-scale-in{from{scale:.9}}
@keyframes sb-scale-out{to{scale:.9}}
.sb-in{animation:sb-fade-in .22s var(--sb-fade) var(--sb-delay,0s) both,sb-move-in .3s var(--sb-spring) var(--sb-delay,0s) both}
.sb-out{animation:sb-fade-out .22s var(--sb-fade) both,sb-move-out .3s var(--sb-spring) both;pointer-events:none}
.sb-fade-out{animation:sb-fade-out .22s var(--sb-fade) both;pointer-events:none}
.sb-pop-in{animation:sb-fade-in .22s var(--sb-fade) both,sb-scale-in .3s var(--sb-spring) both}
.sb-pop-out{animation:sb-fade-out .22s var(--sb-fade) both,sb-scale-out .3s var(--sb-spring) both;pointer-events:none}
@media (prefers-reduced-motion:reduce){
.sb-in{animation:sb-fade-in .22s var(--sb-fade) var(--sb-delay,0s) both}
.sb-out{animation:sb-fade-out .22s var(--sb-fade) both}
.sb-pop-in{animation:sb-fade-in .22s var(--sb-fade) both}
.sb-pop-out{animation:sb-fade-out .22s var(--sb-fade) both}
.sb-times,.sb-fmt-pill[data-ready]{transition:none}
.sb-glow:hover>.sb-ring{transition:opacity 0s}
.sb-check svg{animation:sb-fade-in .22s var(--sb-fade) both}
.sb-check circle,.sb-check path{animation:none;stroke-dashoffset:0}
.sb-toast{animation:sb-fade-in .22s ease both}
}
`;






