/* index.css */
/* ============================================================================
 * Responsive breakpoint scale (documentation only — OPT-05)
 * ----------------------------------------------------------------------------
 * Breakpoints used across src/ (min/max-width media queries):
 *   480px, 600px, 700px, 767px, 768px, 900px, 1000px, 1024px, 1100px
 *
 * 768px is the LOAD-BEARING breakpoint. It is a *JS* breakpoint, not just CSS:
 *   src/hooks/useMobileDetect.js  →  MOBILE_BREAKPOINT = 768
 *   window.innerWidth < 768 switches the entire UI between
 *   YearGrid (desktop, 12×31 grid) and MobileCalendar (mobile, day list).
 * 767px is its max-width CSS partner (the mobile side of the 768 min-width line).
 *
 * The other values are component-local layout tweaks (header, panels, charts).
 * This block is a documented standard only — no media queries are defined here.
 * ========================================================================== */

.tw {
  /* Dark palette */
  --bg-base: #0a0b0f;
  --bg-surface: #12141c;
  --bg-elevated: #1a1d28;
  --bg-hover: #222636;
  --bg-active: #2a2f42;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Text */
  --text-primary: #e8eaed;
  --text-secondary: #8b8f9a;
  --text-tertiary: #555965;
  --text-inverse: #0a0b0f;

  /* Accent */
  --accent: #6c72ff;
  --accent-hover: #8186ff;
  --accent-subtle: rgba(108, 114, 255, 0.12);
  /* The heartbeat's Tide (M6, ADR-040): plain hex, because html2canvas cannot parse color-mix() or color(srgb ...) (BUG-181).
     Deep = work, equal to --accent today but its own token so the strip does not move when --accent does. */
  --hb-deep: #6c72ff;
  --hb-pale: #a9adff;

  /* Semantic */
  --danger: #ff4d4d;
  --danger-hover: #ff3333;
  --success: #34d399;
  --warning: #f59e0b;
  /* Text-safe pairs for warning and danger copy (S2.3). Fills keep --warning and --danger; never use those two for text, and never opacity. */
  --warning-text: #fbbf24;
  --danger-text: #ff8a8a;
  /* Padlock glyph. Own value, not an alias of --text-secondary: that one is 4.10:1 on --bg-active in dark. */
  --lock: #a1a5b0;

  /* Weekend */
  --weekend-tint: rgba(108, 114, 255, 0.04);

  /* Logo mark (R1.1) — theme-adaptive fill of the dim cells */
  --logo-muted: rgba(255, 255, 255, 0.14);
  --weekend-bg: rgba(255, 255, 255, 0.025);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(108, 114, 255, 0.15);

  /* Frost */
  --frost-bg: rgba(18, 20, 28, 0.85);
  --frost-blur: blur(20px);

  /* Layout */
  --header-height: 46px;
}

.tw * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.tw, .tw {
  height: 100%;
}

/* Prevent body scroll when app grid is active (not landing page) */
.tw.app-active {
  overflow: hidden;
}

.tw {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.tw #root {
  height: 100%;
}

.tw button {
  cursor: pointer;
  font-family: inherit;
}

.tw input, .tw select, .tw textarea {
  font-family: inherit;
}

/* Scrollbar */
.tw ::-webkit-scrollbar { width: 5px; height: 5px; }
.tw ::-webkit-scrollbar-track { background: transparent; }
.tw ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.tw ::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

.tw ::selection {
  background: var(--accent);
  color: var(--text-inverse);
}

/* Shared keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Light theme ===== */
.tw [data-theme="light"] {
  --bg-base:     #f0f2f5;
  --bg-surface:  #ffffff;
  --bg-elevated: #f8f9fa;
  --bg-hover:    #edf0f3;
  --bg-active:   #e2e6ea;

  --border-subtle:  rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.10);
  --border-strong:  rgba(0, 0, 0, 0.16);

  --text-primary:   #111318;
  --text-secondary: #3d4252;
  --text-tertiary:  #6b7280;
  --text-inverse:   #ffffff;

  --accent:        #4b52e0;
  --accent-hover:  #3d44cc;
  --accent-subtle: rgba(75, 82, 224, 0.10);
  --hb-deep:       #4b52e0;
  --hb-pale:       #7b81ee;

  --danger:        #dc2626;
  --danger-hover:  #b91c1c;
  --success:       #16a34a;
  --warning:       #b45309;
  --warning-text:  #92400e;
  --danger-text:   #991b1b;
  --lock:          #3d4252;

  --weekend-bg:    rgba(0, 0, 0, 0.022);
  --frost-bg:      rgba(255, 255, 255, 0.88);

  --logo-muted: rgba(0, 0, 0, 0.12);

  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md:     0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg:     0 8px 30px rgba(0, 0, 0, 0.16);
}

/* Light theme grid cell overrides */
.tw [data-theme="light"] .grid-cell { background: #edf0f3; }
.tw [data-theme="light"] .grid-cell.has-events { background: transparent; }
.tw [data-theme="light"] .day-row.even .grid-cell:not(.invalid):not(.has-events) { background: rgba(0,0,0,0.015); }
.tw [data-theme="light"] .grid-cell.weekend:not(.has-events):not(.today) { background: rgba(0,0,0,0.025); }
.tw [data-theme="light"] .day-num { color: rgba(0,0,0,0.28); }
.tw [data-theme="light"] .day-num-today { color: var(--accent); }
.tw [data-theme="light"] .event-bar { box-shadow: 0 1px 3px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2); }
.tw [data-theme="light"] .month-header { background: linear-gradient(180deg, #edf0f3 0%, rgba(237,240,243,0.5) 100%); }
.tw [data-theme="light"] .today-dot { background: var(--accent); }
.tw [data-theme="light"] .holiday-label { color: #92400e; }
.tw [data-theme="light"] .grid-cell.holiday { border-bottom-color: rgba(180,120,0,0.3); }

/* App.css */
/* ===== Skip to content (a11y) ===== */
.tw .skip-to-content {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 10000;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  padding: 0.75rem 1.25rem;
  background: var(--accent, #6c72ff);
  color: var(--text-inverse, #0a0b0f);
  border-radius: 0 0 0.5rem 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: top 0.15s ease;
}
.tw .skip-to-content:focus {
  top: 0;
  clip: auto;
  clip-path: none;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ===== Spinner (shared utility) ===== */
.tw .spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ===== App Shell — full viewport ===== */
.tw .app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

/* ===== Main — fills remaining viewport ===== */
.tw .app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.75rem 0;
  overflow: hidden;
}

/* Grid transition wrapper */
.tw .grid-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tw .grid-wrapper.slide-left {
  opacity: 0;
  transform: translateX(-12px);
}

.tw .grid-wrapper.slide-right {
  opacity: 0;
  transform: translateX(12px);
}

/* Desktop / mobile visibility helpers */
.tw .desktop-only { display: flex; }

@media (max-width: 768px), (pointer: coarse) {
  .tw .desktop-only { display: none !important; }
}

@media (max-width: 768px) {
  .tw .app-main { padding: 0.3rem 0.3rem 0; }
}

/* ===== R2-02: Empty state welcome popup ===== */
.tw .empty-state-popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  animation: hint-fade-in 0.3s ease both;
}
.tw .empty-state-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem 1.5rem;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.tw .empty-state-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}
.tw .empty-state-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 1.25rem;
}
.tw .empty-state-body kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.tw .empty-state-ok {
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.tw .empty-state-ok:hover {
  background: var(--accent-hover);
}
@keyframes hint-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== R3-04: Analytics lazy-load fallback ===== */
.tw .analytics-loading {
  flex: 1;
  min-height: 200px;
}

/* components/ui/Button.css */
/* UI-03: Button primitive — base + variant + size + loading. */

.tw .ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;                                /* D-10: spacing between icon/label slots */
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease-out, border-color 120ms ease-out, transform 80ms ease-out;
  user-select: none;
}

.tw .ui-button:hover:not(:disabled):not([aria-busy="true"]) {
  background: var(--bg-hover);
}

.tw .ui-button:active:not(:disabled):not([aria-busy="true"]) {
  transform: scale(0.98);
}

.tw .ui-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tw .ui-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ─── Variants ─── */

.tw .ui-button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}
.tw .ui-button--primary:hover:not(:disabled):not([aria-busy="true"]) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.tw .ui-button--secondary {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.tw .ui-button--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
}
.tw .ui-button--danger:hover:not(:disabled):not([aria-busy="true"]) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.tw .ui-button--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
}
.tw .ui-button--ghost:hover:not(:disabled):not([aria-busy="true"]) {
  background: var(--accent-subtle);
}

.tw .ui-button--link {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding-inline: 0;                       /* link variant has no horizontal padding */
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tw .ui-button--link:hover:not(:disabled):not([aria-busy="true"]) {
  color: var(--accent-hover);
  background: transparent;
}

/* ─── Sizes ─── */

.tw .ui-button--sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
}

.tw .ui-button--md {
  padding: 6px 14px;
  font-size: 14px;
  min-height: 34px;
}

.tw .ui-button--lg {
  padding: 9px 18px;
  font-size: 16px;
  min-height: 42px;
}

/* ─── Slots ─── */

.tw .ui-button__icon-left,
.tw .ui-button__icon-right {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.tw .ui-button__label {
  display: inline-block;
}

/* ─── Loading spinner (D-14 inline CSS-only) ─── */

.tw .ui-button__spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;  /* reuses @keyframes spin from src/index.css */
  flex-shrink: 0;
}

.tw .ui-button--sm .ui-button__spinner { width: 12px; height: 12px; border-width: 2px; }
.tw .ui-button--md .ui-button__spinner { width: 14px; height: 14px; border-width: 2px; }
.tw .ui-button--lg .ui-button__spinner { width: 16px; height: 16px; border-width: 2px; }

/* components/ui/EmptyState.css */
/* src/components/ui/EmptyState.css — UI primitive (Plan 05-02 Task 1). */

.tw .ui-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-primary);
  min-height: 200px;
}

.tw .ui-empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}

.tw .ui-empty-state__body {
  font-size: 0.875rem;
  margin: 0;
  color: var(--text-secondary);
  max-width: 32em;
  line-height: 1.5;
}

/* Pitfall 18 — animation opt-in (D-22). Motion-free by default; only consumers
 * without the OS reduce-motion flag see the fade-in. */
@media (prefers-reduced-motion: no-preference) {
  .tw .ui-empty-state {
    animation: emptyStateFadeIn 200ms ease-out;
  }
  @keyframes emptyStateFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* components/ui/Overlay.css */
/* UI-02: Overlay primitive — backdrop styling.
   OPT-IN animation per Pitfall 18: base CSS is motion-free;
   animation lives inside @media (prefers-reduced-motion: no-preference).
   Tokens consumed from src/index.css; do NOT redefine. */

.tw .ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;                     /* above existing 1000/2000/5000/9000 modal classes; below Toast 9999 (research finding #3) */
  background: var(--frost-bg);       /* token from src/index.css; light-theme override via [data-theme="light"] */
  backdrop-filter: var(--frost-blur);
  -webkit-backdrop-filter: var(--frost-blur);
  display: flex;
  align-items: center;
  justify-content: center;

  /* Base: motion-free. D-17 opt-in pattern (Pitfall 18). Reduced-motion users
     see the overlay instantly at full opacity with no transition / animation. */
  opacity: 1;
}

/* Opt-in animation: only applies when the user permits motion. D-15, D-16, D-18.
   Backdrop fades with opacity only — no scale transform (D-18). */
@media (prefers-reduced-motion: no-preference) {
  .tw .ui-overlay {
    animation: ui-overlay-fade-in 200ms ease-out;
  }
}

@keyframes ui-overlay-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* components/ui/Modal.css */
/* UI-04: Modal primitive — panel and compound sub-element styling.
   OPT-IN animation per Pitfall 18 (D-17): base is motion-free;
   animation lives inside @media (prefers-reduced-motion: no-preference).
   Tokens consumed from src/index.css; do NOT redefine.
   Overlay.css owns the backdrop — Modal.css only styles the panel and its sub-elements. */

.tw .ui-modal-panel {
  position: relative;
  max-width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;                       /* Header/Footer don't scroll; Body scrolls if needed */

  /* Base: motion-free — D-17 opt-in pattern. */
  opacity: 1;
  transform: scale(1);
}

.tw .ui-modal-panel:focus {
  outline: none;                          /* trap focus visible elsewhere; not on the panel itself */
}

/* Opt-in animation. D-15 opacity 0→1 + transform: scale(0.98→1). D-16 200ms ease-out. */
@media (prefers-reduced-motion: no-preference) {
  .tw .ui-modal-panel {
    animation: ui-modal-panel-in 200ms ease-out;
  }
}

@keyframes ui-modal-panel-in {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1);    }
}

/* ─── Compound sub-elements ─── */

.tw .ui-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.tw .ui-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.tw .ui-modal-body {
  padding: 16px 20px;
  overflow-y: auto;                       /* the only scrollable region inside the panel */
  color: var(--text-primary);
  flex-grow: 1;
}

.tw .ui-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* lib/motion/motion.css */
/* Shared motion tokens (ADR-036). Rule 1: the resting state is the base CSS of each view; the animations live in
   the views' own @media (prefers-reduced-motion: no-preference) blocks and use these tokens. */
.tw {
  --mo-ease: cubic-bezier(.22, .61, .36, 1);
}

/* Final value for screen readers while the ticking digits are aria-hidden */
.tw .mo-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Shared by the calendar grid and the phone view: a bar draws top to bottom. The -4px sides keep the bar's own shadow
   inside the clip, so nothing pops when the class is removed at the end. */
@keyframes moBarDraw {
  from { clip-path: inset(-4px -4px 100% -4px); }
  to   { clip-path: inset(-4px); }
}

/* components/motionView.css */
/* Shared by the M2 views (ADR-036). The resting state is each view's base CSS; everything here is inside the
   no-preference block, so under reduced motion nothing runs and the clock element is not even drawn. */

/* The view's clock (A-188): a 0 x 0 element that runs the shared moBarDraw for as long as the fill-in should last.
   PlaybackRoot waits for that animation, so the mo- class stays on exactly that long. */
.tw .mo-clock {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .tw .mo-clock { animation: moBarDraw var(--mo-clock, 1400ms) linear; }

  /* The one rise: 8 px and a fade, ending on the base style. Each view applies it with its own delay (--ri x 60 ms). */
  @keyframes moRise {
    from { opacity: 0; transform: translateY(8px); }
  }
}

/* BUG-162: a flat overlay for dialogs that open on moving content. The default .ui-overlay re-samples a 20 px blur every
   frame under the count-up and rise (headless Chromium: 73 frames in 2 s against 117 without it), and at 85% opacity the
   blur adds little. This keeps the page behind as unreadable (the old fill plus the 8 and 6 points the blur softened), and
   is constant, never switched off only while animating (it would pop back). Two classes beat the primitive's one by
   specificity, not by stylesheet order. Used by Year in Review; M3's share dialog takes it too. The default is unchanged. */
.tw .ui-overlay.ui-overlay--flat {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(18, 20, 28, 0.93);
}
.tw [data-theme="light"] .ui-overlay.ui-overlay--flat {
  background: rgba(255, 255, 255, 0.94);
}

/* components/AppHeader.css */
/* ===== Brand mark ===== */
.tw .header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  cursor: default;
}

.tw .brand-logo {
  flex-shrink: 0;
  opacity: 0.95;
}

.tw .brand-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  font-family: 'JetBrains Mono', monospace;
}

/* ===== Year nav — premium button style ===== */
.tw .year-nav-center {
  display: flex;
  align-items: center;
  position: relative;
}

.tw .year-nav-group {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 2px;
  flex-shrink: 0;
}

.tw .year-nav-btn {
  /* Gap B (05.1-03): min-width reserves a uniform tappable area so ‹ and › look symmetric
     despite the chevrons' intrinsic stroke-width difference. inline-flex centers the glyph
     inside the reserved box. Vertical padding matches .current-year-btn (0.3rem) so all
     3 chip children share a baseline. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 0.3rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius-md);
  font-size: 1rem;
  line-height: 1;
  font-weight: 400;
  transition: all 0.12s ease;
  font-family: inherit;
}
.tw .year-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tw .current-year-btn {
  /* Gap B (05.1-03): padding vertical (0.3rem) matches .year-nav-btn so the year text
     shares a baseline with ‹ and ›. gap removed because .year-dot is now absolutely
     positioned (no inline space needed). min-width:72px preserved for 4-digit-year layout
     stability. */
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 0.3rem 0.7rem;
  letter-spacing: 0.04em;
  transition: opacity 0.15s, transform 0.15s, color 0.15s;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  cursor: default;
}
.tw .current-year-btn.is-current {
  color: var(--accent);
  cursor: default;
}
.tw .current-year-btn:not(.is-current) {
  cursor: pointer;
  color: var(--text-secondary);
}
.tw .current-year-btn:not(.is-current):hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tw .current-year-btn.slide-left { opacity: 0; transform: translateX(-8px); }
.tw .current-year-btn.slide-right { opacity: 0; transform: translateX(8px); }

.tw .year-dot {
  /* Gap B (05.1-03): absolutely positioned overlay so the year text occupies the full
     flex-centered area of .current-year-btn. The dot now sits on the right edge of the
     chip without pushing the year text leftward. */
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(108, 114, 255, 0.6);
  transition: opacity 0.15s;
}

.tw .year-dot-hidden {
  opacity: 0;
}

/* R2-07: Days-away counter — absolutely positioned to prevent year-nav shift */
.tw .days-away-counter {
  position: absolute;
  left: calc(100% + 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--text-tertiary);
  opacity: 0.7;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: opacity 0.15s;
}

.tw .days-away-counter.days-away-hidden {
  visibility: hidden;
}

.tw .days-away-counter:hover {
  opacity: 1;
}

/* ===== Header — compact, sticky ===== */
.tw .app-header {
  background: var(--frost-bg);
  backdrop-filter: var(--frost-blur);
  -webkit-backdrop-filter: var(--frost-blur);
  border-bottom: 1px solid var(--border-subtle);
  /* BUG-173 F4: clear of a notch in landscape; both insets are 0 elsewhere, so nothing moves. */
  padding: 0.5rem max(1rem, env(safe-area-inset-right, 0px)) 0.5rem max(1rem, env(safe-area-inset-left, 0px));
  flex-shrink: 0;
  z-index: 50;
}

.tw .header-content {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.tw .app-header h1 {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ===== Utility buttons ===== */
.tw .header-utils {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.tw .util-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.68rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.12s ease;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
}
.tw .util-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.tw .util-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(108, 114, 255, 0.25);
}
.tw .util-btn.icon-only { padding: 0.3rem 0.4rem; }

/* ===== Search trigger kbd hint ===== */
.tw .search-trigger { gap: 0.4rem; }
.tw .util-kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  padding: 0.08rem 0.3rem;
  color: var(--text-tertiary);
  line-height: 1.4;
  opacity: 0.75;
}
@media (max-width: 900px) { .tw .search-trigger .util-kbd { display: none; } }

/* ===== Dividers between button groups ===== */
.tw .util-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  flex-shrink: 0;
  margin: 0 0.1rem;
}

/* ===== New event button in header ===== */
.tw .new-event-btn {
  background: var(--accent) !important;
  color: var(--text-inverse) !important;
  border-color: transparent !important;
  font-weight: 600 !important;
}
.tw .new-event-btn:hover {
  background: var(--accent-hover) !important;
  box-shadow: 0 0 12px rgba(108,114,255,0.35);
}
.tw .new-event-btn .util-kbd {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.2);
  color: var(--text-inverse);
  opacity: 1;
}
/* BUG-040: in light the 15% white tint lightened the accent under white text
   (4.34:1); without it 5.86:1 at rest, 7.25:1 on hover. Border kept. Dark keeps
   the tint (6.43:1, approved in 261001-d0p). */
.tw [data-theme="light"] .new-event-btn .util-kbd {
  background: transparent;
}
.tw .new-event-plus {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1;
  margin-right: -0.1rem;
}

/* ===== Export dropdown ===== */
.tw .export-dropdown-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.65rem 0.2rem;
}

.tw .export-dropdown-wrap {
  position: relative;
}

.tw .export-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 160px;
  padding: 4px;
  animation: dropIn 0.12s ease-out;
}

.tw .export-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.1s;
}

.tw .export-dropdown button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tw .export-dropdown-tip {
  padding: 0.4rem 0.65rem 0.3rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text-secondary);
}

.tw .export-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
}

.tw .export-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.3rem 0;
}

/* ===== User avatar & menu ===== */
.tw .user-menu {
  position: relative;
}

.tw .user-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: var(--text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid rgba(108, 114, 255, 0.3);
  transition: all 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.tw .user-avatar:hover {
  background: var(--accent-hover);
  border-color: rgba(108, 114, 255, 0.6);
  box-shadow: 0 0 10px rgba(108, 114, 255, 0.25);
}

.tw .user-dropdown {
  display: block;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  animation: dropIn 0.12s ease-out;
}

.tw .user-email {
  padding: 0.6rem 0.75rem 0.4rem;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border-subtle);
}

.tw .user-signout {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s;
}

.tw .user-signout:hover {
  background: var(--bg-hover);
  color: var(--danger);
}

/* ===== Sync status indicator ===== */
.tw .sync-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.tw .sync-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tw .sync-dot--pulse {
  background: var(--accent);
  animation: sync-pulse 1s ease-in-out infinite;
}

.tw .sync-dot--ok {
  background: #3dba6e;
  animation: sync-ok-fade 3s ease forwards;
}

.tw .sync-dot--err {
  font-size: 0.75rem;
  line-height: 1;
  width: auto;
  height: auto;
  color: #f0a020;
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

@keyframes sync-ok-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Filter badge ===== */
.tw .filter-badge {
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.55rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  padding: 0.05rem 0.3rem;
  border-radius: 100px;
  min-width: 14px;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  /* BUG-173 F4: this rule wins on every phone (width <= 768), so it carries the inset too. */
  .tw .app-header { padding: 0.4rem max(0.5rem, env(safe-area-inset-right, 0px)) 0.4rem max(0.5rem, env(safe-area-inset-left, 0px)); }
  .tw .header-brand { display: none; }
  .tw .current-year-btn { font-size: 0.85rem; padding: 0.2rem 0.5rem; }
  .tw .util-btn { font-size: 0.62rem; padding: 0.25rem 0.45rem; }
  /* BUG-206: a thumb target of 32 x 32 px (WCAG 2.5.8 asks for 24; they measured 22.6 to 26.8 before). The glyph stays centred. */
  .tw .util-btn { min-width: 32px; min-height: 32px; justify-content: center; }
  .tw .search-trigger span { display: none; }
}
@media (max-width: 480px) {
  .tw .util-btn span { display: none; }
  .tw .util-btn { padding: 0.3rem 0.4rem; }
  /* S2.3 (lucas's header ruling): the plan chip needs the room. The dividers go, and so does Help: it duplicates
     Settings > Guided Tour. Without these the chip pushed the avatar 14 px off a 390 px screen (BUG-098). */
  .tw .header-utils .util-divider { display: none; }
  .tw .help-btn { display: none; }
}
@media (max-width: 380px) {
  .tw .header-utils { gap: 0.1rem; }
  .tw .util-btn { padding: 0.3rem 0.3rem; }
}
@media (max-width: 360px) {
  /* year nav: no dot, no padding, no minimum width */
  .tw .current-year-btn { min-width: 0; padding: 0.2rem 0.25rem; }
  .tw .year-dot { display: none; }
  /* BUG-206: the signed-in row (plan chip and avatar) does not fit with 32 px targets from here down: 28 x 28 fits at 360 px. */
  .tw .util-btn { min-width: 28px; min-height: 28px; }
}
/* BUG-218: from 361 to 383 px the signed-in row was 374 px wide (384 from 381) and ran past the viewport: the Free chip put the avatar 0.1 to 13 px off
   screen at 361 to 373 and 381 to 383, "Pro" at 361 to 368 (measured one pixel width at a time in Chromium, docs/testing/G2.md). The 360 px
   compaction (no year dot, no year-button padding, 28 px targets) now also covers 361 to 383, so the row fits wherever it is shown. */
@media (min-width: 361px) and (max-width: 383px) {
  .tw .current-year-btn { min-width: 0; padding: 0.2rem 0.25rem; }
  .tw .year-dot { display: none; }
  .tw .util-btn { min-width: 28px; min-height: 28px; }
}
@media (max-width: 340px) {
  /* BUG-206: at 320 px the signed-in row needs the WCAG 2.5.8 minimum itself (24 x 24 px); 28 left the avatar 9 px off screen. */
  .tw .util-btn { min-width: 24px; min-height: 24px; }
}

/* ===== hide-xs for very small screens ===== */
@media (max-width: 700px) { .tw .hide-xs { display: none; } }

/* ===== Travel ledger button and Export entries (S2.3 slice 3) =====
   The button is .desktop-only: hidden at 768 px and below and on touch, so NOTHING is added to the header at 480 px or below (BUG-098). */
.tw .ledger-btn-pro { display: inline-flex; align-items: center; gap: 0.2rem; margin-left: 0.3rem; font-size: 0.7rem; font-weight: 600; color: var(--lock); }
.tw .export-dropdown button .ledger-btn-pro { margin-left: 0.5rem; }
/* Below 1100 px the header has no spare width for the word: the padlock stays and the name still says "Pro feature" (lucas decides, L9). */
@media (max-width: 1099px) { .tw .ledger-nav-btn .ledger-btn-pro > span { display: none; } }
/* Where the label does not fit (under 1024 px) the button is hidden; the Settings row opens the ledger at every width. The header already runs
   out of room between 769 and about 950 px without it, so it must not take room there (measured in Chromium, L9). */
@media (max-width: 1023px) { .tw .ledger-nav-btn { display: none !important; } }

/* ===== Tablet header (lucas, L9; BUG-098, BUG-100) =====
   Between 769 and 1099 px the header ran past the viewport (874 px of content in an 800 px window), which pushed the plan chip and the avatar
   off screen: no account menu, no sign-out, no buy route. Below 1100 px the text labels of Search, Filter, Analytics, Import and Export go,
   as they already do at 480 px; "New" keeps its word. Every one of those buttons keeps its aria-label and a title. */
@media (max-width: 1099px) {
  .tw .util-btn .util-label { display: none; }
  .tw .search-trigger .util-kbd { display: none; }
  /* the days-away counter sat half under New at 800 px; the year view carries the same count (lucas, L9) */
  .tw .year-nav-center .days-away-counter { display: none; }
}

/* components/YearGrid.css */
/* ===== Container — fills viewport remainder ===== */
.tw .year-grid-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Grid panel ===== */
.tw .year-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  /* BUG-173 F2: unchanged from before; the heartbeat strip above the sticky header depends on the 0.4rem. */
  padding: 0.4rem 0.5rem 0;
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  /* BUG-173 rule 2: a window shorter than the 31-row minimum scrolls here, instead of squashing the rows. */
  overflow-x: hidden;
  overflow-y: auto;
}

/* ===== Month Headers ===== */
.tw .month-header-row {
  display: grid;
  grid-template-columns: 28px repeat(12, 1fr);
  gap: 2px;
  flex-shrink: 0;
  padding: 0 0 3px;
  /* BUG-173 rule 2: pinned while the rows scroll; opaque so rows pass beneath it. Sticky offsets count from inside the
     scroll container's padding, so -0.4rem cancels .year-grid's 0.4rem top padding and the header pins at the card's
     top edge with no gap for rows to show through (F8). */
  position: sticky;
  top: -0.4rem;
  z-index: 7;
  background: var(--bg-surface);
}

.tw .corner-cell { /* empty */ }

/* P2-5: Quarter labels — Q1 Jan, Q2 Apr, Q3 Jul, Q4 Oct */
.tw .quarter-label {
  display: block;
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  opacity: 0.4;
  line-height: 1;
  margin-bottom: 1px;
}

.tw .month-header {
  text-align: center;
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.45rem 0 0.4rem;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, rgba(26, 29, 40, 0.5) 100%);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  position: relative;
  overflow: hidden;
  transition: color 0.15s;
}

.tw .month-header.current-month {
  color: var(--accent);
  background: linear-gradient(180deg, rgba(108, 114, 255, 0.1) 0%, rgba(108, 114, 255, 0.025) 100%);
}

/* R1-08: past month headers — dimmed to match past cells */
.tw .month-header.past-month {
  opacity: 0.5;
}

/* R2-03: Quarter dividers — 1.5px rules between Q1|Q2|Q3|Q4 */
.tw .month-header.quarter-start,
.tw .grid-cell.quarter-start {
  border-left: 1.5px solid rgba(255, 255, 255, 0.06);
}
.tw .grid-cell.quarter-start.invalid {
  border-left-color: transparent;
}

/* R1-02: accent bar moved to top edge of column header */
.tw .month-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 1px 1px;
  box-shadow: 0 0 10px rgba(108, 114, 255, 0.5);
}

.tw .month-name { position: relative; z-index: 1; }

/* ===== Grid Body — 31 rows fill height ===== */
.tw .grid-body {
  flex: 1;
  /* BUG-173 rule 2: a row never goes under 16 px (the .event-bar minimum); 31 * 16 + 30 gaps = 526 px. Taller windows are unchanged. */
  min-height: calc(31 * 16px + 30px);
  display: grid;
  grid-template-rows: repeat(31, minmax(16px, 1fr));
  gap: 1px;
  overflow: hidden;
}

/* ===== Day Rows ===== */
.tw .day-row {
  display: grid;
  grid-template-columns: 28px repeat(12, 1fr);
  gap: 2px;
  min-height: 0;
}

/* R1-04: today-row tint removed — row accent competes with event colors */

/* R1-08 + R2-01 + P2-1: Temporal brightness — past/present/future
   Applied at grid-cell level so continuation filters on event-bar stack naturally.
   Past = 0.8 when empty, present = 1.0 (default), future = 1.2 when empty. A cell with events keeps its colours honest
   (dense-calendar 13.1): the label must stay at 4.5:1, so a past event cell dims by PAST_EVENT_DIM only and a future event
   cell is not lifted at all. */
.tw .grid-cell.is-past:not(.has-events) {
  filter: brightness(0.8);
}
/* PAST_EVENT_DIM in src/utils/colors.js: this number and that constant change together (labelInk.test.js pins it). */
.tw .grid-cell.is-past.has-events {
  filter: brightness(0.95) saturate(0.75);
}
/* Round 2 (13.3, Erik: "brighten the remaining month to enhance the contrast, nothing crazy"): NOW_EVENT_LIFT in colors.js. 2 percent is
   the most a tile can take; the visible gap comes from the past losing colour and the empty cells of the current month brightening. */
.tw .grid-cell.has-events:not(.is-past):not(.invalid) {
  filter: brightness(1.02);
}
.tw .grid-cell.is-past:not(.has-events) {
  opacity: 0.3;
}
.tw .grid-cell.is-past .holiday-label {
  opacity: 0.25;
}

.tw .grid-cell.is-future:not(.has-events) {
  filter: brightness(1.2);
}

/* P2-1: Future month headers — brighter to match future cells */
.tw .month-header.future-month {
  opacity: 1.0;
}

/* R1-01: current month column tint — a subtle spine running down the active month */
.tw .grid-cell.current-month-col:not(.has-events):not(.invalid) {
  background: rgba(108, 114, 255, 0.032);
  filter: brightness(1.1);
}
.tw .grid-cell.current-month-col.weekend:not(.has-events)::before {
  background: rgba(0, 0, 0, 0.12);
}

/* Day labels — R1-05: axis font size reduced to 0.65rem for better proportion */
.tw .day-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-tertiary);
  user-select: none;
  transition: color 0.15s;
}

.tw .day-label.today-label {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Grid Cells ===== */
/* R1-07: border-radius increased 2px → 5px for softer, more refined feel */
.tw .grid-cell {
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.1s ease, box-shadow 0.1s ease;
  padding: 1px 2px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  background: var(--bg-elevated);
  min-height: 0;
}

.tw .grid-cell:hover {
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* R1-06: + affordance on empty cell hover — answers "what do I do here?" */
.tw .grid-cell:not(.has-events):not(.invalid):hover::after {
  content: '+';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  opacity: 0.35;
  pointer-events: none;
  z-index: 1;
}

/* R2-06: Free window glow — 4+ consecutive empty future days glow subtly brighter */
.tw .grid-cell.free-window {
  background: rgba(255, 255, 255, 0.035);
}
.tw .grid-cell.free-window.weekend::before {
  background: rgba(0, 0, 0, 0.10);
}
.tw .grid-cell.free-window.current-month-col {
  background: rgba(108, 114, 255, 0.05);
}

@media (hover: none) {
  .tw .grid-cell:not(.has-events):not(.invalid):hover::after { display: none; }
}

.tw .grid-cell.invalid {
  background: transparent;
  cursor: default;
  opacity: 0;
  pointer-events: none;
}

.tw .grid-cell.has-events {
  background: transparent;
}

.tw .grid-cell.has-events:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ── Weekend — darker charcoal, no hue competition with event colors ── */
.tw .grid-cell.weekend::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
}

.tw .grid-cell.weekend:hover::before {
  background: rgba(0, 0, 0, 0.08);
}

/* ===== Today Marker ===== */
.tw .grid-cell.today {
  box-shadow:
    inset 0 0 0 1.5px var(--accent),
    0 0 8px rgba(108, 114, 255, 0.18);
}

.tw .today-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  z-index: 2;
}

/* The ring (BUG-160): invisible at rest. It only ever animates inside the no-preference block at the foot of this file. */
.tw .today-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
}

/* ===== Holiday markers ===== */
.tw .grid-cell.holiday {
  border-bottom: 2px solid rgba(255, 180, 50, 0.35);
}

/* R3-04 + dense calendar (Option B): a day with 2 or more events is a crowded cell. Its tiles stand side by side in a row (a
   cell has no vertical room for a second 16 px bar: BUG-207), 15 px stay free on the right for the day number (the 13 px
   gutter plus the cell padding), and the amber mark is an inset shadow so it takes no height. */
.tw .grid-cell.has-conflict {
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1px;
  padding-right: 15px;
  box-shadow: inset 0 2px 0 rgba(251, 176, 59, 0.55);
}
.tw .grid-cell.has-conflict.is-past {
  box-shadow: inset 0 2px 0 rgba(251, 176, 59, 0.3);
}
/* The amber mark must survive the other states that own the cell's shadow. */
/* A quarter-start column has a 1.5 px left border: take it from the padding so its tiles are as wide as every other column's. */
.tw .grid-cell.has-conflict.quarter-start {
  padding-left: 0.5px;
}
.tw .grid-cell.has-conflict:hover {
  box-shadow: inset 0 2px 0 rgba(251, 176, 59, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.tw .grid-cell.has-conflict.today {
  box-shadow:
    inset 0 2px 0 rgba(251, 176, 59, 0.55),
    inset 0 0 0 1.5px var(--accent),
    0 0 8px rgba(108, 114, 255, 0.18);
}

.tw .holiday-label {
  font-size: 0.42rem;
  font-weight: 500;
  color: rgba(255, 180, 50, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  padding: 0 2px;
  letter-spacing: 0.01em;
}

.tw .holiday-tick {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 180, 50, 0.5);
  z-index: 1;
}

/* ===== Day number — top-right of each valid cell ===== */
/* R1-05: day-num increased 0.54rem → 0.65rem — axis labels must be quiet but legible */
.tw .day-num {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-tertiary);
  line-height: 1;
  z-index: 4;
  pointer-events: none;
  user-select: none;
  letter-spacing: -0.02em;
  opacity: 0.8;
}

.tw .day-num-on-event {
  opacity: 1;
}

/* In a crowded cell the number sits in the gutter, right of the tiles, on the cell background. */
.tw .grid-cell.has-conflict .day-num {
  right: 2px;
}

.tw .day-num-today {
  color: var(--accent) !important;
  opacity: 1;
  font-weight: 700;
}

.tw .weekend-label {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 0.44rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.65;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 3;
}

/* ===== Event Bars ===== */
/* R1-07: bar border-radius increased 3px → 5px to match cell radius */
.tw .event-bar {
  flex: 1;
  min-height: 16px;
  max-height: 24px;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-size: 0.6rem;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
  display: flex;
  align-items: center;
  padding: 0 5px;
  z-index: 3;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.tw .bar-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0) 40%,
    rgba(0, 0, 0, 0.06) 100%
  );
  pointer-events: none;
  border-radius: inherit;
}

.tw .event-bar:hover {
  transform: translateY(-1px) scaleY(1.05);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 0 14px color-mix(in srgb, var(--bar-color) 35%, transparent);
  z-index: 5;
  filter: brightness(1.1);
}

.tw .event-bar.has-label {
  padding-left: 6px;
}

/* R1-03: continuation cells — reduced opacity creates a river with a clear source */
/* P2-4: dialled from 0.45→0.50 — visible colour difference while preserving vibrancy */
.tw .event-bar.is-continuation {
  filter: brightness(0.50) saturate(0.70);
}

/* The start day used to get brightness(1.05) here. Removed (dense-calendar 13.1): it cost 0.3 to 0.4 of label contrast on
   every colour, and the label and the bar's shape already mark the start. */

.tw .event-bar.is-continuation .bar-shine {
  display: none;
}

/* Hide chevrons on continuation bars — too faint at low opacity, looks like artifacts */
.tw .event-bar.is-continuation.continues-prev::before,
.tw .event-bar.is-continuation.continues-next::after {
  display: none;
}

.tw .event-bar.is-end {
  border-radius: 3px 5px 5px 3px;
}

/* R2-02: Cross-month connectors — flat edges + chevrons link events across columns */
.tw .event-bar.continues-next {
  border-radius: 5px 1px 1px 5px;
}

.tw .event-bar.continues-prev {
  border-radius: 1px 5px 5px 1px;
}

.tw .event-bar.continues-prev.continues-next {
  border-radius: 1px;
}

/* Chevron on right edge: → signals "continues into next month" */
.tw .event-bar.continues-next::after {
  content: '';
  position: absolute;
  right: 1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-left: 3px solid currentColor;
  opacity: 0.4;
  z-index: 2;
  pointer-events: none;
}

/* Chevron on left edge: ← signals "continues from previous month" */
.tw .event-bar.continues-prev::before {
  content: '';
  position: absolute;
  left: 1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-right: 3px solid currentColor;
  opacity: 0.4;
  z-index: 2;
  pointer-events: none;
}

/* Combined: event ends in this month but started in prev — flat left, rounded right */
.tw .event-bar.is-end.continues-prev {
  border-radius: 1px 5px 5px 1px;
}

/* R3-05b: tentative events — dashed border + reduced opacity signals "not yet confirmed" */
.tw .event-bar.is-tentative {
  opacity: 0.55;
  border: 1.5px dashed rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

.tw .event-bar.is-tentative .bar-shine {
  display: none;
}

.tw .event-bar.is-tentative:hover {
  opacity: 0.75;
}

/* ===== Tiles (dense calendar): one per event, side by side in a crowded cell ===== */
/* Specificity (0,3,0) and later in the file than the single-bar rules, so a tile's own radius, size and shadow win over
   .is-end, .continues-prev and friends. The tile keeps the .event-bar class: the fill-in animation selects it. */
.tw .grid-cell.has-conflict .event-bar {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  max-height: none;
  padding: 0;
  border-radius: 3px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset -1px 0 0 rgba(0, 0, 0, 0.35);
}
.tw .grid-cell.has-conflict .event-bar:hover {
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset -1px 0 0 rgba(0, 0, 0, 0.35),
    0 0 14px color-mix(in srgb, var(--bar-color) 35%, transparent);
}
/* A tentative tile marks itself with an outline, not a border: a border adds to a flex item's size and made one tile 2 px
   wider than its neighbours (12.8 against 14.8 px measured at 1024). */
.tw .grid-cell.has-conflict .event-bar.is-tentative {
  border: 0;
  outline: 1px dashed rgba(255, 255, 255, 0.3);
  outline-offset: -1px;
  box-shadow: none;
}
/* The space round a tile's name is the label's margin, not the tile's padding: padding on a zero-basis flex item adds to its base size,
   which made a labelled tile 7 px wider than an unlabelled neighbour (round 3, measured). */
.tw .grid-cell.has-conflict .event-bar.has-label {
  padding: 0;
}
.tw .grid-cell.has-conflict .event-label {
  margin: 0 3px 0 4px;
}
/* Every tile divides the width equally (Erik, round 3; spec 5 point 3 had 60/40 for two events). A tile that starts today carries its name
   with the .event-label fade, at any width. */

/* "+N": the events a crowded day cannot draw. Neutral on purpose (no event colour), 13 px at least. */
.tw .event-chip {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 13px;
  padding: 0 1px;
  border-radius: 3px;
  background: var(--bg-hover);
  box-shadow: inset 0 0 0 1px var(--text-secondary);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  user-select: none;
}

/* The strip right of the tiles that holds the day number. Hovering it lists every event of the day. */
.tw .cell-gutter {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 15px;
  z-index: 2;
}

/* R1-10: gradient label mask — text fades out at right edge instead of hard clip */
/* R3-02: JetBrains Mono on event labels — consistent monospace identity across the grid */
.tw .event-label {
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  /* Gradient mask: text visible left, fades to transparent at right edge */
  -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
  mask-image: linear-gradient(to right, black 80%, transparent 100%);
}

/* R3-06: Emoji rendered larger in event labels — visual anchors for emotional content */
.tw .emoji-anchor {
  font-size: 1.15em;
  line-height: 1;
  vertical-align: baseline;
  letter-spacing: 0.02em;
}

.tw .event-duration {
  position: absolute;
  bottom: 2px;
  left: 4px;
  font-size: 0.44rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  letter-spacing: 0.02em;
  opacity: 0.7;
  pointer-events: none;
  z-index: 3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .tw .month-header { font-size: 0.62rem; }
  .tw .event-label { font-size: 0.54rem; }
}

@media (max-width: 768px) {
  .tw .year-grid-container { margin: 0; }
  .tw .year-grid {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 0.3rem 0.3rem 0;
  }
  .tw .grid-body {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .tw .month-header-row { grid-template-columns: 24px repeat(12, minmax(60px, 1fr)); }
  .tw .day-row { grid-template-columns: 24px repeat(12, minmax(60px, 1fr)); }
  .tw .day-label {
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--bg-surface);
    font-size: 0.5rem;
  }
  .tw .corner-cell {
    position: sticky;
    left: 0;
    z-index: 6;
    background: var(--bg-surface);
  }
  .tw .month-header { font-size: 0.55rem; padding: 0.3rem 0; }
  .tw .event-label { font-size: 0.5rem; }
  .tw .event-bar { padding: 0 3px; }
  /* A 60 px column leaves no room for a 15 px gutter and 14 px tiles: a smaller number and a 13 px gutter keep three tiles at 14 px. */
  .tw .grid-cell.has-conflict { padding-right: 13px; }
  .tw .grid-cell.has-conflict .day-num { right: 1px; font-size: 0.55rem; }
  .tw .cell-gutter { width: 13px; }
}

@media (max-width: 480px) {
  .tw .day-row { grid-template-columns: 20px repeat(12, minmax(48px, 1fr)); }
  .tw .month-header-row { grid-template-columns: 20px repeat(12, minmax(48px, 1fr)); }
}

/* ─── S3-01: Drag-to-create selection ──────────────────────────────────── */
/* Shift+drag (desktop) or long-press-drag (touch) selects a date range */
.tw .grid-cell.drag-selected {
  background: rgba(108, 114, 255, 0.18) !important;
  box-shadow: inset 0 0 0 1.5px rgba(108, 114, 255, 0.4);
  z-index: 3;
}

.tw .grid-cell.drag-selected.weekend::before {
  background: rgba(0, 0, 0, 0.06);
}

.tw .grid-body.is-dragging {
  cursor: crosshair;
  user-select: none;
}

.tw .grid-body.is-dragging .grid-cell {
  cursor: crosshair;
  pointer-events: auto;
}

/* Suppress hover effects during drag */
.tw .grid-body.is-dragging .grid-cell:hover {
  box-shadow: none;
}
.tw .grid-body.is-dragging .grid-cell:not(.has-events):not(.invalid):hover::after {
  display: none;
}

/* ─── R5-02: Week number label ───────────────────────────────────────────── */
.tw .week-num {
  display: block;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  opacity: 1;
  line-height: 1;
  margin-top: 1px;
}

/* ─── Open / import / year-change motion (ADR-036, src/lib/motion) ───
   The resting state is the CSS above. These rules apply only while YearGrid has set .mo-full or .mo-fast on its
   root, and only when the user permits motion. Chrome (grid lines, today marker, weekend shading, holidays, header)
   is never animated: it is there from frame one. Only the event bars draw, top to bottom, with a delay that is
   the month column (--mi, set per cell position) plus the day row (--di, set per row), so the 12 columns fill
   left to right as a wave. The animation is declared once per class, not per bar. */
@media (prefers-reduced-motion: no-preference) {
  .tw .mo-full { --mo-step: 84ms; --mo-day-step: 8ms; --mo-bar-ms: 300ms; }
  .tw .mo-fast { --mo-step: 10ms; --mo-day-step: 3ms; --mo-bar-ms: 250ms; }

  .tw .mo-full .day-row > .grid-cell:nth-child(2),  .tw .mo-fast .day-row > .grid-cell:nth-child(2)  { --mi: 0; }
  .tw .mo-full .day-row > .grid-cell:nth-child(3),  .tw .mo-fast .day-row > .grid-cell:nth-child(3)  { --mi: 1; }
  .tw .mo-full .day-row > .grid-cell:nth-child(4),  .tw .mo-fast .day-row > .grid-cell:nth-child(4)  { --mi: 2; }
  .tw .mo-full .day-row > .grid-cell:nth-child(5),  .tw .mo-fast .day-row > .grid-cell:nth-child(5)  { --mi: 3; }
  .tw .mo-full .day-row > .grid-cell:nth-child(6),  .tw .mo-fast .day-row > .grid-cell:nth-child(6)  { --mi: 4; }
  .tw .mo-full .day-row > .grid-cell:nth-child(7),  .tw .mo-fast .day-row > .grid-cell:nth-child(7)  { --mi: 5; }
  .tw .mo-full .day-row > .grid-cell:nth-child(8),  .tw .mo-fast .day-row > .grid-cell:nth-child(8)  { --mi: 6; }
  .tw .mo-full .day-row > .grid-cell:nth-child(9),  .tw .mo-fast .day-row > .grid-cell:nth-child(9)  { --mi: 7; }
  .tw .mo-full .day-row > .grid-cell:nth-child(10), .tw .mo-fast .day-row > .grid-cell:nth-child(10) { --mi: 8; }
  .tw .mo-full .day-row > .grid-cell:nth-child(11), .tw .mo-fast .day-row > .grid-cell:nth-child(11) { --mi: 9; }
  .tw .mo-full .day-row > .grid-cell:nth-child(12), .tw .mo-fast .day-row > .grid-cell:nth-child(12) { --mi: 10; }
  .tw .mo-full .day-row > .grid-cell:nth-child(13), .tw .mo-fast .day-row > .grid-cell:nth-child(13) { --mi: 11; }

  .tw .mo-full .event-bar,
  .tw .mo-fast .event-bar {
    animation: moBarDraw var(--mo-bar-ms) var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) backwards;
    animation-delay: calc(var(--mi, 0) * var(--mo-step) + var(--di, 0) * var(--mo-day-step));
  }

  /* The today ring (BUG-160): a greeting, two rings of 2.4 s (4.8 s in all, under WCAG 2.2.2's 5 s), transform and
     opacity only. It is declared only while no fill-in plays and none is awaited, so it starts when the fill-in ends. */
  .tw .year-grid-container:not(.mo-full):not(.mo-fast):not(.mo-wait) .today-dot::after {
    animation: todayRing 2.4s var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) 2;
  }
}

@keyframes todayRing {
  from { transform: scale(1); opacity: 0.6; }
  to   { transform: scale(3); opacity: 0; }
}

/* components/Heartbeat.css */
/* ─── Heartbeat ───────────────────────────────────────────────
   The year as a Tide (M6, ADR-040; spec docs/design/M6-tide-heartbeat.md). One continuous liquid form across the year,
   shaped by every event-day: a deep layer (work) under a pale layer (everything else, the total). Two sibling <svg>
   elements, each its own absolutely positioned box, so a transform on them can run on the compositor (a transform on an svg
   child repaints the whole svg every frame). The 12 empty .hb-col boxes are the column mirror of the month headers (BUG-031).

   Box formula: 1200 units are the 12 columns plus their 11 gaps of 2 px (W + 2 px). The viewBox is 1248 units wide (24 either
   side, so the pale layer's sideways slide never shows a gap), which is 1.04 x (W + 2) = 104% + 2.08px, starting 24 units
   (2% + 0.04px) left of January. Month i's left edge is then exactly column i's left edge.

   No stroke, no opacity, no filter, no blur, no mask, no color-mix (html2canvas cannot parse it, BUG-181), no will-change,
   nothing infinite: a test fails on each of them (heartbeatTideCss.test.js). The colours are two plain hex tokens in index.css.
   ───────────────────────────────────────────────────────────── */

.tw .hb {
  display: flex;
  align-items: center;
  gap: 0;
  user-select: none;
  /* The breath recurs this often, start to start. The hook reads the number from config.js (HB_BREATH_PERIOD_MS); this copy
     is only so a test can read it back from the CSS and fail when the two differ. Nothing uses it. */
  --hb-breath-period: 7000ms;
}

.tw .hb-bars {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  height: 100%;
}

.tw .hb-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* A layer: its own box, scaled from its bottom edge. The base state is the final form. */
.tw .hb-tide {
  position: absolute;
  top: 0;
  left: calc(-2% - 0.04px);
  width: calc(104% + 2.08px);
  height: 100%;
  display: block;
  pointer-events: none;
  transform-origin: 50% 100%;
}

.tw .hb-tide-rest path {
  fill: var(--hb-pale);
}

.tw .hb-tide-work path {
  fill: var(--hb-deep);
}

/* The sign-in screen's copy (bare): no grid row around it, so it sets its own height (the component's --hb-h). */
.tw .hb-bare {
  display: block;
  width: 100%;
}

.tw .hb-bare .hb-bars {
  height: var(--hb-h, 32px);
}

/* ─── Context: YearGrid ──────────────────────────────────── */
/* The heartbeat row mirrors .month-header-row in YearGrid.css: same gutter,
   same 2px column gap, same column template at every breakpoint.
   --hb-col-gap must equal that gap. The strip is 32px at every width (M6, Erik: 32 px; it was 24). The margin below the row
   is unchanged, so the first month header sits exactly 8px lower than before and never moves during an animation. */
.tw .hb-grid-row {
  --hb-col-gap: 2px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--hb-col-gap);
  padding: 0;
  margin-bottom: 10px;
  position: relative;
}

.tw .hb-grid-row .hb {
  grid-column: 1 / -1;
  display: contents;
}

.tw .hb-grid-row .hb-bars {
  grid-column: 2 / -1;
  height: 32px;
  /* .hb-bars clips (overflow: hidden), which would make this grid item's automatic minimum width 0: the strip would shrink
     to the viewport and its 12 minmax() columns would be clipped (BUG-180). min-content keeps the strip as wide as
     its columns, scrolling with the grid. */
  min-width: min-content;
  /* Columns mirror the month columns (same gap) */
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--hb-col-gap);
  padding: 0;
  align-items: center;
}

.tw .hb-grid-row .hb-col {
  align-items: center;
  justify-content: flex-start;
}

/* ─── Responsive — match YearGrid breakpoints ────────────── */
@media (max-width: 768px) {
  .tw .hb-grid-row {
    grid-template-columns: 24px 1fr;
  }
  .tw .hb-grid-row .hb-bars {
    grid-template-columns: repeat(12, minmax(60px, 1fr));
  }
  .tw .hb-grid-row { margin-bottom: 8px; }
}

@media (max-width: 480px) {
  .tw .hb-grid-row {
    grid-template-columns: 20px 1fr;
  }
  .tw .hb-grid-row .hb-bars {
    grid-template-columns: repeat(12, minmax(48px, 1fr));
  }
  .tw .hb-grid-row { margin-bottom: 6px; }
}

/* ─── Fill-in and breath (ADR-036, ADR-040; src/lib/motion) ─────────────────
   The fill-in has its own short clock, decoupled from the calendar's class (mo-full 1500 ms): the Heartbeat sets
   .hb-tide-full or .hb-tide-fast in the same commit as the new geometry and keeps it until these animations have finished
   (useTideFill), so the strip is at rest at 2800 ms (1000 ms on a return) and the calendar still ends at 1500 ms (500 ms).
   Full: the deep layer 2600 ms, the pale layer 2400 ms from 400 ms. Fast: 900 ms, and 850 ms from 150 ms.
   Both rise from scaleY(0) past 6 percent to rest, on the one ease (--mo-ease). Only transform is animated.

   The breath is the one recurring loop ADR-040 grants. The hook (useTideBreath) puts .hb-breathing on the root for the
   length of one breath and takes it off, so between breaths nothing runs and nothing is promoted. A swell of 7 percent over
   2400 ms, symmetric (ease-in-out: it is not a view transition, so the single ease does not apply); the pale layer follows
   300 ms later and slides 1 percent of its width. No fill mode on either, so nothing is held when it ends.
   Everything is in this block, so reduced motion shows the final form at once. */
@media (prefers-reduced-motion: no-preference) {
  .tw .hb-tide-full .hb-tide-work {
    animation: hbRiseWork 2600ms var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) backwards;
  }
  .tw .hb-tide-full .hb-tide-rest {
    animation: hbRiseRest 2400ms var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) 400ms backwards;
  }
  .tw .hb-tide-fast .hb-tide-work {
    animation: hbRiseWork 900ms var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) backwards;
  }
  .tw .hb-tide-fast .hb-tide-rest {
    animation: hbRiseRest 850ms var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) 150ms backwards;
  }
  .tw .hb-breathing .hb-tide-work {
    animation: hbBreathWork 2400ms ease-in-out;
  }
  .tw .hb-breathing .hb-tide-rest {
    animation: hbBreathRest 2400ms ease-in-out 300ms;
  }
}

@keyframes hbRiseWork {
  0%   { transform: scaleY(0); }
  65%  { transform: scaleY(1.06); }
  100% { transform: scaleY(1); }
}

@keyframes hbRiseRest {
  0%   { transform: scaleY(0); }
  65%  { transform: scaleY(1.06); }
  100% { transform: scaleY(1); }
}

@keyframes hbBreathWork {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.07); }
}

@keyframes hbBreathRest {
  0%, 100% { transform: translateX(0) scaleY(1); }
  50%      { transform: translateX(1%) scaleY(1.07); }
}

/* components/SummaryBar.css */
/* ─── R4-08: Summary bar ─────────────────────────────────────────────────── */

.tw .summary-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  user-select: none;
}

.tw .sb-item {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.tw .sb-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
}

.tw .sb-label {
  color: var(--text-tertiary);
}

.tw .sb-sep {
  opacity: 0.35;
  margin: 0 0.1rem;
}

.tw .sb-hidden .sb-value {
  color: var(--accent-muted, var(--text-tertiary));
}
.tw .sb-hidden .sb-label {
  font-style: italic;
}

/* BUG-173 rule 2: below 500 px of height the rows need every pixel; the totals are still in Year Overview. */
@media (max-height: 500px) {
  .tw .summary-bar { display: none; }
}

/* components/ColorBlindPatterns.css */
/* ===================================================================
 * S2-01 + B2: Colour Blind Patterns
 * ===================================================================
 * SVG pattern overlays per location. When `.cb-patterns` is applied to
 * .year-grid-container, every event bar shows a subtle repeating pattern.
 *
 * Patterns are index-based (data-cb-pattern="0"–"9"), not tied to
 * location names. YearGrid maps each location in legendConfig to an
 * index (mod 10), so dynamic/custom locations get patterns automatically.
 *
 * Pattern vocabulary (10 patterns, cycling):
 *   0 — diagonal stripes ↗     5 — diagonal stripes ↘
 *   1 — horizontal lines       6 — diamonds
 *   2 — dots                   7 — chevrons
 *   3 — crosshatch             8 — grid dots (2×2)
 *   4 — vertical lines         9 — dashed (catch-all)
 *
 * Toggle: Settings → "Colour blind mode"
 * ================================================================ */

/* ── Base overlay layer ── */
.tw .cb-overlay {
  display: none;
}

.tw .cb-patterns .cb-overlay {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: 0.45;
  mix-blend-mode: soft-light;
  background-repeat: repeat;
  background-size: 8px 8px;
}

/* Ensure label text sits above pattern */
.tw .cb-patterns .event-label {
  z-index: 2;
}
.tw .cb-patterns .event-duration {
  z-index: 2;
}

/* ── 0: diagonal stripes ↗ ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="0"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M-1,1 l2,-2 M0,8 l8,-8 M7,9 l2,-2' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* ── 1: horizontal lines ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="1"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cline x1='0' y1='4' x2='8' y2='4' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* ── 2: dots ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="2"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='4' cy='4' r='1.5' fill='%23fff'/%3E%3C/svg%3E");
}

/* ── 3: crosshatch ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="3"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M-1,1 l2,-2 M0,8 l8,-8 M7,9 l2,-2' stroke='%23fff' stroke-width='1'/%3E%3Cpath d='M9,1 l-2,-2 M8,8 l-8,-8 M1,9 l-2,-2' stroke='%23fff' stroke-width='1'/%3E%3C/svg%3E");
}

/* ── 4: vertical lines ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="4"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cline x1='4' y1='0' x2='4' y2='8' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* ── 5: diagonal stripes ↘ ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="5"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M9,1 l-2,-2 M8,8 l-8,-8 M1,9 l-2,-2' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* ── 6: diamonds ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="6"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M4,1 L7,4 L4,7 L1,4Z' stroke='%23fff' fill='none' stroke-width='1'/%3E%3C/svg%3E");
}

/* ── 7: chevrons ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="7"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M0,6 L4,2 L8,6' stroke='%23fff' fill='none' stroke-width='1.2'/%3E%3C/svg%3E");
}

/* ── 8: grid dots (2×2) ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="8"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23fff'/%3E%3Ccircle cx='6' cy='6' r='1' fill='%23fff'/%3E%3C/svg%3E");
}

/* ── 9: dashed (catch-all for Other/None/unknown) ── */
.tw .cb-patterns .cb-overlay[data-cb-pattern="9"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cline x1='0' y1='4' x2='5' y2='4' stroke='%23fff' stroke-width='1.5' stroke-dasharray='3,3'/%3E%3C/svg%3E");
  background-size: 12px 8px;
}

/* ── Vacation type — zigzag (overrides location pattern) ── */
.tw .cb-patterns .cb-overlay[data-cb-type="vacation"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0,6 L3,2 L6,6 L9,2 L12,6' stroke='%23000' fill='none' stroke-width='1.2'/%3E%3C/svg%3E") !important;
  background-size: 12px 8px !important;
  opacity: 0.3;
}

/* ── Continuation bars: slightly reduce pattern opacity ── */
.tw .cb-patterns .event-bar.is-continuation .cb-overlay {
  opacity: 0.3;
}

/* ── Past events: muted patterns ── */
.tw .cb-patterns .grid-cell.is-past .cb-overlay {
  opacity: 0.25;
}

/* ── Tentative: no pattern (dashed border is already the signal) ── */
.tw .cb-patterns .event-bar.is-tentative .cb-overlay {
  display: none;
}

/* ── Hover: slightly boost pattern ── */
.tw .cb-patterns .event-bar:hover .cb-overlay {
  opacity: 0.55;
}

/* ── Mobile: patterns need to work at smaller bar sizes ── */
@media (max-width: 768px) {
  .tw .cb-patterns .cb-overlay {
    background-size: 6px 6px;
    opacity: 0.5;
  }
  .tw .cb-patterns .cb-overlay[data-cb-pattern="9"] {
    background-size: 10px 6px;
  }
  .tw .cb-patterns .cb-overlay[data-cb-type="vacation"] {
    background-size: 10px 6px !important;
  }
}

/* components/Analytics.css */
/* ===== Analytics — viewport-filling 2×2 grid ===== */

/* OPT-03: visually-hidden quadrant titles. Each <section aria-labelledby>
 * needs a labelable element, but the existing visual design uses per-card h3's,
 * not a quadrant-level heading. We render a quadrant-level h3 for assistive
 * tech and hide it visually with the standard sr-only pattern. */
.tw .analytics-quadrant-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tw .analytics-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* BUG-203: what does not fit (the multi-year Trajectory below the grid) scrolls; it is never clipped. */
  overflow-x: hidden;
  overflow-y: auto;
}

/* Title bar */
.tw .analytics-title-bar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-bottom: 0.35rem;
  flex-shrink: 0;
}

.tw .analytics-title-bar h2 {
  font-size: 1.05rem;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.tw .analytics-filter-note {
  font-size: 0.65rem;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  opacity: 0.8;
}

/* ===== 2×2 Master Grid ===== */
.tw .analytics-grid {
  /* BUG-203: fills the screen when it can (grow) but never shrinks below one screen of cards (basis 680px, the
     1024x768 one-year height), so the Trajectory block under it cannot squeeze it to a 58 px strip. */
  flex: 1 0 680px;
  min-height: 680px; /* an explicit floor: a flex item's automatic minimum would be its content height (1308 px) */
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.tw .analytics-quadrant {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}


/* ============================================================
   U1 — KPI Cards — 3×3 grid, cards stretch to fill
   ============================================================ */
.tw .q-kpis {
  overflow: hidden;
}

.tw .stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0.45rem;
  height: 100%;
}

.tw .stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  transition: border-color 0.15s;
  min-height: 0;
}
.tw .stat-card:hover { border-color: var(--border-strong); }
.tw .stat-card.accent { border-color: rgba(108, 114, 255, 0.25); }
.tw .stat-card.accent:hover { border-color: rgba(108, 114, 255, 0.45); }

/* 7th card — center in bottom-middle */
.tw .stat-card-last {
  grid-column: 2 / 3;
}

.tw .stat-card h3 {
  font-size: 0.62rem;
  color: var(--text-tertiary);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.tw .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.tw .stat-value-sm { font-size: 1.5rem; }
.tw .stat-unit { font-size: 0.75rem; color: var(--text-tertiary); font-weight: 500; }

.tw .stat-note {
  font-size: 0.6rem;
  color: var(--text-tertiary);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}


/* ============================================================
   U2 — Donut Charts — two cards side by side, fill quadrant
   ============================================================ */
.tw .q-donuts {
  overflow: hidden;
}

.tw .donuts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  height: 100%;
}

.tw .chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tw .chart-card h3 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  text-align: center;
  flex-shrink: 0;
}

/* Donut internals — 50/50 vertical split: chart top, legend bottom */
.tw .donut-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.tw .donut-svg-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tw .donut-svg-wrap svg {
  width: 100%;
  height: 100%;
  max-width: 200px;
  max-height: 100%;
}

.tw .donut-legend {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  overflow-y: auto;
  padding-top: 0.5rem;
  justify-content: center;
}

/* Two-column layout for legends with many items (e.g. Days by Location) */
.tw .donut-legend.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.6rem;
  align-content: start;
}

.tw .donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
}

.tw .donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tw .donut-legend-label {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw .donut-legend-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 0.65rem;
}


/* ============================================================
   D1 — Monthly Density (left) + Country Table (right)
   ============================================================ */
.tw .q-bottom-left {
  overflow: hidden;
}

.tw .d1-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
}

/* Density half */
.tw .d1-density {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tw .d1-density h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

/* ── Events per Month bar chart ── */
.tw .epm-chart {
  flex: 1;
  min-height: 80px;
}
.tw .epm-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
}
.tw .epm-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  cursor: default;
  position: relative;
}
.tw .epm-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transition: height 0.3s ease, opacity 0.15s;
  opacity: 0.8;
}
.tw .epm-col:hover .epm-bar {
  opacity: 1;
  box-shadow: 0 0 10px rgba(108, 114, 255, 0.35);
}
.tw .epm-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
  opacity: 1;
  transition: opacity 0.15s;
}
.tw .epm-col:hover .epm-value {
  opacity: 1;
}
.tw .epm-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: 0.02em;
  opacity: 1;
}
.tw .epm-col:hover .epm-label {
  color: var(--text-primary);
  opacity: 1;
}

/* Country half */
.tw .d1-country {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.tw .d1-country h3 {
  font-size: 0.8rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tw .country-table-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tw .country-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.tw .country-table thead { background: var(--bg-elevated); position: sticky; top: 0; z-index: 1; }

.tw .country-table th {
  padding: 0.45rem 0.4rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.tw .country-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.tw .country-table tbody tr:hover { background: var(--bg-elevated); }

.tw .country-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.tw .country-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.tw .total-days { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--text-primary); }
.tw .percentage { font-family: 'JetBrains Mono', monospace; color: var(--accent); font-weight: 600; }


/* ============================================================
   D2 — All Events (unchanged structure, bigger fonts)
   ============================================================ */
.tw .q-events {
  overflow: hidden;
}

.tw .event-list {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-lg);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tw .event-list h3 {
  font-size: 0.8rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  font-weight: 600;
  flex-shrink: 0;
}

.tw .events-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.tw .event-item {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.35rem;
  transition: all 0.12s;
  gap: 0.5rem;
}
.tw .event-item:hover { border-color: var(--border-strong); background: var(--bg-elevated); }

.tw .event-color-bar { width: 3px; min-height: 28px; border-radius: 2px; flex-shrink: 0; }
.tw .event-details { flex: 1; min-width: 0; }
.tw .event-title { font-weight: 600; color: var(--text-primary); font-size: 0.85rem; margin-bottom: 0.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw .event-meta { font-size: 0.68rem; color: var(--text-tertiary); font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw .event-tags { display: flex; gap: 0.3rem; flex-shrink: 0; }
.tw .tag {
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* ===== Responsive ===== */
@media (max-width: 1000px) {
  .tw .analytics-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr;
    /* BUG-203: the grid takes its content height; the container scrolls (no scroller inside a scroller). */
    flex: none;
  }
  .tw .analytics-quadrant { overflow: visible; }
  .tw .q-kpis { min-height: auto; }
  .tw .q-donuts { min-height: auto; }
  .tw .q-bottom-left { min-height: 280px; }
  .tw .q-events { min-height: 260px; }
  .tw .d1-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

@media (max-width: 600px) {
  .tw .analytics-grid { gap: 0.35rem; }

  /* KPI: 2-column, last card centered */
  .tw .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
    height: auto;
  }
  .tw .stat-card-last {
    grid-column: 1 / -1;
    max-width: 50%;
    justify-self: center;
  }
  .tw .stat-value { font-size: 1.5rem; }

  /* Donuts: keep side by side, ensure equal sizing */
  .tw .donuts-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .tw .chart-card { padding: 0.4rem; }
  .tw .chart-card h3 { font-size: 0.65rem; }

  /* Force equal donut SVG sizes on mobile */
  .tw .donut-svg-wrap {
    min-height: 100px;
    max-height: 140px;
  }
  .tw .donut-svg-wrap svg {
    max-width: 140px;
  }
  .tw .donut-legend-item { font-size: 0.58rem; }
  .tw .donut-legend-dot { width: 7px; height: 7px; }
  .tw .donut-legend-value { font-size: 0.52rem; }
}

/* ─── R4-07: Year-over-year comparison strip ─────────────────────────────── */
.tw .yoy-strip {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.55rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.tw .yoy-strip::-webkit-scrollbar { display: none; }

.tw .yoy-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 1.2rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.tw .yoy-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem 1rem;
  border-left: 1px solid var(--border-subtle);
  min-width: 80px;
  flex-shrink: 0;
}

.tw .yoy-metric {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tw .yoy-values {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.tw .yoy-current {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tw .yoy-delta {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
}
.tw .yoy-delta--up {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.1);
}
.tw .yoy-delta--down {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}
.tw .yoy-delta--flat {
  color: var(--text-tertiary);
  background: var(--bg-hover);
}

/* ─── Motion (M2, ADR-036) ──────────────────────────────────────────────────────────────────────────────────────
   The resting state is the CSS above. While PlaybackRoot has the mo- class on the container, the tiles and charts
   rise 8 px with a fade, 60 ms apart (--ri), the events-per-month bars grow from the baseline, 50 ms apart (--mi),
   and everything is at rest within 1.45 s (the view's clock, MotionClock; the last bar lands at 1.41 s). Transform and opacity only. The donuts draw
   through the stroke-dasharray transition they already have (DonutChart). The KPI numbers count up in React. */
@media (prefers-reduced-motion: no-preference) {
  .tw .analytics-container:is(.mo-full, .mo-fast) :is(.stat-card, .chart-card, .d1-density, .d1-country, .event-list) {
    animation: moRise 500ms var(--mo-ease) backwards;
    animation-delay: calc(var(--ri, 0) * 60ms);
  }
  .tw .analytics-container:is(.mo-full, .mo-fast) .epm-bar {
    transform-origin: 50% 100%;
    animation: moEpmGrow 860ms var(--mo-ease) backwards;
    animation-delay: calc(var(--mi, 0) * 50ms);
  }
  @keyframes moEpmGrow {
    from { transform: scaleY(0); }
  }
}


/* components/Trajectory.css */
/* ─── Trajectory — multi-year analytics ──────────────────────────────────── */

.tw .traj-container {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tw .traj-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.tw .traj-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaed);
  margin: 0;
}

.tw .traj-range {
  font-size: 0.75rem;
  color: var(--text-tertiary, #555965);
}

/* ─── Loading ────────────────────────────────────────────────────────────── */

.tw .traj-loading {
  padding: 2rem;
  text-align: center;
}

.tw .traj-loading-text {
  color: var(--text-tertiary, #555965);
  font-size: 0.82rem;
}

/* ─── Sparkline KPI row ──────────────────────────────────────────────────── */

.tw .traj-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 1.5rem;
}

.tw .traj-kpi {
  background: var(--bg-surface, #12141c);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tw .traj-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tw .traj-kpi-label {
  font-size: 0.7rem;
  color: var(--text-tertiary, #555965);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tw .traj-kpi-delta {
  font-size: 0.7rem;
  font-weight: 500;
}
.tw .traj-kpi-delta--up { color: #34d399; }
.tw .traj-kpi-delta--down { color: #f87171; }
.tw .traj-kpi-delta--flat { color: var(--text-tertiary, #555965); }

.tw .traj-kpi-pct {
  opacity: 0.6;
}

.tw .traj-kpi-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tw .traj-kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary, #e8eaed);
}

.tw .traj-sparkline {
  flex-shrink: 0;
}

.tw .traj-kpi-years {
  display: flex;
  gap: 8px;
}

.tw .traj-kpi-year-val {
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
  display: flex;
  gap: 3px;
}

.tw .traj-kpi-year-label {
  opacity: 0.5;
}

/* ─── Section title (reused) ─────────────────────────────────────────────── */

.tw .traj-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary, #8b8f9a);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* ─── Monthly Heatmap ────────────────────────────────────────────────────── */

.tw .traj-heatmap {
  margin-bottom: 1.5rem;
}

.tw .traj-heatmap-grid {
  display: grid;
  grid-template-columns: 44px repeat(12, 1fr);
  gap: 2px;
}

.tw .traj-hm-corner {
  /* empty top-left cell */
}

.tw .traj-hm-month {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
  padding-bottom: 4px;
}

.tw .traj-hm-row {
  display: contents;
}

.tw .traj-hm-year {
  font-size: 0.7rem;
  color: var(--text-secondary, #8b8f9a);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-weight: 500;
}

.tw .traj-hm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  min-height: 28px;
}

.tw .traj-hm-cell:hover {
  outline: 1px solid rgba(108, 114, 255, 0.3);
  outline-offset: -1px;
}

.tw .traj-hm-value {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

/* ─── Bottom row: Location Evolution + Type Balance ──────────────────────── */

.tw .traj-bottom-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

/* ─── Location Evolution ─────────────────────────────────────────────────── */

.tw .traj-evo-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.tw .traj-evo-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tw .traj-evo-year {
  font-size: 0.7rem;
  color: var(--text-secondary, #8b8f9a);
  width: 34px;
  text-align: right;
  font-weight: 500;
  flex-shrink: 0;
}

.tw .traj-evo-bar {
  flex: 1;
  height: 22px;
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.tw .traj-evo-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.3s;
  position: relative;
}

.tw .traj-evo-seg-label {
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  font-weight: 500;
}

.tw .traj-evo-total {
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.tw .traj-evo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tw .traj-evo-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
}

.tw .traj-evo-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ─── Type Balance ───────────────────────────────────────────────────────── */

.tw .traj-type-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.tw .traj-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tw .traj-type-year {
  font-size: 0.7rem;
  color: var(--text-secondary, #8b8f9a);
  width: 34px;
  text-align: right;
  font-weight: 500;
  flex-shrink: 0;
}

.tw .traj-type-bar {
  flex: 1;
  height: 22px;
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

.tw .traj-type-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 500;
  transition: width 0.3s;
}

.tw .traj-type-seg--business {
  background: #97F81E;
  color: #0a0b0f;
}

.tw .traj-type-seg--personal {
  background: #8b95a8;
  color: #0a0b0f;
}

.tw .traj-type-seg--vacation {
  background: #FFD700;
  color: #0a0b0f;
}

.tw .traj-type-legend {
  display: flex;
  gap: 12px;
}

.tw .traj-type-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
}

.tw .traj-type-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tw .traj-type-dot--business { background: #97F81E; }
.tw .traj-type-dot--personal { background: #8b95a8; }
.tw .traj-type-dot--vacation { background: #FFD700; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .tw .traj-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
  .tw .traj-bottom-row {
    grid-template-columns: 1fr;
  }
}

/* components/YearInReview.css */
/* ─── YearInReview shell + modal panel override ─────────────────────────────
   .yir-overlay deleted — Modal/Overlay primitives own backdrop, blur, centering,
   z-index. The .yir-modal-panel override widens the panel beyond the 560px
   primitive default (the card is 480px + needs breathing room for the shell wrap)
   and removes the elevated panel background so the card's own #0e0f14 surface
   reads as the visible chrome (Modal default bg would double-layer). */

.tw .yir-modal-panel {
  max-width: min(640px, calc(100vw - 32px));
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.tw .yir-modal-body {
  padding: 0;
}

.tw .yir-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-height: 100%;
  overflow-y: auto;
}

/* ─── The card (what gets exported as PNG) ──────────────────────────────────── */

.tw .yir-card {
  width: 480px;
  max-width: calc(100vw - 2rem);
  background: #0e0f14;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 2rem;
  color: #e8eaf0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  position: relative;
  overflow: hidden;
}

/* Subtle grain overlay for visual depth */
.tw .yir-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 16px;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */

.tw .yir-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.tw .yir-logo-svg {
  flex-shrink: 0;
  opacity: 0.95;
}

.tw .yir-year-label {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1;
}

.tw .yir-tagline {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 0.2rem;
}

/* ─── Stats row ──────────────────────────────────────────────────────────────── */

.tw .yir-stats-row {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
}

.tw .yir-stat {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  margin: 0 0.2rem;
}

.tw .yir-stat:first-child { margin-left: 0; }
.tw .yir-stat:last-child  { margin-right: 0; }

.tw .yir-stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
}

.tw .yir-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.3rem;
}

/* ─── Section ────────────────────────────────────────────────────────────────── */

.tw .yir-section {
  margin-bottom: 1.25rem;
}

.tw .yir-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 0.6rem;
}

/* ─── Month bars ─────────────────────────────────────────────────────────────── */

.tw .yir-month-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 72px;
  padding-bottom: 20px; /* room for labels */
}

.tw .yir-month-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.tw .yir-month-bar {
  width: 100%;
  min-height: 3px;
  background: linear-gradient(180deg, #a78bfa 0%, var(--accent, #6c72ff) 100%);
  opacity: 0.9;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}

.tw .yir-month-col.peak .yir-month-bar {
  background: linear-gradient(180deg, #a78bfa 0%, var(--accent, #6c72ff) 100%);
  opacity: 1;
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.45);
}

.tw .yir-month-name {
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
}

.tw .yir-month-col.peak .yir-month-name {
  color: rgba(167, 139, 250, 0.85);
  font-weight: 700;   /* M2: a cue that does not rely on colour, beside the "Peak: ..." label below the bars */
}

.tw .yir-peak-note {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.25rem;
}

/* ─── Two-column layout ──────────────────────────────────────────────────────── */

.tw .yir-columns {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.tw .yir-section--half {
  flex: 1;
  margin-bottom: 0;
}

/* ─── Location list ──────────────────────────────────────────────────────────── */

.tw .yir-location-list,
.tw .yir-type-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tw .yir-location-row,
.tw .yir-type-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.tw .yir-location-name,
.tw .yir-type-name {
  flex: 1;
  color: rgba(255, 255, 255, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw .yir-location-days,
.tw .yir-type-days {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
  text-align: right;
}

/* ─── Type dots ──────────────────────────────────────────────────────────────── */

.tw .yir-type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tw .yir-type-dot--personal  { background: #6b7fff; }
.tw .yir-type-dot--business  { background: #97f81e; }
.tw .yir-type-dot--vacation  { background: #ffd700; }

/* ─── Highlight callout ──────────────────────────────────────────────────────── */

.tw .yir-highlight {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
  overflow: hidden;
}

.tw .yir-highlight-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.tw .yir-highlight-value {
  flex: 1;
  color: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw .yir-highlight-days {
  font-size: 0.72rem;
  color: rgba(130, 160, 255, 0.7);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer ─────────────────────────────────────────────────────────────────── */

.tw .yir-footer {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.2);
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ─── Controls (outside card, not in PNG) ───────────────────────────────────── */

/* 04.1 D3 / D-08b: the transparent-panel + zero-body-padding overrides from Plan 04-08
   created a focus-ring clip-plane risk. The YearInReview buttons live inside .yir-controls
   (NOT Modal.Footer) — the card itself IS the chrome here, so any visual separator/clip
   is redundant. Explicit `border-top: none; padding: 0; overflow: visible;` ensures
   focus rings on Share / Download PNG / Close paint fully past the container edge. */
.tw .yir-controls {
  display: flex;
  gap: 0.6rem;
  border-top: none;
  padding: 0;
  overflow: visible;
}

.tw .yir-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.tw .yir-btn:hover { opacity: 0.85; }
.tw .yir-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tw .yir-btn--download {
  /* Outside the always-dark card, on the theme's modal surface: tokens, not white (petra 6; was near-invisible in light). */
  background: var(--border-strong);
  color: var(--text-primary);
}

/* BUG-039: dark text on the fixed purple, 5.14:1 (white was 3.83:1). Share has
   its own hover at full opacity: the shared 0.85 would blend it down to about
   4.0:1. #8186ff equals the dark --accent-hover value, kept literal because the
   card is fixed-dark and reads no tokens. :not(:disabled) leaves a disabled
   Share at the shared opacity 0.5. */
.tw .yir-btn--share {
  background: #6c72ff;
  color: #0a0b0f;
}
.tw .yir-btn--share:not(:disabled):hover {
  opacity: 1;
  background: #8186ff;
}

.tw .yir-btn--close {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}



/* ─── Motion (M2, ADR-036) ─────────────────────────────────────────────────────────────────────────────────────────
   The resting state is the CSS above. While PlaybackRoot has the mo- class on the shell (outside the card, so the
   exported card never carries it), the stat tiles rise 8 px with a fade (--ri x 60 ms), the activity bars grow from the
   baseline (--mi x 35 ms, 600 ms), and the peak month highlights 150 ms after the last bar lands with a short pulse
   and its label fades in. Last frame at 1435 ms; the shell's clock (MotionClock) is 1450 ms. Transform and opacity
   only. The numbers count up in React. The PNG export is made final in the clone (exportTheme.js, A-187). */
@media (prefers-reduced-motion: no-preference) {
  .tw .yir-shell {
    --yir-bar-start: 0ms;
    --yir-bar-stagger: 35ms;
    --yir-bar-ms: 600ms;
    --yir-peak-delay: 1135ms;
    --yir-peak-ms: 300ms;
  }
  .tw .yir-shell:is(.mo-full, .mo-fast) .yir-stat {
    animation: moRise 500ms var(--mo-ease) backwards;
    animation-delay: calc(var(--ri, 0) * 60ms);
  }
  .tw .yir-shell:is(.mo-full, .mo-fast) .yir-month-bar {
    transform-origin: 50% 100%;
    animation: moYirGrow var(--yir-bar-ms) var(--mo-ease) backwards;
    animation-delay: calc(var(--yir-bar-start) + var(--mi, 0) * var(--yir-bar-stagger));
  }
  /* The peak bar keeps its growth and adds the pulse; the pulse has no fill, so it holds nothing before or after. */
  .tw .yir-shell:is(.mo-full, .mo-fast) .yir-month-col.peak .yir-month-bar {
    animation-name: moYirGrow, moYirPeak;
    animation-duration: var(--yir-bar-ms), var(--yir-peak-ms);
    animation-timing-function: var(--mo-ease), var(--mo-ease);
    animation-fill-mode: backwards, none;
    animation-delay: calc(var(--yir-bar-start) + var(--mi, 0) * var(--yir-bar-stagger)), var(--yir-peak-delay);
  }
  .tw .yir-shell:is(.mo-full, .mo-fast) .yir-peak-note {
    animation: moRise var(--yir-peak-ms) var(--mo-ease) backwards;
    animation-delay: var(--yir-peak-delay);
  }
  @keyframes moYirGrow {
    from { transform: scaleY(0); }
  }
  @keyframes moYirPeak {
    45% { transform: scale(1.35, 1.04); }
  }
}

/* components/AvailabilityShareModal.css */
/* ===== Availability Share Modal ===== */
/* MM-04 (chore(04-04)): .avshare-overlay + .avshare-modal + .avshare-top + .avshare-close
   pruned — bespoke modal DOM replaced by Modal compound primitive (D-07 standardized close).
   Gap C (05.1-02): .avshare-title rule removed so Modal.Title inherits canonical
   .ui-modal-title typography from src/components/ui/Modal.css (font-size:16px, weight:600). */

.tw .avshare-desc {
  font-size: 0.72rem;
  color: var(--text-secondary, #8b8f9a);
  margin: 0 0 1rem;
  line-height: 1.5;
}

.tw .avshare-desc strong {
  color: var(--text-primary, #e8eaed);
}

/* ── Mini preview grid ── */
.tw .avshare-preview {
  background: var(--bg-base, #0a0b0f);
  border-radius: 10px;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

/* M4b (Erik 2026-10-26): the plate and every free cell are there from the first frame. The panel enters with opacity only
   (the Modal primitive's scale(0.98) moved the grid by 3.8/3.1/7.6 px, lucas), and the busy cells then trickle in on the
   calendar's waterfall (the .mo-full tokens of YearGrid.css), opacity only, once per open. Lead = the Modal panel duration,
   set inline as --av-lead from MODAL_PANEL_MS (tested). Two classes beat the primitive by specificity, not by order. */
@media (prefers-reduced-motion: no-preference) {
  .tw .ui-modal-panel.avshare-panel { animation: avshare-panel-in 200ms ease-out; }

  .tw .avshare-wave { --mo-step: 84ms; --mo-day-step: 8ms; --mo-bar-ms: 300ms; }

  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(1)  { --mi: 0; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(2)  { --mi: 1; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(3)  { --mi: 2; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(4)  { --mi: 3; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(5)  { --mi: 4; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(6)  { --mi: 5; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(7)  { --mi: 6; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(8)  { --mi: 7; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(9)  { --mi: 8; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(10) { --mi: 9; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(11) { --mi: 10; }
  .tw .avshare-wave .avshare-mini-row > .avshare-mini-cell:nth-child(12) { --mi: 11; }

  .tw .avshare-wave .avshare-mini-cell.avshare-mini-busy::after {
    animation: avshareBusyIn var(--mo-bar-ms) var(--mo-ease) backwards;
    animation-delay: calc(var(--av-lead) + var(--mi, 0) * var(--mo-step) + var(--di, 0) * var(--mo-day-step));
  }
}
@keyframes avshare-panel-in {
  from { opacity: 0; }
}
@keyframes avshareBusyIn {
  from { opacity: 0; }
}

.tw .avshare-mini-header {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
  margin-bottom: 2px;
}

.tw .avshare-mini-month {
  text-align: center;
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tw .avshare-mini-grid {
  display: grid;
  grid-template-rows: repeat(31, 1fr);
  gap: 1px;
}

.tw .avshare-mini-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1px;
}

.tw .avshare-mini-cell {
  aspect-ratio: 1;
  border-radius: 1.5px;
  background: var(--bg-elevated, #1a1d28);
  min-height: 0;
  max-height: 6px;
  position: relative;
}

/* F4: elevated on base is near white on near white in light; a 10 % dark fill reads as a grid (about 1.17:1). Declared
   before the busy and invalid rules, which have the same specificity and must win. */
.tw [data-theme="light"] .avshare-mini-cell {
  background: rgba(0, 0, 0, 0.10);
}

.tw .avshare-mini-cell.avshare-mini-invalid {
  opacity: 0;
}

/* M4b: the busy colour is painted over the free cell by a pseudo-element, so animating it fades from the free fill and not
   from the plate. At rest it is fully there: identical to the old solid background in both themes. */
.tw .avshare-mini-cell.avshare-mini-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent, #6c72ff);
  border-radius: inherit;
}

/* F5: read by screen readers only */
.tw .avshare-copy-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Stats ── */
.tw .avshare-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-family: 'JetBrains Mono', monospace;
}

.tw .avshare-stats-sep {
  opacity: 0.4;
}

/* ── URL row ── */
.tw .avshare-url-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tw .avshare-url {
  flex: 1;
  background: var(--bg-base, #0a0b0f);
  border: 1px solid var(--border-default, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.62rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary, #8b8f9a);
  outline: none;
  min-width: 0;
}

.tw .avshare-url:focus {
  border-color: var(--accent, #6c72ff);
  box-shadow: 0 0 0 2px rgba(108, 114, 255, 0.15);
}

.tw .avshare-copy {
  background: var(--accent, #6c72ff);
  color: var(--text-inverse, #0a0b0f);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  min-width: 90px;
}

.tw .avshare-copy:hover {
  background: var(--accent-hover, #8186ff);
  transform: translateY(-1px);
}

/* Gap E (05.1-02): Copy link disabled state — belt-and-braces guard for the
   busyDates.size === 0 case. Coexists with Plan 05.1-01's EmptyState branch
   which hides the URL row entirely; this rule guarantees a visible disabled
   treatment if a future refactor exposes the button with an empty bitmap. */
.tw .avshare-copy:disabled {
  opacity: 0.4;
  background: var(--bg-elevated, #1a1d28);
  color: var(--text-secondary, #8b8f9a);
  cursor: not-allowed;
  transform: none;
}

.tw .avshare-copy:disabled:hover {
  background: var(--bg-elevated, #1a1d28);
  transform: none;
}

/* ── Privacy note ── */
.tw .avshare-privacy {
  font-size: 0.58rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ── Responsive ── */
/* ─── Compare section ─────────────────────────────────────────────────────── */

.tw .avshare-compare {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tw .avshare-compare-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaed);
  margin-bottom: 4px;
}

.tw .avshare-compare-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.tw .avshare-compare-row {
  display: flex;
  gap: 6px;
}

.tw .avshare-compare-input {
  flex: 1;
  background: var(--bg-base, #0a0b0f);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text-primary, #e8eaed);
  font-size: 0.75rem;
  font-family: inherit;
  outline: none;
}

.tw .avshare-compare-input:focus {
  border-color: rgba(45, 212, 191, 0.4);
}

.tw .avshare-compare-input::placeholder {
  color: var(--text-tertiary, #555965);
}

.tw .avshare-compare-btn {
  background: rgba(45, 212, 191, 0.15);
  color: #2dd4bf;
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.tw .avshare-compare-btn:hover:not(:disabled) {
  background: rgba(45, 212, 191, 0.25);
}

.tw .avshare-compare-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tw .avshare-compare-error {
  font-size: 0.7rem;
  color: #f87171;
  margin-top: 6px;
}

@media (max-width: 480px) {
  .tw .avshare-url-row { flex-direction: column; }
  .tw .avshare-copy { width: 100%; }
  .tw .avshare-compare-row { flex-direction: column; }
  .tw .avshare-compare-btn { width: 100%; }
}

/* components/OverlapView.css */
/* ─── OverlapView — merged busy/free grid for two people ──────────────────── */

/* D-06 sizing seam — consumer override appended to .ui-modal-panel so the 12×31
   overlap grid keeps its current width instead of being cramped into the default
   modal max-width. The old hand-rolled `.overlap-overlay`/`.overlap-modal` wrapper
   pair (backdrop + panel) was removed in Plan 09-01 — ui/Modal + ui/Overlay now
   own the backdrop, focus trap, inert sweep, and role=dialog. */
.tw .overlap-modal-panel {
  width: 720px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Top bar ────────────────────────────────────────────────────────────── */

.tw .overlap-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaed);
  margin: 0;
}

.tw .overlap-year {
  font-size: 0.75rem;
  color: var(--text-tertiary, #555965);
  margin-left: 8px;
}

/* ─── Legend ──────────────────────────────────────────────────────────────── */

.tw .overlap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.tw .overlap-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary, #8b8f9a);
}

.tw .overlap-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.tw .overlap-swatch--both-free { background: rgba(45, 212, 191, 0.3); border: 1px solid rgba(45, 212, 191, 0.5); }
.tw .overlap-swatch--you-busy { background: rgba(108, 114, 255, 0.5); }
.tw .overlap-swatch--they-busy { background: rgba(248, 113, 113, 0.4); }
.tw .overlap-swatch--both-busy { background: rgba(255, 255, 255, 0.12); }
.tw .overlap-swatch--window { background: rgba(45, 212, 191, 0.5); border: 1px solid rgba(45, 212, 191, 0.7); }

/* ─── Stats strip ────────────────────────────────────────────────────────── */

.tw .overlap-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.tw .overlap-stat {
  background: var(--bg-elevated, #1a1d28);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.tw .overlap-stat--accent {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.15);
}

.tw .overlap-stat-num {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #e8eaed);
}

.tw .overlap-stat--accent .overlap-stat-num {
  color: #2dd4bf;
}

.tw .overlap-stat-label {
  font-size: 0.65rem;
  color: var(--text-tertiary, #555965);
}

/* ─── Hover tooltip ──────────────────────────────────────────────────────── */

.tw .overlap-tooltip {
  font-size: 0.7rem;
  color: var(--text-secondary, #8b8f9a);
  margin-bottom: 6px;
  min-height: 1.2em;
}

/* ─── Grid ───────────────────────────────────────────────────────────────── */

.tw .overlap-grid-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.tw .overlap-grid {
  flex: 1;
  min-height: 0;
}

/* Month headers */
.tw .overlap-header-row {
  display: grid;
  grid-template-columns: 28px repeat(12, 1fr);
  gap: 2px;
  margin-bottom: 2px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-surface, #12141c);
  padding-bottom: 4px;
}

.tw .overlap-corner { /* empty */ }

.tw .overlap-month-header {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-tertiary, #555965);
  padding: 2px 0;
}

.tw .overlap-current-month {
  color: var(--accent, #6c72ff);
}

/* Day rows */
.tw .overlap-body {
  display: grid;
  grid-template-rows: repeat(31, 1fr);
  gap: 1px;
}

.tw .overlap-row {
  display: grid;
  grid-template-columns: 28px repeat(12, 1fr);
  gap: 2px;
}

.tw .overlap-today-row {
  /* subtle highlight */
}

.tw .overlap-day-label {
  font-size: 0.6rem;
  color: var(--text-tertiary, #555965);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tw .overlap-today-label {
  color: var(--accent, #6c72ff);
  font-weight: 600;
}

/* ─── Cells ──────────────────────────────────────────────────────────────── */

.tw .overlap-cell {
  border-radius: 3px;
  position: relative;
  aspect-ratio: 1.6;
  min-height: 8px;
  transition: opacity 0.15s;
}

.tw .overlap-cell.overlap-invalid {
  background: transparent;
  opacity: 0;
}

/* Both free — teal tint */
.tw .overlap-cell.overlap-both-free {
  background: rgba(45, 212, 191, 0.08);
}

/* You busy — your accent */
.tw .overlap-cell.overlap-you-busy {
  background: rgba(108, 114, 255, 0.35);
}

/* They busy — warm red */
.tw .overlap-cell.overlap-they-busy {
  background: rgba(248, 113, 113, 0.25);
}

/* Both busy — neutral */
.tw .overlap-cell.overlap-both-busy {
  background: rgba(255, 255, 255, 0.08);
}

/* Weekend tint */
.tw .overlap-cell.overlap-weekend::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.015);
}

/* Today */
.tw .overlap-cell.overlap-today {
  box-shadow: inset 0 0 0 1.5px var(--accent, #6c72ff);
}

.tw .overlap-today-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent, #6c72ff);
}

/* Past */
.tw .overlap-cell.overlap-past {
  opacity: 0.5;
}

/* Mutual free window — highlighted teal */
.tw .overlap-cell.overlap-window {
  background: rgba(45, 212, 191, 0.25);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.3);
}

/* Hover */
.tw .overlap-cell:not(.overlap-invalid):hover {
  outline: 1px solid rgba(255, 255, 255, 0.2);
  outline-offset: -1px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .tw .overlap-header-row,
  .tw .overlap-row {
    grid-template-columns: 22px repeat(12, 1fr);
  }
  .tw .overlap-stats {
    flex-wrap: wrap;
    gap: 6px;
  }
  .tw .overlap-stat {
    padding: 4px 8px;
  }
  .tw .overlap-legend {
    gap: 8px;
  }
}

/* components/Tooltip.css */
.tw .custom-tooltip {
  position: fixed;
  z-index: 2000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  max-width: 280px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
}

.tw .custom-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tw .tooltip-event {
  padding: 0.3rem 0;
}

.tw .tooltip-event + .tooltip-event {
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.25rem;
  padding-top: 0.4rem;
}

.tw .tooltip-row-main {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.tw .tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tw .tooltip-name {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw .tooltip-row-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-left: 1.15rem; /* align under name */
  flex-wrap: wrap;
}

.tw .tooltip-dates {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-tertiary);
}

.tw .tooltip-location {
  font-size: 0.62rem;
  color: var(--text-secondary);
}

.tw .tooltip-type {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.tw .tooltip-type--business {
  color: #EEFF33;
  background: rgba(238, 255, 51, 0.1);
}

.tw .tooltip-type--vacation {
  color: #FFD700;
  background: rgba(255, 215, 0, 0.1);
}

.tw .tooltip-type--personal {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

/* BUG-210: the business and vacation tags were lime and gold text on the light tooltip (about 1.2:1). In the light theme
   they use dark ink of the same hue on the same tint. */
.tw [data-theme="light"] .tooltip-type--business {
  color: #4A5200;
  background: rgba(150, 165, 0, 0.14);
}
.tw [data-theme="light"] .tooltip-type--vacation {
  color: #5C4700;
  background: rgba(255, 215, 0, 0.22);
}

/* components/LegendBar.css */
/* ===== Legend Bar — anchored at bottom of grid ===== */
.tw .legend-bar {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--border-default);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: visible;
  position: relative;
}

.tw .legend-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.15s;
}
.tw .legend-toggle:hover { color: var(--text-secondary); }

.tw .legend-toggle-icon {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.tw .legend-content {
  display: flex;
  gap: 1.25rem;
  padding: 0 0.75rem 0.65rem;
  flex-wrap: wrap;
  animation: dropIn 0.2s ease-out;
}

.tw .legend-section h3 {
  font-size: 0.52rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tw .legend-section-hint {
  font-weight: 400;
  font-size: 0.45rem;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  opacity: 0.6;
  text-transform: none;
}

.tw .legend-divider {
  width: 1px;
  background: var(--border-default);
  align-self: stretch;
}

.tw .legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* ===== Legend Chip — interactive item ===== */
.tw .legend-chip {
  display: flex;
  align-items: center;
  position: relative;
  border-radius: 6px;
  transition: opacity 0.15s;
}

.tw .legend-chip.dimmed {
  opacity: 0.25;
}
.tw .legend-chip.dimmed:hover {
  opacity: 0.5;
}

.tw .legend-chip-main {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.62rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.tw .legend-chip-main:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.tw .legend-chip-color {
  width: 14px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.tw .legend-chip-textsample {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 700;
  width: 18px;
}

.tw .legend-chip-name {
  line-height: 1;
}

.tw .legend-chip-inherit {
  font-size: 0.5rem;
  opacity: 0.4;
  margin-left: -0.05rem;
}

.tw .legend-chip-count {
  font-size: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  padding: 0 0.25rem;
  border-radius: 3px;
  line-height: 1.4;
  margin-left: 0.1rem;
}

/* Edit pencil button — appears on hover */
.tw .legend-chip-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  padding: 0.2rem 0;
  border: 1px solid var(--border-default);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  font-size: 0.52rem;
  cursor: pointer;
  opacity: 0.45;
  transition: all 0.15s ease;
}

.tw .legend-chip:hover .legend-chip-edit {
  opacity: 1;
  transform: scale(1.15);
}

.tw .legend-chip-edit:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(108, 114, 255, 0.25);
  transform: scale(1.2);
}

.tw .legend-chip-edit:active {
  transform: scale(1.25);
}

/* ===== Edit Popover ===== */
.tw .lp-popover {
  position: fixed;
  z-index: 2000;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.1);
  animation: lpPopIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  overflow: visible;
}

@keyframes lpPopIn {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tw .lp-pop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.tw .lp-pop-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tw .lp-pop-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.12s;
}
.tw .lp-pop-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Popover fields */
.tw .lp-pop-field {
  padding: 0.6rem 0.85rem;
}

.tw .lp-pop-field label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.tw .lp-pop-field input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.55rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.78rem;
  transition: border-color 0.15s;
}
.tw .lp-pop-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* Color picker */
.tw .lp-color-picker {
  padding: 0.5rem 0.85rem 0.65rem;
}

.tw .lp-color-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}

.tw .lp-color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tw .lp-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.tw .lp-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.tw .lp-swatch.active {
  border-color: white;
  box-shadow: 0 0 0 1px var(--bg-base), 0 0 8px rgba(255,255,255,0.2);
}

/* Custom color input — native picker disguised */
.tw .lp-swatch-custom {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.1s;
}
.tw .lp-swatch-custom:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.tw .lp-swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.tw .lp-swatch-custom-icon {
  font-size: 0.55rem;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* Inherit note */
.tw .lp-inherit-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem 0.65rem;
  font-size: 0.65rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.tw .lp-inherit-icon {
  font-size: 0.7rem;
  flex-shrink: 0;
}

/* Trip count toggle in popover */
.tw .lp-pop-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.85rem 0.6rem;
  border-top: 1px solid var(--border-subtle);
}

.tw .lp-pop-toggle-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.tw .lp-mini-switch {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--bg-active);
  border: 1px solid var(--border-default);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.tw .lp-mini-switch.on {
  background: var(--accent);
  border-color: var(--accent);
}

.tw .lp-mini-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.tw .lp-mini-switch.on .lp-mini-switch-thumb {
  transform: translateX(14px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .tw .legend-bar { border-radius: 0 0 var(--radius-md) var(--radius-md); }
  .tw .legend-toggle { padding: 0.3rem 0.5rem; font-size: 0.55rem; }
  .tw .legend-content { gap: 0.6rem; padding: 0 0.5rem 0.5rem; }
  .tw .legend-chip-main { font-size: 0.55rem; }
  .tw .legend-chip-color { width: 12px; height: 8px; }
  .tw .lp-popover { width: 240px; }
}

/* components/FilterBar.css */
.tw .filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
  overflow-x: auto;
  flex-shrink: 0;
  animation: filterFadeIn 0.15s ease-out;
}

@keyframes filterFadeIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.tw .filter-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.tw .filter-label {
  font-size: 0.5rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 0.15rem;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

.tw .filter-sep {
  width: 1px;
  height: 14px;
  background: var(--border-default);
  flex-shrink: 0;
  margin: 0 0.15rem;
}

.tw .filter-chip {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.18rem 0.4rem;
  border: 1px solid var(--border-default);
  border-radius: 16px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.54rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.tw .filter-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tw .filter-chip.dimmed {
  opacity: 0.22;
  border-color: transparent;
}

.tw .filter-chip.dimmed:hover {
  opacity: 0.5;
}

.tw .filter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Full names on desktop, short codes on narrow */
.tw .filter-text-full { display: inline; }
.tw .filter-text-short { display: none; }

@media (max-width: 1100px) {
  .tw .filter-text-full { display: none; }
  .tw .filter-text-short { display: inline; }
}

@media (max-width: 768px) {
  .tw .filter-bar { margin-bottom: 0.3rem; gap: 0.3rem; padding: 0.2rem 0.3rem; }
  .tw .filter-chip { font-size: 0.48rem; padding: 0.12rem 0.3rem; }
  .tw .filter-label { font-size: 0.45rem; }
}

/* components/Toast.css */
/* ===== Toast Container ===== */
.tw .toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}

.tw .toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.06);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  pointer-events: auto;
}

.tw .toast-exit {
  animation: toastOut 0.35s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.94); }
}

.tw .toast-icon {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.tw .toast-msg {
  color: var(--text-primary);
}

.tw .toast-success {
  background: rgba(26, 31, 24, 0.92);
  border: 1px solid rgba(52, 211, 153, 0.25);
}
.tw .toast-success .toast-icon { color: #34d399; }

.tw .toast-error {
  background: rgba(31, 20, 20, 0.92);
  border: 1px solid rgba(255, 77, 77, 0.3);
}
.tw .toast-error .toast-icon { color: #ff4d4d; }

.tw .toast-warning {
  background: rgba(30, 27, 16, 0.92);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.tw .toast-warning .toast-icon { color: #fbbf24; }

.tw .toast-info,
.tw .toast-update {
  background: rgba(18, 20, 28, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
}
.tw .toast-info .toast-icon { color: var(--text-secondary); }

@media (max-width: 480px) {
  .tw .toast-container { bottom: 1rem; left: 1rem; right: 1rem; transform: none; align-items: stretch; }
  .tw .toast { border-radius: var(--radius-lg); }
}

/* ─── Undo action button in toast (R4-02) ─────────────────────────────────── */
.tw .toast-has-action {
  padding-right: 0.6rem;
}
.tw .toast-action {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  cursor: pointer;
  margin-left: 0.35rem;
  white-space: nowrap;
  transition: background 0.12s;
}
.tw .toast-action:hover {
  background: rgba(255,255,255,0.25);
}

/* PWA-02 / D-01 — action toast (sticky, primary action + dismiss) */
.tw .toast-sticky {
  /* no auto-dismiss; visually identical to base toast except for buttons */
}

.tw .toast-action.toast-action--primary {
  background: var(--accent);
  color: var(--text-inverse);
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-md, 6px);
  border: none;
  cursor: pointer;
  margin-left: 8px;
}
.tw .toast-action.toast-action--primary:hover {
  filter: brightness(1.08);
}

.tw .toast-action.toast-action--dismiss {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 2px 8px;
  margin-left: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.tw .toast-action.toast-action--dismiss:hover {
  color: var(--text-primary);
  background: transparent;
}

/* ─── BUG-024 light theme ───────────────────────────────────────────────────
   The per-type toast surfaces above are fixed dark values that ignore the
   theme, so in the light theme the near-black --text-primary message sat on a
   near-black pill. The light theme re-skins every toast here with tokens from
   src/index.css; the dark rules above stay untouched (this block is append-only).
   Longhand colour properties only (background-color / border-color), so only
   the colour changes and the jsdom contrast test in src/test/toast.test.jsx
   can read the resolved value. */
.tw [data-theme="light"] .toast {
  box-shadow: var(--shadow-md);
}

/* Surface for every type. The PWA update toast container has class
   toast-update (BUG-033) and is targeted here via the .toast.toast-sticky
   compound. toast-action is a button class only (Undo, Reload, dismiss) and must
   never be styled bare. */
.tw [data-theme="light"] .toast-success,
.tw [data-theme="light"] .toast-error,
.tw [data-theme="light"] .toast-warning,
.tw [data-theme="light"] .toast-info,
.tw [data-theme="light"] .toast.toast-sticky {
  background-color: var(--bg-surface);
  border-color: var(--border-default);
}

/* Type icons. The light warning icon keeps --text-primary (the glyph shape
   carries the warning cue), a choice made before the --warning token existed
   (BUG-034); see docs/features/toast.md. The info icon already uses
   --text-secondary and the PWA icon inherits --text-primary. */
.tw [data-theme="light"] .toast-success .toast-icon { color: var(--success); }
.tw [data-theme="light"] .toast-error .toast-icon { color: var(--danger); }
.tw [data-theme="light"] .toast-warning .toast-icon { color: var(--text-primary); }

/* Undo button (toasts created with an action argument). Only reached through
   .toast-has-action, so the PWA Reload / dismiss buttons keep their own rules. */
.tw [data-theme="light"] .toast-has-action .toast-action {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.tw [data-theme="light"] .toast-has-action .toast-action:hover {
  background-color: var(--bg-active);
}

/* components/ledger/ledger.css */
/* The travel ledger view (S2.3 slice 3). Tokens only; no opacity on any text (lucas, design section 7).
   Designed at 390 px first (one column, 16 px gutters, 44 px controls), two columns from 960 px. */

.tw .ledger { flex: 1; min-height: 0; display: flex; flex-direction: column; color: var(--text-primary); }

/* The scroller. scroll-padding keeps a focus ring clear of the sticky Confirm bar and the top edge (design 7, S2.2 learning). */
.tw .ledger-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* The sticky Confirm bar sits above the scroller's own bottom padding, so it covers more than its own height: bar (67 px, two rows 130 px) plus
     the ring offset. 8.5rem keeps a focused control and its ring clear of it; the top needs less (BUG-104). */
  --ledger-pad-b: 2rem;
  scroll-padding-block-start: 5.5rem;
  scroll-padding-block-end: 8.5rem;
  padding: 0.5rem 1rem var(--ledger-pad-b);
}
.tw .ledger-inner { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 0.9rem; }

.tw .ledger-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding-top: 0.25rem; }
.tw .ledger-title { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--text-primary); scroll-margin-block: 0.75rem; }
.tw .ledger-title:focus, .tw .ledger h1.ledger-title:focus-visible { outline: none; }   /* h1 raises the specificity above `.ledger [tabindex]:focus-visible`, which comes later in this file and drew the ring (lucas, L9) */   /* a target for screen readers and the first Tab, not a control: no ring */

.tw .ledger-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; align-items: start; }
.tw .ledger-col { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
@media (min-width: 960px) {
  .tw .ledger-inner { max-width: 1000px; }
  .tw .ledger-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }   /* the 183 list sits in the second column */
}

/* ── Cards ─────────────────────────────── */
.tw .ledger-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}
.tw .ledger-h2 { font-size: 0.95rem; font-weight: 600; margin: 0; color: var(--text-primary); scroll-margin-block: 0.75rem; }
.tw .ledger-text { font-size: 0.85rem; line-height: 1.5; margin: 0; color: var(--text-primary); }
.tw .ledger-hint { font-size: 0.75rem; line-height: 1.45; margin: 0; color: var(--text-secondary); }
.tw .ledger-mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.tw .ledger-step { font-size: 0.75rem; margin: 0; color: var(--text-secondary); }

.tw .ledger-btn { min-height: 44px; scroll-margin-block: 0.75rem; }
/* The Button primitive fades a disabled/busy button with opacity, which would fade its text; use a flat pair (BUG-097). */
/* aria-disabled still acts (it moves focus to the field), so its text must reach 4.5:1: --text-secondary on --bg-active was 4.10:1 in dark (BUG-105).
   --bg-elevated gives 5.2:1 in dark and more in light; the border and the secondary text colour still set it apart from an active button. */
.tw .ledger .ledger-btn[aria-disabled="true"] { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text-secondary); cursor: not-allowed; opacity: 1; }
.tw .ledger .ledger-btn:disabled, .tw .ledger .ledger-btn[aria-busy="true"] { opacity: 1; background: var(--bg-elevated); border-color: var(--border-strong); color: var(--text-secondary); }

.tw .ledger-link {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0.5rem 0;
  min-height: 44px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  text-decoration: underline;
  cursor: pointer;
  scroll-margin-block: 0.75rem;
}
.tw .ledger-text .ledger-link, .tw .ledger-home .ledger-link { display: inline; padding: 0; min-height: 0; }
.tw .ledger-home .ledger-link { padding: 0.65rem 0.3rem; }

.tw .ledger .ledger-link:focus-visible, .tw .ledger button:focus-visible, .tw .ledger select:focus-visible, .tw .ledger [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Header strip ────────────────────────── */
.tw .ledger-headstrip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.2rem 1rem; font-size: 0.8rem; color: var(--text-secondary); }
.tw .ledger-schengen { font-weight: 600; color: var(--text-primary); }
.tw .ledger-home { color: var(--text-secondary); }

/* ── Hero ────────────────────────────────── */
.tw .ledger-preview { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.75rem; color: var(--lock); }
.tw .ledger-hero-count { font-size: 2.6rem; font-weight: 600; line-height: 1.1; margin: 0; color: var(--text-primary); }

.tw .ledger-bar { height: 8px; width: 100%; background: var(--border-strong); border-radius: 4px; overflow: hidden; }
.tw .ledger-bar--thin { height: 6px; }
.tw .ledger-bar-fill { height: 100%; width: 100%; transform-origin: left center; transform: scaleX(var(--fill, 0)); background: var(--accent); border-radius: 4px; }
.tw .ledger-bar-fill--warning, .tw .ledger-bar-fill--watch, .tw .ledger-bar-fill--reached { background: var(--warning); }
.tw .ledger-bar-fill--over { background: var(--danger); }
/* The signature moment: the bar fills from empty over 600 ms, once per session (the first time the numbers appear). */
.tw .ledger-bar-fill--play { animation: ledger-fill 600ms ease-out; }
@keyframes ledger-fill { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .tw .ledger-bar-fill--play { animation: none; } }

.tw .ledger-state { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.85rem; }
.tw .ledger-state-icon { flex-shrink: 0; }
.tw .ledger-state--warning, .tw .ledger-state--reached { color: var(--warning-text); }
.tw .ledger-state--over { color: var(--danger-text); }

.tw .ledger-perk { display: flex; flex-direction: column; gap: 0.35rem; }

/* M2 (ADR-036): the stay line reveals once per open (moRise, motionView.css: a fade and an 8 px rise), after the hero
   count has had a moment. While PlaybackRoot has the mo- class on the perk block; the base style is the end state.
   The keyframes live in motionView.css: this file sets no opacity (ledgerViewScreen.test.jsx, "text is never faded"). */
@media (prefers-reduced-motion: no-preference) {
  .tw .ledger-perk:is(.mo-full, .mo-fast) > p:first-of-type {
    animation: moRise 500ms var(--mo-ease) 250ms backwards;
  }
}

/* ── Planning aid ────────────────────────── */
.tw .ledger-aid { display: flex; flex-direction: column; gap: 0.3rem; }
.tw .ledger-aid-line { display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem 0.4rem; margin: 0; font-size: 0.75rem; line-height: 1.4; color: var(--text-secondary); }
.tw .ledger-aid-i {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;              /* the hit area is 44 px, the glyph is small */
  margin: -0.6rem -0.5rem;
  background: none; border: 0; color: var(--text-secondary); font: inherit; font-size: 0.75rem; font-style: italic; font-weight: 600; cursor: pointer;
}
.tw .ledger-aid-i > span { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 1.5px solid var(--text-secondary); border-radius: 50%; }
.tw .ledger-aid-text { margin: 0; font-size: 0.75rem; line-height: 1.5; color: var(--text-secondary); }

/* ── Forecast strip ──────────────────────── */
.tw .ledger-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cells, 180), minmax(0, 1fr));
  height: 28px;
  background: var(--border-strong);
  border-radius: 4px;
}
.tw .ledger-run { grid-row: 1; height: 100%; }
.tw .ledger-run--confirmed { background: var(--accent); }
.tw .ledger-run--tentative {
  /* hatched, so a tentative trip is a pattern and a legend word, not a colour alone */
  background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 7px);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tw .ledger-strip-today { grid-row: 1; height: 100%; border-left: 3px solid var(--text-primary); z-index: 1; pointer-events: none; }
.tw .ledger-peak { grid-row: 1; height: 100%; border-left: 2px dashed var(--text-primary); z-index: 1; pointer-events: none; }
.tw .ledger-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; list-style: none; margin: 0; padding: 0; font-size: 0.75rem; color: var(--text-secondary); }
.tw .ledger-legend li { display: flex; align-items: center; gap: 0.4rem; }
.tw .ledger-swatch { width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; }
.tw .ledger-swatch--confirmed { background: var(--accent); }
.tw .ledger-swatch--tentative { background: repeating-linear-gradient(135deg, var(--accent) 0 3px, transparent 3px 7px); box-shadow: inset 0 0 0 1px var(--accent); }
.tw .ledger-swatch--today { background: transparent; border-left: 3px solid var(--text-primary); border-radius: 0; width: 6px; }
.tw .ledger-peak-label { margin: 0; font-size: 0.8rem; color: var(--text-primary); }
.tw .ledger-fc-lines { display: flex; flex-direction: column; gap: 0.2rem; }
.tw .ledger-fc-line { margin: 0; font-size: 0.82rem; line-height: 1.45; color: var(--text-primary); }
.tw .ledger-fc-line--over { color: var(--danger-text); }

/* ── Days per country ────────────────────── */
.tw .ledger-cd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.tw .ledger-cd-row { display: flex; flex-direction: column; gap: 0.3rem; }
.tw .ledger-cd-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem; }
.tw .ledger-cd-name { color: var(--text-primary); overflow-wrap: anywhere; }
.tw .ledger-cd-days { color: var(--text-primary); }
.tw .ledger-cd-state { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.3rem 0.4rem; margin: 0; font-size: 0.78rem; line-height: 1.45; }
.tw .ledger-cd-state > span { flex-basis: 100%; color: var(--text-primary); }
.tw .ledger-cd-state--watch strong, .tw .ledger-cd-state--watch .ledger-state-icon { color: var(--warning-text); }
.tw .ledger-cd-state--reached strong, .tw .ledger-cd-state--reached .ledger-state-icon { color: var(--danger-text); }

/* ── Setup ───────────────────────────────── */
.tw .ledger-select {
  width: 100%;
  min-height: 44px;
  padding: 0 0.6rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 0.9rem;
}
.tw .ledger-select--small { width: auto; max-width: 100%; font-size: 0.8rem; }
.tw .ledger-places { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.tw .ledger-place { display: flex; flex-direction: column; gap: 0.4rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border-default); }
.tw .ledger-place-name { margin: 0; font-size: 0.88rem; font-weight: 600; overflow-wrap: anywhere; }
.tw .ledger-place-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tw .ledger-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 0.6rem; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 0.8rem; color: var(--text-primary); }
.tw .ledger-choice {
  min-height: 44px; padding: 0 0.8rem;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font: inherit; font-size: 0.8rem; cursor: pointer; scroll-margin-block: 0.75rem;
}
.tw .ledger-choice[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--accent); }
.tw .ledger-more { color: var(--text-secondary); }
.tw .ledger-sticky {
  position: sticky;
  bottom: calc(-1 * var(--ledger-pad-b));   /* flush with the bottom of the screen, not above the scroller's padding */
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 0 -1rem -0.9rem;
  padding: 0.7rem 1rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.tw .ledger-res-note { color: var(--text-secondary); }

/* ── Banners, notices, lists ─────────────── */
.tw .ledger-banner { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.8rem 1rem; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: var(--radius-lg); }
.tw .ledger-banner-actions, .tw .ledger-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tw .ledger-notice { border-color: var(--warning); }
.tw .ledger-dropped { margin: 0; }
.tw .ledger-plain-list { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; line-height: 1.6; color: var(--text-primary); overflow-wrap: anywhere; }
.tw .ledger-status { margin: 0; min-height: 0; font-size: 0.8rem; color: var(--text-primary); }
.tw .ledger-status:empty { display: none; }

/* ── Locked preview (free and lapsed) ───── */
.tw .ledger-lock { display: flex; flex-direction: column; gap: 0.6rem; }
.tw .ledger-lock-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.tw .ledger-lock-btn {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  min-height: 44px; padding: 0 0.9rem;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  font: inherit; font-size: 0.85rem; text-align: left; cursor: pointer; scroll-margin-block: 0.75rem;
}
.tw .ledger-lock-btn svg { color: var(--lock); flex-shrink: 0; }
.tw .ledger-lock-label { flex: 1; }
.tw .ledger-pro-tag { font-size: 0.72rem; font-weight: 600; color: var(--lock); }
.tw .ledger-lock-panel { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.9rem 1rem; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); }
.tw .ledger-lock-panel:focus { outline: none; }
.tw .ledger-lock-text { margin: 0; font-size: 0.85rem; line-height: 1.5; color: var(--text-primary); }
.tw .ledger-lock-text--quiet { color: var(--text-secondary); font-size: 0.78rem; }
.tw .ledger-lock-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ── Loading ─────────────────────────────── */
.tw .ledger-skeleton { display: flex; flex-direction: column; gap: 0.7rem; padding: 0.5rem 0; }
.tw .ledger-skeleton-bar { display: block; height: 1rem; width: 100%; border-radius: var(--radius-sm); background: var(--bg-active); }
.tw .ledger-skeleton-bar--short { width: 55%; }
@media (prefers-reduced-motion: no-preference) {
  .tw .ledger-skeleton-bar { animation: ledger-pulse 1.4s ease-in-out infinite; }
}
@keyframes ledger-pulse { 50% { background: var(--bg-hover); } }

.tw .ledger-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.tw .ledger-counter { margin-left: 0.4rem; font-weight: 400; color: var(--text-secondary); }

/* components/MobileCalendar.css */
/* ===== Mobile Calendar — vertical day-bar view ===== */
.tw .mobile-calendar {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg-base);
  overflow: hidden;
  position: relative;
  user-select: none;
}

/* ── Top bar ──────────────────────────────────── */
.tw .mcal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 44px;
}

.tw .mcal-home-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: background 0.1s;
}
.tw .mcal-home-btn:active { background: var(--bg-hover); }

.tw .mcal-month-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  flex: 1;
  text-align: center;
}

.tw .mcal-header-right {
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.tw .mcal-year-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Dots nav ─────────────────────────────────── */
.tw .mcal-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 1rem;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.tw .mcal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: none;
  background: var(--border-default);
  cursor: pointer;
  padding: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-tap-highlight-color: transparent;
}
.tw .mcal-dot.active {
  background: var(--accent);
  width: 14px;
  border-radius: 3px;
}
.tw .mcal-dot.current:not(.active) {
  background: var(--text-tertiary);
}

/* ── Start card (R1.5, docs/design/rework/phone-start-card.md) ─────────────
   In flow between the dots and the scroller: it takes its own height, overlays nothing (not the FAB, not a day row). */
.tw .mcal-start {
  flex-shrink: 0;
  margin: 8px 8px 0;
  padding: 10px 12px 12px 15px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: inset 3px 0 0 var(--accent);
}
.tw .mcal-start-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}
.tw .mcal-start-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.tw .mcal-start-body {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.tw .mcal-start-ok {
  min-height: 44px;
  min-width: 64px;
  margin: -6px 0;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--text-inverse);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tw .mcal-start-ok:active { background: var(--accent-hover); }
.tw .mcal-start-ok:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tw .mcal-start-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0 1px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: -4px;
}
@media (prefers-reduced-motion: no-preference) {
  .tw .mcal-start { animation: mcal-start-in 200ms cubic-bezier(0.16, 1, 0.3, 1); }
}
@keyframes mcal-start-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Horizontal scroll container ─────────────── */
.tw .mcal-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 28px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 5px 28px;
  gap: 8px;
  box-sizing: border-box;
  align-items: stretch;
}
.tw .mcal-scroll::-webkit-scrollbar { display: none; }

/* ── Month slide ──────────────────────────────── */
.tw .mcal-slide {
  min-width: calc(100vw - 64px);
  max-width: calc(100vw - 64px);
  height: 100%;
  scroll-snap-align: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* ── Month card ───────────────────────────────── */
.tw .mcal-card {
  position: relative;   /* contains .mcal-sr (absolute), or its off-screen box widens the whole view and scrollIntoView drags the root */
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  transition: opacity 0.2s;
}
.tw .mcal-card::-webkit-scrollbar { display: none; }
.tw .mcal-slide:not(.mo-vis) .mcal-card { opacity: 0.45; }

/* ── Month view ───────────────────────────────── */
.tw .mmonth-view {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

/* ── Day row ──────────────────────────────────── */
.tw .mday-row {
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 2px 8px 2px 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s;
  position: relative;
}
.tw .mday-row:active { background: var(--bg-hover); }

/* Weekend row — darker charcoal, matches desktop scheme */
.tw .mday-row.mday-weekend {
  background: rgba(0, 0, 0, 0.12);
}
.tw .mday-row.mday-weekend:active {
  background: var(--bg-hover);
}

/* Sa/Su micro-label below day number */
.tw .mday-weekday-label {
  font-size: 0.42rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  opacity: 0.7;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 1px;
}

.tw .mday-today::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2.5px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* ── Day number ───────────────────────────────── */
.tw .mday-num-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  width: 26px;
  flex-shrink: 0;
  padding-right: 2px;
}
.tw .mday-num {
  font-size: 0.67rem;
  font-weight: 500;
  color: var(--text-tertiary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tw .mday-num-today {
  color: var(--accent);
  font-weight: 800;
}

/* ── Event bars ───────────────────────────────── */
.tw .mday-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
  min-width: 0;
  justify-content: center;
}
.tw .mday-bar {
  border-radius: 3px;
  height: 16px;
  display: flex;
  align-items: center;
  padding: 0 5px;
  overflow: hidden;
}
.tw .mday-bar-empty {
  background: var(--bg-elevated);
  opacity: 0.4;
}
/* "+N more": the rest of a busy day. Neutral, as high as a bar; a tap anywhere in the row opens the day sheet. */
.tw .mday-bar.mday-more {
  height: 16px;
  white-space: nowrap;
  justify-content: center;
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--text-secondary);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}
.tw .mday-bar-label {
  font-size: 0.62rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* ── Day sheet ────────────────────────────────── */
.tw .msheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
}
.tw .msheet {
  background: var(--bg-surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border-default);
  width: 100%;
  padding: 0 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  max-height: 65vh;
  overflow-y: auto;
  animation: msheetIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes msheetIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.tw .msheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-default);
  margin: 0.75rem auto 1rem;
}
.tw .msheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.tw .msheet-dayname {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.tw .msheet-date {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.tw .msheet-add-btn {
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tw .msheet-empty {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-style: italic;
  text-align: center;
  padding: 1.75rem 0;
}
.tw .msheet-events {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.tw .msheet-event {
  padding: 0.7rem 0.85rem;
  background: var(--bg-elevated);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tw .msheet-event:active { background: var(--bg-hover); }
.tw .msheet-event-desc {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.tw .msheet-event-meta {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.tw .msheet-event-type {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  text-transform: capitalize;
}
.tw .msheet-event-loc {
  font-size: 0.65rem;
  color: var(--text-tertiary);
}
.tw .msheet-event-loc::before { content: '· '; }

/* ── FAB ──────────────────────────────────────── */
.tw .mcal-fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  right: 1.25rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(108, 114, 255, 0.45);
  cursor: pointer;
  z-index: 100;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tw .mcal-fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 8px rgba(108, 114, 255, 0.3);
}

/* ─── Open / import motion (ADR-036, src/lib/motion) ─────────────────
   Only while MobileCalendar has set .mo-full on its root, and only when motion is permitted. The month(s) on screen (.mo-vis: one, or both of the pair)
   draws its bars top to bottom, a day row (--di) after the one above. Empty rows, the header and the FAB do not move. */
@media (prefers-reduced-motion: no-preference) {
  .tw .mo-full .mcal-slide.mo-vis .mday-bar:not(.mday-bar-empty) {
    animation: moBarDraw 0.5s var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) backwards;
    animation-delay: calc(var(--di, 0) * 14ms);
  }
  /* The fast version (RETURN_PLAYBACK = 'fast', src/lib/motion/config.js): the same draw, quicker. */
  .tw .mo-fast .mcal-slide.mo-vis .mday-bar:not(.mday-bar-empty) {
    animation: moBarDraw 0.25s var(--mo-ease, cubic-bezier(.22, .61, .36, 1)) backwards;
    animation-delay: calc(var(--di, 0) * 6ms);
  }
}

/* ─── BUG-173 rule 3: two months side by side (phone landscape), docs/design/BUG-173-short-windows.md ─────────────
   `.mcal-two` is on the root from 560 px of width. The strip keeps its 36 slides; each is half the width less the gap,
   and the leading month snaps to the left edge. Both cards share one vertical scroll (MobileCalendar.jsx). */

.tw .mcal-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The year has not loaded yet: a quiet placeholder where the bar would be, and no animation of its own. */
.tw .mday-bar-skel {
  background: repeating-linear-gradient(135deg, var(--bg-elevated) 0 4px, transparent 4px 8px);
  opacity: 0.55;   /* a hatch, not a bar: an empty day is a plain bar, so the two cannot be mistaken */
}

/* Sticky month title at the top of each card (two-month view only; "January 2027" always carries its year). */
.tw .mmonth-title {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  padding: 6px 12px 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border-subtle);
}

.tw .mcal-nav-btn {
  width: 44px;
  height: 44px;
  margin: -2px 0;            /* a 44 px target inside the 40 px bar */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tw .mcal-nav-btn:active { background: var(--bg-hover); }
.tw .mcal-nav-btn:disabled { opacity: 0.3; cursor: default; }

.tw .mcal-range {
  flex: 1;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tw .mcal-two .mcal-header {
  height: 40px;
  min-height: 40px;
  padding: 0 calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px));
}
.tw .mcal-two .mcal-header-right { width: auto; min-width: 36px; }
.tw .mcal-two .mcal-year-label { color: var(--text-secondary); font-size: 0.68rem; white-space: nowrap; }

.tw .mcal-two .mcal-scroll {
  padding: 5px calc(12px + env(safe-area-inset-right, 0px)) 5px calc(12px + env(safe-area-inset-left, 0px));
  scroll-padding: 0 calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px));
  gap: 8px;
}
.tw .mcal-two .mcal-slide {
  min-width: calc((100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 8px) / 2);
  max-width: calc((100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 8px) / 2);
  scroll-snap-align: start;
  scroll-snap-stop: always;   /* a swipe moves one month, so pairs overlap (Oct+Nov, then Nov+Dec) */
}
.tw .mcal-two .mmonth-view { padding-bottom: 56px; }   /* the FAB never covers the last row */

.tw .mcal-two .mcal-fab {
  width: 44px;
  height: 44px;
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
}

/* The day sheet in landscape: a centred panel, not a full-width bottom sheet. */
.tw .mcal-two .msheet-backdrop { justify-content: center; }
.tw .mcal-two .msheet {
  width: min(520px, 100%);
  max-height: 85dvh;
}

/* Every row at least as tall as a weekend row (number + Sa/Su label + padding), so day 14 sits on one line in both
   cards. A row with two bars still grows; the columns then differ by that row only. */
.tw .mcal-two .mday-row { min-height: calc(1.09rem + 5px); }

/* Start card, landscape: one compact strip, never a stacked card. */
.tw .mcal-two .mcal-start {
  margin: 4px calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px));
  padding: 4px 12px 4px 15px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
}
.tw .mcal-two .mcal-start-head { display: contents; }
.tw .mcal-two .mcal-start-title { white-space: nowrap; }
.tw .mcal-two .mcal-start-body { flex: 1 1 220px; margin: 0; }
.tw .mcal-two .mcal-start-ok { order: 3; }

/* components/EventModal.css */

/* ===== Form ===== */
.tw .event-form {
  padding: 1rem 1.25rem;
}

/* min-width: 0 lets flex items shrink below the intrinsic min-width of an
   <input type="date"> — without it, mobile date inputs overflow their flex
   track and the Start/End fields visually overlap (BUG-015). */
.tw .form-group { margin-bottom: 1rem; flex: 1; min-width: 0; }

.tw .form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tw .form-group input,
.tw .form-group select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--bg-elevated);
  color: var(--text-primary);
  color-scheme: dark;
}

.tw .form-group input::placeholder { color: var(--text-tertiary); }

.tw .form-group input:focus,
.tw .form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.tw .form-group select option { background: var(--bg-elevated); color: var(--text-primary); }
.tw .form-row { display: flex; gap: 0.6rem; }

/* ===== Form Actions ===== */
.tw .form-actions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tw .action-buttons { display: flex; gap: 0.4rem; }

.tw .save-btn, .tw .cancel-btn, .tw .delete-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  transition: all 0.15s ease;
}

.tw .save-btn { background: var(--accent); color: var(--text-inverse); }
.tw .save-btn:hover { background: var(--accent-hover); box-shadow: 0 0 12px rgba(108, 114, 255, 0.3); }

.tw .cancel-btn { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-default); }
.tw .cancel-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.tw .delete-btn { background: transparent; color: var(--danger); border: 1px solid rgba(255, 77, 77, 0.25); }
.tw .delete-btn:hover { background: rgba(255, 77, 77, 0.1); border-color: var(--danger); }

/* ===== EventModal panel sizing — Modal primitive owns backdrop/animation/header/close;
       these classes apply via <Modal className="event-modal-panel{--quick}">. ===== */
.tw .event-modal-panel {
  width: min(480px, 92vw);
}

.tw .event-modal-panel--quick {
  width: min(360px, 92vw);
}

/* Mobile bottom-sheet treatment for Quick Add (preserved from .modal-content--quick) */
@media (max-width: 767px) {
  .tw .event-modal-panel--quick input[type="date"] {
    color: var(--text-primary);
    color-scheme: dark;
    background: var(--bg-elevated);
  }
  .tw .event-modal-panel--quick {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    margin: 0;
  }
}

.tw .qa-hint {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  margin-top: -0.25rem;
  margin-bottom: 0.5rem;
  font-style: italic;
}

/* ─── R4-02: Notes textarea ──────────────────────────────────────────────── */
.tw .em-notes {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.5rem 0.6rem;
  resize: vertical;
  min-height: 68px;
  box-sizing: border-box;
}
.tw .em-notes:focus {
  outline: none;
  border-color: var(--accent);
}
.tw .em-notes::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ─── R5-05: NL parse hint ───────────────────────────────────────────────── */
.tw .qa-nl-hint {
  margin: 0.3rem 0 0 0;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.01em;
  animation: hint-appear 0.15s ease;
}
@keyframes hint-appear {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── R5-01: Repeat hint ─────────────────────────────────────────────────── */
.tw .em-repeat-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(108, 114, 255, 0.06);
  border: 1px solid rgba(108, 114, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

/* ─── Legend hint (shown during onboarding) ───────────────────────────────── */
.tw .legend-hint {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(108, 114, 255, 0.06);
  border: 1px solid rgba(108, 114, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  margin: -0.25rem 0 0.5rem;
  line-height: 1.4;
  animation: hint-appear 0.15s ease;
}

.tw .legend-hint-icon {
  flex-shrink: 0;
  font-size: 0.85rem;
}

.tw .legend-hint strong {
  color: var(--accent);
  font-weight: 600;
}

/* components/EventPanel.css */
/* ===== Side Panel (MM-11 renamed from .event-panel; Modal primitive owns chrome — these are side-panel positioning overrides ONLY) ===== */
.tw .event-modal-panel-side {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  border-left: 1px solid var(--border-default);
  border-radius: 0;
}

/* Color accent bar */
.tw .panel-accent {
  height: 5px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.tw .panel-accent-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.2) 0%, transparent 50%, rgba(255,255,255,0.1) 100%);
}

/* ===== Body ===== */
.tw .panel-body {
  padding: 1.25rem 1.25rem;
  flex: 1;
  overflow-y: auto;
}

.tw .panel-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  line-height: 1.3;
}

/* Meta rows */
.tw .panel-meta {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tw .panel-meta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tw .panel-meta-icon {
  font-size: 0.85rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tw .panel-meta-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tw .panel-days {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
  margin-left: 0.3rem;
}

.tw .panel-type-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}

.tw .panel-loc-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

/* Action buttons */
.tw .panel-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.tw .panel-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  border: none;
  transition: all 0.12s;
  flex: 1;
}

.tw .panel-btn-edit {
  background: var(--accent);
  color: var(--text-inverse);
}
.tw .panel-btn-edit:hover {
  background: var(--accent-hover);
}

.tw .panel-btn-delete {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 77, 77, 0.2);
}
.tw .panel-btn-delete:hover {
  background: rgba(255, 77, 77, 0.08);
  border-color: var(--danger);
}

.tw .panel-btn-cancel {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.tw .panel-btn-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tw .panel-btn-save {
  background: var(--accent);
  color: var(--text-inverse);
}
.tw .panel-btn-save:hover {
  background: var(--accent-hover);
}

/* ===== Edit mode form ===== */
.tw .panel-edit {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.tw .pf-group {
  margin-bottom: 0.85rem;
}

.tw .pf-group label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.3rem;
}

.tw .pf-group input,
.tw .pf-group select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.82rem;
  color-scheme: dark;
  transition: border-color 0.15s;
}

.tw .pf-group input:focus,
.tw .pf-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.tw .pf-group input::placeholder {
  color: var(--text-tertiary);
}

.tw .pf-group select option {
  background: var(--bg-elevated);
}

.tw .pf-row {
  display: flex;
  gap: 0.5rem;
}
.tw .pf-row .pf-group { flex: 1; }

.tw .panel-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 480px) {
  .tw .event-modal-panel-side { width: 100vw; max-width: 100vw; }
}

/* ─── R4-02: Notes display ───────────────────────────────────────────────── */
.tw .panel-notes {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}
.tw .panel-notes-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.tw .panel-notes-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ─── R4-02: Notes textarea in edit form ─────────────────────────────────── */
.tw .pf-notes {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.5rem 0.6rem;
  resize: vertical;
  min-height: 72px;
  box-sizing: border-box;
}
.tw .pf-notes:focus {
  outline: none;
  border-color: var(--accent);
}
.tw .pf-notes::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* ─── R5-01: Repeat badge ────────────────────────────────────────────────── */
.tw .panel-repeat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(108, 114, 255, 0.1);
  border: 1px solid rgba(108, 114, 255, 0.2);
  border-radius: 99px;
  padding: 0.2rem 0.55rem;
  margin-top: 0.6rem;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

/* components/DayPicker.css */
/* ===== DayPicker Panel (Modal primitive consumer — MM-05) =====
 * .day-picker-overlay deleted (Modal/Overlay primitive owns the backdrop)
 * .day-picker renamed → .day-picker-panel (passed as className to <Modal>)
 * .day-picker-header deleted (Modal.Header owns the header layout)
 * .day-picker-close deleted (D-07 standardized Button primitive owns the close)
 * @keyframes pickerIn deleted (Modal primitive owns enter animation)
 */

.tw .day-picker-panel {
  background: var(--frost-bg);
  backdrop-filter: var(--frost-blur);
  -webkit-backdrop-filter: var(--frost-blur);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.1);
  width: 280px;
  overflow: hidden;
}

.tw .day-picker-date {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.tw .day-picker-events {
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  /* R3-06 + BUG-211b: growth is bounded by the panel's max height (DayPicker.jsx), and the Modal body is the one scroll region,
     so a busy day scrolls inside the panel with the header and "+ Add new event" always in view. */
  overscroll-behavior: contain;
}

.tw .day-picker-event {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: filter 0.12s, transform 0.12s;
  text-align: left;
}

.tw .day-picker-event:hover {
  filter: brightness(1.15);
  transform: translateX(2px);
}

.tw .day-picker-event-desc {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tw .day-picker-event-action {
  font-size: 0.6rem;
  opacity: 0.6;
  margin-left: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'JetBrains Mono', monospace;
}

.tw .day-picker-add {
  width: 100%;
  padding: 0.65rem;
  border: none;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.tw .day-picker-add:hover {
  background: var(--accent-subtle);
}

