/* ============================================================================
   WhenFinder - "Almanac" design system
   Warm parchment + ink, vermilion brand, teal availability-heat, marigold for
   consensus. Display: Fraunces. Body: Hanken Grotesk. Mono: Space Mono.
   ========================================================================== */

:root {
  /* paper & ink */
  --paper:      #f2ebdb;
  --paper-2:    #ece2cd;   /* card insets / wells */
  --card:       #fbf7ec;   /* raised surfaces */
  --ink:        #221d16;
  --ink-soft:   #6f6453;
  --ink-faint:  #a99c84;
  --line:       #ddd0b4;
  --line-soft:  #e7dcc4;

  /* brand + signals */
  --ember:      #ce4421;   /* primary action / brand */
  --ember-deep: #a8330f;
  --ember-tint: #f6d8c8;
  --spruce:     #1f5d56;   /* availability heat (max) */
  --spruce-ink: #123b36;
  --marigold:   #e0a13a;   /* "works for everyone" */
  --marigold-deep:#b97c16;

  /* heat scale (none → everyone), teal-on-parchment */
  --heat-0: #ece3cf;
  --heat-1: #cfddc9;
  --heat-2: #a6cbb8;
  --heat-3: #6fb1a0;
  --heat-4: #3c8c80;
  --heat-5: #1f5d56;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 0 #fffaf0 inset, 0 18px 40px -24px rgba(40,28,12,.45);
  --shadow-lift: 0 1px 0 #fffaf0 inset, 0 28px 60px -28px rgba(40,28,12,.55);
  --ring: 0 0 0 3px rgba(206,68,33,.22);

  --maxw: 1040px;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }

/* min-height, not height: a body pinned to the viewport's height stops position:sticky after one screen. */
html { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(120% 80% at 100% -10%, rgba(224,161,58,.16), transparent 55%),
    radial-gradient(90% 70% at -10% 0%, rgba(31,93,86,.10), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* film-grain overlay for warmth/texture */
.grain {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ---------- typography ---------- */
h1,h2,h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; line-height: 1.04; margin: 0; letter-spacing: -.015em; }
.mono { font-family: "Space Mono", ui-monospace, monospace; }
a { color: var(--ember-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(18px, 5vw, 40px);
  background: linear-gradient(var(--paper), rgba(242,235,219,.72));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 34px; width: auto; display: block; }
/* Wordmark, matching the logo: bold lowercase sans, "when" in navy, "finder" in the logo's spruce. */
.brand-word { font-family: "Hanken Grotesk", system-ui, sans-serif; font-weight: 800; font-size: 1.42rem; letter-spacing: -.045em; line-height: 1; }
.brand-word .w-when { color: #071f4a; }
.brand-word .w-finder { color: #00876b; }
.brand-word-sm { font-size: .95rem; }
.topnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.topnav .who { color: var(--ink-soft); font-size: .9rem; margin-right: 4px; }
/* Phones: the header scrolls away with the page (screen height is precious) and the nav
   collapses to the one main action + a Menu button that opens a sheet with the rest. */
.topnav .nav-menu { display: none; }
@media (max-width: 640px) {
  .topbar { position: relative; padding: 10px 16px; gap: 10px; }
  .topnav { gap: 6px; flex-wrap: nowrap; }
  .topnav .who, .topnav .nav-wide { display: none; }
  .topnav .nav-menu { display: inline-flex; }
  .topnav .btn-sm { padding: 7px 12px; font-size: .82rem; }
}
@media (max-width: 360px) { .brand-word { font-size: 1.2rem; } .brand-logo { height: 28px; } }
.menu-list { display: grid; gap: 8px; }
.menu-list .btn { width: 100%; justify-content: flex-start; }

main { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: clamp(22px, 4vw, 48px) clamp(18px, 5vw, 40px); flex: 1 0 auto; }

.sitefoot {
  flex-shrink: 0;
  text-align: center; color: var(--ink-faint); font-size: .85rem;
  padding: 28px; border-top: 1px solid var(--line-soft); margin-top: 40px;
}
.sitefoot .dot { margin: 0 8px; }

/* ---------- buttons ---------- */
.btn {
  --bg: var(--ink); --fg: var(--paper);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; line-height: 1;
  padding: 12px 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--bg); color: var(--fg); cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s;
}
.btn:hover { text-decoration: none; }
@media (hover: hover) { .btn:hover { transform: translateY(-1px); } }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { --bg: var(--ember); --fg: #fff6ef; box-shadow: 0 12px 24px -14px rgba(206,68,33,.85); }
.btn-primary:hover { --bg: var(--ember-deep); }
.btn-ghost { --bg: transparent; --fg: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper-2); }
.btn-spruce { --bg: var(--spruce); --fg: #f2fbf7; }
.btn-spruce:hover { --bg: var(--spruce-ink); }
.btn-danger { --bg: var(--ember-deep); --fg: #fff6ef; }
.btn-danger:hover { --bg: #8f2a0c; }
.btn-sm { padding: 8px 13px; font-size: .85rem; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--fg); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); box-shadow: var(--shadow);
}
.well { background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.eyebrow { font-family: "Space Mono", monospace; text-transform: uppercase; letter-spacing: .22em; font-size: .72rem; color: var(--ember-deep); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 16px; }
.field[hidden] { display: none; }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field > label.tier { display: inline-flex; }   /* the create form's "must attend" / "optional" tags stay pills */
.field .hint { font-size: .8rem; color: var(--ink-soft); margin-top: 5px; }
.input, .textarea, select.input {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, select.input:focus { outline: none; border-color: var(--ember); box-shadow: var(--ring); }
.textarea { min-height: 84px; resize: vertical; }

/* WYSIWYG Markdown editor (js/md-editor.js): toolbar + contenteditable box styled like an input */
.mde { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); overflow: hidden; }
.mde:focus-within { border-color: var(--ember); box-shadow: var(--ring); }
.mde-bar { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); background: var(--paper-2); flex-wrap: wrap; }
.mde-btn { font: inherit; font-size: .82rem; font-weight: 700; min-width: 30px; height: 28px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.mde-btn.i { font-style: italic; font-family: "Fraunces", serif; }
.mde-btn:hover { background: var(--card); border-color: var(--line); color: var(--ink); }
.mde-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.mde-box { padding: 10px 12px; font: inherit; line-height: 1.55; outline: none; position: relative; color: var(--ink); }
.mde-box p { margin: 0 0 .6em; } .mde-box p:last-child { margin-bottom: 0; }
.mde-box h1, .mde-box h2, .mde-box h3, .mde-box h4 { font-size: 1.05rem; margin: .6em 0 .3em; }
.mde-box ul, .mde-box ol { margin: 0 0 .6em 1.2em; }
.mde-box a { color: var(--ember-deep); text-decoration: underline; }
.mde.empty .mde-box::before { content: attr(data-placeholder); color: var(--ink-faint); position: absolute; pointer-events: none; }
.field.invalid .input, .field.invalid .textarea { border-color: var(--ember); }
.field .err { color: var(--ember-deep); font-size: .82rem; margin-top: 5px; display: none; }
.field.invalid .err { display: block; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 10px; width: min(92vw, 420px); }
.toast {
  background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lift); font-size: .92rem; animation: toast-in .35s var(--ease);
  border-left: 4px solid var(--marigold);
}
.toast.error { border-left-color: var(--ember); }
.toast.success { border-left-color: var(--heat-4); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- staggered entrance ---------- */
.enter > * { opacity: 0; transform: translateY(14px); animation: rise .6s var(--ease) forwards; }
.enter > *:nth-child(1){ animation-delay: .02s }
.enter > *:nth-child(2){ animation-delay: .09s }
.enter > *:nth-child(3){ animation-delay: .16s }
.enter > *:nth-child(4){ animation-delay: .23s }
.enter > *:nth-child(5){ animation-delay: .30s }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .enter > * { animation: none; opacity: 1; transform: none; } }

/* ============================================================================
   Landing / hero
   ========================================================================== */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(24px, 5vw, 60px); align-items: center; }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); }
.hero h1 .swash { font-style: italic; color: var(--ember); }
.hero .lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--ink-soft); max-width: 46ch; margin: 20px 0 26px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.codejump { display: flex; gap: 8px; margin-top: 26px; max-width: 360px; }
.codejump .input { font-family: "Space Mono", monospace; text-transform: lowercase; letter-spacing: .04em; }

/* hero illustration: a living availability heat strip */
.hero-art { position: relative; }
.hero-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lift); transform: rotate(-1.4deg); }
.hero-cell { aspect-ratio: 1; border-radius: 8px; background: var(--heat-0); animation: heatpulse 5s var(--ease) infinite; }
@keyframes heatpulse { 0%,100%{ filter: none } 50%{ filter: saturate(1.25) } }
.hero-tag { position: absolute; right: -8px; bottom: -14px; transform: rotate(3deg); background: var(--marigold); color: var(--ink); font-family: "Space Mono", monospace; font-weight: 700; font-size: .8rem; padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); }

.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: clamp(40px, 7vw, 80px); }
.feature { padding: 20px; }
.feature h3 { font-size: 1.15rem; margin-bottom: 6px; }
.feature .ix { font-size: 1.6rem; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .feature-row { grid-template-columns: 1fr; }
}

/* ============================================================================
   Auth pages
   ========================================================================== */
.authwrap { max-width: 440px; margin: 4vh auto 0; }
.authwrap h1 { font-size: 2.2rem; margin-bottom: 6px; }
.authwrap .sub { color: var(--ink-soft); margin-bottom: 24px; }
.auth-alt { margin-top: 18px; text-align: center; color: var(--ink-soft); font-size: .92rem; }

/* ============================================================================
   Dashboard
   ========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.evlist { display: grid; gap: 14px; }
.evcard { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; }
@media (hover: hover) { .evcard:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); transition: .2s var(--ease); } }
.evcard .ev-main { min-width: 0; }
.evcard .ev-name { font-family: "Fraunces", serif; font-size: 1.25rem; font-weight: 600; }
.evcard .ev-meta { color: var(--ink-soft); font-size: .85rem; margin-top: 3px; }
.evcard .ev-code { font-family: "Space Mono", monospace; color: var(--ember-deep); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.active   { background: var(--ember-tint);  color: var(--ember-deep); }
.badge.scheduled{ background: #d7ece4;             color: var(--spruce-ink); }
.badge.cancelled{ background: #e7ddca;             color: var(--ink-soft); }

/* (Not plain ".empty": the editor and the week strip use "empty" as a state class.) */
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .ix { font-size: 3rem; opacity: .5; }

/* ============================================================================
   Create event
   ========================================================================== */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; gap: 0; } }
.grid-host { margin-top: 8px; }
.lvl-row { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.lvl-row .hint { margin: 0; }

/* share / success panel */
.share { text-align: center; }
.share .code-ticket {
  display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
  margin: 14px auto 22px; padding: 22px 40px; background: var(--ink); color: var(--paper);
  border-radius: 16px; position: relative; box-shadow: var(--shadow-lift);
}
.share .code-ticket::before, .share .code-ticket::after { content: ""; position: absolute; top: 50%; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); transform: translateY(-50%); }
.share .code-ticket::before { left: -11px; } .share .code-ticket::after { right: -11px; }
.share .code-ticket .lbl { font-family: "Space Mono", monospace; font-size: .68rem; letter-spacing: .25em; text-transform: uppercase; color: var(--marigold); }
.share .code-ticket .code { font-family: "Space Mono", monospace; font-size: 2rem; font-weight: 700; letter-spacing: .08em; }
@media (max-width: 480px) { .share .code-ticket { padding: 16px 22px; } .share .code-ticket .code { font-size: 1.45rem; letter-spacing: .06em; } }
.share-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.qr-box { background: #fff; padding: 14px; border-radius: 14px; display: inline-block; border: 1px solid var(--line); }
.qr-box img, .qr-box svg { display: block; width: 180px; height: 180px; }
.no-email { margin-top: 20px; padding: 14px 18px; background: var(--ember-tint); border-radius: var(--radius-sm); color: var(--ember-deep); font-size: .9rem; }

/* ============================================================================
   Event view - heatmap + responses
   ========================================================================== */
.ev-hero { margin-bottom: 26px; }
.ev-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.ev-hero .desc { color: var(--ink-soft); margin-top: 10px; max-width: 60ch; }
/* Wraps on a narrow screen: a non-wrapping pill here once made every event page wider than a phone. */
.tz-banner { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; max-width: 100%; margin-top: 14px; font-size: .85rem; color: var(--spruce-ink); background: #dcebe4; padding: 7px 13px; border-radius: 18px; }
.tz-banner .mono { color: var(--spruce-ink); overflow-wrap: anywhere; }

.cancelled-box { border-color: var(--line); margin-bottom: 28px; }
.cancelled-box h3 { margin-bottom: 6px; }
.cancelled-box .cb-actions { margin: 12px 0 0; }
.scheduled-banner { display: flex; align-items: center; gap: 16px; padding: 22px 26px; background: linear-gradient(100deg, #dcece4, #eef4e6); border: 1px solid #bcd8cc; border-radius: var(--radius); margin-bottom: 24px; }
.scheduled-banner .big { font-family: "Fraunces", serif; font-size: 1.5rem; color: var(--spruce-ink); }
.scheduled-banner .ix { font-size: 2.2rem; }
.scheduled-banner .sb-main { min-width: 0; flex: 1; }
.scheduled-banner { align-items: flex-start; }
.sb-cal { margin-top: 12px; }
/* "from the organiser" inside the box; the host's inline editor swaps in under the eyebrow */
.sb-info { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #bcd8cc; }
.sb-info .details-body { margin-top: 4px; }
.sb-info .sb-edit { margin-top: 8px; }
.sb-info .details-form { margin-top: 6px; }
.details-form .details-input { width: 100%; }
.details-form .hint { margin: 6px 0 0; }
.details-form-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.sb-tools { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #bcd8cc; }
.sb-tools .win-list { margin-top: 0; }
.sb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sb-actions .btn[disabled] { opacity: .55; cursor: not-allowed; }

/* "From the organiser" */
.details-card { margin-bottom: 22px; }
.details-body { margin-top: 8px; font-size: .95rem; line-height: 1.55; }
.details-body p { margin: 0 0 .6em; } .details-body p:last-child { margin-bottom: 0; }
.details-body a { color: var(--ember-deep); text-decoration: underline; word-break: break-word; }
.details-body ul, .details-body ol { margin: 0 0 .6em 1.2em; }
.details-body code { font-family: "Space Mono", monospace; font-size: .85em; background: var(--paper-2); padding: 1px 4px; border-radius: 4px; }
.details-body h1, .details-body h2, .details-body h3 { font-size: 1.05rem; margin: .6em 0 .3em; }
.details-edit { margin-top: 10px; font-size: .9rem; }
.details-edit summary { cursor: pointer; color: var(--ember-deep); font-weight: 600; }
.details-edit .details-form { margin-top: 10px; }


.heat-legend { display: flex; align-items: center; gap: 10px; font-size: .78rem; color: var(--ink-soft); margin-top: 4px; }
.heat-legend .scale { display: flex; gap: 3px; }
.heat-legend .scale i { width: 16px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- availability panel (event page) ---------- */
.ev-when { color: var(--ink-soft); margin-top: 8px; font-size: .95rem; }
.avail-card { margin-bottom: 18px; }
.avail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.avail-head h2 { font-size: 1.4rem; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--spruce); margin: 0; }
.closed-note { font-size: .95rem; color: var(--ink-soft); }
.seg { display: inline-flex; background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px; }
.seg button { font: inherit; font-weight: 600; font-size: .86rem; border: none; background: transparent; color: var(--ink-soft); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.pane-hint { font-size: .88rem; margin: 0 0 10px; }
.composer .field { margin-bottom: 12px; }

/* paint level picker */
.levels { display: inline-flex; gap: 6px; }
.levels .lv { font: inherit; font-size: .82rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.levels .lv::before { content: ""; width: 12px; height: 12px; border-radius: 3px; }
.levels .lv.free::before { background: var(--spruce); }
.levels .lv.maybe::before { background: repeating-linear-gradient(135deg, var(--spruce) 0 3px, #cfe3dc 3px 6px); }
.levels .lv.must::before { background: var(--marigold); }
.levels .lv.opt::before { background: var(--heat-2); }
.levels .lv[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--card); box-shadow: 0 0 0 1px var(--ink); }

/* quick fill */
.qf { background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; }
.qf-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qf-row .input { width: auto; padding: 8px 10px; font-size: .9rem; }
.qf-w { font-size: .9rem; color: var(--ink-soft); }
.qf-sub { margin-top: 8px; justify-content: space-between; }
.qf-sub .hint { margin: 0; font-size: .8rem; color: var(--ink-soft); flex: 1 1 220px; }

/* the grid */
.ag { --ag-row: 22px; --ag-gutter: 34px; user-select: none; -webkit-user-select: none; }
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.ag-pager { display: inline-flex; align-items: center; gap: 6px; }
.ag-pager.single .ag-nav { display: none; }
.ag-page { font-family: "Space Mono", monospace; font-size: .8rem; color: var(--ink); min-width: 120px; text-align: center; }
.ag-nav { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--ink); }
.ag-nav:disabled { opacity: .35; cursor: default; }
.ag-tools { display: inline-flex; align-items: center; gap: 6px; }
.ag-zone { font: inherit; font-size: .8rem; max-width: 190px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
/* All 24 hours ⇄ the usual day: an icon filling the grid's top-left corner. */
.ag-corner { display: flex; }
.ag-allday { flex: 1; display: flex; align-items: center; justify-content: center; padding: 0; border: none; border-radius: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.ag-allday[aria-pressed="true"] { color: var(--ink); background: var(--line-soft); }
@media (hover: hover) { .ag-allday:hover { color: var(--ink); background: var(--line-soft); } }
/* Show / hide the others' answers (guests), in the grid's toolbar. */
.others-pill { font: inherit; font-size: .8rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.others-pill[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.others-pill[hidden] { display: none; }

/* Whole-range thumbnail above a multi-week edit grid: a tiny column per day, grouped by week. */
.ag-ov { margin: 0 0 10px; padding: 8px 10px; background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.ag-ov-cap { display: block; font-size: .8rem; color: var(--ink-soft); margin-bottom: 7px; }
.ag-ov-cap strong { color: var(--ink); }
.ag-ov-wks { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-ov-wk { font: inherit; display: inline-flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 5px 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: pointer; color: var(--ink-soft); }
.ag-ov-wk:hover { border-color: var(--ink-soft); }
.ag-ov-wk.cur { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); color: var(--ink); }
.ag-ov-wk.empty { border-style: dashed; }
.ag-ov-cols { display: inline-flex; gap: 1px; }
.ag-ov-day { position: relative; width: 7px; height: 32px; background: var(--paper); border-radius: 1px; overflow: hidden; }
.ag-ov-day i { position: absolute; left: 0; width: 100%; display: block; }
.ag-ov-day i.p2 { background: var(--spruce); }
.ag-ov-day i.p1 { background: repeating-linear-gradient(135deg, var(--spruce) 0 2px, #cfe3dc 2px 4px); }
.ag-ov-day i.busy { background: #6f6453; opacity: .5; }
.ag-ov-day i.off { background: repeating-linear-gradient(135deg, var(--paper-2) 0 2px, var(--paper) 2px 4px); }
.ag-ov-day i.pad { background: #ebe6da; }
/* heat grid's strip: the group gradient per day */
.ag-ov-day i.h1 { background: var(--heat-1); } .ag-ov-day i.h2 { background: var(--heat-2); } .ag-ov-day i.h3 { background: var(--heat-3); }
.ag-ov-day i.h4 { background: var(--heat-4); } .ag-ov-day i.h5 { background: var(--heat-5); }
.ag-ov-day i.hb { background: repeating-linear-gradient(135deg, #8f8373 0 2px, #a99c84 2px 4px); }
.ag-ov-day i.blocked { background: repeating-linear-gradient(45deg, #d9cfb9 0 1px, #e9e0cc 1px 3px); }
/* a remembered calendar in the import sheet: the row plus a forget button */
.saved-list { display: grid; gap: 8px; margin-bottom: 14px; }
.saved-row { display: flex; align-items: center; gap: 6px; }
.saved-row .prov-btn { flex: 1; }
.saved-head { margin: 0 0 6px; }
.remember-row { margin-top: 10px; }
.remember-row .hint { margin: 4px 0 0 26px; }
.ag-ov-lbl { font-family: "Space Mono", monospace; font-size: .6rem; line-height: 1; white-space: nowrap; }

.ag-grid {
  display: grid;
  grid-template-columns: var(--ag-gutter) repeat(var(--ag-cols, 7), minmax(0, 1fr));
  grid-auto-rows: var(--ag-row);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card);
}
.ag-corner { background: var(--paper-2); }
.ag-day { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; background: var(--paper-2); border-left: 1px solid var(--line-soft); grid-row: span 2; font-size: .74rem; }
.ag-grid > .ag-corner { grid-row: span 2; }
.ag-day .wd { font-weight: 700; }
.ag-day .dm { color: var(--ink-soft); font-size: .68rem; }
.ag-time { font-family: "Space Mono", monospace; font-size: .66rem; color: var(--ink-faint); text-align: right; padding-right: 5px; line-height: 1; transform: translateY(-4px); background: var(--paper-2); }
.ag-time.hr { color: var(--ink-soft); }
/* The heat grid scrolls under a finger (taps pick a time). The paintable cells of an edit grid
   don't: a finger paints there, and press-and-hold then move scrolls (avail.js) - the times down
   the left and the greyed-out days scroll as usual. */
.ag-cell { position: relative; border-left: 1px solid var(--line-soft); border-top: 1px dotted var(--line-soft); background: var(--card); touch-action: manipulation; cursor: pointer; }
.ag-edit .ag-cell { -webkit-touch-callout: none; }
.ag-edit .ag-cell:not(.off) { touch-action: none; }
/* a press-and-hold has switched this touch to scrolling: say so on the grid */
.ag-grid.ag-scrolling { box-shadow: 0 0 0 2px var(--spruce); }
/* Title of an imported-calendar block, drawn in its first cell and sized to the block. */
.ag-cell .busy-lbl { position: absolute; left: 0; top: 0; width: 100%; box-sizing: border-box; padding: 1px 2px; font-size: 9.5px; line-height: 1.15; font-weight: 600; color: #f7f1e3; text-shadow: 0 1px 0 rgba(0,0,0,.35); overflow: hidden; overflow-wrap: break-word; pointer-events: none; z-index: 1; }
.ag-cell.hr { border-top: 1px solid var(--line); }
.ag-cell.off { background: repeating-linear-gradient(135deg, var(--paper-2) 0 4px, var(--paper) 4px 8px); cursor: default; }
/* Days before the first / after the last date: flat grey, never markable, so the week reads as a calendar week. */
.ag-cell.pad { background: #ebe6da; border-top-color: #e2dccf; }
.ag-day.pad { color: var(--ink-faint); }
.ag-day.pad .wd { font-weight: 500; }
/* edit mode */
.ag-edit .ag-cell.p2 { background: var(--spruce); border-top-color: rgba(255,255,255,.18); }
.ag-edit .ag-cell.p1 { background: repeating-linear-gradient(135deg, var(--spruce) 0 3px, #cfe3dc 3px 6px); }
/* this person's own imported calendar - hard-blocked, tap to inspect */
.ag-edit .ag-cell.busy { background: repeating-linear-gradient(135deg, #5a5143 0 4px, #6f6453 4px 8px); border-top-color: rgba(255,255,255,.12); cursor: pointer; }
@media (hover: hover) { .ag-edit .ag-cell.busy:hover { box-shadow: inset 0 0 0 2px var(--marigold); } }
/* A calendar event covers PART of this half hour: still paintable, but the group won't count it as free. */
.ag-edit .ag-cell.busy-part { box-shadow: inset 4px 0 0 #5a5143; }
.busy-legend .sw { width: 16px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.busy-legend .sw.busy { background: repeating-linear-gradient(135deg, #5a5143 0 4px, #6f6453 4px 8px); }
/* someone ELSE can't make this cell - still paintable, but it won't be picked */
/* A MUST-ATTEND person is busy: warm graphite hatch - "closed", not "danger". Lighter than
   your own imported-calendar cells (.busy) so the two stay distinct; still paintable. */
.ag-edit .ag-cell.hard { background: repeating-linear-gradient(135deg, #8f8373 0 4px, #a99c84 4px 8px); border-top-color: rgba(255,255,255,.14); }
.ag-edit .ag-cell.hard.p2 { background: repeating-linear-gradient(135deg, #8f8373 0 4px, transparent 4px 8px), #6f9d94; }
.ag-edit .ag-cell.hard.p1 { background: repeating-linear-gradient(135deg, #8f8373 0 4px, transparent 4px 8px), repeating-linear-gradient(45deg, #6f9d94 0 3px, #d6e0dc 3px 6px); }
.ag-edit .ag-cell.blocked { background: repeating-linear-gradient(45deg, #d9cfb9 0 2px, #e9e0cc 2px 6px); }
/* Guest's "show others' availability": the group gradient under unpainted cells. */
.ag-edit .ag-cell.h1:not(.p1):not(.p2) { background: var(--heat-1); }
.ag-edit .ag-cell.h2:not(.p1):not(.p2) { background: var(--heat-2); }
.ag-edit .ag-cell.h3:not(.p1):not(.p2) { background: var(--heat-3); }
.ag-edit .ag-cell.h4:not(.p1):not(.p2) { background: var(--heat-4); }
.ag-edit .ag-cell.h5:not(.p1):not(.p2) { background: var(--heat-5); }
.ag-edit .ag-cell.blocked.p2 { background: repeating-linear-gradient(45deg, rgba(34,29,22,.28) 0 2px, transparent 2px 6px), #6f9d94; }
.ag-edit .ag-cell.blocked.p1 { background: repeating-linear-gradient(45deg, rgba(34,29,22,.28) 0 2px, transparent 2px 6px), repeating-linear-gradient(135deg, #6f9d94 0 3px, #d6e0dc 3px 6px); }
.blocked-legend .sw { width: 16px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.blocked-legend .sw.blocked { background: repeating-linear-gradient(45deg, #d9cfb9 0 2px, #e9e0cc 2px 6px); border: 1px solid var(--line); }
.heat-legend .sw.hard { width: 16px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; background: repeating-linear-gradient(135deg, #8f8373 0 4px, #a99c84 4px 8px); }
@media (hover: hover) { .ag-edit .ag-cell:not(.off):hover { box-shadow: inset 0 0 0 2px var(--marigold); } }
/* heat mode */
.ag-heat .ag-cell.h0 { background: var(--heat-0); }
.ag-heat .ag-cell.h1 { background: var(--heat-1); }
.ag-heat .ag-cell.h2 { background: var(--heat-2); }
.ag-heat .ag-cell.h3 { background: var(--heat-3); }
.ag-heat .ag-cell.h4 { background: var(--heat-4); }
.ag-heat .ag-cell.h5 { background: var(--heat-5); }
.ag-heat .ag-cell.all { background: #17463f; }
.ag-heat .ag-cell.hb { background: repeating-linear-gradient(135deg, #8f8373 0 4px, #a99c84 4px 8px); }
.ag-heat .ag-cell.sel { box-shadow: inset 2px 0 0 var(--ember), inset -2px 0 0 var(--ember); }
.ag-heat .ag-cell.sel-start { box-shadow: inset 2px 2px 0 var(--ember), inset -2px 0 0 var(--ember); }
@media (hover: hover) { .ag-heat .ag-cell:not(.off):hover { filter: brightness(.93); } }
.heat-legend { margin-top: 8px; }
.heat-legend .scale i.h0 { background: var(--heat-0); } .heat-legend .scale i.h1 { background: var(--heat-1); } .heat-legend .scale i.h2 { background: var(--heat-2); }
.heat-legend .scale i.h3 { background: var(--heat-3); } .heat-legend .scale i.h4 { background: var(--heat-4); } .heat-legend .scale i.h5 { background: var(--heat-5); }
@media (max-width: 600px) {
  .ag { --ag-row: 19px; --ag-gutter: 28px; }
  .ag-day { font-size: .68rem; }
  .ag-day .dm { font-size: .6rem; }
  .ag-time { font-size: .6rem; }
  .ag-zone { max-width: 150px; }
  .avail-card { padding: 14px; }
}

/* ---------- imported calendars (Me tab) ---------- */
.cal-block { margin: 2px 0 14px; padding: 12px 14px; background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cal-list { display: grid; gap: 8px; margin-top: 10px; }
.cal-empty { margin: 8px 0 0; }
.cal-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: start; padding: 10px 12px; background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.cal-row .cal-items-wrap { grid-column: 1 / -1; font-size: .84rem; }
.cal-row .cal-items-wrap summary { cursor: pointer; color: var(--ember-deep); font-weight: 600; font-size: .82rem; }
.cal-row.err { border-color: var(--ember); }
.cal-glyph { width: 32px; height: 32px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem; }
.cal-main { min-width: 0; }
.cal-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-meta { font-size: .78rem; color: var(--ink-soft); }
.cal-privacy { margin: 8px 0 0; font-size: .8rem; line-height: 1.4; }
.cal-items { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.ci-nohint { color: var(--ink-faint); font-weight: 400; font-size: .78rem; }
.cal-item { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; font-size: .84rem; padding: 4px 0; border-top: 1px dotted var(--line-soft); }
.cal-item .ci-when { font-family: "Space Mono", monospace; font-size: .74rem; color: var(--ink-soft); white-space: nowrap; }
.cal-item .ci-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.cal-item.tentative .ci-title { font-weight: 500; font-style: italic; }
.cal-item .chip-x { font-size: 1.05rem; }
.cal-actions { display: inline-flex; gap: 6px; }
@media (max-width: 480px) { .cal-actions .btn { padding-left: 8px; padding-right: 8px; } }
.others-toggle { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0 6px; font-size: .86rem; color: var(--ink-soft); }
.others-toggle .others-count { font-weight: 600; }

/* Loud "you haven't sent this yet" bar: fixed to the bottom of the viewport while the grid
   (or name) differs from what was last sent. */
.unsaved-bar { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); width: min(calc(100% - 24px), 520px); z-index: 8000; display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: var(--radius); background: var(--ember); color: #fff; box-shadow: 0 18px 40px -14px rgba(206,68,33,.6), var(--shadow); animation: unsaved-in .25s var(--ease); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.unsaved-bar.dragging { cursor: grabbing; animation: none; box-shadow: 0 24px 48px -16px rgba(40,28,12,.6); }
.unsaved-bar[hidden] { display: none; }
.unsaved-bar .ub-grip { font-size: 1rem; line-height: 1; opacity: .7; letter-spacing: -2px; flex-shrink: 0; }
.unsaved-bar .ub-text { flex: 1; }
.unsaved-bar .btn { cursor: pointer; }
.unsaved-bar .ub-text { font-size: .92rem; line-height: 1.3; }
.unsaved-bar .ub-text strong { font-family: "Space Mono", monospace; text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; }
.unsaved-bar .btn-primary { background: #fff; color: var(--ember-deep); border-color: #fff; white-space: nowrap; }
.composer.is-dirty button[type="submit"] { box-shadow: 0 0 0 4px var(--ember-tint); animation: unsaved-pulse 1.6s ease-in-out infinite; }
@keyframes unsaved-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes unsaved-pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--ember-tint); } 50% { box-shadow: 0 0 0 8px rgba(206,68,33,.18); } }
@media (prefers-reduced-motion: reduce) { .unsaved-bar, .composer.is-dirty button[type="submit"] { animation: none; } }
.cal-removed { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .84rem; }
.cal-removed .hint { margin: 0; }
.chip .chip-x { border: none; background: transparent; cursor: pointer; font-size: .95rem; line-height: 1; color: var(--ember-deep); padding: 0 2px; }
.busy-detail { border-color: #cfc3aa; }

/* bottom sheet (phone) / centred dialog (desktop) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(34,29,22,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 18px calc(24px + env(safe-area-inset-bottom, 0px)); box-shadow: var(--shadow-lift); animation: sheet-up .25s var(--ease); }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: var(--radius); padding: 22px 24px; } }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h3 { font-size: 1.3rem; }
.sheet-x { border: none; background: var(--paper-2); width: 34px; height: 34px; border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.prov-list { display: grid; gap: 8px; }
.prov-btn { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; padding: 11px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; color: var(--ink); }
.prov-btn:hover { border-color: var(--ink); }
a.prov-btn { text-decoration: none; box-sizing: border-box; }
.prov-btn[disabled] { opacity: .55; cursor: not-allowed; }
.prov-sub { font-weight: 400; color: var(--ink-soft); font-size: .86rem; }
.prov-glyph { width: 34px; height: 34px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.prov-name { font-weight: 600; }
.prov-arrow { color: var(--ink-faint); font-size: 1.2rem; }
.prov-title { font-size: 1.1rem; margin: 10px 0 6px; }
.steps { margin: 0 0 8px; padding-left: 20px; font-size: .92rem; display: grid; gap: 4px; }
.sheet-err { color: var(--ember-deep); font-size: .86rem; margin: 6px 0 10px; }

/* tapped window detail */
.win-detail { margin-top: 12px; padding: 12px 14px; background: var(--paper-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); font-size: .9rem; }
.win-when .alt { color: var(--ink-soft); font-size: .82rem; }
.win-count { margin-top: 4px; font-family: "Space Mono", monospace; font-size: .82rem; color: var(--ink-soft); }
.win-count.everyone { color: var(--marigold-deep); }
.win-count.hard-note { color: var(--ink); font-family: inherit; font-size: .88rem; }
.win-list { margin-top: 8px; display: grid; gap: 4px; font-size: .86rem; }
.win-list .k { display: inline-block; min-width: 76px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }
.win-list .k.free { color: var(--spruce); } .win-list .k.maybe { color: var(--marigold-deep); } .win-list .k.busy { color: var(--ink-faint); }

.attendee-block { margin-bottom: 18px; }
.attendees { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line-soft); font-size: .84rem; }
.chip .st { width: 7px; height: 7px; border-radius: 50%; }
.chip .st.ready { background: var(--spruce); } .chip .st.touched { background: var(--marigold); } .chip .st.pending { background: var(--ink-faint); }

/* finalize panel (creator) */
.finalize { border: 1.5px dashed var(--marigold); background: #fcf4e3; }
.finalize h3 { color: var(--marigold-deep); }
.rank { display: grid; gap: 8px; margin: 12px 0; }
.rank-row[role="button"] { cursor: pointer; }
.rank-row[role="button"]:hover { border-color: var(--ink-soft); }
.rank-row.open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-color: var(--ink-soft); }
.rank-detail { padding: 10px 12px 12px; border: 1px solid var(--ink-soft); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: var(--paper-2); }
.rank-who .out { font-weight: 600; color: var(--ember-deep); }
.rank-who .out .k.busy { color: var(--ember-deep); }
.rank-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line-soft); }
.rank-row .pos { font-family: "Space Mono", monospace; font-weight: 700; color: var(--ember-deep); }
.rank-row .sc { font-family: "Space Mono", monospace; font-size: .85rem; color: var(--ink-soft); }
.rank-row .when { display: flex; flex-direction: column; }
.rank-row .when .sub { font-size: .76rem; color: var(--ink-soft); font-weight: 400; }
.rank-row.everyone { border-color: var(--marigold); }
.rank-row .star { color: var(--marigold-deep); }
@media (max-width: 520px) { .rank-row { grid-template-columns: auto 1fr auto; } .rank-row .sc { grid-column: 2; font-size: .78rem; } .rank-row .btn { grid-row: 1 / span 2; grid-column: 3; } }
.range-edit { margin: 12px 0 4px; font-size: .9rem; }
.range-edit summary { cursor: pointer; color: var(--ember-deep); font-weight: 600; }
.range-edit .field-row { margin-top: 10px; }
.owner { margin-top: 4px; }

/* Organiser's share + named-guest block (top of the event page, and the post-create screen). */
.share-block { margin-bottom: 22px; }
.link-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--paper-2); border: 1px solid var(--line-soft); margin-top: 8px; }
.link-row .lk-main { min-width: 0; }
.link-row .lk-title { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: 8px; }
.link-row .lk-sub { color: var(--ink-soft); font-size: .78rem; margin-top: 2px; }
.link-row .lk-url, .qr-sheet .lk-url { font-family: "Space Mono", monospace; font-size: .74rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row .lk-actions { display: flex; gap: 6px; }
.qr-sheet { text-align: center; }
.qr-sheet .sheet-head { text-align: left; }
.qr-sheet .qr-box img { width: 220px; height: 220px; }
.qr-sheet .btn { margin: 0 auto; }
.qr-sheet > div:last-child { justify-content: center; }
.tier { display: inline-flex; align-items: center; gap: 5px; line-height: 1; font-family: "Space Mono", monospace; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--card); vertical-align: middle; }
.tier.must { border-color: var(--marigold); color: var(--marigold-deep); }
/* The star is a pseudo-element with its own metrics so it centres on the pill regardless of the
   monospace font's glyph baseline (a literal ★ in the text sat visibly low). */
.tier.must::before { content: "★"; font-family: system-ui, sans-serif; font-size: 1.15em; line-height: 1; display: inline-block; transform: translateY(-.04em); }
.tier.dot { width: 16px; height: 16px; padding: 0; justify-content: center; gap: 0; letter-spacing: 0; box-sizing: border-box; }
.tier.dot::before { font-size: .62rem; transform: none; letter-spacing: 0; }
.invite-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.invite-form .textarea { min-height: 72px; }
.invite-form .lvl-row { margin: 8px 0 10px; }
.invite-list { display: grid; gap: 6px; margin-top: 10px; }
/* password protection (organiser block) */
.pw-block { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.pw-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pw-row .input { flex: 1 1 200px; max-width: 320px; }
.tier.pw-on { background: var(--spruce); color: #f2fbf7; border-color: var(--spruce); margin-left: 8px; }
.lock-wrap { max-width: 440px; }
.invite-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line-soft); font-size: .9rem; }
.invite-row .iv-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-row .iv-meta { color: var(--ink-soft); font-size: .78rem; margin-top: 2px; }
.invite-row .iv-actions { display: flex; gap: 6px; }
.chip .tier { margin-left: 2px; }
@media (max-width: 480px) {
  .link-row, .invite-row { grid-template-columns: 1fr; }
  .invite-row .iv-actions { justify-content: flex-start; }
}

.loading { text-align: center; padding: 80px 20px; color: var(--ink-faint); }
.loading .ring { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--ember); border-radius: 50%; margin: 0 auto 14px; animation: spin .8s linear infinite; }

/* ============================================================================
   Pricing + legal pages
   ========================================================================== */
.sitefoot .footnav { display: flex; justify-content: center; gap: 18px; margin-top: 10px; }
.sitefoot .footnav a { color: var(--ink-soft); }
.pricing-head { max-width: 640px; margin-bottom: clamp(22px, 4vw, 36px); }
.pricing-head h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); }
.pricing-head h1 .swash { font-style: italic; color: var(--ember); }
.pricing-head .lede { color: var(--ink-soft); font-size: 1.08rem; margin: 14px 0 0; max-width: 52ch; }
.beta-ribbon { display: inline-block; margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: #fcf4e3; border: 1.5px dashed var(--marigold); color: var(--ink); font-size: .92rem; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 22px 20px; }
.plan-beta { border-color: var(--spruce); box-shadow: 0 0 0 3px #d7ece4, var(--shadow-lift); }
.plan-flag { position: absolute; top: -11px; left: 16px; background: var(--spruce); color: #f2fbf7; font-family: "Space Mono", monospace; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; }
.plan-name { font-family: "Fraunces", serif; font-size: 1.5rem; font-weight: 600; }
.plan-tag { font-size: .86rem; margin: 0; min-height: 2.6em; }
.plan-price { display: flex; align-items: baseline; gap: 3px; margin: 4px 0 6px; }
.plan-price .amt { font-family: "Fraunces", serif; font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.plan-price .per { color: var(--ink-soft); font-size: .9rem; }
.plan-price.has-note { flex-wrap: wrap; }
/* "paid annually" - a small line under the figure, on its own row */
.plan-price .plan-note { flex-basis: 100%; margin-top: -4px; font-size: .72rem; letter-spacing: .02em; color: var(--ink-soft); }
.plan-caps { list-style: none; margin: 0; padding: 10px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); font-weight: 600; font-size: .9rem; display: grid; gap: 4px; }
.plan-features { list-style: none; margin: 0; padding: 0; font-size: .86rem; color: var(--ink-soft); display: grid; gap: 6px; flex: 1; }
.plan-features li::before { content: "✓ "; color: var(--spruce); font-weight: 700; }
.plan-btn { margin-top: 8px; align-self: flex-start; }
.pricing-faq { margin-top: 28px; }
.pricing-faq h2 { font-size: 1.4rem; margin-bottom: 8px; }
.faq { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; font-size: .92rem; }
.pricing-cta { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 26px; }
.legal { max-width: 720px; margin: 0 auto; }
.legal h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin: 4px 0 6px; }
.legal-updated { font-size: .88rem; margin-bottom: 18px; }
.legal-body section + section { margin-top: 22px; }
.legal-body h2 { font-size: 1.2rem; margin-bottom: 6px; }
.legal-body p { margin: 0 0 .7em; font-size: .95rem; line-height: 1.6; }
.legal-body p:last-child { margin-bottom: 0; }
.legal-foot { margin-top: 18px; font-size: .9rem; }

/* ============================================================================
   Beta: sign-up gate, invitations
   ========================================================================== */
.beta-wrap { max-width: 480px; }
.beta-card { margin-top: 4px; }
.beta-lede { margin: 0 0 16px; font-size: 1.02rem; line-height: 1.5; }
.beta-form .field { margin-bottom: 12px; }
.beta-thanks { margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: #dcebe4; color: var(--spruce-ink); font-weight: 600; }
.beta-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink-faint); font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; }
.beta-or::before, .beta-or::after { content: ""; flex: 1; border-top: 1px solid var(--line-soft); }
.beta-have { width: 100%; }
.beta-code { margin-top: 14px; }
.beta-code .lk-title { font-weight: 600; margin: 0; }
.beta-code .hint { margin: 2px 0 10px; font-size: .84rem; color: var(--ink-soft); }
.beta-code .codejump { margin-top: 0; max-width: none; }
.beta-code .codejump .btn { white-space: nowrap; }
.beta-code .codejump .input { text-transform: none; }
.invite-note { margin: 0 0 24px; padding: 12px 14px; border-radius: var(--radius-sm); background: #fcf4e3; border: 1.5px dashed var(--marigold); font-size: .95rem; }
.invite-card { margin-top: 18px; margin-bottom: 18px; }
.invite-card.compact { margin-top: 24px; }
.invite-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.invite-sub { font-size: .88rem; margin: 6px 0 0; max-width: 56ch; }
.invite-count { font-family: "Space Mono", monospace; font-size: .74rem; color: var(--spruce-ink); background: #dcebe4; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.invite-card .link-row { margin-top: 10px; }
.invite-card .hint { font-size: .8rem; color: var(--ink-soft); margin: 8px 0 0; }

/* ============================================================================
   Live updates
   ========================================================================== */
.ev-banners { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* connection indicator at the far right of the header: green = socket open, grey = not */
/* pinned to the header's right edge, outside the nav's own padding; half the size of a nav glyph */
.ws-dot { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); cursor: help; transition: background .3s; }
.ws-dot.connecting { animation: live-blink 1.2s ease-in-out infinite; }
.ws-dot.on { background: var(--spruce); box-shadow: 0 0 0 2px rgba(31,93,86,.18); }
@media (max-width: 600px) { .ws-dot { right: 6px; } }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ws-dot.connecting { animation: none; } }

/* ---------- browser notifications (event header) ---------- */
.notify-ctl { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.notify-ctl[hidden] { display: none; }
.notify-btn { font: inherit; font-size: .8rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer; }
.notify-btn:hover { border-color: var(--ink); color: var(--ink); }
.notify-btn.on { background: #fcf4e3; border-color: var(--marigold); color: var(--marigold-deep); }
.notify-every { font-size: .8rem; }

/* ---- timezone picker in the event banner (every time on the page follows it) ---- */
.tz-pick { font: inherit; font-size: .85rem; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 1px 4px; max-width: 14rem; }

/* ---- data retention: what every visitor is told, the organiser's card, guest actions ---- */
.keep-note { font-size: .82rem; color: var(--ink-soft); margin: 8px 0 0; }
.keep-note a { color: inherit; text-decoration: underline; }
.retention-card { margin-top: 14px; }
.retention-card > summary { cursor: pointer; list-style: none; }
.retention-card > summary::-webkit-details-marker { display: none; }
.retention-card[open] > summary .muted { display: none; }
.retention-card .btn { margin-top: 8px; }
.composer-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mine-card { margin-top: 14px; }
.btn.remove-mine { --fg: var(--ember, #b4472c); }

/* ============================================================================
   Phones and touch screens
   ========================================================================== */
/* A finger needs room, and iOS Safari zooms into any control under 16px (and stays zoomed). */
@media (pointer: coarse) {
  .input, .textarea, select.input, .tz-pick, .ag-zone, .qf-row .input, .mde-box { font-size: 16px; }
  .btn-sm, .notify-btn, .levels .lv, .seg button, .others-pill, .tz-pick { min-height: 40px; }
  .switch { min-height: 40px; }   /* the label is the target, not the 18px box inside it */
  .ag-nav, .sheet-x { width: 40px; height: 40px; }
  .mde-btn { min-width: 36px; height: 36px; }
  .chip .chip-x, .cal-item .chip-x { min-width: 32px; min-height: 32px; }
  .sitefoot .footnav a { padding: 8px 4px; }
}

/* The "Unsaved changes" bar on a phone: docked along the bottom edge, one line, not draggable
   (a finger dragging it fights the page). Toasts and the page's end make room for it. */
@media (max-width: 640px) {
  .unsaved-bar { left: 8px !important; right: 8px; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; transform: none !important; padding: 8px 8px 8px 14px; cursor: default; touch-action: auto; }
  .unsaved-bar .ub-grip, .unsaved-bar .ub-long { display: none; }
  body.has-unsaved .toasts { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body.has-unsaved .sitefoot { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
}

/* Calendar import and quick fill: <details> that start closed on a phone, open on a wide screen. */
.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; font-size: .92rem; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▾"; margin-left: auto; color: var(--ink-soft); transition: transform .2s; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold > summary .fold-sub { font-weight: 400; color: var(--ink-soft); font-size: .84rem; }
.fold[open] > summary { margin-bottom: 10px; }
.qf.fold > summary { color: var(--ink); }

/* a guest's private edit link, under their answer */
.mine-link { margin-top: 10px; font-size: .85rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
/* Phones: the week strip keeps only its actionable sentence. */
@media (max-width: 640px) { .ag-ov-cap strong { display: none; } }
/* Phones: the timezone pill becomes a full-width two-line box - the picker fills its row,
   the event's own zone sits under it - instead of wrapping into three ragged lines. */
@media (max-width: 640px) {
  /* A grid, not flex: iOS Safari won't shrink a <select> in a flex row below its widest option
     ("America/Los_Angeles (event time)"), so it pushed past the screen's edge. A minmax(0, 1fr)
     column holds it to the room there is. */
  .ev-banners { min-width: 0; }
  .tz-banner { display: grid; grid-template-columns: auto minmax(0, 1fr); width: 100%; border-radius: var(--radius-sm); padding: 6px 10px; font-size: .8rem; }
  .tz-banner .tz-pick { width: 100%; min-width: 0; max-width: 100%; }
  .tz-banner .tzb-ev { grid-column: 1 / -1; min-width: 0; }
  .tz-banner .tzb-dot { display: none; }
}

/* ============================================================================
   Step-by-step guides (js/guide.js) and the 📖 button that opens them
   ========================================================================== */
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.page-title-row .eyebrow { margin: 0; }
.guide-btn { font: inherit; font-size: .82rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer; flex-shrink: 0; }
@media (hover: hover) { .guide-btn:hover { border-color: var(--ink); color: var(--ink); } }
@media (pointer: coarse) { .guide-btn { min-height: 40px; } }

.guide { position: fixed; inset: 0; z-index: 9500; }
.guide-catch { position: absolute; inset: 0; }
.guide.guide-nospot .guide-catch { background: rgba(34,29,22,.55); }
/* The highlighted part: a clear window in the dimmed page, ringed in marigold. */
.guide-spot { position: fixed; border-radius: 10px; pointer-events: none; box-shadow: 0 0 0 9999px rgba(34,29,22,.55), 0 0 0 3px var(--marigold); transition: top .2s var(--ease), left .2s var(--ease), width .2s var(--ease), height .2s var(--ease); }
.guide-spot[hidden] { display: none; }
.guide-card { position: fixed; width: min(380px, calc(100vw - 24px)); background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 12px; box-shadow: var(--shadow-lift); outline: none; animation: fade .2s; }
.guide-card.guide-center { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); }
.guide-head { display: flex; align-items: center; justify-content: space-between; }
.guide-count { font-family: "Space Mono", monospace; font-size: .72rem; color: var(--ink-faint); }
.guide-x { width: 30px; height: 30px; font-size: 1.1rem; }
.guide-title { font-size: 1.2rem; margin: 2px 0 6px; }
.guide-text p { margin: 0 0 .55em; font-size: .93rem; line-height: 1.5; }
.guide-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.guide-never { font: inherit; font-size: .8rem; background: none; border: none; padding: 10px 0 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
/* Phones: the explanation along the bottom, the part it talks about above it. */
.guide-phone .guide-card, .guide-phone .guide-card.guide-center { top: auto !important; left: 8px !important; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); width: auto; transform: none; max-height: 48vh; overflow: auto; }
@media (prefers-reduced-motion: reduce) { .guide-spot { transition: none; } .guide-card { animation: none; } }

/* Phones: the week strip above the grid picks the week, so the ‹ dates › pager goes; a toolbar
   left with nothing to show goes too. Folded boxes (calendar, quick fill) stay one slim line. */
@media (max-width: 640px) {
  .ag-pager { display: none; }
  .ag-toolbar:not(:has(.ag-tools > :not([hidden]))) { display: none; }
  .ag-tools { margin-left: auto; }
  .fold:not([open]) { padding-top: 9px; padding-bottom: 9px; }
}
.page-title-row .eyebrow { min-width: 0; overflow-wrap: anywhere; }
