/* =========================================================================
   personal — an AI calendar
   -------------------------------------------------------------------------
   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;

  --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;
}

/* ------------------------------------------------------------------ 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;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), hsl(var(--tag-focus)));
  display: grid; place-items: center;
  color: #fff; font-size: 0.7rem; font-weight: 700;
  letter-spacing: -0.02em;
  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; }

/* --------------------------------------------------------------- calendar */

.canvas {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding-top: var(--header-h);
}

/* Day-of-week strip — sticks below the topbar, also material. */
.daystrip {
  position: absolute;
  top: var(--header-h); left: 0; right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 7), 1fr);
  background: var(--material);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-bottom: 1px solid var(--separator);
}

.daystrip__spacer { border-right: 1px solid var(--separator); }

.daycol-head {
  padding: 0.4375rem 0.5rem 0.5rem;
  text-align: center;
  border-right: 1px solid var(--separator);
  min-width: 0;
}
.daycol-head__dow {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.daycol-head__num {
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  width: 2.125rem; height: 2.125rem;
  margin: 0.0625rem auto 0;
  border-radius: 50%;
}
.daycol-head--today .daycol-head__dow { color: var(--now); }
.daycol-head--today .daycol-head__num { background: var(--now); color: #fff; font-weight: 600; }
.daycol-head--weekend .daycol-head__num { color: var(--text-secondary); }

/* scrollable time grid */
.grid-scroll {
  position: absolute;
  inset: calc(var(--header-h) + 3.625rem) 0 0 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  /* Fade content where it meets the floating strip above, instead of a
     hard 1px divider. */
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px);
}

.grid {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--cols, 7), 1fr);
  position: relative;
  /* --hour-h is set from JS so zoom is a single variable */
  height: calc(var(--hour-h, 3.25rem) * 24);
}

.gutter { position: relative; border-right: 1px solid var(--separator); }

.gutter__label {
  position: absolute;
  right: 0.5rem;
  transform: translateY(-50%);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.daycol {
  position: relative;
  border-right: 1px solid var(--separator);
  min-width: 0;
}
.daycol--weekend { background: color-mix(in srgb, var(--text) 2%, transparent); }

.hourline {
  position: absolute; left: 0; right: 0;
  border-top: 1px solid var(--separator);
  pointer-events: none;
}
.hourline--half { border-top-style: dotted; opacity: 0.55; }

/* now indicator */
.now-line {
  position: absolute; left: 0; right: 0;
  z-index: 8;
  pointer-events: none;
  border-top: 1.5px solid var(--now);
}
.now-line::before {
  content: '';
  position: absolute;
  left: -4px; top: -4.75px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--now);
}
.now-flag {
  position: absolute;
  right: 0.375rem;
  transform: translateY(-50%);
  z-index: 9;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: var(--now);
  padding: 0.0625rem 0.3125rem;
  border-radius: 4px;
  pointer-events: none;
}

/* ----------------------------------------------------------------- events */

.event {
  position: absolute;
  left: 2px; right: 2px;
  z-index: 10;
  border-radius: var(--radius-sm);
  padding: 0.1875rem 0.375rem;
  overflow: hidden;
  cursor: grab;
  touch-action: none;             /* we own the gesture */
  will-change: transform;
  background: hsl(var(--tag) / 0.16);
  border-left: 2.5px solid hsl(var(--tag));
  color: hsl(var(--tag));
  /* only discrete state transitions here; drag is spring-driven */
  transition: box-shadow 140ms ease-out, background-color 140ms ease-out;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .event {
    background: hsl(var(--tag) / 0.24);
    color: hsl(var(--tag) / 0.96);
  }
}
.event:hover { background: hsl(var(--tag) / 0.24); }
.event:focus-visible { outline-offset: 1px; }

.event__title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.004em;
  line-height: 1.25;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event__time {
  font-size: 0.6875rem;
  line-height: 1.25;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.event--short { padding-top: 0; padding-bottom: 0; display: flex; gap: 0.375rem; align-items: center; }
.event--short .event__time { font-size: 0.625rem; }

.event--dragging {
  cursor: grabbing;
  z-index: 40;
  box-shadow: var(--shadow-lg);
  background: hsl(var(--tag) / 0.3);
}
.event--ghost { opacity: 0.32; }

/* resize handles */
.event__grip {
  position: absolute;
  left: 0; right: 0;
  height: 7px;
  cursor: ns-resize;
  touch-action: none;
}
.event__grip--top { top: -2px; }
.event__grip--bottom { bottom: -2px; }

/* a draft the AI proposed but you have not accepted */
.event--draft {
  border-left-style: dashed;
  background: repeating-linear-gradient(
    45deg,
    hsl(var(--tag) / 0.16) 0 6px,
    hsl(var(--tag) / 0.07) 6px 12px
  );
}

/* the box you drag on empty grid to create an event */
.selection {
  position: absolute;
  left: 2px; right: 2px;
  z-index: 12;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  pointer-events: none;
  display: flex; align-items: flex-start;
  padding: 0.1875rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- month view */

.month {
  position: absolute;
  inset: var(--header-h) 0 0 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.month__dows {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--separator);
  background: var(--material);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
}
.month__dow {
  padding: 0.4375rem 0;
  text-align: center;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.month__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  min-height: 0;
}
.month__cell {
  border-right: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
  padding: 0.25rem;
  min-width: 0;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
}
.month__cell--muted { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
.month__num {
  font-size: 0.75rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  align-self: flex-end;
  width: 1.375rem; height: 1.375rem;
  display: grid; place-items: center;
  border-radius: 50%;
  flex: none;
}
.month__cell--today .month__num { background: var(--now); color: #fff; font-weight: 700; }
.month__cell--muted .month__num { color: var(--text-tertiary); }
.month__chip {
  font-size: 0.6875rem;
  font-weight: 550;
  line-height: 1.35;
  padding: 0.0625rem 0.3125rem;
  border-radius: 4px;
  background: hsl(var(--tag) / 0.18);
  color: var(--text);
  border-left: 2px solid hsl(var(--tag));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; text-align: left;
  flex: none;
}
.month__more { font-size: 0.625rem; color: var(--text-tertiary); padding-left: 0.3125rem; text-align: left; }

/* ------------------------------------------------------- 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)); }

/* ------------------------------------------------------------- inspector */

.inspector {
  position: fixed;
  z-index: 90;
  width: 19rem;
  border-radius: var(--radius-lg);
  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);
  padding: 0.875rem;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  /* transform-origin is set in JS to the event that opened it, so it grows
     out of its trigger rather than from nowhere */
}
.inspector[data-open='true'] { pointer-events: auto; }

.inspector__title {
  width: 100%;
  font-size: 1rem; font-weight: 650; letter-spacing: -0.012em;
  border: 0; background: none; outline: none;
  padding: 0 0 0.25rem;
}
.inspector__when {
  font-size: 0.8125rem; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.75rem;
}
.inspector__row { display: flex; gap: 0.375rem; padding-bottom: 0.75rem; flex-wrap: wrap; }
.swatch {
  width: 1.375rem; height: 1.375rem; border-radius: 50%;
  background: hsl(var(--tag)); position: relative;
  transition: transform 120ms ease-out;
}
.swatch:hover { transform: scale(1.12); }
.swatch[aria-pressed='true']::after {
  content: ''; position: absolute; inset: -3px;
  border: 2px solid hsl(var(--tag)); border-radius: 50%; opacity: 0.45;
}
.inspector__actions { display: flex; gap: 0.375rem; border-top: 1px solid var(--separator); padding-top: 0.75rem; }
.btn {
  flex: 1;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 550;
  background: var(--separator);
  transition: background-color 120ms ease-out, transform 100ms ease-out;
}
.btn:hover { background: var(--separator-strong); }
.btn:active { transform: scale(0.97); }
.btn--danger { color: var(--now); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

/* ------------------------------------------------------------------ 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); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 60rem) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .fab { display: grid; }
}

@media (max-width: 40rem) {
  :root { --gutter: 2.75rem; --sidebar-w: 0; }
  .topbar { padding: 0 0.625rem; gap: 0.375rem; }
  /* The long form wraps to three or four lines here and pushes the day strip
     off screen, so it must never wrap. JS also swaps in a shorter string. */
  .topbar__title {
    font-size: 1.0625rem;
    min-width: 0;
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .topbar__title em { display: none; }
  /* No room for a Today button — the title is the affordance instead. */
  .today-btn { display: none; }
  .segmented { gap: 0; }
  .segmented button { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
  .palette { top: 8vh; width: calc(100vw - 1.5rem); }
  .inspector { width: calc(100vw - 2rem); }
}

/* ----------------------------------------------------- accessibility prefs */

/* Reduced motion = a gentler equivalent, not the absence of feedback. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .palette__spinner { animation: none; border-top-color: var(--separator-strong); }
}

/* 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; }
}
