/* ============================================
   My Life — design system
   Bright, colour-coded personal command centre
   ============================================ */

/* ---- Type scale ---- */
:root {
  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;

  /* ---- Spacing (4px base) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-full: 999px;

  /* ---- Domain accents ---- */
  --c-today:     oklch(0.70 0.175 55);
  --c-companies: oklch(0.62 0.145 162);
  --c-marketing: oklch(0.58 0.205 295);
  --c-inbox:     oklch(0.62 0.165 245);
  --c-home:      oklch(0.65 0.125 200);
  --c-quick:     oklch(0.63 0.195 12);
}

/* ---- Light mode (default) ---- */
:root,
[data-theme='light'] {
  --bg: oklch(0.98 0.009 85);
  --bg-2: oklch(0.955 0.012 80);
  --surface: oklch(1 0 0);
  --border: oklch(0.915 0.008 85);
  --border-strong: oklch(0.86 0.01 85);
  --ink: oklch(0.24 0.022 265);
  --ink-soft: oklch(0.44 0.02 265);
  --muted: oklch(0.575 0.018 265);
  --shadow-sm: 0 1px 2px oklch(0.3 0.03 265 / 0.05), 0 1px 3px oklch(0.3 0.03 265 / 0.04);
  --shadow-md: 0 4px 6px oklch(0.3 0.03 265 / 0.05), 0 10px 20px oklch(0.3 0.03 265 / 0.06);
  --shadow-lg: 0 12px 20px oklch(0.3 0.03 265 / 0.07), 0 24px 48px oklch(0.3 0.03 265 / 0.09);
  --tint-strength: 0.13;
  --chip-strength: 0.12;
}

/* ---- Dark mode ---- */
[data-theme='dark'] {
  --bg: oklch(0.175 0.018 265);
  --bg-2: oklch(0.205 0.02 265);
  --surface: oklch(0.225 0.021 265);
  --border: oklch(0.30 0.022 265);
  --border-strong: oklch(0.37 0.025 265);
  --ink: oklch(0.965 0.006 265);
  --ink-soft: oklch(0.85 0.012 265);
  --muted: oklch(0.68 0.018 265);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px oklch(0 0 0 / 0.3), 0 10px 20px oklch(0 0 0 / 0.28);
  --shadow-lg: 0 12px 20px oklch(0 0 0 / 0.35), 0 24px 48px oklch(0 0 0 / 0.4);
  --tint-strength: 0.20;
  --chip-strength: 0.22;
}

/* ---- Reset ---- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Warm ambient glow behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(70% 55% at 8% -5%, oklch(0.70 0.175 55 / 0.10), transparent 70%),
    radial-gradient(60% 50% at 100% 0%, oklch(0.58 0.205 295 / 0.09), transparent 70%),
    radial-gradient(70% 60% at 50% 105%, oklch(0.62 0.165 245 / 0.07), transparent 75%);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  /* clear the fixed bottom nav */
  padding: 0 var(--space-5) calc(112px + env(safe-area-inset-bottom));
}

@media (min-width: 980px) {
  .shell { padding-bottom: 132px; }
}

/* ============ Header ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: calc(var(--space-6) + env(safe-area-inset-top)) 0 var(--space-5);
}

.logo-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-right: auto;
  min-width: 0;
}

.logo-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--c-today), var(--c-quick) 45%, var(--c-marketing));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: var(--shadow-md);
}

.logo-mark svg { width: 22px; height: 22px; display: block; }

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
  line-height: 1;
}

.wordmark span { color: var(--muted); font-weight: 500; }

.badge-preview {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: oklch(0.70 0.175 55 / 0.14);
  color: oklch(0.46 0.14 52);
  border: 1px solid oklch(0.70 0.175 55 / 0.28);
  white-space: nowrap;
}

[data-theme='dark'] .badge-preview {
  color: oklch(0.82 0.13 62);
  background: oklch(0.70 0.175 55 / 0.18);
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, color 0.2s ease, border-color 0.2s ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-btn:active { transform: translateY(0) scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .moon { display: none; }
[data-theme='dark'] .icon-btn .sun { display: none; }
[data-theme='dark'] .icon-btn .moon { display: block; }

/* ============ Greeting ============ */
.greeting {
  padding: var(--space-2) 0 var(--space-8);
}

.greeting h1 {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.greeting h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--c-today), var(--c-quick) 55%, var(--c-marketing));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.greeting p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ============ Tile grid ============ */
.tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 620px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile-wide { grid-column: span 2; }
}

@media (min-width: 980px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile-wide { grid-column: span 2; }
}

/* ============ Tile ============ */
.tile {
  --accent: var(--muted);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.2s cubic-bezier(0.2, 0.7, 0.3, 1),
              box-shadow 0.2s ease,
              border-color 0.2s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

/* Colour wash */
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(130% 105% at 100% 0%,
    color-mix(in oklch, var(--accent) calc(var(--tint-strength) * 100%), transparent) 0%,
    transparent 62%);
  transition: opacity 0.25s ease;
}

/* Top accent hairline */
.tile::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 85%);
  opacity: 0.85;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in oklch, var(--accent) 40%, var(--border));
}

.tile:hover::before { opacity: 1.35; }
.tile:active { transform: translateY(-1px) scale(0.995); }

.tile-locked {
  cursor: default;
  opacity: 0.72;
}

.tile-locked:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}

/* Tile head */
.tile-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tile-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) calc(var(--chip-strength) * 100%), transparent);
  border: 1px solid color-mix(in oklch, var(--accent) 22%, transparent);
}

.tile-icon svg { width: 20px; height: 20px; }

.tile-label {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-right: auto;
}

.tile-status {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 13%, transparent);
  white-space: nowrap;
}

.tile-arrow {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.tile-arrow svg { width: 18px; height: 18px; display: block; }
.tile:hover .tile-arrow { color: var(--accent); transform: translateX(3px); }

/* Metric */
.metric {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.metric-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}

.metric-unit {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.metric-delta {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}

.delta-up {
  color: oklch(0.48 0.14 162);
  background: oklch(0.62 0.145 162 / 0.15);
}

.delta-down {
  color: oklch(0.52 0.17 20);
  background: oklch(0.63 0.195 12 / 0.15);
}

[data-theme='dark'] .delta-up { color: oklch(0.80 0.14 162); }
[data-theme='dark'] .delta-down { color: oklch(0.80 0.15 18); }

/* Rows */
.rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: auto;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-top: 1px solid var(--border);
}

.rows .row:first-child { border-top: 0; }

.row-dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
}

.row-label {
  color: var(--ink-soft);
  margin-right: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-time {
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 12%, transparent);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ---- Today hero tile ---- */
.next-up {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in oklch, var(--accent) 20%, transparent);
}

.next-time {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.next-body { min-width: 0; }

.next-title {
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.stat {
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-num {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-cap {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
}

/* ---- Sparkline ---- */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
}

.spark i {
  flex: 1;
  border-radius: 3px 3px 1px 1px;
  background: color-mix(in oklch, var(--accent) 32%, transparent);
  transition: background 0.2s ease;
  animation: grow 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.spark i:last-child { background: var(--accent); }
.tile:hover .spark i { background: color-mix(in oklch, var(--accent) 55%, transparent); }
.tile:hover .spark i:last-child { background: var(--accent); }

/* ---- Entity pills (Companies) ---- */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pill {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--ink-soft);
}

/* ============ Quick actions ============ */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) 0 var(--space-4);
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 620px) {
  .actions { grid-template-columns: repeat(4, 1fr); }
}

.action {
  --accent: var(--c-quick);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: var(--text-sm);
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1),
              box-shadow 0.18s ease, border-color 0.18s ease;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in oklch, var(--accent) 40%, var(--border));
}

.action:active { transform: translateY(0) scale(0.98); }

.action-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) calc(var(--chip-strength) * 100%), transparent);
  border: 1px solid color-mix(in oklch, var(--accent) 20%, transparent);
}

.action-icon svg { width: 17px; height: 17px; }

.action-text { font-weight: 650; line-height: 1.25; }
.action-sub { font-size: var(--text-xs); color: var(--muted); }

/* ============ Footer ============ */
.foot {
  padding: var(--space-10) 0 0;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* ============ Bottom navigation ============ */
.navbar {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  background: color-mix(in oklch, var(--surface) 82%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-4) calc(var(--space-2) + env(safe-area-inset-bottom));
}

.nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  gap: var(--space-1);
  max-width: 520px;
  margin: 0 auto;
}

/* Floating pill on wider screens */
@media (min-width: 980px) {
  .navbar {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2) var(--space-4);
  }
  .nav-inner { grid-template-columns: repeat(5, 88px); max-width: none; }
}

.nav-item {
  --accent: var(--muted);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-2) 0 var(--space-1);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 30px;
  border-radius: var(--radius-full);
  transition: background 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.nav-ico svg { width: 21px; height: 21px; display: block; }

.nav-item:hover { color: var(--ink-soft); }
.nav-item:hover .nav-ico { background: var(--bg-2); }

.nav-item.is-active { color: var(--accent); }

.nav-item.is-active .nav-ico {
  background: color-mix(in oklch, var(--accent) calc(var(--chip-strength) * 100%), transparent);
  transform: translateY(-1px);
}

.nav-txt { line-height: 1; }

/* Unread dot */
.nav-dot {
  position: absolute;
  top: 6px;
  right: 50%;
  margin-right: -18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-inbox);
  border: 2px solid var(--surface);
}

/* Raised centre action */
.nav-fab-slot {
  display: grid;
  place-items: center;
}

.nav-fab {
  width: 52px;
  height: 52px;
  margin-top: -20px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(140deg, var(--c-today), var(--c-quick) 52%, var(--c-marketing));
  box-shadow: 0 6px 16px oklch(0.63 0.195 12 / 0.35), var(--shadow-md);
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.18s ease;
}

.nav-fab svg { width: 23px; height: 23px; display: block; }

.nav-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 24px oklch(0.63 0.195 12 / 0.42), var(--shadow-lg);
}

.nav-fab:active { transform: translateY(-1px) scale(0.97); }

@media (min-width: 980px) {
  .nav-fab { margin-top: -14px; }
}

/* ============ Animation ============ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes grow {
  from { transform: scaleY(0.1); opacity: 0; transform-origin: bottom; }
  to { transform: scaleY(1); opacity: 1; transform-origin: bottom; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--c-inbox);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================
   Auth + biometric gate
   Full-bleed overlay. Sits above the shell and
   the bottom nav so no data is readable behind.
   ============================================ */

body.locked {
  overflow: hidden;
}

body.locked .shell,
body.locked .navbar {
  /* Blur rather than display:none so the app still feels present behind
     the lock, but nothing is legible. */
  filter: blur(18px) saturate(0.7);
  pointer-events: none;
  user-select: none;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 12% 0%, oklch(0.70 0.175 55 / 0.16), transparent 60%),
    radial-gradient(110% 85% at 92% 8%, oklch(0.58 0.205 295 / 0.15), transparent 62%),
    radial-gradient(120% 90% at 50% 100%, oklch(0.62 0.145 162 / 0.13), transparent 65%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-6) var(--space-6);
  animation: gate-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes gate-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.gate-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-sm);
  letter-spacing: 0.01em;
  color: var(--ink);
}

.gate-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  line-height: 1.15;
  color: var(--ink);
  margin: 0 0 var(--space-2);
}

.gate-lede {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--space-6);
  line-height: 1.5;
}

/* ---- Fields ---- */

.field {
  display: block;
  margin-bottom: var(--space-4);
}

.field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: var(--space-2);
}

.field input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  /* 16px minimum stops iOS Safari zooming the viewport on focus. */
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field input:focus-visible {
  outline: none;
  background: var(--surface);
  border-color: var(--c-companies);
  box-shadow: 0 0 0 3.5px oklch(0.62 0.145 162 / 0.18);
}

/* ---- Buttons ---- */

.gate-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  margin-top: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: oklch(1 0 0);
  background: linear-gradient(135deg,
    oklch(0.64 0.15 162) 0%,
    oklch(0.58 0.16 175) 100%);
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.gate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.04);
}

.gate-btn:active:not(:disabled) {
  transform: translateY(0);
}

.gate-btn:focus-visible {
  outline: 2.5px solid var(--c-companies);
  outline-offset: 2.5px;
}

.gate-btn:disabled {
  cursor: progress;
  filter: saturate(0.55) brightness(0.98);
}

.gate-link {
  display: block;
  width: 100%;
  margin-top: var(--space-5);
  padding: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s ease;
}

.gate-link:hover { color: var(--ink); }
.gate-link:focus-visible {
  outline: 2px solid var(--c-companies);
  outline-offset: 2px;
}

/* ---- Messages ---- */

.gate-msg {
  font-size: var(--text-xs);
  line-height: 1.45;
  margin: 0 0 var(--space-3);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
}

.gate-msg[data-kind='error'] {
  color: oklch(0.45 0.17 22);
  background: oklch(0.63 0.195 12 / 0.09);
  border-color: oklch(0.63 0.195 12 / 0.28);
}

.gate-msg[data-kind='warn'] {
  color: oklch(0.44 0.11 62);
  background: oklch(0.70 0.175 55 / 0.11);
  border-color: oklch(0.70 0.175 55 / 0.3);
}

.gate-msg[data-kind='info'] {
  color: oklch(0.42 0.1 175);
  background: oklch(0.62 0.145 162 / 0.1);
  border-color: oklch(0.62 0.145 162 / 0.28);
}

[data-theme='dark'] .gate-msg[data-kind='error'] { color: oklch(0.84 0.11 22); }
[data-theme='dark'] .gate-msg[data-kind='warn']  { color: oklch(0.86 0.1 68); }
[data-theme='dark'] .gate-msg[data-kind='info']  { color: oklch(0.84 0.1 168); }

/* ---- Face ID glyph ---- */

.gate-face {
  width: 3.75rem;
  height: 3.75rem;
  margin-bottom: var(--space-5);
  display: grid;
  place-items: center;
  color: var(--c-companies);
  background: oklch(0.62 0.145 162 / 0.11);
  border-radius: var(--radius);
}

.gate-face svg {
  width: 2.1rem;
  height: 2.1rem;
}

#unlock-btn[data-busy='1'] + #enrol-row,
.gate-btn[data-busy='1'] .btn-label {
  opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .gate-card { animation: none; }
  .gate-btn:hover:not(:disabled) { transform: none; }
}

/* ============================================================
   Today tile — freshness footer + sample-data chips
   ============================================================ */

.tile-foot {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  min-height: 1.15rem;
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.freshness::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent, var(--c-today));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent, var(--c-today)) 22%, transparent);
}

.freshness.is-stale {
  color: oklch(0.58 0.16 45);
}

.freshness.is-stale::before {
  background: oklch(0.68 0.17 55);
  box-shadow: none;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.chip-sample {
  margin-left: auto;
  margin-right: var(--space-2);
  padding: 0.15rem 0.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ============================================================
   Detail sheet
   ============================================================ */

body.has-sheet {
  overflow: hidden;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* display:flex above beats the UA [hidden] rule, which would leave a
   full-screen backdrop blurring the page and eating every click. */
.sheet[hidden] { display: none; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0.22 0.03 265 / 0.42);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sheet.is-open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.sheet.is-open .sheet-panel {
  transform: translateY(0);
  opacity: 1;
}

@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-panel {
    border-radius: var(--radius-lg);
    border-bottom: 1px solid var(--border);
    max-height: 82vh;
  }
}

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  margin: var(--space-3) auto 0;
  flex: none;
}

@media (min-width: 720px) { .sheet-grab { display: none; } }

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sheet-titles { flex: 1; min-width: 0; }

.sheet-titles h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}

.sheet-titles p {
  margin: 0.15rem 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

#today-refresh.is-spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2) var(--space-5) var(--space-8);
}

/* Section heads */

.sh-sec { margin-top: var(--space-5); }

.sh-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.sh-head h3 {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.sh-count {
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  background: color-mix(in oklch, var(--accent, var(--c-today)) 16%, var(--surface));
  color: color-mix(in oklch, var(--accent, var(--c-today)) 72%, var(--ink));
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

/* Rows */

.sh-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sh-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: start;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
}

/* On a phone the three columns squeeze the subject into one word per line,
   so stack: time + area chip on the first line, subject full width below. */
@media (max-width: 560px) {
  .sh-row { grid-template-columns: auto 1fr; }
  .sh-time { grid-area: 1 / 1; }
  .sh-chip { grid-area: 1 / 2; justify-self: end; }
  .sh-main { grid-area: 2 / 1 / 3 / -1; }
}

.sh-time {
  padding-top: 0.1rem;
  overflow-wrap: break-word;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
}

.sh-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sh-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: break-word;
}

a.sh-title { text-decoration: none; }
a.sh-title:hover { text-decoration: underline; }

.sh-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  overflow-wrap: break-word;
}

/* Which calendar an event came from. Reads as a quiet pill so a row with both
   an owner and a location stays scannable, and an owner-only row still has a
   visible anchor. Inline-block so it never splits across a wrap. */
.sh-who {
  display: inline-block;
  margin-right: var(--space-2);
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}

/* Unread marker as a left rail, not an inline dot: an inline dot lands
   mid-sentence whenever the subject wraps to two lines. */
.sh-row { position: relative; }

.sh-row.is-unread::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent, var(--c-today));
}

.sh-row.is-unread .sh-title { font-weight: 700; }

.sh-chip {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Empty + warning states */

.sh-empty {
  padding: var(--space-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.sh-empty p {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
}

.sh-empty small {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.45;
}

.sh-warn {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid oklch(0.82 0.09 55);
  background: oklch(0.96 0.035 70);
  color: oklch(0.36 0.08 50);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.sh-warn ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }

.sh-note {
  margin: var(--space-6) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.55;
}

[data-theme="dark"] .sheet-backdrop { background: oklch(0.12 0.02 265 / 0.6); }
[data-theme="dark"] .sh-warn {
  border-color: oklch(0.45 0.08 55);
  background: oklch(0.28 0.04 60);
  color: oklch(0.88 0.05 70);
}
