/* =========================================================================
   Term — a school planner
   -------------------------------------------------------------------------
   Visual system notes:
   - Chrome is translucent material with content scrolling *under* it, never
     opaque bars that eat a fixed strip of the viewport.
   - Tracking is size-specific. Large text gets negative tracking (letters read
     too far apart as they grow), body sits near zero, small caps-y labels get
     positive. A single letter-spacing value is always wrong somewhere.
   - Spacing is in rem so the layout scales with the user's text size.
   - No transitions on anything gesture-driven — those are springs in JS.
     Transitions here are only for discrete state (hover, press, theme).
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&display=swap');

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  /* Surfaces. --bg is solid; everything above it is material. */
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --material: rgba(255, 255, 255, 0.72);
  --material-thick: rgba(255, 255, 255, 0.86);
  --material-edge: rgba(255, 255, 255, 0.5);

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #a1a1a6;

  --separator: rgba(0, 0, 0, 0.07);
  --separator-strong: rgba(0, 0, 0, 0.14);

  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --now: #ff3b30;

  /* Event tags. Each is a hue; fills and text derive from it so a new tag
     only needs one line. */
  --tag-work: 211 100% 52%;
  --tag-personal: 280 68% 58%;
  --tag-focus: 250 84% 62%;
  --tag-health: 142 62% 42%;
  --tag-travel: 28 96% 52%;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 1px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-press: 120ms;
  --duration-ui: 180ms;
  --duration-panel: 220ms;

  --gutter: 3.75rem;   /* time labels column */
  --header-h: 3.5rem;
  --sidebar-w: 15rem;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --material: rgba(30, 30, 32, 0.72);
    --material-thick: rgba(30, 30, 32, 0.88);
    --material-edge: rgba(255, 255, 255, 0.09);

    --text: #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary: #636366;

    --separator: rgba(255, 255, 255, 0.09);
    --separator-strong: rgba(255, 255, 255, 0.16);

    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.2);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme='dark'] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --material: rgba(30, 30, 32, 0.72);
  --material-thick: rgba(30, 30, 32, 0.88);
  --material-edge: rgba(255, 255, 255, 0.09);
  --text: #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary: #636366;
  --separator: rgba(255, 255, 255, 0.09);
  --separator-strong: rgba(255, 255, 255, 0.16);
  --accent-soft: rgba(10, 132, 255, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 100%;
  line-height: 1.5;
  letter-spacing: 0;          /* body sits at zero */
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input  { font: inherit; color: inherit; }

/* Several things here set an explicit `display`, which silently beats the UA's
   [hidden] rule — an "invisible" absolutely-positioned panel then keeps
   swallowing pointer events. Make the attribute win. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------------------------------------------------------- authentication */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(24rem, 46%) 1fr;
  background: var(--bg-elevated);
  overflow: hidden;
}

.auth__panel {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 5vw, 5rem);
  background: var(--bg-elevated);
}

.auth__content {
  width: min(100%, 25rem);
  display: flex;
  flex-direction: column;
  min-height: min(39rem, calc(100dvh - 6rem));
}

.auth__logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: max-content;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  opacity: 0;
  transform: translateY(8px);
}

.auth__logo img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  box-shadow: var(--shadow-sm);
}

.auth__copy {
  margin-top: auto;
  opacity: 0;
  transform: translateY(12px);
}

.auth__copy h1 {
  max-width: 8.5em;
  margin: 0;
  font-size: clamp(2.45rem, 4.25vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.064em;
  font-weight: 670;
}

.auth__copy p {
  max-width: 27rem;
  margin: 1.25rem 0 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.55;
}

.auth__form {
  display: grid;
  gap: 0.75rem;
  margin-top: 2.5rem;
  opacity: 0;
  transform: translateY(14px);
}

.auth__label {
  font-size: 0.82rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.008em;
}

.auth__form input {
  width: 100%;
  height: 3.25rem;
  padding: 0 0.95rem;
  border: 1px solid var(--separator-strong);
  border-radius: 0.75rem;
  outline: 0;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--duration-ui) ease, box-shadow var(--duration-ui) ease, background var(--duration-ui) ease;
}

.auth__form input:hover { border-color: color-mix(in srgb, var(--text-secondary) 52%, transparent); }
.auth__form input:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth__password { position: relative; }
.auth__password input { padding-right: 4.25rem; }

.auth__reveal {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  padding: 0.35rem 0.45rem;
  border-radius: 0.4rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
}

.auth__reveal:hover { background: var(--accent-soft); }

.auth__submit {
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  padding: 0 0.95rem 0 1.05rem;
  border-radius: 0.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  letter-spacing: -0.012em;
  box-shadow: 0 6px 18px rgba(10, 132, 255, 0.22);
  transition: transform var(--duration-press) ease, filter var(--duration-ui) ease, opacity var(--duration-ui) ease;
}

.auth__submit:hover { filter: brightness(1.05); }
.auth__submit:active { transform: scale(0.985); }
.auth__submit:disabled { cursor: wait; opacity: 0.68; }
.auth__submit-icon { font-size: 1.25rem; transition: transform var(--duration-ui) var(--ease-out); }
.auth__submit:hover .auth__submit-icon { transform: translateX(3px); }

.auth__error,
.auth__hint {
  margin: -0.1rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

.auth__error { color: #d70015; }
.auth__hint { color: var(--text-secondary); }

.auth__notice {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.4rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--accent) 23%, transparent);
  border-radius: 0.75rem;
  background: var(--accent-soft);
  font-size: 0.8rem;
  line-height: 1.4;
}

.auth__notice span { color: var(--text-secondary); }

.auth__privacy {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  margin: auto 0 0;
  padding-top: 2rem;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  opacity: 0;
}

.auth__privacy svg {
  width: 0.9rem;
  height: 0.9rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.auth__preview {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(2rem, 6vw, 6rem);
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(145deg, #087af0 0%, #156de1 48%, #5554d9 100%);
}

.auth__preview::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.26;
  background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 4.5rem 4.5rem;
  mask-image: linear-gradient(to bottom right, transparent 5%, #000 65%);
}

.auth__orb {
  position: absolute;
  z-index: -1;
  width: 24rem;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(1px);
  opacity: 0.45;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,.65), rgba(255,255,255,0) 68%);
}

.auth__orb--one { top: -8rem; right: -5rem; }
.auth__orb--two { bottom: -12rem; left: -8rem; transform: scale(1.35); opacity: 0.24; }

.auth__day {
  width: min(100%, 31rem);
  padding: 1.25rem;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 1.5rem;
  background: rgba(255,255,255,.86);
  box-shadow: 0 32px 80px rgba(15, 38, 88, .34), inset 0 1px rgba(255,255,255,.65);
  color: #1d1d1f;
  backdrop-filter: blur(28px) saturate(150%);
  opacity: 0;
  transform: translateY(22px) rotate(-1.5deg) scale(.98);
}

.auth__day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.1rem 0.25rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.auth__day-head span { font-size: 1.05rem; font-weight: 650; letter-spacing: -.025em; }
.auth__day-head strong { font-size: 2.2rem; line-height: 1; letter-spacing: -.06em; }
.auth__timeline { display: grid; grid-template-columns: 3rem 1fr; gap: 0.6rem 0.75rem; padding: 1rem 0 0.8rem; }
.auth__time { padding-top: 0.75rem; color: #77777c; font-size: 0.68rem; font-variant-numeric: tabular-nums; }

.auth__lesson {
  position: relative;
  display: grid;
  gap: 0.12rem;
  min-height: 3.8rem;
  padding: 0.65rem 0.8rem 0.65rem 1rem;
  border-radius: 0.8rem;
  overflow: hidden;
  background: #eef6ff;
}

.auth__lesson::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 0.3rem; background: #0a84ff; }
.auth__lesson b { font-size: 0.82rem; letter-spacing: -.012em; }
.auth__lesson span { color: #6e6e73; font-size: 0.7rem; }
.auth__lesson--green { background: #eaf9f2; }
.auth__lesson--green::before { background: #20a874; }
.auth__lesson--violet { background: #f3effc; }
.auth__lesson--violet::before { background: #745bd4; }
.auth__lesson--orange { background: #fff4e6; }
.auth__lesson--orange::before { background: #ef9216; }

.auth__next {
  display: flex;
  justify-content: space-between;
  margin-left: 3.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.7rem;
  background: #1d1d1f;
  color: #fff;
  font-size: 0.72rem;
}

.auth__next span { color: #a7a7ab; }

.auth[data-state='ready'] .auth__logo,
.auth[data-state='ready'] .auth__copy,
.auth[data-state='ready'] .auth__form,
.auth[data-state='ready'] .auth__privacy,
.auth[data-state='ready'] .auth__day {
  animation: auth-enter 560ms var(--ease-out) forwards;
}

.auth[data-state='ready'] .auth__copy { animation-delay: 70ms; }
.auth[data-state='ready'] .auth__form { animation-delay: 130ms; }
.auth[data-state='ready'] .auth__privacy { animation-delay: 190ms; }
.auth[data-state='ready'] .auth__day { animation-delay: 90ms; }
.auth[data-state='leaving'] { animation: auth-leave 240ms ease-in forwards; }

/* The command palette, floating action and toast layer live beside `.app` in
   the DOM, so hide them explicitly while the authentication surface is up. */
.auth:not([hidden]) ~ .scrim,
.auth:not([hidden]) ~ .palette,
.auth:not([hidden]) ~ .fab,
.auth:not([hidden]) ~ .toasts { display: none; }

@keyframes auth-enter { to { opacity: 1; transform: none; } }
@keyframes auth-leave { to { opacity: 0; transform: scale(1.006); } }

.sign-out {
  align-self: flex-start;
  margin: -0.2rem 0 0 0.35rem;
  color: var(--text-tertiary);
  font-size: 0.72rem;
  transition: color var(--duration-ui) ease;
}

.sign-out:hover { color: var(--text); }

@media (max-width: 760px) {
  .auth { display: block; background: var(--bg-elevated); }
  .auth__panel { min-height: 100dvh; padding: max(1.5rem, env(safe-area-inset-top)) 1.4rem max(1.5rem, env(safe-area-inset-bottom)); }
  .auth__content { min-height: calc(100dvh - 3rem); width: min(100%, 27rem); }
  .auth__copy h1 { font-size: clamp(2.7rem, 14vw, 4rem); }
  .auth__preview { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .auth[data-state='ready'] .auth__logo,
  .auth[data-state='ready'] .auth__copy,
  .auth[data-state='ready'] .auth__form,
  .auth[data-state='ready'] .auth__privacy,
  .auth[data-state='ready'] .auth__day {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .auth[data-state='leaving'] { animation: none; }
  .auth__submit-icon { transition: none; }
}

/* ------------------------------------------------------------------ shell */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0.875rem;
  background: var(--material);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-right: 1px solid var(--separator);
  overflow-y: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.375rem 0;
}

.brand__mark {
  width: 1.5rem; height: 1.5rem;
  display: block;
  border-radius: 0.4375rem;
  box-shadow: var(--shadow-sm);
}

.topbar__mark {
  display: none;
  width: 1.625rem;
  height: 1.625rem;
  flex: 0 0 auto;
  border-radius: 0.475rem;
  box-shadow: var(--shadow-sm);
}

.brand__name {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.014em;   /* tighten as it grows */
}

/* mini month */
.mini { user-select: none; }

.mini__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0.375rem 0.5rem;
}

.mini__title { font-size: 0.8rem; font-weight: 600; letter-spacing: -0.008em; }

.mini__nav { display: flex; gap: 0.125rem; }

.icon-btn {
  width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.icon-btn:hover { background: var(--separator); color: var(--text); }
.icon-btn:active { background: var(--separator-strong); }
.icon-btn svg { width: 1rem; height: 1rem; }

.mini__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.mini__dow {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.04em;      /* small text opens up */
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: center;
  padding-bottom: 0.25rem;
}

.mini__day {
  aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  border-radius: 50%;
  color: var(--text);
  position: relative;
  transition: background-color 120ms ease-out;
}
.mini__day:hover { background: var(--separator); }
.mini__day--muted { color: var(--text-tertiary); }
.mini__day--today { color: var(--now); font-weight: 700; }
.mini__day--selected { background: var(--accent); color: #fff; font-weight: 600; }
.mini__day--selected:hover { background: var(--accent); }
.mini__day--has::after {
  content: ''; position: absolute; bottom: 2px;
  width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; opacity: 0.55;
}
.mini__day--selected.mini__day--has::after { background: #fff; opacity: 0.9; }

/* tag filters */
.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 0 0.375rem 0.375rem;
}

.tags { display: flex; flex-direction: column; gap: 1px; }

.tag-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  text-align: left;
  width: 100%;
  transition: background-color 120ms ease-out;
}
.tag-row:hover { background: var(--separator); }
.tag-row__dot {
  width: 0.625rem; height: 0.625rem; border-radius: 3px;
  background: hsl(var(--tag)); flex: none;
  transition: opacity 120ms ease-out, transform 120ms ease-out;
}
.tag-row[aria-pressed='false'] .tag-row__dot { opacity: 0.25; transform: scale(0.8); }
.tag-row[aria-pressed='false'] .tag-row__name { color: var(--text-tertiary); }
.tag-row__count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; }

/* the AI entry point */
.ask-btn {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--separator);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: left;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.ask-btn:hover { box-shadow: var(--shadow-md); }
.ask-btn:active { transform: scale(0.98); }
.ask-btn__kbd {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--separator);
  padding: 0.0625rem 0.3125rem;
  border-radius: 4px;
}

.status {
  display: flex; align-items: center; gap: 0.4375rem;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}
.status__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-tertiary);
  flex: none;
}
.status--online .status__dot { background: hsl(var(--tag-health)); }
.status--offline .status__dot { background: hsl(var(--tag-travel)); }

/* ------------------------------------------------------------------- main */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Floating translucent chrome. Content scrolls under it. */
.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem;
  background: var(--material);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-bottom: 1px solid var(--separator);
}

.topbar__title {
  font-size: 1.3125rem;
  font-weight: 650;
  letter-spacing: -0.021em;    /* display text tightens */
  line-height: 1.1;
  min-width: 11ch;
  font-variant-numeric: tabular-nums;
}
.topbar__title em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-tertiary);
}

.topbar__nav { display: flex; align-items: center; gap: 0.125rem; }

.today-btn {
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 550;
  letter-spacing: -0.005em;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-sm);
  transition: transform 100ms ease-out;
}
.today-btn:active { transform: scale(0.96); }

/* segmented control */
.segmented {
  margin-left: auto;
  display: flex;
  position: relative;
  padding: 2px;
  border-radius: 9px;
  background: var(--separator);
  isolation: isolate;
}
.segmented__thumb {
  position: absolute;
  top: 2px; left: 0;
  height: calc(100% - 4px);
  border-radius: 7px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  z-index: -1;
  /* positioned by a spring in JS, not a transition */
}
.segmented button {
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.003em;
  color: var(--text-secondary);
  border-radius: 7px;
  transition: color 140ms ease-out;
}
.segmented button[aria-selected='true'] { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------- command palette */

.scrim {
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;               /* driven by spring */
  pointer-events: none;
}
.scrim[data-open='true'] { pointer-events: auto; }

.palette {
  position: fixed;
  z-index: 101;
  top: 18vh; left: 50%;
  width: min(40rem, calc(100vw - 2rem));
  transform: translateX(-50%);
  border-radius: var(--radius-xl);
  background: var(--material-thick);
  backdrop-filter: blur(40px) saturate(190%);
  -webkit-backdrop-filter: blur(40px) saturate(190%);
  border: 1px solid var(--material-edge);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  will-change: transform, opacity;
  pointer-events: none;
  opacity: 0;
}
.palette[data-open='true'] { pointer-events: auto; }

.palette__field {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
}
.palette__glyph { width: 1.25rem; height: 1.25rem; color: var(--text-tertiary); flex: none; }
.palette__input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font-size: 1.125rem;
  font-weight: 450;
  letter-spacing: -0.011em;
}
.palette__input::placeholder { color: var(--text-tertiary); }

.palette__spinner {
  width: 1rem; height: 1rem; flex: none;
  border: 2px solid var(--separator-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 640ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.palette__hint {
  padding: 0 1.25rem 0.875rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: flex; gap: 0.75rem; flex-wrap: wrap;
}
.palette__hint b { font-weight: 550; color: var(--text-secondary); }

.palette__results {
  border-top: 1px solid var(--separator);
  max-height: min(24rem, 50vh);
  overflow-y: auto;
  padding: 0.375rem;
}

.draft {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  text-align: left;
  transition: background-color 120ms ease-out;
}
.draft:hover, .draft[data-active='true'] { background: var(--separator); }
.draft__bar { width: 3px; align-self: stretch; border-radius: 2px; background: hsl(var(--tag)); flex: none; }
.draft__body { flex: 1; min-width: 0; }
.draft__title {
  font-size: 0.875rem; font-weight: 600; letter-spacing: -0.006em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.draft__when { font-size: 0.75rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.draft__why { font-size: 0.75rem; color: var(--text-tertiary); font-style: italic; }
.draft__add {
  font-size: 0.75rem; font-weight: 600; color: var(--accent);
  padding: 0.25rem 0.625rem; border-radius: 999px;
  background: var(--accent-soft); flex: none;
}

.palette__foot {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-top: 1px solid var(--separator);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}
.badge {
  font-size: 0.625rem; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
  padding: 0.0625rem 0.375rem; border-radius: 4px;
  background: var(--separator);
}
.badge--model    { background: hsl(var(--tag-health) / 0.18); color: hsl(var(--tag-health)); }
.badge--edge     { background: hsl(var(--tag-work) / 0.18);   color: hsl(var(--tag-work)); }
.badge--fallback { background: hsl(var(--tag-travel) / 0.18); color: hsl(var(--tag-travel)); }

/* ------------------------------------------------------------------ toast */

.toasts {
  position: fixed;
  bottom: 1.25rem; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.5rem 0.5rem 0.9375rem;
  border-radius: 999px;
  background: var(--material-thick);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--material-edge);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem; font-weight: 500;
  white-space: nowrap;
  pointer-events: auto;
  will-change: transform, opacity;
}
.toast__undo {
  font-size: 0.8125rem; font-weight: 600; color: var(--accent);
  padding: 0.1875rem 0.625rem; border-radius: 999px;
  background: var(--accent-soft);
}

/* --------------------------------------------------------------- mobile AI */

.fab {
  display: none;
  position: fixed;
  right: 1.125rem;
  bottom: calc(1.125rem + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  width: 3.25rem; height: 3.25rem;
  border-radius: 50%;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), hsl(var(--tag-focus)));
  box-shadow: var(--shadow-lg);
  transition: transform 110ms ease-out;
}
.fab svg { width: 1.375rem; height: 1.375rem; }
.fab:active { transform: scale(0.92); }


/* ----------------------------------------------------- accessibility prefs */

/* Reduced motion = a gentler equivalent, not the absence of feedback. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
  }
  .palette__spinner { animation: none; border-top-color: var(--separator-strong); }
  .ask-btn:active,
  .today-btn:active,
  .fab:active { transform: none; }
}

/* Frostier and solid rather than translucent. */
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .daystrip, .month__dows,
  .palette, .inspector, .toast {
    background: var(--bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .scrim { background: rgba(0, 0, 0, 0.5); backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root {
    --separator: rgba(0, 0, 0, 0.24);
    --separator-strong: rgba(0, 0, 0, 0.4);
    --text-secondary: #3a3a3c;
    --text-tertiary: #545456;
  }
  .event { border: 1px solid hsl(var(--tag)); border-left-width: 3px; }
  .palette, .inspector, .toast { border-color: var(--separator-strong); }
}

@media print {
  .sidebar, .topbar, .palette, .scrim, .inspector, .toasts { display: none !important; }
  .canvas { padding-top: 0; }
}
