/* CynchCalendar. Token names follow the rest of the estate so the apps feel related;
   the accent is indigo rather than CynchUp's teal, because a calendar is a different
   room in the same house. */

:root {
  --ink: #101826;
  --ink-soft: #3d4a5c;
  --muted: #71808f;
  --paper: #f7f8fa;
  --card: #ffffff;
  --line: #e0e4ea;
  --line-soft: #eef1f5;
  --accent: #3b5bdb;
  --accent-deep: #2f49af;
  --accent-wash: #e8ecfd;
  --signal: #e8543f;
  --ok: #2e7d4f;
  --err: #c0392b;
  --now: #e8543f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 38, .06), 0 8px 24px -12px rgba(16, 24, 38, .22);
  --shadow-lg: 0 4px 8px rgba(16, 24, 38, .08), 0 24px 48px -16px rgba(16, 24, 38, .3);
  --font-body: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --hour-height: 48px;
  --gutter: 56px;
}

/* Dark palette, applied two ways: from the operating system by default, and from an
   explicit data-theme when someone overrides it. The token list is repeated rather
   than shared because a media query cannot be aliased to a plain selector. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8edf2;
    --ink-soft: #b6c2cf;
    --muted: #8593a3;
    --paper: #0f1418;
    --card: #171d24;
    --line: #262f39;
    --line-soft: #1e262e;
    --accent: #7c93f0;
    --accent-deep: #a3b3f7;
    --accent-wash: #1c2440;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, .5), 0 24px 48px -16px rgba(0, 0, 0, .8);
  }
}

[data-theme="dark"] {
  --ink: #e8edf2;
  --ink-soft: #b6c2cf;
  --muted: #8593a3;
  --paper: #0f1418;
  --card: #171d24;
  --line: #262f39;
  --line-soft: #1e262e;
  --accent: #7c93f0;
  --accent-deep: #a3b3f7;
  --accent-wash: #1c2440;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, .5), 0 24px 48px -16px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  overscroll-behavior: none;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }

/* ── shared controls ────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card);
  font-weight: 500; color: var(--ink);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--line-soft); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--danger { color: var(--err); }
.btn--ghost { border-color: transparent; background: none; }
.btn--ghost:hover { background: var(--line-soft); }
.btn--icon { padding: 7px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-wash); }
.textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.error-banner {
  background: color-mix(in srgb, var(--err) 12%, transparent);
  color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}

/* ── sign in and the emailed-link screens ───────────────────────────── */
/* Class names mirror cynch-mailer's login so the two read as one product. */

.login-wrap { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px;
  box-shadow: var(--shadow);
}
.login-header { margin-bottom: 22px; }
.login-brand { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.login-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 0; }
.login-lead { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 8px 0 0; }

.login-form { display: block; }
.login-row { margin-bottom: 14px; }
.login-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .03em; }
.login-input {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
}
.login-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-wash); }

/* The password field and its show/hide toggle. */
.login-input-wrap { position: relative; display: block; }
.login-input-wrap .login-input { padding-right: 40px; }
.login-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 6px;
  display: grid; place-items: center; font-size: 14px; opacity: .55;
}
.login-eye:hover { opacity: 1; background: var(--line-soft); }
.login-eye[aria-pressed="true"] { opacity: 1; color: var(--accent); }

.login-error {
  background: color-mix(in srgb, var(--err) 12%, transparent);
  color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
}
.login-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.login-actions .btn { justify-content: center; min-width: 132px; }
.login-link { font-size: 13px; color: var(--accent); text-decoration: none; }
.login-link:hover { text-decoration: underline; }

/* Spinner shown in the submit button while a request is in flight. */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, #fff 45%, transparent);
  border-top-color: #fff;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* The guest invitation page still uses these. */
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.auth__card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth__mark { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.auth__sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }

/* ── app shell ──────────────────────────────────────────────────────── */

.app { display: grid; grid-template-rows: auto 1fr; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.topbar__mark { font-weight: 700; letter-spacing: -.02em; font-size: 16px; margin-right: 4px; }
/* Shrinks and ellipsises rather than shoving the view switcher off a narrow screen. */
.topbar__title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.nav-arrows { display: flex; gap: 2px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { padding: 6px 12px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-deep); font-weight: 600; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; flex: none;
}

.body { display: grid; grid-template-columns: 232px 1fr; min-height: 0; position: relative; }
.only-narrow { display: none; }
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  /* The sidebar becomes a sheet over the grid, opened by the ☰ button in the topbar.
     Positioned against .body rather than the viewport, so it starts below the topbar
     whatever height that has wrapped to. */
  .sidebar { display: none; }
  .sidebar--open { display: block; position: absolute; inset: 0; z-index: 30; overflow-y: auto; }
  .only-narrow { display: inline-flex; }

  /* Everything does not fit on one line at 375px, so the spacer becomes a full-width
     break: navigation on the first row, the view switcher and avatar on the second. */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .topbar__spacer { flex-basis: 100%; height: 0; }
  .topbar > :last-child { margin-left: auto; }
  .topbar__mark { display: none; }
  .topbar__title { font-size: 15px; }
  .seg button { padding: 6px 12px; }
}

.sidebar { border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; background: var(--paper); }
.sidebar__section { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 8px; }

/* mini month */
.mini { user-select: none; }
.mini__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini__label { font-size: 13px; font-weight: 600; }
.mini__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini__dow { font-size: 10px; color: var(--muted); text-align: center; font-weight: 600; padding-bottom: 2px; }
.mini__day {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%;
  font-size: 11.5px; color: var(--ink-soft);
}
.mini__day:hover { background: var(--line-soft); }
.mini__day--muted { color: var(--muted); opacity: .55; }
.mini__day--today { color: var(--accent-deep); font-weight: 700; }
.mini__day--sel { background: var(--accent); color: #fff; font-weight: 600; }
.mini__day--sel:hover { background: var(--accent-deep); }

.cal-list { display: flex; flex-direction: column; gap: 1px; }
.cal-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.cal-item:hover { background: var(--line-soft); }
.cal-item input { appearance: none; width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid currentColor; flex: none; cursor: pointer; }
.cal-item input:checked { background: currentColor; }
.cal-item input:checked::after { content: "✓"; display: block; color: var(--card); font-size: 11px; line-height: 12px; text-align: center; font-weight: 900; }
.cal-item__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }

/* ── the grid ───────────────────────────────────────────────────────── */

.view { overflow: auto; position: relative; }

.grid-head {
  position: sticky; top: 0; z-index: 12; background: var(--card);
  border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr);
}
.grid-head__spacer { border-right: 1px solid var(--line-soft); }
.dayhead { padding: 6px 4px 4px; text-align: center; border-right: 1px solid var(--line-soft); }
.dayhead__dow { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dayhead__num { font-size: 20px; font-weight: 500; line-height: 1.3; }
.dayhead--today .dayhead__dow { color: var(--accent); }
.dayhead--today .dayhead__num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 30px; height: 30px; display: inline-grid; place-items: center; font-size: 15px; font-weight: 600;
}

/* all-day strip */
.allday {
  display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr);
  border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: var(--head-height, 52px); z-index: 11;
  min-height: 24px;
}
.allday__label { font-size: 10px; color: var(--muted); text-align: right; padding: 4px 6px 0 0; border-right: 1px solid var(--line-soft); }
.allday__col { border-right: 1px solid var(--line-soft); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-height: 22px; }

.timegrid { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); position: relative; }
.timegrid__gutter { border-right: 1px solid var(--line-soft); }
.hourlabel { height: var(--hour-height); position: relative; }
.hourlabel span { position: absolute; right: 6px; top: -7px; font-size: 10.5px; color: var(--muted); background: var(--paper); padding: 0 2px; }
.daycol { border-right: 1px solid var(--line-soft); position: relative; }
.daycol--weekend { background: color-mix(in srgb, var(--muted) 4%, transparent); }
.hourcell { height: var(--hour-height); border-bottom: 1px solid var(--line-soft); }
.hourcell:hover { background: var(--accent-wash); }

.nowline { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); z-index: 6; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--now); }

/* an event block */
.ev {
  position: absolute; overflow: hidden; z-index: 5;
  border-radius: 5px; padding: 2px 5px;
  font-size: 11.5px; line-height: 1.25; text-align: left;
  border-left: 3px solid var(--ev-color, var(--accent));
  background: var(--ev-bg, var(--accent-wash));
  color: var(--ev-ink, var(--ink));
  transition: filter .1s;
}
.ev:hover { filter: brightness(.96); z-index: 7; }
/* Tall enough to stack: title on its own line, time underneath. The .ev--short
   variant puts them side by side instead, because a 30-minute block has one line. */
.ev:not(.ev--short) .ev__title, .ev:not(.ev--short) .ev__time { display: block; }
.ev__time { font-weight: 400; opacity: .8; font-size: 10.5px; }
.ev__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev--short { display: flex; gap: 5px; align-items: baseline; padding: 1px 5px; }
.ev--short .ev__title { flex: 1; }
.ev--allday { position: static; padding: 2px 6px; border-radius: 4px; border-left-width: 3px; }
.ev--declined { opacity: .55; text-decoration: line-through; }
.ev--tentative { background: repeating-linear-gradient(45deg, var(--ev-bg) 0 6px, transparent 6px 12px); }
.ev__call { opacity: .75; }

/* month */
.month { display: grid; grid-template-rows: auto 1fr; min-height: 100%; }
.month__dows { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 10; }
.month__dow { text-align: center; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 0; }
.month__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(96px, 1fr); }
.mcell { border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 2px 3px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mcell--outside { background: color-mix(in srgb, var(--muted) 4%, transparent); }
.mcell__num { align-self: center; font-size: 12px; color: var(--ink-soft); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.mcell--today .mcell__num { background: var(--accent); color: #fff; font-weight: 700; }
.mcell__more { font-size: 10.5px; color: var(--muted); padding-left: 4px; text-align: left; }
.mcell__more:hover { color: var(--accent); }

/* ── dialogs and popovers ───────────────────────────────────────────── */

dialog { border: none; padding: 0; background: none; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(16, 24, 38, .38); backdrop-filter: blur(2px); }
.sheet {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px));
  max-height: min(86dvh, 780px); display: flex; flex-direction: column;
}
.sheet--sm { width: min(400px, calc(100vw - 24px)); }
.sheet__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.sheet__head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.sheet__body { padding: 16px; overflow-y: auto; flex: 1; }
.sheet__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.sheet__foot .btn--danger { margin-right: auto; }

/* event detail */
.detail__title { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 2px; }
.detail__when { color: var(--ink-soft); font-size: 13px; }
.detail__repeat { color: var(--muted); font-size: 12px; }
.detail__row { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.detail__row .ico { flex: none; width: 18px; color: var(--muted); text-align: center; }
.detail__row a { color: var(--accent); }
.detail__body { white-space: pre-wrap; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; border-radius: 999px; background: var(--line-soft); font-size: 12px; }
.chip .avatar { width: 20px; height: 20px; font-size: 9px; }
.chip__x { color: var(--muted); font-size: 14px; line-height: 1; padding: 0 2px; }
.chip__x:hover { color: var(--err); }
.chip--accepted { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ok) 55%, transparent); }
.chip--declined { opacity: .6; text-decoration: line-through; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.rsvp { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rsvp__btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.notes__meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.notes__other { border-left: 2px solid var(--line); padding-left: 10px; margin-bottom: 10px; font-size: 13px; white-space: pre-wrap; }
.saving { font-size: 11px; color: var(--muted); }

.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kbd { font-family: var(--font-mono); font-size: 11px; background: var(--line-soft); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
