/* Tokens: shared by the sign-in gate and the app. */
:root {
  /* Surfaces and lines */
  --paper: #f5f7fb;
  --card: #fff;
  --side: #fbfcfe;
  --hover: #f6f8fe;
  --line: #e4e8ef;
  --line-soft: #edf0f4;
  --line-button: #d0d5dd;
  /* Form control edges: 3:1 or better on white, on the page and on the top bar */
  --line-control: #808b9d;
  --line-control-hover: #667085;
  /* Text */
  --ink: #1b2430;
  --ink-2: #344054;
  --soft: #475467;
  --muted: #667085;
  /* Brand: the logo's blue, violet and cyan, in small doses */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-press: #1e40af;
  --accent-ink: #1d4ed8;
  --accent-soft: #eef3ff;
  --brand-blue: #3699fd;
  --brand-violet: #7b55fc;
  --brand-cyan: #0acdea;
  --brand-gradient: linear-gradient(135deg, #3699fd 0%, #6358fc 52%, #0acdea 100%);
  /* Status tones: text, tint, edge and dot */
  --neutral-ink: #475467;
  --neutral-bg: #f2f4f7;
  --neutral-line: #e4e7ec;
  --neutral-dot: #8590a2;
  --info-ink: #1d4ed8;
  --info-bg: #eff4ff;
  --info-line: #c7d7fe;
  --info-dot: #2563eb;
  --success-ink: #067647;
  --success-bg: #ecfdf3;
  --success-line: #abefc6;
  --success-dot: #079455;
  --attention-ink: #b54708;
  --attention-bg: #fffaeb;
  --attention-line: #fedf89;
  --attention-dot: #dc6803;
  --danger-ink: #b42318;
  --danger-bg: #fef3f2;
  --danger-line: #fecdca;
  --danger-dot: #d92d20;
  --paused-ink: #5925dc;
  --paused-bg: #f4f3ff;
  --paused-line: #d9d6fe;
  --paused-dot: #7a5af8;
  /* Type */
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-text: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 0.9375rem;
  --text-xl: 1rem;
  --text-2xl: 1.25rem;
  --text-3xl: 1.75rem;
  /* Space: 4, 8, 12, 16, 24, 32 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  /* Radii */
  --radius-sm: 8px;
  --radius-control: 10px;
  --radius-lg: 12px;
  --radius: 16px;
  --radius-pill: 999px;
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 6px -2px rgba(16, 24, 40, 0.05), 0 12px 24px -16px rgba(16, 24, 40, 0.14);
  --shadow-raised: 0 4px 8px -4px rgba(16, 24, 40, 0.08), 0 18px 36px -12px rgba(16, 24, 40, 0.22);
  --shadow-primary: 0 1px 2px rgba(16, 24, 40, 0.12), 0 4px 10px -4px rgba(37, 99, 235, 0.55);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.22);
  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.75, 0.25, 1);
  --spring: linear(0, 0.08, 0.28, 0.53, 0.78, 0.98, 1.13, 1.21, 1.23, 1.21, 1.17, 1.11, 1.05, 1, 0.97, 0.95, 0.945,
    0.95, 0.96, 0.975, 0.99, 1, 1.007, 1.012, 1.013, 1.01, 1.006, 1.003, 1);
  --spring-soft: linear(0, 0.06, 0.2, 0.38, 0.57, 0.75, 0.89, 1, 1.07, 1.11, 1.126, 1.12, 1.1, 1.08, 1.06, 1.04,
    1.02, 1, 0.993, 0.987, 0.984, 0.986, 0.99, 0.995, 1);
  /* Overshoots by 6% at most, so the glass never uncovers what the face hides. */
  --spring-glass: linear(0, 0.1, 0.3, 0.52, 0.72, 0.87, 0.97, 1.04, 1.075, 1.086, 1.08, 1.065, 1.045, 1.027, 1.012,
    1.002, 0.996, 0.993, 0.994, 0.997, 1);
  --fast: 150ms;
  --base: 200ms;
  /* Layout */
  --side-w: 256px;
  --topbar-h: 64px;
  --content-max: 1280px;
  --gutter: 32px;
  --card-pad: 24px;
  --pad-x: max(var(--gutter), calc((100% - var(--content-max)) / 2));
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sign-in gate ---------------------------------------------------------------------------------------------- */

.gate {
  --gate-soft: var(--soft);
  --gate-w: 30rem;
  --gate-btn-w: 340px;
  --gate-kai-size: clamp(128px, min(41vw, 28vh), 256px);
  --gate-spring: var(--spring);
  --gate-spring-soft: var(--spring-soft);
  --gate-spring-glass: var(--spring-glass);
  --gate-ease-out: var(--ease-out);
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  /* The error and footer hang from a zero-height row, so an error never moves the creature or the column. */
  grid-template: "." 1fr "kai" auto "copy" auto "after" 0 "." 1fr / minmax(0, var(--gate-w));
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  /* The extra bottom padding is the footer's room, so the visible block is centred. */
  padding: max(20px, 4vh) 16px calc(max(20px, 4vh) + 43px);
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  overflow-x: clip;
}
.gate-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.gate-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  /* A faint grain stops the gradients banding. */
  background: radial-gradient(54% 48% at 50% 46%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .13 0 0 0 0 .3 0 0 0 .12 -.045'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 160px;
}
.gate-blob, .gate-sheen { position: absolute; display: block; will-change: transform; }
.gate-blob { width: 78vmax; height: 78vmax; border-radius: 50%; }
.gate-blob-1 {
  left: -30vmax;
  top: -40vmax;
  background: radial-gradient(closest-side, rgba(118, 162, 255, 0.58), rgba(118, 162, 255, 0));
  animation: gate-in 1.2s ease-out backwards, gate-blob-1 36s ease-in-out -9s infinite alternate;
}
.gate-blob-2 {
  left: -28vmax;
  bottom: -44vmax;
  background: radial-gradient(closest-side, rgba(176, 146, 255, 0.5), rgba(176, 146, 255, 0));
  animation: gate-in 1.2s ease-out backwards, gate-blob-2 29s ease-in-out -13s infinite alternate;
}
.gate-blob-3 {
  right: -30vmax;
  bottom: -38vmax;
  background: radial-gradient(closest-side, rgba(96, 224, 238, 0.52), rgba(96, 224, 238, 0));
  animation: gate-in 1.2s ease-out backwards, gate-blob-3 41s ease-in-out -6s infinite alternate;
}
.gate-blob-4 {
  right: -26vmax;
  top: -42vmax;
  width: 64vmax;
  height: 64vmax;
  background: radial-gradient(closest-side, rgba(150, 206, 255, 0.55), rgba(150, 206, 255, 0));
  animation: gate-in 1.2s ease-out backwards, gate-blob-4 24s ease-in-out -4s infinite alternate;
}
.gate-sheen {
  left: 50%;
  top: 50%;
  width: 180vmax;
  height: 64vmax;
  margin: -32vmax 0 0 -90vmax;
  transform: rotate(-20deg);
  background: linear-gradient(180deg, rgba(140, 228, 245, 0) 10%, rgba(140, 228, 245, 0.16) 34%, rgba(255, 255, 255, 0.34) 50%,
    rgba(186, 164, 255, 0.14) 66%, rgba(186, 164, 255, 0) 90%);
  animation: gate-in 1.4s ease-out backwards, gate-sheen 45s ease-in-out -15s infinite alternate;
}
@keyframes gate-blob-1 { to { transform: translate3d(22vw, 16vh, 0) scale(1.18); } }
@keyframes gate-blob-2 { to { transform: translate3d(26vw, -18vh, 0) scale(0.88); } }
@keyframes gate-blob-3 { to { transform: translate3d(-24vw, -20vh, 0) scale(1.2); } }
@keyframes gate-blob-4 { to { transform: translate3d(-20vw, 22vh, 0) scale(0.92); } }
@keyframes gate-sheen {
  from { transform: translate3d(-18vw, -10vh, 0) rotate(-26deg); }
  to { transform: translate3d(18vw, 10vh, 0) rotate(-14deg); }
}
@keyframes gate-in { from { opacity: 0; } }
@keyframes gate-rise { from { opacity: 0; transform: translateY(16px); } }

.gate-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.gate-kai {
  --gate-ex: var(--gate-gx, 0);
  --gate-ey: var(--gate-gy, 0);
  grid-area: kai;
  position: relative;
  z-index: 1;
  width: var(--gate-kai-size);
  aspect-ratio: 1;
  -webkit-tap-highlight-color: transparent;
}
.gate-kai-glow, .gate-kai-body, .gate-kai-l, .gate-kai svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gate-kai-glow { animation: gate-kai-glow 6.2s ease-in-out infinite; }
.gate-kai-glow g { animation: gate-in 0.7s ease-out 0.8s backwards; }
.gate-kai-body { transform-origin: 50% 86%; animation: gate-kai-bob 6.2s ease-in-out infinite, gate-kai-sway 9.4s ease-in-out -2s infinite; }
.gate-kai-blue, .gate-kai-cyan {
  transition: translate 0.8s var(--gate-ease-out), scale 0.6s var(--gate-spring-soft), rotate 0.9s var(--gate-ease-out);
}
.gate-kai-blue { --gate-unfold: 0.18s; translate: calc(var(--gate-ex) * -0.8%) calc(var(--gate-ey) * -0.7%); transform-origin: 40% 34%; }
.gate-kai-cyan { --gate-unfold: 0.26s; translate: calc(var(--gate-ex) * -0.45%) calc(var(--gate-ey) * -0.4%); transform-origin: 64% 63%; }
.gate-kai-unfold {
  transform-origin: 52.2% 47.4%;
  animation: gate-kai-unfold 0.9s var(--gate-spring-glass) var(--gate-unfold) backwards, gate-in 0.15s ease-out var(--gate-unfold) backwards;
}
.gate-kai-blue svg { transform-origin: 40% 34%; animation: gate-kai-drift-blue 7.4s ease-in-out -2s infinite alternate; }
.gate-kai-cyan svg { transform-origin: 64% 63%; animation: gate-kai-drift-cyan 9.7s ease-in-out -5s infinite alternate; }
.gate-kai-face {
  translate: calc(var(--gate-ex) * 1.4%) calc(var(--gate-ey) * 1.1%);
  transform-origin: 52.2% 47.4%;
  transition: translate 0.8s var(--gate-ease-out);
  animation: gate-kai-pop 0.6s var(--gate-spring) backwards, gate-in 0.16s ease-out backwards;
}
.gate-kai-head, .gate-kai-mull { transform-origin: 52% 52%; }
.gate-kai-head { transition: translate 0.7s var(--gate-ease-out), rotate 0.7s var(--gate-ease-out); }
.gate-kai-eyes { translate: calc(var(--gate-ex) * 3.6%) calc(var(--gate-ey) * 2.6%); transition: translate 0.45s var(--gate-ease-out); }
.gate-kai-lids { transform-origin: 51.8% 47.1%; animation: gate-kai-wake 1.55s linear backwards; }
.gate-kai-open, .gate-kai-sad, .gate-kai-happy {
  transform-origin: 99.4px 90.4px;
  transition: opacity 0.2s ease, scale 0.3s var(--gate-spring-soft), translate 0.3s var(--gate-ease-out);
}
.gate-kai-happy { scale: 0.7; translate: 0 2px; }
@keyframes gate-kai-pop { from { transform: scale(0.5); } }
@keyframes gate-kai-unfold { from { transform: scale(0.3); } }
@keyframes gate-kai-wake {
  0%, 58% { transform: scaleY(0.08); }
  70%, 76% { transform: scaleY(0.5); }
  82% { transform: scaleY(0.1); }
  93% { transform: scaleY(1.08); }
}
@keyframes gate-kai-bob { 50% { translate: 0 -4%; } }
@keyframes gate-kai-sway { 0%, 100% { rotate: -1.4deg; } 50% { rotate: 1.4deg; } }
@keyframes gate-kai-glow { 50% { scale: 0.93; opacity: 0.72; } }
@keyframes gate-kai-drift-blue {
  from { transform: translate(0.6%, 0.5%) rotate(1deg) scale(0.99); }
  to { transform: translate(-1.2%, -1.1%) rotate(-2.6deg) scale(1.03); }
}
@keyframes gate-kai-drift-cyan {
  from { transform: translate(-0.5%, -0.6%) rotate(-1.4deg) scale(1.01); }
  to { transform: translate(1.1%, 1%) rotate(2.8deg) scale(0.975); }
}

.gate[data-mood="happy"] .gate-kai-open { opacity: 0; scale: 1 0.3; }
.gate[data-mood="happy"] .gate-kai-happy { opacity: 1; scale: 1; translate: 0 0; }
.gate[data-mood="happy"] .gate-kai-blue { scale: 1.045; rotate: -2deg; }
.gate[data-mood="happy"] .gate-kai-cyan { scale: 1.035; rotate: 2deg; }
/* Busy: the head and eyes ease into the pose, then inner layers loop from rest, one animation each so they composite. */
.gate[data-state="busy"] .gate-kai { --gate-ex: 0.4; --gate-ey: -1; }
.gate[data-state="busy"] .gate-kai-head { rotate: -3deg; }
.gate[data-state="busy"] .gate-kai-eyes { translate: calc(var(--gate-ex) * 3.6% - 2%) calc(var(--gate-ey) * 2.6%); }
.gate[data-state="busy"] .gate-kai-mull { animation: gate-kai-ponder 2.6s ease-in-out 0.65s infinite; }
.gate[data-state="busy"] .gate-kai-look { animation: gate-kai-think 2.6s ease-in-out 0.65s infinite; }
.gate[data-state="busy"] .gate-kai-unfold {
  animation: gate-kai-unfold 0.9s var(--gate-spring-glass) var(--gate-unfold) backwards, gate-in 0.15s ease-out var(--gate-unfold) backwards,
    gate-kai-work 1.3s ease-in-out infinite alternate;
}
.gate[data-state="busy"] .gate-kai-cyan .gate-kai-unfold { animation-delay: var(--gate-unfold), var(--gate-unfold), 0.65s; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai { --gate-ey: 0.45; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai-open { opacity: 0; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai-sad { opacity: 1; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai-head { translate: 0 1.6%; rotate: -2.5deg; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai-blue { rotate: -4deg; }
.gate[data-state="error"]:not([data-mood="happy"]) .gate-kai-cyan { rotate: 3deg; }
@keyframes gate-kai-ponder { 50% { rotate: 6deg; } }
@keyframes gate-kai-think { 50% { translate: 4.4% -0.6%; } }
@keyframes gate-kai-work { to { scale: 1.05; } }

.gate-copy { grid-area: copy; position: relative; display: grid; justify-items: center; width: 100%; }
/* A pool of light keeps the column's text AA; its falloff is a shadow, so it adds no scroll size. */
.gate-copy::before {
  content: "";
  position: absolute;
  inset: 4% 6% 0;
  z-index: -1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 72px 56px rgba(255, 255, 255, 0.62);
  pointer-events: none;
}
.gate-kicker {
  margin: 6px 0 8px;
  padding-left: 0.16em;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.gate h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}
/* The lede and the waking line share one cell and crossfade, so neither moves the button. */
.gate-say { display: grid; max-width: 26em; margin: 14px 0 28px; font-size: 1rem; }
.gate-say > p { grid-area: 1 / 1; margin: 0; transition: opacity 0.35s ease, visibility 0.35s; }
.gate-lede { line-height: 1.55; color: var(--gate-soft); text-wrap: balance; }
.gate-wait { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--gate-soft); visibility: hidden; opacity: 0; }
.gate-wait::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}
@keyframes gate-pulse { 50% { opacity: 0.4; scale: 0.7; } }

.gate-btn {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(100%, var(--gate-btn-w));
  min-height: 50px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-lg);
  background: #2f2f2f;
  color: #fff;
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.18), 0 14px 28px -16px rgba(16, 24, 40, 0.55);
  transition: opacity 0.4s ease 0.12s, translate 0.6s var(--gate-ease-out) 0.12s, visibility 0.4s 0.12s;
}
/* A white veil under the label and logo lifts #2f2f2f to about #3b3b3b on hover. */
.gate-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: #fff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.gate-btn:enabled:hover::after { opacity: 0.06; }
.gate-btn:enabled:active::after { opacity: 0; }
.gate-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.18); }
.gate-btn:disabled { cursor: progress; }
.gate-btn-icon { position: relative; flex: none; width: 21px; height: 21px; }
.gate-ms { display: block; width: 21px; height: 21px; }
.gate-spin {
  display: none;
  position: absolute;
  inset: 1.5px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
}
.gate-going { display: none; }
.gate[data-state="busy"] .gate-ms, .gate[data-state="busy"] .gate-go { display: none; }
.gate[data-state="busy"] .gate-spin { display: block; animation: gate-spin 0.8s linear infinite; }
.gate[data-state="busy"] .gate-going { display: inline; }
@keyframes gate-spin { to { transform: rotate(1turn); } }

/* z-index 1 here and on .gate-kai keeps them above the column's light pool, also while the column rises. */
.gate-after { grid-area: after; align-self: start; position: relative; z-index: 1; display: grid; justify-items: center; width: 100%; }
.gate-copy, .gate-after { animation: gate-rise 0.9s var(--gate-spring-soft) 0.42s backwards; }
.gate #gate-error {
  display: flex;
  gap: 9px;
  width: min(100%, var(--gate-btn-w));
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-lg);
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: var(--text-md);
  line-height: 1.45;
  text-align: left;
  text-wrap: pretty;
  animation: gate-rise 0.45s var(--gate-ease-out) backwards;
}
.gate #gate-error::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='%23d92d20' stroke-width='1.6'/%3E%3Cpath d='M8 4.4v4.3' stroke='%23d92d20' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.3' r='.95' fill='%23d92d20'/%3E%3C/svg%3E") center / contain no-repeat;
}
.gate-foot {
  margin: 28px 0 0;
  font-size: 0.78rem;
  color: var(--gate-soft);
  animation: gate-in 0.6s ease-out 0.8s backwards;
  transition: opacity 0.5s ease 0.15s, visibility 0.5s 0.15s;
}
/* Under an error the footer sits past the light pool, so it takes darker ink. */
.gate[data-state="error"] .gate-foot { color: var(--ink-2); }

.gate[data-state="waking"] .gate-lede { visibility: hidden; opacity: 0; }
.gate[data-state="waking"] .gate-wait { visibility: visible; opacity: 1; }
.gate[data-state="waking"] .gate-wait::before { animation: gate-pulse 1.4s ease-in-out infinite; }
.gate[data-state="waking"] .gate-btn { visibility: hidden; opacity: 0; translate: 0 10px; }
.gate[data-state="waking"] .gate-foot { visibility: hidden; opacity: 0; }

@media (max-height: 540px) and (min-width: 600px) {
  .gate {
    --gate-kai-size: min(200px, 50vh);
    grid-template: ". ." 1fr "kai copy" auto ". after" 0 ". ." 1fr / auto minmax(0, 24rem);
    column-gap: clamp(24px, 5vw, 56px);
  }
  .gate-kicker { margin-top: 0; }
  .gate-say { margin: 10px 0 20px; }
  .gate-foot { margin-top: 18px; }
}
@media (max-height: 640px) {
  .gate[data-state="error"] .gate-foot { display: none; }
}
@media (max-width: 480px) {
  .gate { --gate-btn-w: 100%; }
  .gate-say { font-size: 0.9375rem; margin-bottom: 24px; }
}
@media (min-width: 1800px) and (min-height: 1000px) {
  .gate { --gate-kai-size: 280px; --gate-w: 32rem; --gate-btn-w: 360px; }
  .gate h1 { font-size: 3rem; }
  .gate-say { font-size: 1.0625rem; }
}
@media (prefers-reduced-motion: reduce) {
  .gate *, .gate *::before, .gate *::after {
    animation: none !important;
    transition-property: opacity, visibility !important;
    translate: none !important;
    rotate: none !important;
    scale: none !important;
    will-change: auto !important;
  }
}
@media (forced-colors: active) {
  .gate-bg, .gate-copy::before { display: none; }
  .gate-btn { border: 1px solid; }
}


/* App shell ---------------------------------------------------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  font-family: var(--font-text);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  animation: app-in var(--base) var(--ease-out);
}
@keyframes app-in { from { opacity: 0; } }
/* A focused control scrolls into view clear of the sticky top bar. */
html:has(> body > .app:not([hidden])) { scroll-padding-top: calc(var(--topbar-h) + var(--space-2)); }
.app h2, .app h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.app h2 { margin: 0 0 var(--space-2); font-size: var(--text-xl); line-height: 1.35; }
.app h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); line-height: 1.4; }
/* Base paragraphs weigh no more than a class (:where), so any component's own spacing wins. */
.app :where(p) { margin: 0 0 var(--space-3); }
.app :is(p, li, dd, h2, h3, strong) { overflow-wrap: anywhere; }
.app :where(a) { color: var(--accent-ink); }
.app hr { margin: var(--space-2) 0; border: 0; border-top: 1px solid var(--line-soft); }
/* An expandable section opens with the same thin chevron as the rest of the icons. */
.app summary { display: flex; align-items: center; gap: 6px; min-height: 24px; list-style: none; cursor: pointer; color: var(--ink-2); font-weight: 600; }
.app summary::-webkit-details-marker { display: none; }
.app summary::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  background: currentColor;
  opacity: 0.7;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6l6 6-6 6'/%3E%3C/svg%3E") center / 16px no-repeat;
  transition: transform var(--fast) ease;
}
.app details[open] > summary::before { transform: rotate(90deg); }
.app summary:hover { color: var(--ink); }
.app blockquote { margin: var(--space-3) 0; padding: var(--space-2) var(--space-4); border-left: 3px solid var(--line-button); color: var(--soft); }

.side {
  position: sticky;
  top: 0;
  z-index: 30;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  height: 100vh;
  height: 100dvh;
  padding: var(--space-4) var(--space-3) var(--space-3);
  background: var(--side);
  border-right: 1px solid var(--line);
}
/* On desktop the sidebar is pinned to the window, so it never travels with the page, not even in a trackpad's bounce
   at the top or bottom of a page. */
@media (min-width: 961px) {
  .side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); height: auto; }
  .shell { grid-column: 2; }
  html:has(> body > .app:not([hidden])) { overscroll-behavior-y: none; }
}
/* A faint, static echo of the sign-in's light. */
.side::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 240px;
  pointer-events: none;
  background: radial-gradient(75% 60% at 8% 0%, rgba(118, 162, 255, 0.17), rgba(118, 162, 255, 0) 72%),
    radial-gradient(60% 55% at 96% 6%, rgba(96, 224, 238, 0.13), rgba(96, 224, 238, 0) 72%),
    radial-gradient(55% 45% at 52% 0%, rgba(176, 146, 255, 0.11), rgba(176, 146, 255, 0) 72%);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-lg);
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; flex: none; width: 36px; height: auto; filter: drop-shadow(0 4px 8px rgba(72, 111, 253, 0.22)); }
.brand-name { display: grid; line-height: 1.15; }
.brand-name strong { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; letter-spacing: -0.03em; }
.brand-name span { font-size: var(--text-xs); color: var(--soft); }

.workspace-pick { display: grid; gap: 6px; padding: 0 var(--space-2); }
.app .workspace-pick { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.app .workspace-pick select { width: 100%; letter-spacing: normal; text-transform: none; font-weight: 500; }

#nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: var(--space-3);
  margin: 0 calc(var(--space-1) * -1);
  padding: 0 var(--space-1) var(--space-2);
  /* An item that takes focus scrolls clear of the fades. */
  scroll-padding: 32px 0 56px;
  scrollbar-width: thin;
}
/* The nav fades at an edge where more of it is hidden. */
#nav.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
}
#nav.has-less {
  -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to top, #000 calc(100% - 24px), transparent);
}
#nav.has-more.has-less {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 24px, #000 calc(100% - 48px), transparent);
}
/* Under the chip below, the top edge is clear (the chip reaches 14px into the nav), so no name shows half covered. */
#nav.has-less.has-above {
  -webkit-mask-image: linear-gradient(to bottom, transparent 22px, #000 46px);
  mask-image: linear-gradient(to bottom, transparent 22px, #000 46px);
  scroll-padding-top: 50px;
}
#nav.has-more.has-less.has-above {
  -webkit-mask-image: linear-gradient(to bottom, transparent 22px, #000 46px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, transparent 22px, #000 46px, #000 calc(100% - 48px), transparent);
}
/* Counts scrolled out of sight above: a chip at the top of the nav names where, and takes you there. */
.nav-above {
  position: absolute;
  left: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 2 * var(--space-5));
  min-height: 28px;
  padding: 0 var(--space-3) 0 var(--space-2);
  border: 1px solid var(--info-line);
  border-radius: var(--radius-pill);
  background: #fff;
  box-shadow: var(--shadow-raised);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  /* It sits on the nav's top edge, half in the space above it, so it covers as little of the nav as it can. */
  transform: translate(-50%, -50%);
}
.nav-above > span { overflow: hidden; text-overflow: ellipsis; }
.nav-above .icon { width: 14px; height: 14px; transform: rotate(180deg); }
.nav-above:hover { background: var(--accent-soft); }
.nav-group { display: grid; gap: 2px; }
/* A group's name doubles as its show/hide switch, so a long nav can be folded to what someone uses. */
.nav-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 26px;
  padding: 0 6px 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
  transition: color var(--fast) ease, background-color var(--fast) ease;
}
.nav-label:hover { color: var(--ink-2); background: rgba(16, 24, 40, 0.035); }
.nav-label .icon { width: 14px; height: 14px; opacity: 0.7; transition: transform var(--fast) ease; }
.nav-label[aria-expanded="false"] .icon { transform: rotate(-90deg); }
.nav-label:hover .icon { opacity: 1; }
/* A folded group still says when something inside it is waiting (and its name says what, to screen readers). */
.nav-note { text-transform: none; }
.nav-label.has-badge[aria-expanded="false"] > span:first-child::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: var(--space-2);
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 2px;
}
.nav-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
/* A long group is read in chunks: a small step before an item that starts a new chunk. */
.nav-list .nav-break { margin-top: 6px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--ink-2);
  font-weight: 500;
  transition: background-color var(--fast) ease, color var(--fast) ease;
}
.nav-item .icon { flex: none; color: var(--muted); transition: color var(--fast) ease; }
.nav-item:hover { background: rgba(16, 24, 40, 0.045); color: var(--ink); text-decoration: none; }
.nav-item:hover .icon { color: var(--soft); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 3px;
  height: 18px;
  margin-top: -9px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand-blue), var(--brand-violet));
}
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.who { display: flex; align-items: center; gap: 10px; padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--line); }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dce7ff, #ece4ff);
  box-shadow: inset 0 0 0 1px rgba(72, 82, 214, 0.14);
  color: #3538cd;
  font-size: var(--text-xs);
  font-weight: 700;
}
.who-text { display: grid; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.who-text strong, .who-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text strong { font-weight: 600; }
.who-text span { font-size: var(--text-xs); color: var(--muted); }

.scrim { display: none; }

.shell { position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0; }
/* The same faint light at the top of the page, behind the title only. */
.shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 300px;
  pointer-events: none;
  background: radial-gradient(40% 100% at 0% 0%, rgba(118, 162, 255, 0.13), rgba(118, 162, 255, 0) 72%),
    radial-gradient(34% 90% at 56% 0%, rgba(176, 146, 255, 0.08), rgba(176, 146, 255, 0) 72%),
    radial-gradient(36% 100% at 100% 0%, rgba(96, 224, 238, 0.12), rgba(96, 224, 238, 0) 72%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
  padding: 0 var(--pad-x);
  background: rgba(245, 247, 251, 0.78);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.06);
}
.topbar .menu-btn, .top-brand, .side-head .side-close { display: none; }
.top-brand { flex: none; align-items: center; border-radius: var(--radius-sm); }
.top-brand img { display: block; width: 30px; height: auto; }
.crumb { display: flex; align-items: center; gap: 6px; flex: none; min-width: 0; color: var(--soft); white-space: nowrap; }
.crumb-sep { color: #98a2b3; }
#crumb { overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-weight: 600; }
/* With the sidebar shown, the crumb has a slot of its own, so the search box stays in one place from screen to screen. */
@media (min-width: 961px) {
  .crumb { flex: 0 0 15rem; }
  .crumb + .search { margin-left: var(--space-2); }
}

.search { position: relative; flex: 0 1 440px; min-width: 140px; margin: 0 0 0 var(--space-5); }
.search .icon { position: absolute; left: 12px; top: 50%; margin-top: -8px; color: var(--muted); pointer-events: none; }
.app .topbar .search input { width: 100%; height: 38px; padding: 0 40px 0 36px; }
.search kbd { position: absolute; right: 10px; top: 50%; margin-top: -10px; transition: opacity var(--fast) ease; pointer-events: none; }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { opacity: 0; }

.top-status { flex: none; margin-left: auto; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-xs);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease;
}
button.status-chip:hover { background: #fff; border-color: var(--line-button); color: var(--ink); }
/* The tone's icon stands in for the dot where the words are hidden (phones), so a shape says it as well as a colour. */
.status-chip > .icon { display: none; color: var(--tone-dot); }

main { padding: var(--space-5) var(--pad-x) 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-5); margin-bottom: var(--space-5); }
.page-title { flex: 1 1 24rem; min-width: 0; }
.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}
#title:focus { outline: none; }
.page-head p { max-width: 72ch; margin: 6px 0 0; color: var(--soft); font-size: var(--text-lg); text-wrap: pretty; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.page-actions:empty { display: none; }

.skip-link {
  position: fixed;
  left: var(--space-3);
  top: var(--space-3);
  z-index: 70;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; text-decoration: none; }
/* While the phone drawer is open, the page behind it is out of reach, and so is the way to skip to it. */
.app[data-drawer="open"] .skip-link { display: none; }

/* Every screen renders into its own .screen inside #view: top-level blocks stack with one gap and no margins. Scrolled
   to, a block lands 16px under the top bar (the page's scroll padding plus its margin). */
.screen { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-4); }
.screen > * { margin-block: 0; scroll-margin-top: var(--space-2); }

/* Components --------------------------------------------------------------------------------------------------- */

.icon { flex: none; }

/* Cards and stats */
.card {
  min-width: 0;
  padding: var(--card-pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.card h2, .card-head h2 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}
.card > h2 { margin-bottom: var(--space-3); }
.card :where(p) { margin: 0 0 var(--space-3); }
.card > :last-child { margin-bottom: 0; }
.card > .form + *, .card > :not(h2, .card-head) + .form { margin-top: var(--space-5); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-sm); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.spread > h2 { margin: 0; }
/* An overline above a title: what kind of thing this is, or where it lives. */
.eyebrow { display: block; margin-bottom: 2px; color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; line-height: 1.4; text-transform: uppercase; }
/* A count beside a heading: a quiet chip with tabular figures (countChip()). */
.count-chip {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  margin-left: var(--space-2);
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  box-shadow: inset 0 0 0 1px var(--neutral-line);
  color: var(--soft);
  font-family: var(--font-text);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  vertical-align: 2px;
  font-variant-numeric: tabular-nums;
}
.count-chip.is-attention { background: var(--attention-bg); box-shadow: inset 0 0 0 1px var(--attention-line); color: var(--attention-ink); }
/* A card's own footer that shows more of its list in place ("Show 10 more"). */
.card > .card-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: calc(100% + 2 * var(--card-pad));
  min-height: 44px;
  margin: var(--space-1) calc(var(--card-pad) * -1) calc(var(--card-pad) * -1);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius) var(--radius);
  background: none;
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background-color var(--fast) ease;
}
.card > .card-toggle:hover { background: var(--hover); }
.card-toggle .icon { transition: transform var(--fast) ease; }
.card-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.app .card > .card-toggle:focus-visible { outline-offset: -2px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  min-height: 112px;
  padding: var(--space-4) var(--card-pad);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.stat .label { color: var(--soft); font-size: var(--text-sm); font-weight: 500; }
.stat .value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat .hint { margin-top: auto; padding-top: var(--space-1); color: var(--muted); font-size: var(--text-sm); }
.stat.alert .value { color: var(--danger-ink); }

/* Tones: one set of colours for pills, dots, banners and toasts */
.is-neutral { --tone-ink: var(--neutral-ink); --tone-bg: var(--neutral-bg); --tone-line: var(--neutral-line); --tone-dot: var(--neutral-dot); }
.is-info { --tone-ink: var(--info-ink); --tone-bg: var(--info-bg); --tone-line: var(--info-line); --tone-dot: var(--info-dot); }
.is-success { --tone-ink: var(--success-ink); --tone-bg: var(--success-bg); --tone-line: var(--success-line); --tone-dot: var(--success-dot); }
.is-attention { --tone-ink: var(--attention-ink); --tone-bg: var(--attention-bg); --tone-line: var(--attention-line); --tone-dot: var(--attention-dot); }
.is-danger { --tone-ink: var(--danger-ink); --tone-bg: var(--danger-bg); --tone-line: var(--danger-line); --tone-dot: var(--danger-dot); }
.is-paused { --tone-ink: var(--paused-ink); --tone-bg: var(--paused-bg); --tone-line: var(--paused-line); --tone-dot: var(--paused-dot); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px 0 8px;
  border-radius: var(--radius-pill);
  background: var(--tone-bg, var(--neutral-bg));
  box-shadow: inset 0 0 0 1px var(--tone-line, var(--neutral-line));
  color: var(--tone-ink, var(--neutral-ink));
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.pill::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--tone-dot, var(--neutral-dot)); }
.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone-dot, var(--neutral-dot));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone-dot, var(--neutral-dot)) 18%, transparent);
}

/* Buttons: primary, secondary, danger, remove, quiet; .btn-sm and .btn-icon modify any of them. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  user-select: none;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease, box-shadow var(--fast) ease,
    transform var(--fast) ease;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
/* Done for good, yet still focusable where it is ("Saved"): it looks like a disabled button and answers to nothing. */
.btn[aria-disabled="true"] { opacity: 0.5; box-shadow: none; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-press); box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.24); }
.btn-secondary { border-color: var(--line-button); background: #fff; box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { border-color: #b4bcc8; background: #f9fafb; color: var(--ink); }
.btn-secondary:active:not(:disabled) { background: var(--neutral-bg); box-shadow: none; }
.btn-danger { background: var(--danger-dot); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12), 0 4px 10px -4px rgba(217, 45, 32, 0.5); }
.btn-danger:hover:not(:disabled) { background: var(--danger-ink); }
.btn-danger:active:not(:disabled) { background: #912018; box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.24); }
/* Removing something for good, or taking access away: it asks first, so the button itself stays quiet. */
.btn-remove { border-color: var(--danger-line); background: #fff; color: var(--danger-ink); box-shadow: var(--shadow-xs); }
.btn-remove:hover:not(:disabled) { border-color: #fda29b; background: var(--danger-bg); }
.btn-remove:active:not(:disabled) { background: #fee4e2; box-shadow: none; }
.btn-quiet:hover:not(:disabled) { background: rgba(16, 24, 40, 0.05); color: var(--ink); }
.btn-quiet:active:not(:disabled) { background: rgba(16, 24, 40, 0.08); }
.btn-sm { min-height: 30px; padding: 0 10px; gap: 6px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
:is(.btn, button)[aria-busy="true"] { cursor: progress; opacity: 1; }
.btn[aria-busy="true"]::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn[aria-busy="true"] > .icon { display: none; }
@keyframes spin { to { transform: rotate(1turn); } }
.link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font-size: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  text-underline-offset: 3px;
}
.link:hover { text-decoration: underline; }
.app :is(a, button, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app .nav-item:focus-visible { outline-offset: -2px; }

/* Forms: labels above, ink values, control edges at 3:1 */
.app label { display: grid; gap: 6px; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.app :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="hidden"]), select, textarea) {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-control);
  background: #fff;
  box-shadow: var(--shadow-xs);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 22px;
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}
/* Date and time fields have taller insides: held to the height of every other field. */
.app input:is([type="date"], [type="time"]) { height: 38px; }
.app :is(input, select, textarea):hover:not(:disabled, :focus) { border-color: var(--line-control-hover); }
.app :is(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea):focus {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.app :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
.app :is(input, select, textarea):disabled { border-color: var(--line-button); background: #f9fafb; color: var(--muted); cursor: not-allowed; }
.app input[readonly] { background: #f9fafb; }
.app select:not([multiple]) {
  appearance: none;
  padding-right: 36px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23475467' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
}
.app select:not([multiple]):disabled { background-color: #f9fafb; }
.app select[multiple] { padding: 4px; }
.app select[multiple] option { padding: 4px 8px; border-radius: 6px; }
.app textarea { min-height: 112px; resize: vertical; }
.app input[type="search"]::-webkit-search-decoration { appearance: none; }
.app :is(input[type="checkbox"], input[type="radio"]) { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.app label:has(> :is(input[type="checkbox"], input[type="radio"])) {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 400;
}
.app input[type="file"] {
  max-width: 100%;
  padding: 5px;
  border: 1px dashed var(--line-control);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--soft);
  font-size: var(--text-sm);
  font-weight: 400;
}
.app input[type="file"]::file-selector-button {
  height: 28px;
  margin-right: var(--space-3);
  padding: 0 var(--space-3);
  border: 1px solid var(--line-button);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-xs);
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.app fieldset { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.app legend { margin-bottom: var(--space-2); padding: 0; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.form { display: grid; gap: var(--space-4); }
.form > button, .form > .btn { justify-self: start; }
.form :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { width: 100%; }
.form .row:has(> label) { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); align-items: start; gap: var(--space-4); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.hint { color: var(--muted); font-size: var(--text-sm); font-weight: 400; }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

/* Segmented filters */
.segmented {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  border-radius: var(--radius-control);
  background: #eceff5;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.04);
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--soft);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--fast) ease, color var(--fast) ease, box-shadow var(--fast) ease;
}
.segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1), 0 1px 1px rgba(16, 24, 40, 0.04); }
.segmented .count { color: var(--soft); font-weight: 500; font-variant-numeric: tabular-nums; }

/* Banners and inline alerts. A banner without a tone is a notice that needs attention. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--tone-line, var(--attention-line));
  border-radius: var(--radius-lg);
  background: var(--tone-bg, var(--attention-bg));
  color: var(--ink);
}
.banner > .icon { width: 18px; height: 18px; margin-top: 2px; color: var(--tone-dot, var(--attention-dot)); }
.banner-body { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.banner .banner-body p { margin: 0; }
.banner-title { font-weight: 600; }
.banner.is-danger .banner-title { color: var(--danger-ink); }
.banner-actions { display: flex; flex-wrap: wrap; align-items: center; align-self: center; gap: var(--space-2); flex: none; }

/* Tables: sticky head, row hover; on phones the rows stack into labelled blocks (.table-cards) */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-md); }
.card .table { width: calc(100% + 2 * var(--card-pad)); margin: 0 calc(var(--card-pad) * -1); }
.table th {
  position: sticky;
  top: var(--topbar-h);
  z-index: 1;
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--soft);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}
.table td { padding: var(--space-3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table :is(th, td):first-child { padding-left: var(--card-pad); }
.table :is(th, td):last-child { padding-right: var(--card-pad); }
.table tbody tr { transition: background-color var(--fast) ease; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .end { text-align: right; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table time { white-space: nowrap; }
.table caption { text-align: left; }

/* Lists of rows inside cards */
.list { display: grid; gap: var(--space-3); }
.list > * + * { padding-top: var(--space-3); border-top: 1px solid var(--line-soft); }
.card > .spread + .spread { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line-soft); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.spread { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.spread > :first-child { flex: 1 1 18rem; min-width: 0; }

/* Empty states: the resting creature and one line. empty-line is the quiet version inside lists and panels. */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); color: var(--soft); text-align: center; }
.empty-art { display: block; width: 64px; height: auto; margin-bottom: var(--space-1); filter: drop-shadow(0 6px 12px rgba(72, 111, 253, 0.16)); }
.empty p { max-width: 46ch; margin: 0; text-wrap: pretty; }
.empty .btn { margin-top: var(--space-2); }
.screen > .empty { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.app .empty-line { margin: 0; padding: var(--space-1) 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }

/* Loading skeletons */
.skeleton { display: grid; gap: var(--space-4); }
.sk {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eceff4 30%, #f7f8fb 50%, #eceff4 70%) 0 0 / 300% 100%;
  animation: sk-shine 1.6s ease-in-out infinite;
}
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-card { display: grid; gap: var(--space-4); }
.sk-title { width: 28%; height: 16px; }
.sk-label { width: 46%; }
.sk-value { width: 34%; height: 28px; }
.sk-rows { display: grid; align-content: start; gap: 14px; }
.sk-rows .sk:nth-child(3n + 1) { width: 94%; }
.sk-rows .sk:nth-child(3n + 2) { width: 78%; }
.sk-rows .sk:nth-child(3n) { width: 61%; }
.sk-split { grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.6fr); gap: var(--space-5); }
.sk-split > .sk-rows:first-child { padding-right: var(--space-5); border-right: 1px solid var(--line-soft); }
/* A main column beside a narrower side column, like Today and Overview. */
.sk-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); align-items: start; gap: var(--space-4); }

/* Toasts */
.toasts {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 60;
  display: grid;
  gap: var(--space-2);
  width: min(400px, calc(100vw - 2 * var(--space-4)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-3) var(--space-2) var(--space-3) 14px;
  border-radius: var(--radius-lg);
  background: #1b2430;
  box-shadow: var(--shadow-raised);
  color: #fff;
  pointer-events: auto;
  animation: toast-in var(--base) var(--ease-out);
}
.toast > .icon { width: 18px; height: 18px; margin-top: 1px; }
.toast.is-success > .icon { color: #47cd89; }
.toast.is-danger > .icon { color: #fda29b; }
.toast.is-info > .icon, .toast.is-neutral > .icon { color: #84adff; }
.toast.is-attention > .icon { color: #fdb022; }
.toast.is-paused > .icon { color: #bdb4fe; }
.toast p { flex: 1 1 auto; min-width: 0; margin: 0; }
.toast-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin: -2px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}
.toast-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialogs */
.dialog {
  width: min(480px, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100dvh - 2 * var(--space-4));
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 24px 48px -12px rgba(16, 24, 40, 0.28);
  color: var(--ink);
}
.dialog[open] { animation: dialog-in var(--base) var(--ease-out); }
.dialog::backdrop { background: rgba(16, 24, 40, 0.36); }
.dialog-body { display: grid; gap: var(--space-4); padding: var(--space-5); }
.dialog h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.015em; line-height: 1.3; }
.dialog p { margin: 0; color: var(--soft); }
/* A toast raised while a dialog is open sits inside it, and keeps its own white text. */
.dialog .toast p { color: inherit; }
.dialog :is(input, select, textarea) { width: 100%; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* Code, keys and copy */
.code {
  margin: 0;
  padding: var(--space-3) 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: #f6f8fb;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  white-space: pre;
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-button);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #fff;
  color: var(--soft);
  font-family: var(--font-text);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}

/* Utilities */
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }
/* Numbers and times line up: tables, pills, and the meta lines of list rows and details, which are mostly times. */
.num, .app time, .table, .pill, .manage-list > button .small, .manage-facts dd, .manage-detail .small, .settings-changes { font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: var(--space-3); }
/* A part of a screen that loads later (loadingPart()). */
.part-loading { padding: var(--space-2) 0 var(--space-1); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--space-4); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* While a change is saved, the screen's controls are disabled but keep their look; the pressed one shows progress. */
.screen[data-saving] :is(.btn, button, input, select, textarea):disabled { opacity: 1; cursor: progress; }

/* Shared patterns ---------------------------------------------------------------------------------------------- */
/* Browse-and-edit layouts the modules share (My Kai, reminders, accounts, routines, workspaces): a toolbar, a list
   beside a detail panel, facts, prose, sections, and forms with a footer. Owned by the foundation. */

.manage-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.manage-toolbar > .small, .manage-toolbar > span { color: var(--soft); }
.manage-toolbar input[type="search"] { width: min(100%, 300px); }
.manage-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.manage-tabs.segmented { gap: 2px; }
.manage-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.6fr);
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.manage-list { display: grid; align-content: start; min-width: 0; border-right: 1px solid var(--line); background: #fcfdfe; }
.manage-list > button {
  position: relative;
  display: grid;
  gap: 2px;
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) 20px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  overflow-wrap: anywhere;
  transition: background-color var(--fast) ease;
}
.manage-list > button strong { color: var(--ink); font-weight: 600; line-height: 1.4; }
.manage-list > button .small { line-height: 1.45; }
.manage-list > button .muted { color: var(--soft); }
.manage-list > button:hover { background: var(--hover); }
.manage-list > button[aria-pressed="true"] { background: var(--accent-soft); }
.manage-list > button[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand-blue), var(--brand-violet));
}
.app .manage-list > button:focus-visible { outline-offset: -2px; }
.manage-detail { display: block; min-width: 0; padding: var(--card-pad); }
.manage-detail > :first-child { margin-top: 0; }
.manage-detail h2, .manage-form h2 { margin: 0; font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.015em; line-height: 1.3; }
.manage-detail h3, .manage-form h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.manage-detail :where(p) { margin: var(--space-2) 0 0; line-height: 1.55; }
.manage-detail > .spread { flex-wrap: wrap; align-items: flex-start; }
.manage-detail > .spread > .pill { margin-top: 3px; }
.manage-detail > .segmented { margin-top: var(--space-4); }
.manage-facts { display: grid; grid-template-columns: minmax(110px, 0.6fr) minmax(0, 1.4fr); gap: var(--space-2) var(--space-4); margin: var(--space-5) 0 0; }
.manage-facts dt { color: var(--soft); font-size: var(--text-sm); line-height: 1.6; }
.manage-facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.manage-prose { margin: var(--space-4) 0 0; max-width: 72ch; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.manage-detail > .manage-prose:first-child, .manage-detail .spread + .manage-prose { margin-top: var(--space-3); }
.manage-section { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line-soft); }
.manage-section > summary { margin: calc(var(--space-1) * -1) 0; padding: var(--space-1) 0; }
details.manage-section[open] > summary { margin-bottom: var(--space-3); }
.manage-section details .form, details.manage-section > .form { margin-top: var(--space-3); }
.manage-section > .manage-form { margin-top: var(--space-5); }
.manage-actions, .brain-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-5); }
.manage-form textarea { line-height: 1.55; }
.manage-form .manage-section { margin-top: 0; padding-top: var(--space-4); }
.manage-form .manage-section.form { gap: var(--space-3); }
.manage-form .manage-section > h3 { margin: 0; }
/* A group of fields inside a module form keeps the form's rhythm, also inside an unstyled wrapper. */
.manage-form section.manage-section:not(.form), .manage-form section.manage-section:not(.form) > div:not([class]) { display: grid; gap: var(--space-3); }
.manage-create { width: 100%; max-width: 800px; }
.manage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}
.manage-save-status { margin-right: auto; color: var(--soft); }
.manage-preview { padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: #f8fafc; color: var(--ink-2); font-size: var(--text-sm); }
.manage-preview p { margin: var(--space-1) 0 0; }
.manage-history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}
.manage-history:last-child { border-bottom: 0; }
.manage-history p { margin: 2px 0 0; }
.manage-related {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: var(--space-3) 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  text-align: left;
  color: var(--ink-2);
}
.manage-related strong { color: var(--ink); }
.manage-related > :last-child { color: var(--accent-ink); font-weight: 600; }
.manage-related:hover > :last-child { text-decoration: underline; }
.manage-related + .btn, .manage-related + button { margin-top: var(--space-3); }
.connection-check { margin: var(--space-2) 0; }
.connection-check span { overflow-wrap: anywhere; }
/* On phones a library's list and its detail take turns; the detail starts with a way back to the list:
   btn("quiet", [icon("chevron-left", 16), "All reminders"], back, { class: "btn-sm pane-back" }). */
.pane-back { display: none; }

/* Buttons a module sets one after another in a card or section, outside a row: keep them apart, also when they wrap. */
:is(.card, .manage-section):not(.form) > .btn { margin-block: var(--space-1); }
:is(.card, .manage-section):not(.form) > .btn + .btn { margin-left: var(--space-2); }

/* Narrower screens ---------------------------------------------------------------------------------------------- */

@media (max-width: 1199px) {
  .sk-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  :root { --gutter: 24px; }
  .stats:has(> :nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manage-layout { grid-template-columns: minmax(210px, 0.85fr) minmax(0, 1.15fr); }
}
/* Tablets and phones: the sidebar becomes a drawer behind the menu button. */
@media (max-width: 960px) {
  :root { --topbar-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(304px, 86vw);
    height: 100%;
    box-shadow: var(--shadow-raised);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform var(--base) var(--ease-out), visibility 0s linear var(--base);
  }
  .app[data-drawer="open"] .side { transform: none; visibility: visible; transition: transform var(--base) var(--ease-out); }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(16, 24, 40, 0.36);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--base) ease, visibility 0s linear var(--base);
  }
  .app[data-drawer="open"] .scrim { opacity: 1; visibility: visible; transition: opacity var(--base) ease; }
  .topbar .menu-btn, .side-head .side-close { display: inline-flex; }
  .topbar .menu-btn { margin-left: -8px; }
  .topbar { gap: var(--space-3); }
  .search { margin-left: auto; }
}
@media (max-width: 760px) {
  .manage-layout { grid-template-columns: minmax(0, 1fr); }
  .manage-list { border-right: 0; }
  /* A library's list and its open item take turns (data-pane), so nothing scrolls inside anything else. */
  .manage-layout[data-pane="detail"] > .manage-list, .manage-layout[data-pane="list"] > .manage-detail { display: none; }
  .pane-back { display: inline-flex; margin: 0 0 var(--space-3) -10px; }
  .manage-toolbar input[type="search"] { flex: 1 1 100%; width: 100%; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --card-pad: 16px; }
  .crumb, .search kbd { display: none; }
  .top-brand { display: inline-flex; }
  .search { flex: 1 1 auto; margin-left: 0; }
  .status-chip { width: 32px; padding: 0; justify-content: center; }
  .status-chip > .dot { display: none; }
  .status-chip > .icon { display: block; }
  .status-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  main { padding-top: var(--space-4); }
  .page-head { margin-bottom: var(--space-4); }
  /* Refresh is just its icon on phones, and sits beside the title when it is the page's only action. */
  .page-refresh { width: 36px; padding: 0; }
  .page-refresh > .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .page-head:has(> .page-actions > .page-refresh:only-child) { flex-wrap: nowrap; align-items: flex-start; }
  .page-head:has(> .page-actions > .page-refresh:only-child) > .page-title { flex-basis: 0; }
  /* Filters stay on one line: a row wider than the screen scrolls sideways, and fades where more of it is hidden. */
  .segmented { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented > button { flex: none; }
  /* The row now clips what overflows it, so the focus ring is drawn inside the button. */
  .app .segmented > button:focus-visible { outline-offset: -2px; }
  .segmented.fade-end {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  }
  .segmented.fade-start {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
  }
  .segmented.fade-start.fade-end {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  }
  .page-head h1 { font-size: 1.5rem; }
  .page-head p { font-size: var(--text-md); }
  /* 16px stops phones zooming into a field on focus. */
  .app :is(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea) { font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { min-height: 0; }
  .stat .value { font-size: 1.5rem; }
  .table.table-cards, .table.table-cards tbody, .table.table-cards td { display: block; }
  .table.table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table.table-cards tr { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--card-pad); border-bottom: 1px solid var(--line-soft); }
  .table.table-cards tr:last-child { border-bottom: 0; }
  .table.table-cards td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 34%) minmax(0, 1fr);
    justify-items: start;
    gap: var(--space-3);
    padding: 2px 0;
    border: 0;
    text-align: left;
  }
  .table.table-cards td:empty { display: none; }
  .table.table-cards td::before { content: attr(data-label); color: var(--muted); font-size: var(--text-sm); }
  .table.table-cards td:not([data-label])::before, .table.table-cards td[data-label=""]::before { content: none; }
  .table.table-cards td:not([data-label]), .table.table-cards td[data-label=""] { display: block; }
  .table.table-cards .cell-title { order: -1; display: block; padding-bottom: var(--space-1); font-weight: 600; }
  .table.table-cards .cell-title::before { content: none; }
  .table.table-cards tbody tr:hover { background: none; }
  .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); width: auto; }
  .banner { flex-wrap: wrap; }
  .banner-body { flex: 1 1 0; }
  .banner-actions { flex: 1 1 100%; align-self: auto; margin-left: calc(18px + var(--space-3)); }
  .sk-split { grid-template-columns: minmax(0, 1fr); }
  .sk-split > .sk-rows:first-child { padding: 0 0 var(--space-4); border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .manage-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .manage-facts dd { margin-bottom: var(--space-2); }
  .manage-footer > .btn, .manage-footer > button { flex: 1 1 auto; }
  .brain-empty { padding: var(--space-4); }
}

/* Short windows (a phone held sideways, a page zoomed to 400%): the whole sidebar scrolls, so the nav is never squeezed
   to a line or two under its fades. */
@media (max-height: 480px) {
  .side { overflow-y: auto; }
  #nav { flex: none; overflow: visible; }
  #nav.has-more, #nav.has-less, #nav.has-more.has-less, #nav.has-less.has-above, #nav.has-more.has-less.has-above { -webkit-mask-image: none; mask-image: none; }
}

@media (prefers-reduced-motion: reduce) {
  .app, .app *, .app *::before, .app *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .sk { background: #eceff4; }
}
@media (forced-colors: active) {
  .side::before, .shell::before { display: none; }
  .app summary::before { forced-color-adjust: none; background: CanvasText; }
  .btn, .segmented button, .status-chip, .pill, .badge, .toast, .count-chip, .nav-above { border: 1px solid; }
  .nav-item[aria-current="page"], .manage-list > button[aria-pressed="true"] { outline: 2px solid; outline-offset: -2px; }
  .segmented button[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* Screen sections. Each group styles its own screens between its markers, and nowhere else. */

/* Screen: myday */
/* Today: capture, focus and what waits for you on the left; the next 24 hours and goals on the right. */
.today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); align-items: start; gap: var(--space-4); }
.today-main, .today-side { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-4); min-width: 0; }

.today-capture { display: flex; align-items: flex-start; gap: var(--space-4); }
/* The sign-in's light, once and faintly, behind the creature only. */
.card.today-capture { background: radial-gradient(42% 120% at 0% 0%, rgba(118, 162, 255, 0.11), rgba(118, 162, 255, 0) 70%), radial-gradient(30% 90% at 12% 0%, rgba(96, 224, 238, 0.08), rgba(96, 224, 238, 0) 70%), var(--card); }
.today-art { display: block; flex: none; width: 44px; height: auto; margin-top: 2px; filter: drop-shadow(0 6px 12px rgba(72, 111, 253, 0.16)); }
/* One column that can shrink, so the field gives way before Save leaves the card on the narrowest phones. */
.today-capture-form { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1 1 auto; gap: var(--space-2); min-width: 0; }
.app .today-capture-label { color: var(--ink); font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.today-capture-row { display: flex; gap: var(--space-2); }
.today-capture-row > input { flex: 1 1 auto; min-width: 0; }
.today-capture-row > .btn { flex: none; }
.card p.today-capture-hint { margin: 0; color: var(--soft); font-size: var(--text-sm); }
.today-capture-form > .form-error { margin-top: var(--space-1); }

/* Rows: a marker, the text, a flag. A row that opens something is one big target. */
.today-list { display: grid; margin: 0 calc(var(--card-pad) * -1); padding: 0; list-style: none; }
.today-row {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--card-pad);
  border-top: 1px solid var(--line-soft);
  transition: background-color var(--fast) ease;
}
.today-row:first-child { border-top: 0; }
.today-row.is-link:hover { background: var(--hover); }
.today-goal { grid-template-columns: minmax(0, 1fr); }
.card p.today-goal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); margin-top: var(--space-1); }
.today-text { min-width: 0; }
.today-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--info-line);
  color: var(--accent-ink);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.today-dot { justify-self: center; width: 6px; height: 6px; margin: 0 11px; border-radius: 50%; background: var(--neutral-dot); }
.today-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--tone-bg);
  box-shadow: inset 0 0 0 1px var(--tone-line);
  color: var(--tone-dot);
}
.today-title {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
}
.card p.today-title { margin: 0; }
.today-title > .icon { margin-right: 6px; color: var(--soft); vertical-align: -2px; }
button.today-open { cursor: pointer; }
button.today-open::after { content: ""; position: absolute; inset: 0; }
.today-row.is-link:hover .today-open { color: var(--accent-ink); }
.app .today-row .today-open:focus-visible { outline: none; }
.today-row:has(.today-open:focus-visible) { z-index: 1; border-radius: var(--radius-control); box-shadow: inset 0 0 0 2px var(--accent); }
.card p.today-meta { margin: 2px 0 0; color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.today-row > .pill { justify-self: end; }
.today-row > .icon { color: var(--muted); }
.today-more { border-top: 1px solid var(--line-soft); }
.today-more .today-title { font-weight: 500; }
.today-focus .empty, .today-review .empty-line, .today-goals .empty-line { padding-block: var(--space-2); }

/* Coming up: one agenda of reminders and calendar events, by day */
.today-day { margin: var(--space-4) 0 var(--space-1); color: var(--muted); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; line-height: 1.4; text-transform: uppercase; }
.today-agenda-list > .today-day:first-child { margin-top: 0; }
/* The agenda's heading takes focus after Load calendar; a heading shows no ring, like the page title. */
.app .today-agenda h2:focus { outline: none; }
.today-event { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr); align-items: start; gap: var(--space-3); padding: var(--space-2) 0; }
.today-time {
  padding: 3px 0;
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.today-time.is-day { font-size: var(--text-xs); line-height: 1.75; }
.today-event.is-reminder .today-time { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--info-line); color: var(--accent-ink); }
/* A reminder in the agenda opens in Reminders: the whole row is the target. */
.today-event.is-reminder { position: relative; border-radius: var(--radius-control); }
.today-event.is-reminder:hover .today-open { color: var(--accent-ink); }
.app .today-event .today-open:focus-visible { outline: none; }
.today-event:has(.today-open:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.today-event .today-title { font-weight: 600; }
.today-agenda-list > .banner { margin-top: var(--space-3); }
.today-agenda-loading { display: grid; gap: var(--space-3); padding: var(--space-3) 0; }
.today-agenda-loading .sk:nth-child(2) { width: 78%; }
.today-agenda-loading .sk:nth-child(3) { width: 61%; }
.today-calendar-ask {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--line-button);
  border-radius: var(--radius-lg);
  color: var(--soft);
  font-size: var(--text-sm);
}
.today-calendar-ask > .icon { margin-top: 1px; color: var(--accent); }
.card .today-calendar-ask p { margin: 0; }
.today-calendar-ask > .btn { grid-column: 2; justify-self: start; }
.today-agenda-list > .empty-line + .today-calendar-ask { margin-top: var(--space-2); }

/* A thin progress line, in the brand's colours */
.brain-progress { display: block; height: 4px; margin-top: var(--space-2); overflow: hidden; border-radius: var(--radius-pill); background: var(--neutral-bg); }
.brain-progress::before { content: ""; display: block; width: var(--done, 0%); height: 100%; border-radius: inherit; background: var(--brand-gradient); }

/* One column below 1200px, in the order the cards are read and tabbed through. */
@media (max-width: 1199px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
  .today-main, .today-side { display: contents; }
}
@media (max-width: 480px) {
  .today-art, .today-capture-row .btn .icon { display: none; }
  .today-row > .pill { grid-column: 2; justify-self: start; }
}

/* Libraries: filters and search above one list beside the selected item */
.brain-toolbar input[type="search"] { flex: 0 1 280px; }
.brain-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); }
.brain-layout[data-empty] { grid-template-columns: minmax(0, 1fr); }
.brain-layout[data-empty] > .brain-detail { display: none; }
.brain-layout[data-empty] > .brain-list { border-right: 0; background: var(--card); }
.app .brain-detail h2:is(:focus, :focus-visible), .app .brain-suggestions h2:is(:focus, :focus-visible), .app .brain-prep h2:is(:focus, :focus-visible) { outline: none; }
.brain-detail-head > div { min-width: 0; }
p.brain-detail-none { color: var(--muted); }
.brain-facts dd .link { min-height: 0; }
.brain-facts dd { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); }
.brain-facts dd > .brain-source-quote { flex-basis: 100%; }
/* Archive and Forget stay together at the end of the row, also when the row wraps. */
.brain-actions-more { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.brain-detail > .brain-readonly { margin-top: var(--space-5); }

/* Sources: where a record came from */
.brain-source { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); color: var(--soft); font-size: var(--text-sm); }
.brain-source-name { color: var(--muted); }
.brain-source-label { color: var(--ink-2); }
/* Links out are meta, not headlines: quieter than the titles beside them. */
.brain-source-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); font-weight: 500; }
.brain-source-link .icon { flex: none; }
.app blockquote.brain-source-quote { flex-basis: 100%; margin: var(--space-1) 0 0; padding: 2px 0 2px var(--space-3); border-left: 3px solid var(--line-button); color: var(--soft); font-size: var(--text-sm); line-height: 1.55; white-space: pre-wrap; }

/* The project brief and the lists inside a detail */
.brain-brief-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
.manage-detail .brain-brief-head h3 { margin: 0; }
.brain-brief-chats { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--line-soft); }
.manage-detail p.brain-brief-meta, .card p.brain-brief-meta, p.brain-brief-meta { margin: 2px 0 0; color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.brain-brief-chats p.brain-brief-meta { flex-basis: 100%; margin: 0; }
.brain-brief h3 + .brain-brief-list, .brain-brief h4 + .brain-brief-list { margin-top: var(--space-1); }
.app .brain-brief h4, .app .brain-prep h4 { margin: var(--space-5) 0 0; color: var(--ink-2); font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; }
.brain-brief > h3:not(:first-child) { margin-top: var(--space-5); }
.brain-brief-list { display: grid; margin: 0; padding: 0; list-style: none; }
.brain-brief-item { min-width: 0; padding: var(--space-3) 0; border-bottom: 1px solid var(--line-soft); }
.brain-brief-item:last-child { border-bottom: 0; }
.brain-brief-item > .spread { flex-wrap: nowrap; align-items: flex-start; }
.brain-brief-open { display: inline; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600; line-height: 1.4; text-align: left; text-underline-offset: 3px; overflow-wrap: anywhere; cursor: pointer; }
.brain-brief-open:hover { color: var(--accent-ink); text-decoration: underline; }
.manage-detail p.brain-brief-body, .card p.brain-brief-body, p.brain-brief-body {
  display: -webkit-box;
  margin: var(--space-1) 0 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.brain-task { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.brain-task > .pill { flex: none; margin-top: 1px; }
.manage-detail p.brain-decision { margin: 0; line-height: 1.5; }
.brain-brief-replaced { margin-top: var(--space-3); }
.brain-brief-replaced .brain-decision { color: var(--soft); text-decoration: line-through; text-decoration-color: var(--line-control); }
.brain-brief-item details { margin-top: var(--space-1); }
.brain-brief-item details > summary { font-size: var(--text-sm); }
.manage-detail p.brain-brief-note, .card p.brain-brief-note, p.brain-brief-note { margin: var(--space-4) 0 0; color: var(--muted); font-size: var(--text-sm); }
.brain-brief-loading { display: grid; gap: var(--space-3); padding: var(--space-2) 0; }
.brain-brief-loading .sk:nth-child(3) { width: 78%; }
.brain-brief-loading .sk:nth-child(4) { width: 61%; }
.brain-brief-item > .brain-source-link { margin-top: var(--space-1); }

/* Goals: the plan as a short run of steps */
.brain-goal-count { color: var(--soft); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.brain-goal .brain-progress { margin: 0 0 var(--space-4); }
.manage-detail p.brain-goal-note { margin: 0; color: var(--soft); }
.brain-goal > .banner { margin-bottom: var(--space-4); }
.brain-goal-next { margin-bottom: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fbfcfe; }
.manage-detail .brain-goal-next p { margin: 0; }
.brain-goal-next .brain-actions { margin-top: var(--space-3); }
.brain-steps { display: grid; margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.brain-step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); padding-bottom: var(--space-5); }
.brain-step:last-child { padding-bottom: 0; }
.brain-step::before { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 4px; width: 1px; background: var(--line); }
.brain-step:last-child::before { display: none; }
.brain-step-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tone-bg);
  box-shadow: inset 0 0 0 1px var(--tone-line);
  color: var(--tone-ink);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.brain-step.is-current .brain-step-mark { box-shadow: inset 0 0 0 1px var(--tone-line), 0 0 0 3px color-mix(in srgb, var(--tone-dot) 18%, transparent); }
.brain-step-body { display: grid; gap: var(--space-2); min-width: 0; padding-top: 3px; }
.brain-step-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.brain-step-head > strong { flex: 1 1 14rem; min-width: 0; line-height: 1.4; }
.manage-detail p.brain-step-text { margin: 0; color: var(--soft); font-size: var(--text-sm); }
.manage-detail .brain-output { max-width: none; margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: #f8fafc; color: var(--ink); font-size: var(--text-md); }
.brain-step-draft > summary { font-size: var(--text-sm); }
.brain-step-draft[open] > summary { margin-bottom: var(--space-2); }
.manage-detail p.brain-step-notes { margin: 0; color: var(--ink-2); font-size: var(--text-sm); }
.brain-step-notes > span { color: var(--soft); font-weight: 600; }
.brain-step textarea { width: 100%; min-height: 5rem; }
.brain-step-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* The plan editor */
.brain-plan { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.app .brain-plan-step { gap: 0; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fbfcfe; }
.app .brain-plan-step legend { float: left; width: 100%; margin-bottom: var(--space-3); color: var(--ink); font-family: var(--font-display); font-size: var(--text-md); }
.brain-plan-step > label + label { margin-top: var(--space-3); }
.brain-plan-step > .btn { justify-self: start; margin-top: var(--space-2); }

/* The editor */
.brain-edit-type { display: grid; gap: 6px; justify-items: start; }
.brain-edit-label { color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.manage-form p.brain-edit-note { display: flex; align-items: center; gap: var(--space-2); margin: 0; color: var(--soft); font-size: var(--text-sm); }
.brain-edit-note > .icon { color: var(--muted); }
.brain-edit-more > summary { width: max-content; }
.brain-edit-more[open] > summary { margin-bottom: var(--space-3); }
.brain-edit-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--space-2) var(--space-4); }
.brain-edit-chats > .hint { margin-top: var(--space-1); }
/* A row whose fields are all hidden for this kind takes no room. */
.brain-editor .row:not(:has(> :not([hidden]))) { display: none; }

/* Sub-views: meeting brief, suggestions, Outlook and To Do */
.brain-prep-result:empty, .brain-extract-results:empty { display: none; }
.manage-detail .brain-prep-draft, .card .brain-prep-draft { margin: 0; font-size: var(--text-md); }
.brain-prep .manage-section { margin-top: var(--space-5); }
.brain-suggestion .eyebrow { margin-bottom: 0; }
.brain-suggestion .spread > div { min-width: 0; }
.brain-suggestion .spread > .btn, .brain-import-list .spread > .btn { flex: none; }
.brain-import .today-list { margin-bottom: calc(var(--card-pad) * -1); }

@media (max-width: 760px) {
  .brain-toolbar { align-items: stretch; }
  .brain-toolbar input[type="search"] { flex: 1 1 100%; width: 100%; }
}
@media (max-width: 640px) {
  .brain-import-list .brain-brief-item > .spread { flex-wrap: wrap; }
  .brain-task { flex-wrap: wrap; }
}
@media (forced-colors: active) {
  .today-row:has(.today-open:focus-visible) { outline: 2px solid Highlight; outline-offset: -2px; }
  .brain-progress { border: 1px solid CanvasText; }
  .brain-progress::before { background: Highlight; }
}
/* End of screen: myday */

/* Screen: mymore */
/* Reminders: a list beside the chosen item. On phones the two take turns (data-pane). Connectors: cards. */
.mymore-group {
  margin: 0;
  padding: var(--space-4) var(--space-4) var(--space-1) 20px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mymore-shared { display: flex; align-items: center; gap: 6px; color: var(--soft); }
.mymore-shared .icon { color: var(--muted); }
.mymore-split .manage-list > button > span:has(> .pill) { margin-top: var(--space-1); }
.mymore-list-empty { padding: var(--space-4) var(--space-4) var(--space-4) 20px; }
.mymore-panel-empty { padding: var(--space-6) 0; text-align: center; }
:is(.brain-actions, .mymore-row) > .mymore-end { margin-left: auto; }
.mymore-foot { color: var(--soft); font-size: var(--text-sm); }
.mymore-external { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: 500; }

/* Reminders */
.mymore-next {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #f8fafc;
}
.mymore-next > .eyebrow { margin: 0; }
.manage-detail .mymore-next > p { margin: 2px 0 0; }
.manage-detail .mymore-next > .mymore-next-time {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}
.mymore-soon { color: var(--accent-ink); font-family: var(--font-text); font-size: var(--text-sm); font-weight: 600; letter-spacing: normal; }
.mymore-fields { display: grid; gap: var(--space-3); }
.form .mymore-inline { display: flex; align-items: center; gap: var(--space-2); }
.form .mymore-inline > input { flex: none; width: 6.5rem; }
.form .mymore-inline > select { flex: 0 1 12rem; }
.mymore-days > div { display: flex; flex-wrap: wrap; gap: 6px; }
.app .mymore-days > div > label {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-control);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--ink-2);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease;
}
.app .mymore-days input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.app .mymore-days > div > label:hover { border-color: var(--line-control-hover); }
.app .mymore-days > div > label:has(:checked) { border-color: var(--accent); background: var(--accent); color: #fff; }
.app .mymore-days > div > label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mymore-preview {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #f8fafc;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.mymore-preview > .icon { margin-top: 2px; color: var(--accent); }
.mymore-preview.is-attention { border-color: var(--attention-line); background: var(--attention-bg); color: var(--ink); }
.mymore-preview.is-attention > .icon { color: var(--attention-dot); }
.mymore-fixed { display: flex; align-items: center; gap: var(--space-2); margin: 0; color: var(--ink-2); }
.mymore-fixed .icon { color: var(--muted); }
/* The snooze dialog: each choice is a row that shows the time it picks. */
.mymore-options { gap: var(--space-2); }
.app .mymore-options > label {
  padding: 10px var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.app .mymore-options > label:has(:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mymore-options .hint { margin-left: auto; color: var(--soft); font-variant-numeric: tabular-nums; }

/* Choice cards: providers, permissions, what an automation watches */
.mymore-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--space-2) var(--space-3); }
.app .mymore-choices > label.mymore-choice {
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  cursor: pointer;
  transition: border-color var(--fast) ease, background-color var(--fast) ease, box-shadow var(--fast) ease;
}
.app .mymore-choices > label.mymore-choice:hover { border-color: var(--line-control-hover); }
.app .mymore-choices > label.mymore-choice:has(:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.app .mymore-choices > label.mymore-choice:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mymore-choice > input { margin-top: 3px; }
.mymore-choice-text { display: grid; flex: 1 1 auto; gap: 2px; min-width: 0; }
.mymore-choice-text strong { color: var(--ink); font-weight: 600; }
.mymore-choice > .pill { flex: none; margin-left: auto; }
.mymore-choice > .mymore-glyph { width: 30px; height: 30px; border-radius: var(--radius-sm); }

/* Connectors */
.mymore-calendars { display: grid; max-height: 40vh; overflow: auto; padding-left: var(--space-5); }
.mymore-welcome > .empty { padding-bottom: var(--space-5); }
.mymore-welcome > .empty > .row { justify-content: center; margin-top: var(--space-2); }
.mymore-promises {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-4) var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line-soft);
}
.mymore-promises > div { display: grid; align-content: start; gap: var(--space-1); }
.mymore-promises .icon { color: var(--accent); }
.card .mymore-promises p { margin: 0; }
.mymore-welcome > .empty > h2 { margin: 0; color: var(--ink); }
.mymore-steps { display: grid; gap: var(--space-2); margin: 0; padding-left: 1.25rem; line-height: 1.55; }
.mymore-uri { display: grid; gap: var(--space-1); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: #f8fafc; }
.mymore-uri > .spread > :first-child { flex-basis: 14rem; }
.mymore-code { font-family: var(--font-mono); font-size: var(--text-sm); overflow-wrap: anywhere; }
/* Provider configuration: one short form, with the app-registration walk-through folded away. */
.provider-lead { margin: 0; color: var(--ink-2); }
.provider-guide { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); }
.provider-guide > summary { cursor: pointer; font-weight: 600; }
.provider-guide-body { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
.provider-manual { display: grid; gap: var(--space-4); }
.provider-create { align-items: start; justify-items: start; }
.provider-create > p { margin: 0; }
/* Accounts and apps as cards: the provider's initial, the name, a status, what Kai may do, and the next step at the
   bottom, so a row of cards lines its buttons up. Also Organization integrations' shared accounts and Provider
   configuration's two providers. */
.connector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--space-4); }
.connector-card { display: flex; flex-direction: column; gap: var(--space-3); }
.card.connector-card :where(p), .card.connector-sheet :where(p) { margin: 0; }
.connector-head { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }
.connector-head > .pill { flex: none; margin-top: 2px; }
.connector-name { display: grid; flex: 1 1 auto; align-content: start; gap: 2px; min-width: 0; min-height: 40px; }
.app :is(.connector-name, .connector-title) > :is(h2, h3) {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.connector-name > .eyebrow { margin: 0; }
.connector-title { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-2); min-width: 0; }
.connector-email { color: var(--soft); font-size: var(--text-sm); overflow-wrap: anywhere; }
.connector-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-control);
  background: var(--neutral-bg);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
/* A logo sits on white, whatever its colours. */
.connector-icon.has-logo { background: var(--card); }
.connector-icon > img { display: block; width: 24px; height: 24px; object-fit: contain; }
/* An app that cannot be connected yet: sunk into the page, its logo greyed. The text keeps its contrast. */
.connector-app.is-off { background: var(--paper); box-shadow: none; }
.connector-app.is-off .connector-icon > img { filter: grayscale(1); opacity: 0.55; }
.connector-text { color: var(--ink-2); }
.connector-caps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.connector-caps > li {
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 20px;
}
.connector-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--soft); font-size: var(--text-sm); }
.connector-meta > .icon { color: var(--muted); }
.connector-alert { display: flex; align-items: center; gap: 6px; color: var(--attention-ink); font-size: var(--text-sm); font-weight: 600; }
.connector-alert > .icon { color: var(--attention-dot); }
.connector-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: auto; padding-top: var(--space-1); }
.connector-actions > .mymore-end { margin-left: auto; }
.connector-toolbar > .connector-filters { min-width: 0; max-width: 100%; }
.connector-content { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
.connector-none { padding: 0; }
/* One app, and which account to use it with */
.connector-sheet { display: grid; gap: var(--space-4); }
.connector-sheet > .connector-head .connector-name { min-height: 0; }
.connector-sheet > .connector-actions { margin-top: 0; padding-top: 0; }
/* An AI tool's notes on what it can do and how access works line up with its sheet. */
.connector-sheet + .grid-2 { max-width: 800px; }
.connector-examples {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #f8fafc;
  color: var(--ink-2);
  list-style: none;
}
.connector-existing { display: grid; gap: var(--space-2); }
.app .connector-existing > h3 { margin: 0; font-size: var(--text-md); }
.connector-choices { display: grid; gap: var(--space-2); }
.connector-choice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--fast) ease, background-color var(--fast) ease;
}
.connector-choice:hover { border-color: var(--line-control-hover); background: var(--hover); }
.connector-choice-text { display: grid; flex: 1 1 auto; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.connector-choice-text strong { color: var(--ink); font-weight: 600; }
.connector-choice > .icon { color: var(--muted); }
/* Connect and Manage: what Kai may do, in the catalog's groups; workspaces or defaults; the controls below. */
.connector-cap-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: start; gap: var(--space-4) var(--space-5); }
.app .connector-cap-group > legend { margin-bottom: var(--space-1); color: var(--muted); font-size: var(--text-xs); letter-spacing: 0.06em; text-transform: uppercase; }
.connector-cap-group > .checks, .connector-spaces > .checks { display: grid; align-content: start; gap: var(--space-1) var(--space-4); }
.connector-spaces > .checks { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.app :is(.connector-cap-group, .connector-spaces) .connection-check { align-items: flex-start; margin: 0; }
.app :is(.connector-cap-group, .connector-spaces) .connection-check > input { margin-top: 3px; }
.connector-spaces > .hint { margin: 0; }
.connector-note { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0; }
.connector-note > .icon { flex: none; margin-top: 2px; color: var(--muted); }
.connector-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.connector-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); }
.app .connector-section-head > h3 { margin: 0; }
.connector-calendars {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #f8fafc;
}
.app .connector-calendars p { margin: 0; }
.connector-controls { display: grid; gap: var(--space-3); }
.card.connector-controls > :where(h2, p) { margin: 0; }
.connector-controls > .connector-actions { margin-top: 0; padding-top: 0; }
/* Provider configuration */
.provider-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.provider-card > .manage-facts, .provider-service > .manage-facts { margin: 0; }
.provider-service > .card-head { margin-bottom: var(--space-3); }
.card.provider-service > p { margin-bottom: var(--space-4); }
/* The provider's form takes focus when it opens (the page heading stays), like a heading: no ring. */
.app .provider-setup h2[tabindex]:focus { outline: none; }

/* Automations */
.mymore-automations { display: grid; gap: var(--space-3); }
.mymore-automation { display: grid; gap: var(--space-3); padding-block: var(--space-4); }
.card.mymore-automation p { margin: 0; }
.mymore-automation-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--space-2) var(--space-4); }
.mymore-automation-text { display: grid; gap: 2px; min-width: 0; }
.mymore-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.card .mymore-title > h2 { margin: 0; }
.mymore-automation-main > .mymore-row { align-self: center; }
.mymore-automation > div:empty { display: none; }
.mymore-glyph { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--accent); }
.mymore-meta { display: flex; align-items: center; gap: 6px; }
.mymore-meta > .icon { color: var(--muted); }
.mymore-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.mymore-test { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: #f8fafc; font-size: var(--text-sm); }
.mymore-test ul { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.mymore-test .btn-icon { margin: -4px -8px -4px 0; }
.mymore-runs-toggle { margin-left: 52px; }
.mymore-runs-toggle > summary { width: max-content; font-size: var(--text-sm); }
.mymore-automation > .mymore-test, .mymore-automation > div > .mymore-test, .mymore-automation > div > .banner, .mymore-automation > .banner { margin-left: 52px; }
.mymore-runs { margin-top: var(--space-2); }
.mymore-ideas { display: grid; gap: var(--space-3); padding-top: var(--space-5); border-top: 1px solid var(--line-soft); }
.card .mymore-ideas > .eyebrow { margin: 0; }
.mymore-idea-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--space-3); }
.mymore-idea {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--ink-2);
  text-align: left;
  transition: border-color var(--fast) ease, background-color var(--fast) ease;
}
.mymore-idea:hover { border-color: #b3c7fb; background: var(--accent-soft); }
.mymore-idea > span:last-child { display: grid; gap: 2px; }
.mymore-idea strong { color: var(--ink); font-weight: 600; }
/* Start from a template: a closed box above a new item's form. Picking one fills the form in and closes it. */
.template-box { display: grid; gap: var(--space-2); }
.template-picker { padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.template-picker > summary { display: flex; align-items: center; gap: var(--space-2); width: max-content; max-width: 100%; color: var(--ink); font-weight: 600; cursor: pointer; }
.template-picker > summary > .icon { color: var(--accent); }
.template-picker[open] > summary { margin-bottom: var(--space-3); }
.template-status:empty { display: none; }
.template-status { margin: 0; }
/* Asking Kai to fill in the form: a faint echo of the sign-in's light, behind two lines of text only. */
.mymore-ask {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid #e1e7f7;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(54, 153, 253, 0.07), rgba(123, 85, 252, 0.05) 55%, rgba(10, 205, 234, 0.06));
}
.mymore-destination { display: flex; align-items: flex-start; gap: var(--space-3); }
.mymore-destination > .icon { margin-top: 2px; color: var(--accent); }

/* The chosen item's heading takes focus on phones, like the page title: no ring for a heading. */
.mymore-split .manage-detail h2:focus { outline: none; }
.mymore-split .manage-detail > .banner { margin-top: var(--space-4); }
@media (max-width: 1100px) {
  .mymore-automation-main { grid-template-columns: auto minmax(0, 1fr); }
  .mymore-automation-main > .mymore-row { grid-column: 2; }
}
@media (max-width: 640px) {
  .connector-controls > .connector-actions > .mymore-end { margin-left: 0; }
  .connector-toolbar > .connector-filters { flex: 1 1 100%; }
  .mymore-automation-main { grid-template-columns: minmax(0, 1fr); }
  .mymore-automation-main > .mymore-glyph { display: none; }
  .mymore-automation-main > .mymore-row { grid-column: 1; }
  .mymore-runs-toggle, .mymore-automation > .mymore-test, .mymore-automation > div > .mymore-test, .mymore-automation > div > .banner, .mymore-automation > .banner { margin-left: 0; }
}
@media (forced-colors: active) {
  .app .mymore-days > div > label:has(:checked) { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .app .mymore-choices > label.mymore-choice:has(:checked), .app .mymore-options > label:has(:checked) { outline: 2px solid Highlight; outline-offset: -2px; }
  .mymore-preview, .mymore-next, .mymore-test, .mymore-uri { border: 1px solid CanvasText; }
  .connector-icon, .connector-caps > li, .connector-choice, .connector-examples, .connector-calendars { border: 1px solid CanvasText; }
}
/* End of screen: mymore */

/* Screen: ops */
/* Overview, Actions, Approvals, Audit log and Search. */

/* Shared by these screens: card heads with a count, filter rows, scope notes, list feet, row titles that open things */
.ops-head-text { flex: 1 1 12rem; min-width: 0; }
.card-head .ops-head-text p { margin: 2px 0 0; }
.ops-lock { display: inline-flex; margin-right: 6px; color: var(--muted); vertical-align: -1px; }
.ops-filter { max-width: 100%; margin-bottom: var(--space-4); }
.screen > .ops-filter { margin-bottom: 0; }
/* The phone version of a filter: a label beside a select (shown at 640px and below). */
.app .ops-filter-pick { display: none; }
.ops-scope { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin: calc(var(--space-1) * -1) 0 var(--space-3); color: var(--soft); font-size: var(--text-sm); }
.ops-scope > .icon { color: var(--muted); }
.ops-scope .link { margin-left: var(--space-1); }
.ops-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin: 0 calc(var(--card-pad) * -1) calc(var(--card-pad) * -1);
  padding: var(--space-3) var(--card-pad);
  border-top: 1px solid var(--line);
  color: var(--soft);
  font-size: var(--text-sm);
}
.card .ops-foot p { margin: 0; }
.card > .empty-line + .ops-foot { margin-top: var(--space-4); }
/* A title that opens the thing it names: reads as text, answers like a link. */
.ops-open {
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
  text-underline-offset: 3px;
  transition: color var(--fast) ease;
}
.ops-open:hover { color: var(--accent-ink); text-decoration: underline; }
.ops-who.is-unknown { color: var(--soft); }
/* What a proposal changes: a quiet list, messages quoted in full, outside guests called out. */
.ops-changes { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ops-changes > li { position: relative; min-width: 0; padding-left: 18px; overflow-wrap: anywhere; }
.ops-changes > li::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-control);
}
.ops-changes > li:has(> .ops-quote) { padding-left: 0; }
.ops-changes > li:has(> .ops-quote)::before { content: none; }
.ops-changes > li:has(> .ops-quote) > span { display: block; color: var(--soft); font-size: var(--text-sm); }
.ops-changes > li.is-attention { color: var(--attention-ink); font-weight: 600; }
.ops-changes > li.is-attention::before { background: var(--attention-dot); }
.ops-changes > .ops-more { color: var(--muted); font-size: var(--text-sm); }
.ops-changes > .ops-more::before { content: none; }
.ops-more .link { font-size: var(--text-sm); }
.app .ops-quote {
  margin: 0 0 6px;
  padding: 2px 0 2px var(--space-3);
  border-left: 3px solid var(--info-line);
  color: var(--ink);
  white-space: pre-line;
}

/* Overview: the service first, then its pulse, then work on the left and what is coming on the right */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); align-items: start; gap: var(--space-4); }
.ov-col { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-4); min-width: 0; }
.ov-needs, .ov-queue { container-type: inline-size; }
.ov-list { display: grid; margin: 0; padding: 0; list-style: none; }
.ov-list > li { min-width: 0; padding: var(--space-3) 0; border-top: 1px solid var(--line-soft); }
.ov-list > li:first-child { padding-top: 0; border-top: 0; }
.ov-list > li:last-child { padding-bottom: 0; }
.ov-text { min-width: 0; }
.card p.ov-title { margin: 0; color: var(--ink); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.card p.ov-meta, .ov-meta { margin: 2px 0 0; color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.card p.ov-detail {
  display: -webkit-box;
  margin: var(--space-1) 0 0;
  overflow: hidden;
  color: var(--soft);
  font-size: var(--text-sm);
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.card p.ov-tags { margin: 6px 0 0; }
.ov-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  background: var(--tone-bg);
  box-shadow: inset 0 0 0 1px var(--tone-line);
  color: var(--tone-dot);
}
.ov-icon.is-neutral { color: var(--soft); }
.ov-needs > .card-toggle { margin-top: var(--space-3); }
.ov-col .card > .banner + * { margin-top: var(--space-3); }
.ov-clear { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--soft); font-size: var(--text-sm); }
.ov-clear > .icon { margin-top: 1px; color: var(--success-dot); }
.card .ov-clear p { margin: 0; }

/* The pulse: each tile opens what it counts */
.ov-tile { position: relative; transition: border-color var(--fast) ease, box-shadow var(--fast) ease; }
.ov-tile:hover { border-color: var(--line-button); }
.ov-tile-hit {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  padding: var(--space-4);
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--muted);
  transition: color var(--fast) ease;
}
.ov-tile:hover .ov-tile-hit { color: var(--accent-ink); }
.app .ov-tile-hit:focus-visible { outline-offset: -2px; }
.ov-queue { scroll-margin-top: var(--space-2); }

/* Service health. A state other than healthy tints the top of the card, faintly. */
.ov-health { display: grid; gap: var(--space-4); }
.ov-health:not(.is-success) { background: linear-gradient(180deg, var(--tone-bg), var(--card) 160px); }
.ov-health-top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-3) var(--space-4); }
.ov-health-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--tone-bg);
  box-shadow: inset 0 0 0 1px var(--tone-line);
  color: var(--tone-dot);
}
.ov-health.is-neutral .ov-health-icon { color: var(--soft); }
.ov-health-body { flex: 1 1 14rem; min-width: 0; }
.ov-health-body h2 { margin: 0 0 2px; line-height: 1.4; }
.card p.ov-health-text { max-width: 80ch; margin: 0; color: var(--soft); }
.ov-problems { display: grid; gap: var(--space-1); max-width: 80ch; margin: 2px 0 0; padding: 0; color: var(--ink-2); list-style: none; }
.ov-problems strong { color: var(--ink); font-weight: 600; }
.ov-aside { color: var(--soft); }
.ov-fix {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  max-width: 80ch;
  margin-top: var(--space-3);
  padding: 10px var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--card);
  color: var(--ink-2);
  font-size: var(--text-sm);
}
.ov-fix .icon { margin-top: 2px; color: var(--soft); }
.card .ov-fix p { margin: 0; }
.ov-fix strong { font-weight: 600; }
.ov-health-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.ov-conns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  margin: 0;
  padding: var(--space-4) 0 0;
  border-top: 1px solid var(--line-soft);
  list-style: none;
}
.ov-conn { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); white-space: nowrap; }
.ov-conn strong { color: var(--ink-2); font-weight: 600; }
.ov-conn span:last-child { color: var(--soft); }
.ov-conn-link { margin-left: auto; font-size: var(--text-sm); }

/* Needs you, and Teach Kai: icon, text, one action */
.ov-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-3); }
.ov-item > .ov-icon { align-self: start; }
@container (max-width: 440px) {
  .ov-needs .ov-item { grid-template-columns: auto minmax(0, 1fr); }
  .ov-needs .ov-item > .btn { grid-column: 2; justify-self: start; margin-top: var(--space-1); }
}

/* The queue: title and meta, status, next step */
.ov-row { display: grid; grid-template-columns: minmax(0, 1fr) 9.25rem 5.5rem; align-items: center; gap: var(--space-2) var(--space-3); }
.ov-row > .pill { justify-self: start; }
.ov-act { display: flex; justify-content: flex-end; }
@container (max-width: 560px) {
  .ov-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text act" "pill act"; row-gap: 6px; }
  .ov-row > .ov-text { grid-area: text; }
  .ov-row > .pill { grid-area: pill; }
  .ov-row > .ov-act { grid-area: act; }
  .ov-row > .ov-act:empty { display: none; }
}

/* Coming up: an agenda */
.ov-run { display: grid; grid-template-columns: 4.75rem minmax(0, 1fr); align-items: center; gap: var(--space-3); }
.ov-when {
  display: grid;
  gap: 1px;
  padding: 6px var(--space-1);
  border-radius: var(--radius-control);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line);
  line-height: 1.2;
  text-align: center;
}
.ov-when span { color: var(--soft); font-size: var(--text-xs); font-weight: 500; }
.ov-when strong { color: var(--ink); font-family: var(--font-display); font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; }
.ov-when.is-today { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--info-line); }
.ov-when.is-today span { color: var(--accent-ink); }
.ov-coming .empty-line + .link { margin-top: var(--space-1); }

/* Approvals: one row per proposal, a card each on Approvals and compact rows on Actions */
.approval {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title buttons" "changes changes";
  align-items: start;
  gap: var(--space-4) var(--space-5);
  scroll-margin-top: var(--space-2);
}
.app .approval:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app .approval:focus:not(:focus-visible) { outline: none; }
.approval-title { grid-area: title; min-width: 0; }
.approval-title :is(h2, h3) { margin: 0 0 4px; font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.approval .approval-meta { margin: 0; color: var(--soft); font-size: var(--text-sm); }
.approval-buttons { grid-area: buttons; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.approval > .ops-changes { grid-area: changes; }
.card.approval > .ops-changes { padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: #f8fafc; }
.approval.is-compact { gap: var(--space-2) var(--space-5); }
.approval.is-compact .approval-title h3 { font-size: var(--text-lg); }
.approval.is-compact .ops-changes { color: var(--ink-2); font-size: var(--text-sm); }
.approval.is-compact .ops-quote {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
/* An email, event, file, document or cells waiting for approval: kAI's frozen preview, in full and as written. */
.ops-changes > li:has(> .approval-preview) { padding-left: 0; }
.ops-changes > li:has(> .approval-preview)::before { content: none; }
.app .approval-preview { max-width: 72ch; color: var(--ink); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Actions */
:is(.actions-waiting, .ov-needs) .count-chip { background: var(--attention-bg); box-shadow: inset 0 0 0 1px var(--attention-line); color: var(--attention-ink); }
.actions-card :is(.table, .empty-line, .empty) { transition: opacity var(--fast) ease; }
.actions-card[aria-busy="true"] :is(.table, .empty-line, .empty) { opacity: 0.5; }
.actions-table th.actions-col-what { width: 38%; }
.actions-table :is(td.actions-col-place, td.actions-col-owner) { color: var(--soft); white-space: nowrap; }
.actions-table td.actions-col-time { color: var(--soft); white-space: nowrap; }
.actions-what { display: grid; gap: 2px; justify-items: start; min-width: 0; }
.actions-sub { color: var(--soft); font-size: var(--text-sm); font-weight: 400; }
.actions-sub:empty, .actions-sub-place { display: none; }
.actions-status { display: grid; gap: 6px; justify-items: start; }
.actions-note {
  display: -webkit-box;
  max-width: 34ch;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--soft);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* One action, in a dialog: a head that stays, the story in the middle, its buttons at the foot */
.action-sheet { width: min(640px, calc(100vw - 2 * var(--space-4))); }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4) var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.sheet-title { display: grid; gap: var(--space-2); min-width: 0; }
.action-sheet .sheet-title h2 { overflow-wrap: anywhere; }
.action-sheet .sheet-title h2:focus { outline: none; }
.sheet-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); color: var(--soft); font-size: var(--text-sm); }
.sheet-meta:empty { display: none; }
.sheet-body { display: grid; gap: var(--space-5); padding: var(--space-5); }
.sheet-block { display: grid; gap: var(--space-3); min-width: 0; }
.sheet-block h3 { margin: 0; font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.005em; }
.action-sheet p.sheet-hint { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.sheet-steps { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.sheet-steps > li {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #f8fafc;
}
.sheet-step-text { flex: 1 1 18rem; min-width: 0; }
.sheet-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-5); margin: 0; }
.sheet-facts dt { color: var(--soft); font-size: var(--text-sm); line-height: 22px; }
.sheet-facts dd { min-width: 0; margin: 0; color: var(--ink); line-height: 22px; overflow-wrap: anywhere; }
.sheet-facts dt:has(+ dd > .sheet-ref) { line-height: 30px; }
.sheet-ref { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.sheet-ref code { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--ink-2); }
.sheet-history { display: grid; margin: 0; padding: 0; list-style: none; }
.sheet-history > li { position: relative; display: grid; gap: 2px; padding: 0 0 var(--space-3) var(--space-5); }
.sheet-history > li:last-child { padding-bottom: 0; }
.sheet-history > li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 2px var(--line-control);
}
.sheet-history > li:last-child::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sheet-history > li:not(:last-child)::after { content: ""; position: absolute; left: 7.5px; top: 19px; bottom: 2px; width: 1px; background: var(--line); }
.sheet-history-what { font-weight: 600; }
.sheet-history-meta { color: var(--soft); font-size: var(--text-sm); }
.sheet-answer { padding: var(--space-4); border: 1px solid var(--attention-line); border-radius: var(--radius-lg); background: var(--attention-bg); }
.sheet-answer .form { gap: var(--space-3); }
.app .sheet-answer .form > label { color: var(--ink); font-size: var(--text-md); font-weight: 400; }
.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--card);
}

/* Audit log: a toolbar, then the events by day */
.audit-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.audit-toolbar > .ops-filter { margin-bottom: 0; }
.app .audit-pick { display: flex; align-items: center; gap: var(--space-2); }
.audit-pick select { min-width: 13rem; max-width: 100%; }
.audit-table th.audit-col-time { width: 1%; }
.audit-table th.audit-col-event { width: 40%; }
.audit-table th.audit-col-who { width: 22%; }
.audit-table td.audit-col-time { padding-right: var(--space-5); color: var(--soft); white-space: nowrap; }
.audit-table tr.audit-day > td { padding-top: var(--space-5); padding-bottom: var(--space-2); }
.audit-table tbody tr.audit-day:hover { background: none; }
.audit-table tbody tr.audit-day:first-child > td { padding-top: var(--space-3); }
.audit-table .audit-day-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: 0;
}
.audit-day-title span { color: var(--muted); font-family: var(--font-text); font-size: var(--text-sm); font-weight: 400; }
.audit-event { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); min-width: 0; overflow-wrap: anywhere; }
.audit-what { color: var(--ink); font-weight: 600; }
.audit-subject { color: var(--soft); }
.audit-subject.is-link {
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-2);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--line-button);
  text-underline-offset: 3px;
  transition: color var(--fast) ease, text-decoration-color var(--fast) ease;
}
.audit-subject.is-link:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.audit-actor { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-2); }
.audit-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--neutral-ink);
  font-size: var(--text-xs);
  font-weight: 600;
}
.audit-details { display: grid; gap: 2px; min-width: 0; color: var(--soft); font-size: var(--text-sm); overflow-wrap: anywhere; }
.audit-reason { color: var(--ink-2); }
.audit-foot-text { display: grid; gap: 2px; }
.audit-foot-text p:focus { outline: none; }

/* Search: grouped results; a result row is one big target */
.search-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); max-width: 60rem; }
.search-rows { display: grid; margin: 0 calc(var(--card-pad) * -1); padding: 0; list-style: none; }
.search-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-1) var(--space-4);
  padding: var(--space-3) var(--card-pad);
  border-top: 1px solid var(--line-soft);
  transition: background-color var(--fast) ease;
}
.search-row:first-child { padding-top: var(--space-1); border-top: 0; }
.search-row:last-child { padding-bottom: 0; }
.search-row.has-icon { grid-template-columns: auto minmax(0, 1fr) auto; }
.search-row.has-icon > .ov-icon { margin-top: 2px; }
.search-row.is-link:hover { background: var(--hover); }
.search-text { min-width: 0; }
.card p.search-line { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.search-title, .search-hit { color: var(--ink); font-weight: 600; }
.search-hit {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  line-height: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.search-hit::after { content: ""; position: absolute; inset: 0; }
.search-hit .icon { margin-left: 6px; color: var(--muted); vertical-align: -2px; }
.search-row.is-link:hover .search-hit { color: var(--accent-ink); text-decoration: none; }
.app .search-row .search-hit:focus-visible { outline: none; }
.search-row:has(.search-hit:focus-visible) { z-index: 1; border-radius: var(--radius-control); box-shadow: inset 0 0 0 2px var(--accent); }
.search-aside { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.search-mark { padding: 0 1px; border-radius: 3px; background: color-mix(in srgb, var(--attention-line) 60%, #fff); color: inherit; }
.card p.search-snippet {
  display: -webkit-box;
  grid-column: 1 / -1;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--soft);
  font-size: var(--text-sm);
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.search-row.has-icon > .search-snippet { grid-column: 2 / -1; }
.search-passages { display: grid; grid-column: 1 / -1; gap: 6px; margin: var(--space-1) 0 0; padding: 0; list-style: none; }
.search-row.has-icon .search-passages { grid-column: 2 / -1; }
.search-passages li { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: var(--space-3); color: var(--soft); font-size: var(--text-sm); line-height: 1.5; }
.search-where { color: var(--muted); }
.card p.search-note { margin: var(--space-3) 0 0; color: var(--muted); font-size: var(--text-sm); }
.app .empty > .search-slash { margin-top: var(--space-2); color: var(--soft); font-size: var(--text-sm); }

@media (max-width: 1279px) {
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .ov-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .ov-side > .ov-coming:not(:only-child) { grid-row: span 2; }
}
/* Between phone and desktop the workspace moves under the title, so the action keeps room to read. */
@media (min-width: 641px) and (max-width: 1100px) {
  .actions-table :is(th, td).actions-col-place { display: none; }
  .actions-sub-place { display: inline; }
  .actions-sub:has(.actions-sub-place) { display: block; }
  .actions-table td.actions-col-owner { white-space: normal; }
  .actions-note { max-width: 24ch; }
}
@media (max-width: 720px) {
  .ov-side { grid-template-columns: minmax(0, 1fr); }
  .ov-side > .ov-coming:not(:only-child) { grid-row: auto; }
}
@media (max-width: 640px) {
  .ov-health-top { gap: var(--space-3); }
  .ov-health-icon { width: 32px; height: 32px; border-radius: var(--radius-control); }
  .ov-health-icon .icon { width: 16px; height: 16px; }
  .ov-health-body { flex-basis: calc(100% - 44px); }
  .ov-health-actions { flex-basis: 100%; }
  .ov-conns { gap: var(--space-2) var(--space-4); }
  .ov-conn-link { flex-basis: 100%; margin-left: 0; }
  /* A shorter queue on phones; All actions has the rest */
  .ov-rows > li:nth-child(n + 7) { display: none; }
  /* Filters become a labelled select: every choice in reach, nothing wraps or scrolls sideways */
  .ops-filter > .segmented { display: none; }
  .app .ops-filter-pick { display: flex; align-items: center; gap: var(--space-2); }
  .audit-toolbar > .ops-filter { width: 100%; }
  :is(.ops-filter-pick, .audit-pick) > span { flex: none; width: 3rem; }
  .app :is(.ops-filter-pick, .audit-pick) select { flex: 1 1 auto; min-width: 0; }

  .approval, .approval.is-compact { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "changes" "buttons"; }
  .approval-buttons > .btn { flex: 1 1 0; }

  /* Action rows as compact blocks: title, status, then where and when on one line, with the next step beside them */
  .actions-table.table-cards tr { flex-flow: row wrap; align-items: center; gap: 6px var(--space-2); }
  .actions-table.table-cards td { display: block; padding: 0; }
  .actions-table.table-cards td::before { content: none; }
  .actions-table.table-cards :is(td.actions-col-what, td.actions-col-state) { flex: 1 0 100%; }
  .actions-table.table-cards :is(td.actions-col-place, td.actions-col-owner, td.actions-col-time) { font-size: var(--text-sm); }
  .actions-table.table-cards :is(td.actions-col-owner, td.actions-col-time)::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 3px;
    margin: 0 var(--space-2) 3px 0;
    border-radius: 50%;
    background: currentColor;
  }
  .actions-table.table-cards td.actions-col-next { margin-left: auto; }
  .actions-table.table-cards td.actions-col-next:empty { display: none; }
  .actions-note { max-width: none; }

  .sheet-head { padding: var(--space-4) var(--space-3) var(--space-3) var(--space-4); }
  .sheet-body { gap: var(--space-4); padding: var(--space-4); }
  .sheet-foot { padding: var(--space-3) var(--space-4); }
  .sheet-facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sheet-facts dd { margin-bottom: var(--space-2); }
  .sheet-facts dt:has(+ dd > .sheet-ref) { line-height: 22px; }

  .app .audit-pick { width: 100%; }
  .audit-table.table-cards tr:not(.audit-day) { flex-flow: row wrap; align-items: baseline; gap: 4px var(--space-2); }
  .audit-table.table-cards td { padding: 0; }
  .audit-table.table-cards tr:not(.audit-day) td { display: block; }
  .audit-table.table-cards td::before { content: none; }
  .audit-table.table-cards :is(td.audit-col-event, td.audit-col-details) { flex: 1 0 100%; }
  .audit-table.table-cards td.audit-col-time { order: 0; padding: 0; font-size: var(--text-sm); }
  .audit-table.table-cards td.audit-col-who { order: 1; color: var(--soft); font-size: var(--text-sm); }
  .audit-table.table-cards td.audit-col-who::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 3px;
    margin: 0 var(--space-2) 3px 0;
    border-radius: 50%;
    background: currentColor;
  }
  .audit-table.table-cards td.audit-col-details { order: 2; }
  .audit-table.table-cards tbody tr.audit-day > td { padding: 0; }
  .audit-table.table-cards tr.audit-day { padding-top: var(--space-5); padding-bottom: var(--space-2); }
  .audit-table.table-cards tr.audit-day:first-child { padding-top: var(--space-2); }

  .search-row { grid-template-columns: minmax(0, 1fr); }
  .search-row.has-icon { grid-template-columns: auto minmax(0, 1fr); }
  .search-aside { justify-content: flex-start; }
  .search-row.has-icon .search-aside { grid-column: 2; }
  .search-passages li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (forced-colors: active) {
  .search-mark { forced-color-adjust: none; background: Mark; color: MarkText; }
  .search-row:has(.search-hit:focus-visible) { outline: 2px solid Highlight; }
  .ov-icon, .ov-health-icon, .audit-tag { border: 1px solid; }
}
/* End of screen: ops */

/* Screen: manage */
/* Routines and workspaces: the list beside the open item. On phones the two take turns, the list and then the item with a
   way back, so nothing scrolls inside anything else. */
/* A row's status sits under its name, as in every other library list. */
.setup-row-head { display: grid; justify-items: start; gap: var(--space-1); min-width: 0; }
.setup-row-head > strong { min-width: 0; }
.setup-row-head > .pill { margin-bottom: 2px; }
.setup-scope { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-1); }
.setup-scope .link { font-size: inherit; }
.setup-empty-actions { justify-content: center; }
.setup-notices { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.setup-note { display: grid; gap: 2px; }
/* Changes with lasting effects (pause, delete) sit apart at the end, each with what it does. */
.setup-zones { margin-top: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.setup-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-5); padding: var(--space-4); }
.setup-zone + .setup-zone { border-top: 1px solid var(--line-soft); }
.setup-zone > div { flex: 1 1 18rem; min-width: 0; }
.manage-detail .setup-zone h3 { margin: 0 0 2px; font-size: var(--text-md); }
.manage-detail .setup-zone p { margin: 0; color: var(--soft); font-size: var(--text-sm); }
/* Headings that take focus after a change say where you are; the shell's own heading shows no ring either. */
.app .setup-split .manage-detail h2:focus-visible, .app .workspace-tab > h3:focus-visible { outline: none; }

/* Choices that explain themselves: a radio, a title and one line */
.setup-choices { display: grid; gap: 6px; }
.app .setup-choices label.setup-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line-button);
  border-radius: var(--radius-control);
  background: var(--card);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color var(--fast) ease, background-color var(--fast) ease, box-shadow var(--fast) ease;
}
.app .setup-choices label.setup-choice input { margin-top: 2px; }
.app .setup-choices label.setup-choice:hover { border-color: var(--line-control-hover); }
.app .setup-choices label.setup-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.app .setup-choices label.setup-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.app .setup-choices label.setup-choice:has(input:disabled) { border-style: dashed; background: #f9fafb; color: var(--soft); cursor: not-allowed; }
.setup-choice-text { display: grid; gap: 1px; min-width: 0; }
.setup-choice-title { font-weight: 600; }
.app .setup-choice .hint { color: var(--soft); }

/* Routines: the open routine */
.manage-detail .routine-summary { color: var(--ink-2); }
.manage-detail .routine-detail { color: var(--soft); font-size: var(--text-sm); }
.routine-then { color: var(--soft); }
.manage-detail .routine-quote {
  max-width: 72ch;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--line-button);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: #f8fafc;
  line-height: 1.6;
  white-space: pre-wrap;
}
.routine-run { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); min-width: 0; }
.routine-run-time { color: var(--ink); font-weight: 600; }
.routine-run-note { color: var(--soft); font-size: var(--text-sm); }

/* Routines: the editor, in three groups side by side when there is room */
.routine-editor-card { container: routine-editor / inline-size; }
.app .routine-editor { gap: var(--space-5); }
.routine-name-field { max-width: 30rem; }
.routine-sections { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--space-5); }
.app .routine-section { gap: var(--space-4); align-content: start; }
.app .routine-section > legend {
  width: 100%;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
@container routine-editor (min-width: 900px) {
  .routine-sections { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5) var(--space-6); }
}

/* Days of the week as toggles */
.app .routine-days { gap: 0; }
.app .routine-days > legend { margin-bottom: 6px; }
.routine-day-list { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 24rem; }
.app .routine-day-list label.routine-day {
  position: relative;
  display: grid;
  place-items: center;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease;
}
.app .routine-day-list .routine-day input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.app .routine-day-list label.routine-day:hover { border-color: var(--line-control-hover); }
.app .routine-day-list label.routine-day:has(input:checked) { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: var(--shadow-primary); }
.app .routine-day-list label.routine-day:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The next runs, checked as the schedule changes */
.routine-preview { display: grid; gap: 6px; transition: opacity var(--fast) ease; }
.routine-preview:empty { display: none; }
.routine-preview.is-stale { opacity: 0.6; }
.routine-preview-title { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-weight: 600; }
.routine-preview-title .icon { color: var(--accent); }
.routine-preview-zone { color: var(--soft); font-weight: 400; }
.routine-preview-list { display: grid; gap: 2px; margin: 0; padding: 0 0 0 22px; list-style: none; }
.routine-preview-list time { color: var(--ink); font-weight: 500; }
.routine-preview-note { display: flex; align-items: flex-start; gap: 6px; }
.routine-preview-note > .icon { margin-top: 1px; color: var(--accent); }
.routine-preview-note.is-attention { color: var(--attention-ink); }
.routine-preview-note.is-attention > .icon { color: var(--attention-dot); }

/* Start, end and skip dates */
.routine-limits > summary { padding: var(--space-1) 0; }
.routine-limits-body { display: grid; gap: var(--space-4); margin-top: var(--space-3); }
.routine-limits-body > .hint { margin: 0; }
.app .routine-skip-field { gap: var(--space-2); }
.app .routine-skip-field > legend { margin-bottom: 6px; }
.routine-skip-add { display: flex; align-items: center; gap: var(--space-2); }
.app .routine-skip-add input { flex: 1 1 auto; min-width: 0; }
.routine-skips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.routine-skip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 0 2px 0 10px;
  border: 1px solid var(--line-button);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.routine-skip-remove {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--soft);
}
.routine-skip-remove:hover { background: var(--neutral-bg); color: var(--ink); }

/* Workspaces */
.manage-detail .workspace-about { color: var(--ink-2); }
.manage-detail .workspace-note { margin: 0 0 var(--space-2); color: var(--soft); font-size: var(--text-sm); }
.workspace-tab > h3 { display: flex; align-items: center; }
.workspace-chats { margin: 0; padding: 0; list-style: none; }
.workspace-chat { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) 0; border-top: 1px solid var(--line-soft); }
.workspace-chat:first-child { border-top: 0; }
.workspace-chat-text { display: grid; flex: 1 1 auto; min-width: 0; line-height: 1.4; }
.workspace-chat-name { font-weight: 600; overflow-wrap: anywhere; }
.workspace-chat-meta { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.workspace-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--line-soft); }
.workspace-add > label { flex: 1 1 16rem; min-width: 0; }
.workspace-add > .btn { min-height: 38px; }
.app .workspace-add select { width: 100%; }
.workspace-routines { display: grid; }
.workspace-routines .manage-related:last-child { border-bottom: 0; }
.workspace-routine { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); }
.workspace-routine-text { display: grid; gap: 2px; min-width: 0; }
.workspace-routine:hover .workspace-routine-text strong { text-decoration: underline; text-underline-offset: 3px; }
.workspace-tab > .btn { margin-top: var(--space-3); }
.workspace-settings > h3 { margin: 0; }
.workspace-settings { max-width: 34rem; }

/* People & access */
.people-card .card-head { align-items: flex-start; }
.people-person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.people-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dce7ff, #ece4ff);
  box-shadow: inset 0 0 0 1px rgba(72, 82, 214, 0.14);
  color: #3538cd;
  font-size: var(--text-xs);
  font-weight: 700;
}
.people-avatar.is-unknown { background: var(--neutral-bg); box-shadow: inset 0 0 0 1px var(--neutral-line); color: var(--soft); }
.people-who { display: grid; justify-items: start; gap: 1px; min-width: 0; line-height: 1.4; }
/* An email breaks only when it must: its whole width counts when the table sizes its columns. */
.people-name { font-weight: 600; overflow-wrap: break-word; }
.people-sub { color: var(--muted); font-size: var(--text-sm); font-weight: 400; overflow-wrap: break-word; }
.people-table td.people-col-ends { white-space: nowrap; }
/* Who gave a role shows under the role between phones and wide screens, instead of in a column of its own. */
.people-given { display: none; }
@media (min-width: 641px) and (max-width: 1279px) {
  .people-table :is(th, td).people-col-given { display: none; }
  .people-table .people-given { display: block; }
}

@media (max-width: 760px) {
  .screen:has(> .setup-split[data-pane="detail"]) > .setup-toolbar { display: none; }
}
@media (forced-colors: active) {
  .app .routine-day-list label.routine-day:has(input:checked) { forced-color-adjust: none; background: Highlight; border-color: Highlight; color: HighlightText; }
  .app .setup-choices label.setup-choice:has(input:checked) { outline: 2px solid; outline-offset: -2px; }
  .routine-skip { border: 1px solid; }
}
/* End of screen: manage */

/* Screen: config */

/* Teach Kai: a calm list beside one editor, and two reading views. */
.teach-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.teach-views .icon { width: 16px; height: 16px; }
.app .teach-activity { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.app .teach-activity select { width: 240px; max-width: 100%; }

.manage-layout.teach-split { grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.8fr); }
/* On wider screens the list stays in view beside a long editor and scrolls on its own. */
@media (min-width: 761px) {
  .manage-layout.teach-split { overflow: visible; }
  .teach-split > .teach-list {
    position: sticky;
    top: calc(var(--topbar-h) + var(--space-4));
    align-self: start;
    max-height: calc(100vh - var(--topbar-h) - var(--space-6));
    overflow-y: auto;
    border-radius: var(--radius) 0 0 var(--radius);
    scrollbar-width: thin;
  }
  .teach-split > .teach-detail { margin-left: -1px; border-left: 1px solid var(--line); }
}
.app .teach-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-4) var(--space-4) var(--space-2) 20px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-family: var(--font-text);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}
.teach-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.teach-more { padding: var(--space-3) var(--space-4) var(--space-3) 20px; border-bottom: 1px solid var(--line-soft); }
.teach-more .link { font-size: var(--text-sm); }
.teach-list > .teach-more:last-child { border-bottom: 0; }

.teach-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.teach-head > div { min-width: 0; }
.teach-head > .pill { flex: none; margin-top: 2px; }
/* The chosen item's heading takes focus on phones, like the page title: no ring for a heading. */
.app .teach-head h2[tabindex]:focus { outline: none; }
.manage-detail .teach-lede { max-width: 72ch; margin-top: var(--space-1); color: var(--soft); }
.teach-detail > .banner { margin-top: var(--space-4); }
.teach-detail > .manage-facts { margin-top: var(--space-4); }
.teach-detail > .teach-form { margin-top: var(--space-5); }
.teach-form > h2 { margin: 0; }

/* Writing fields read like a page: roomy, with a faint paper tint. */
.app textarea.teach-text { min-height: 9rem; padding: 12px 16px; background: #fcfdff; font-size: var(--text-lg); line-height: 1.65; }
.teach-field { display: grid; gap: 6px; min-width: 0; }
.teach-field > .hint { margin: 0; }
.teach-version-note > span { display: block; color: var(--soft); font-style: italic; }
.teach-field-label { color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.teach-count { justify-self: end; color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.teach-count.is-near { color: var(--attention-ink); font-weight: 600; }
.teach-fields { display: grid; gap: var(--space-4); min-width: 0; }
.teach-jobs { gap: var(--space-2); }
.teach-jobs > .hint { margin: var(--space-1) 0 0; }
.teach-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: var(--space-2) var(--space-4); }
.app .teach-checks > label.teach-check { align-items: flex-start; gap: 10px; }
.teach-check > input { margin-top: 3px; }
.teach-tools .teach-check > span { display: grid; gap: 1px; }
.teach-tools strong { font-weight: 600; }
.teach-original { border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: #f8fafc; }
.app .teach-original > summary { padding: 6px var(--space-3); font-size: var(--text-sm); }
.teach-original[open] > summary { border-bottom: 1px solid var(--line-soft); }
.teach-original .teach-prose { padding: var(--space-3); color: var(--soft); font-size: var(--text-sm); }
.teach-prose { max-width: 72ch; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.teach-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}
.teach-save-status { margin-right: auto; color: var(--soft); font-size: var(--text-sm); }
.teach-footer > .btn-sm:first-child { margin-right: var(--space-2); }

/* Documents in a collection */
.teach-docs-head { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-1); }
.teach-docs-head h3 { margin: 0; }
.teach-docs-head .count-chip, .app .teach-read-group .count-chip { margin-left: 0; }
.teach-docs-wait { display: grid; gap: var(--space-3); padding: var(--space-3) 0; }
.teach-docs-wait .sk:nth-child(1) { width: 72%; }
.teach-docs-wait .sk:nth-child(2) { width: 58%; }
.teach-docs-wait .sk:nth-child(3) { width: 66%; }
.teach-doc-list { margin: 0; padding: 0; list-style: none; }
.teach-doc { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line-soft); }
.teach-doc:last-child { border-bottom: 0; }
.teach-doc-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--neutral-bg); color: var(--soft); }
.teach-doc-main { display: grid; gap: 1px; min-width: 0; }
.teach-doc-main strong { font-weight: 600; line-height: 1.4; }
.teach-doc-meta { color: var(--soft); font-size: var(--text-sm); }
.teach-doc-meta .is-attention { color: var(--attention-ink); font-weight: 600; }
.teach-doc-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.teach-add-doc > .teach-form { margin-top: var(--space-3); }
.teach-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line-soft); }

/* A file field to click or drop on; the native control stays inside for keyboards and screen readers. */
.app label.teach-file {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px var(--space-3);
  padding: var(--space-4);
  border: 1px dashed var(--line-control);
  border-radius: var(--radius-lg);
  background: #fcfdff;
  color: var(--soft);
  font-size: var(--text-sm);
  font-weight: 400;
  cursor: pointer;
  transition: border-color var(--fast) ease, background-color var(--fast) ease;
}
.app label.teach-file:hover, .app label.teach-file.is-over { border-color: var(--accent); background: var(--accent-soft); }
.app label.teach-file:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.app input.teach-file-input { position: absolute; inset: 0; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; }
.teach-file-icon { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--accent); }
.teach-file:hover .teach-file-icon { background: #fff; }
.teach-file-text strong { color: var(--accent-ink); font-weight: 600; }
/* Soft, not muted: the box takes the accent tint on hover, where muted text would fall under 4.5:1. */
.app label.teach-file .hint { display: block; color: var(--soft); }
.teach-file-chosen { grid-column: 2; color: var(--soft); overflow-wrap: anywhere; }
.teach-file.has-file .teach-file-chosen { color: var(--ink); font-weight: 600; }

/* Add to Kai */
.teach-create { width: 100%; max-width: 800px; }
.teach-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: var(--space-3); }
.teach-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink-2);
  text-align: left;
  transition: border-color var(--fast) ease, background-color var(--fast) ease, box-shadow var(--fast) ease;
}
.teach-choice:hover { border-color: var(--info-line); background: var(--accent-soft); box-shadow: var(--shadow-xs); }
.teach-choice-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--accent); }
.teach-choice:hover .teach-choice-icon { background: #fff; }
.teach-choice-text { display: grid; gap: 2px; min-width: 0; }
.teach-choice-text strong { color: var(--ink); font-weight: 600; }
.teach-choice-text span { color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.teach-create-foot { display: flex; justify-content: flex-end; margin-top: var(--space-4); }
.teach-create > .teach-form > .teach-footer { margin-top: var(--space-2); }

/* Reading views: one column, like a document. */
.teach-intro { max-width: 72ch; margin: 0; color: var(--soft); }
.teach-reading, .app .teach-read-group, .teach-read-head, .teach-coverage-more { width: 100%; max-width: 920px; }
.teach-read-head { display: grid; gap: var(--space-1); }
.app .teach-read-head .teach-read-group { margin: 0; }
.app .teach-read-group { display: flex; align-items: baseline; gap: var(--space-2); margin: var(--space-2) 0 0; font-size: var(--text-lg); }
.teach-reading { display: grid; gap: var(--space-2); }
.teach-reading-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2) var(--space-4); }
.teach-reading-head > div { min-width: 0; }
.teach-reading-head > .pill { flex: none; }
.app .teach-reading-head h3 { margin: 0; font-size: var(--text-xl); }
.card .teach-reading-scope { margin: 0; color: var(--soft); font-size: var(--text-sm); }
.teach-reading .teach-prose { max-width: none; margin: var(--space-2) 0; padding-left: var(--space-4); border-left: 3px solid var(--line); color: var(--ink); font-size: var(--text-lg); }
.teach-reading > .link { justify-self: start; }
.teach-coverage-list { display: grid; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.teach-coverage-list li { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); gap: var(--space-3); }
.teach-coverage-list strong { font-weight: 600; }

/* Connections */
.connection-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: 0; color: var(--ink-2); }
.connection-list { display: grid; margin: 0; padding: 0; list-style: none; }
.connection { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: start; gap: var(--space-4); padding: var(--space-5) 0; border-top: 1px solid var(--line-soft); }
.connection:first-child { padding-top: 0; border-top: 0; }
.connection:last-child { padding-bottom: 0; }
.connection-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-lg); background: var(--tone-bg); box-shadow: inset 0 0 0 1px var(--tone-line); color: var(--tone-ink); }
.connection-main { display: grid; gap: 2px; min-width: 0; }
.connection-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.connection-title h2 { margin: 0; }
.card .connection-what, .card .connection-uses { margin: 0; color: var(--soft); font-size: var(--text-sm); }
.card .connection-detail { display: flex; flex-wrap: wrap; gap: 2px var(--space-4); margin: var(--space-2) 0 0; color: var(--ink-2); }
.connection-seen { align-self: center; color: var(--muted); font-size: var(--text-sm); }
.connection-uses > span { color: var(--muted); }
.connection-main > .banner { margin-top: var(--space-3); }
.connection-actions { display: flex; gap: var(--space-2); }

/* MCP: an AI tool's set-up sheet in Connectors (accounts.js) */
.mcp-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); min-width: 0; }
.mcp-label { color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.mcp-address { display: flex; align-items: center; gap: var(--space-3); min-width: 0; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--paper); }
.mcp-address code { flex: 1 1 auto; min-width: 0; color: var(--ink); font-family: var(--font-mono); font-size: var(--text-sm); overflow-wrap: anywhere; }
.steps { display: grid; gap: var(--space-3); margin: var(--space-1) 0 0; padding: 0; list-style: none; counter-reset: mcp-step; }
.steps > li { position: relative; display: grid; gap: var(--space-2); min-width: 0; padding-left: 36px; line-height: 24px; counter-increment: mcp-step; }
.steps > li::before {
  content: counter(mcp-step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mcp-snippet { position: relative; min-width: 0; line-height: 1.5; }
.mcp-snippet .code { padding-right: 96px; }
.mcp-snippet .btn { position: absolute; top: var(--space-2); right: var(--space-2); }
.mcp-list { display: grid; gap: var(--space-2); margin: 0; padding-left: 18px; color: var(--ink-2); }
.mcp-list li::marker { color: var(--muted); }

/* LLM */
.llm-model > .banner { margin-bottom: var(--space-4); }
.llm-picker { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.llm-find-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.app .llm-find-row .llm-find { flex: 0 1 22rem; min-width: 0; }
.llm-find-count { color: var(--soft); font-size: var(--text-sm); }
.llm-picker-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* A long model name never widens the card on a narrow phone. */
.llm-picker-row select { flex: 1 1 14rem; width: 0; min-width: 0; }
.card .llm-model-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-3); margin: 0; color: var(--muted); font-size: var(--text-sm); }
.card .llm-model-note.is-changed { color: var(--attention-ink); }
.llm-model-note code { color: var(--soft); font-family: var(--font-mono); font-size: var(--text-xs); }
.llm-specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr)); gap: var(--space-3); margin: var(--space-4) 0 0; }
.llm-spec { min-width: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); background: var(--paper); }
.llm-spec dt { color: var(--soft); font-size: var(--text-xs); font-weight: 600; }
.llm-spec dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 2px 0 0; font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.llm-spec dd span { color: var(--muted); font-family: var(--font-text); font-size: var(--text-xs); font-weight: 400; }
.llm-key-name { font-weight: 600; }
.llm-key-hint { margin-top: 2px; color: var(--muted); font-size: var(--text-sm); font-weight: 400; }
.llm-key-hint code { color: var(--soft); font-family: var(--font-mono); font-size: var(--text-xs); }
.llm-spent { color: var(--danger-ink); font-weight: 600; }
.llm-key-actions { justify-content: flex-end; }
.card .llm-keys-note { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-4) 0 0; color: var(--soft); font-size: var(--text-sm); }
.llm-keys-note .icon { color: var(--muted); }

/* Settings */
.settings-form { display: grid; gap: var(--space-4); }
.settings-section { display: grid; grid-template-columns: minmax(0, 16rem) minmax(0, 1fr); gap: var(--space-5) var(--space-6); }
.settings-intro h2 { margin: 0 0 6px; }
.card .settings-intro p { margin: 0; color: var(--soft); font-size: var(--text-sm); text-wrap: pretty; }
.settings-fields { display: grid; align-content: start; gap: var(--space-5); min-width: 0; }
.settings-group legend { margin-bottom: var(--space-3); }
.settings-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: var(--space-3); }
.app .settings-choices > .settings-choice {
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-button);
  border-radius: var(--radius-lg);
  background: var(--card);
  cursor: pointer;
  transition: border-color var(--fast) ease, background-color var(--fast) ease, box-shadow var(--fast) ease;
}
.app .settings-choices > .settings-choice:hover { border-color: var(--line-control-hover); }
.app .settings-choices > .settings-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.app .settings-choices > .settings-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.app .settings-fields :is(.settings-choice, .settings-check):has(input:disabled) { cursor: not-allowed; opacity: 0.6; }
.app .settings-fields .settings-check { align-items: flex-start; gap: 10px; }
.settings-choice input, .settings-check input { margin-top: 3px; }
.settings-choice-text { display: grid; gap: 2px; min-width: 0; }
.settings-choice-text strong { color: var(--ink); font-weight: 600; }
.settings-choice-text span { color: var(--soft); font-size: var(--text-sm); line-height: 1.45; }
.settings-checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--space-4) var(--space-5); }
.settings-quiet { display: grid; grid-template-columns: repeat(2, minmax(0, 9.5rem)) minmax(0, 1fr); gap: var(--space-4); }
.app .settings-quiet :is(input, select) { width: 100%; }
/* The save bar stays in reach while there are changes. */
.settings-save { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.settings-save.is-dirty {
  position: sticky;
  bottom: var(--space-4);
  z-index: 5;
  border-color: var(--info-line);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  box-shadow: var(--shadow-raised);
}
.settings-note { flex: 1 1 18rem; min-width: 0; }
.app .settings-note input { width: 100%; }
.settings-save-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.settings-status { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.is-dirty > .settings-status { color: var(--attention-ink); font-weight: 600; }
.settings-versions { display: grid; margin: 0; padding: 0; list-style: none; }
.settings-version { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--space-4); row-gap: 6px; padding: var(--space-4) 0; border-top: 1px solid var(--line-soft); }
.settings-version > :not(.settings-version-actions) { grid-column: 1; }
.settings-version-actions { grid-column: 2; grid-row: 1; align-self: center; }
.settings-version:first-child { padding-top: 0; border-top: 0; }
.settings-version:last-child { padding-bottom: 0; }
.settings-version-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); min-height: 30px; }
.settings-version-title { display: flex; align-items: center; gap: var(--space-2); }
.settings-version-title strong { font-weight: 600; }
.settings-version-meta { color: var(--muted); font-size: var(--text-sm); }
.card .settings-version-note { margin: 0; color: var(--ink-2); }
.settings-changes { display: grid; gap: 2px; margin: 0; padding-left: 18px; color: var(--soft); font-size: var(--text-sm); }
.settings-changes li::marker { color: var(--muted); }
.settings-changes strong { color: var(--ink); font-weight: 600; }
.card .settings-changes-none { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.settings-history > .link { margin-top: var(--space-4); }

/* Organization integrations: kAI's own services first, each a card with its connections, then the shared accounts. */
.integration-section { display: grid; gap: var(--space-3); min-width: 0; }
.integration-section + .integration-section { margin-top: var(--space-4); }
.app .integration-head h2 { margin: 0; font-size: var(--text-xl); }
.app .integration-head p { max-width: 72ch; margin: 2px 0 0; color: var(--soft); }
.integration-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; gap: var(--space-4); }
.integration-service { display: grid; gap: var(--space-3); }
.card.integration-service p.integration-text { margin: 0; color: var(--ink-2); }
.integration-service > .connector-head .connector-name { min-height: 0; padding-top: 9px; }
.integration-service > .connector-head > .pill { margin-top: 9px; }
.integration-details { padding-top: var(--space-3); border-top: 1px solid var(--line-soft); }
.integration-details > summary { width: max-content; max-width: 100%; }
.integration-details > summary .count-chip { margin-left: var(--space-1); }
.integration-details[open] > summary { margin-bottom: var(--space-4); }
.integration-service > .connection-list { padding-top: var(--space-4); border-top: 1px solid var(--line-soft); }
.app .connection-title h4 { margin: 0; font-family: var(--font-display); font-size: var(--text-md); font-weight: 600; line-height: 1.4; }
.integration-empty { padding: 0; }

@media (max-width: 1100px) {
  .manage-layout.teach-split { grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.4fr); }
}
@media (min-width: 1101px) {
  .llm-key-table td.end { width: 1%; white-space: nowrap; }
  .llm-key-actions { flex-wrap: nowrap; }
}
/* Tablets: the least needed column gives way before the rows stack at 640px, and each key's buttons take a line of their
   own under it, so every row reads the same way. */
@media (min-width: 641px) and (max-width: 1100px) {
  .llm-key-table :is(th, td):nth-child(5) { display: none; }
  .llm-key-table tr { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(0, 1.3fr); align-items: center; }
  .llm-key-table th.end { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); }
  .llm-key-table :is(th, td):nth-child(4) { padding-right: var(--card-pad); }
  .llm-key-table td { border-bottom: 0; }
  .llm-key-table tbody tr { border-bottom: 1px solid var(--line-soft); }
  .llm-key-table tbody tr:last-child { border-bottom: 0; }
  .llm-key-table td.end { grid-column: 1 / -1; padding-top: 0; padding-left: var(--card-pad); }
  .llm-key-actions { justify-content: flex-start; }
}
.llm-key-table td.num { white-space: nowrap; }
@media (max-width: 960px) {
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
}
/* Phones: the library list and the editor take turns, so nothing scrolls inside anything else. */
@media (max-width: 760px) {
  .manage-layout.teach-split { grid-template-columns: minmax(0, 1fr); }
  .teach-coverage-list li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 640px) {
  /* Two filter rows share this toolbar: tighter buttons. */
  .teach-toolbar > .segmented button { padding: 0 var(--space-2); }
  .teach-toolbar > label.teach-activity { flex: 1 1 100%; }
  .app .teach-activity select { flex: 1 1 auto; width: auto; }
  .teach-head { flex-direction: column; gap: var(--space-2); }
  .teach-doc { grid-template-columns: auto minmax(0, 1fr); }
  .teach-doc-end { grid-column: 2; justify-content: flex-start; }
  .teach-footer > .btn, .teach-footer > button { flex: 1 1 auto; }
  .teach-save-status { flex-basis: 100%; order: -1; }
  .connection { grid-template-columns: 40px minmax(0, 1fr); column-gap: var(--space-3); padding: var(--space-4) 0; }
  .connection-actions { grid-column: 2; }
  .connection-main > .banner { margin-left: -52px; }
  .llm-key-actions { justify-content: flex-start; flex-wrap: wrap; }
  .settings-version { grid-template-columns: minmax(0, 1fr); }
  .settings-version-actions { grid-column: 1; grid-row: auto; order: 9; justify-self: start; }
  /* From and Until side by side where they fit, one above the other on the narrowest phones. */
  .settings-quiet { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); }
  .settings-quiet > label { min-width: 0; }
  .settings-zone { grid-column: 1 / -1; }
  .settings-save.is-dirty { bottom: var(--space-2); }
  .settings-note { flex-basis: 100%; order: 3; }
}
@media (forced-colors: active) {
  .app .settings-choices > .settings-choice:has(input:checked), .teach-choice:hover { outline: 2px solid Highlight; outline-offset: -2px; }
  .app label.teach-file, .teach-original, .llm-spec, .mcp-address, .settings-save { border: 1px solid CanvasText; }
}
/* End of screen: config */

/* Projects: the organization's projects beside the chosen one (projects.js). */
.project-scope { margin: 0; }
.project-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.project-form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.project-form-pair > label { min-width: 0; }
.project-form-pair input[hidden] { display: none; }
@media (max-width: 560px) { .project-form-pair { grid-template-columns: 1fr; } }
.project-run-note > .banner { margin: 0; }

/* The portfolio (projects.js, managers run the list): summary cards, the project table, and a project's overview. */
.pf-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.pf-card {
  display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); text-align: left; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.pf-card:hover { border-color: var(--line-button); }
.pf-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pf-card-label { display: flex; align-items: center; gap: var(--space-2); color: var(--soft); font-size: var(--text-md); }
.pf-card-count { font-size: var(--text-3xl); font-weight: 600; line-height: 1; }
.pf-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neutral-dot); }
.pf-card[data-tone="ongoing"] .pf-dot { background: var(--brand-violet); }
.pf-card[data-tone="progress"] .pf-dot { background: var(--info-dot); }
.pf-card[data-tone="halted"] .pf-dot { background: var(--danger-dot); }
.pf-card[data-tone="waiting"] .pf-dot { background: var(--paused-dot); }
.pf-card[data-tone="done"] .pf-dot { background: var(--success-dot); }
.pf-panel { padding: 0; overflow: hidden; }
.pf-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line-soft); }
.pf-toolbar h2, .pf-toolbar h3 { margin: 0; font-size: var(--text-lg); }
.pf-toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.pf-toolbar-end input[type="search"] { width: 240px; max-width: 100%; }
.pf-count { font-weight: 400; }
.pf-table-wrap { overflow-x: auto; }
.pf-table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: var(--text-md); }
.pf-team-table { min-width: 560px; }
.pf-table th { padding: var(--space-3) var(--space-3); text-align: left; font-size: var(--text-sm); font-weight: 600; color: var(--soft); background: var(--side); border-bottom: 1px solid var(--line-soft); }
.pf-table th:first-child, .pf-table td:first-child { padding-left: var(--space-4); }
.pf-table td { padding: var(--space-3); border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--ink-2); }
.pf-table tbody tr:last-child td { border-bottom: 0; }
.pf-row { cursor: pointer; }
.pf-row:hover, .pf-row:focus-within { background: var(--hover); }
.pf-name { display: block; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; }
.pf-name:hover { color: var(--accent-ink); text-decoration: underline; }
.pf-sub { display: block; margin-top: 2px; }
.pf-comment-cell { min-width: 200px; }
.pf-table:not(.pf-team-table) td:nth-child(2), .pf-table:not(.pf-team-table) td:nth-child(3) { white-space: nowrap; }
.pf-end { white-space: nowrap; text-align: right; }
.pf-end > * + * { margin-left: var(--space-2); }
.pf-chevron { display: inline-flex; vertical-align: middle; color: var(--muted); }
.pf-team { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.pf-faces { display: inline-flex; }
.pf-faces .avatar { width: 26px; height: 26px; font-size: 10px; margin-right: -6px; border: 2px solid var(--card); }
.pf-faces:not(:empty) { margin-right: 6px; }
.pf-none { margin: 0; padding: var(--space-5) var(--space-4); color: var(--muted); }
.pf-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--muted); }
.pf-badges { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.pf-chip { padding: 2px 10px; font-size: var(--text-xs); color: var(--ink-2); background: var(--neutral-bg); border: 1px solid var(--neutral-line); border-radius: var(--radius-pill); }
.pf-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }
.pf-fact { display: flex; flex-direction: column; gap: 4px; padding: var(--space-3) var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.pf-fact-label { font-size: var(--text-sm); color: var(--muted); }
.pf-fact-value { font-size: var(--text-xl); font-weight: 600; color: var(--ink); }
.pf-latest { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); background: var(--attention-bg); border: 1px solid var(--attention-line); border-radius: var(--radius-lg); }
.pf-latest h3 { margin: 0 0 4px; font-size: var(--text-sm); color: var(--attention-ink); }
.pf-latest p { margin: 0 0 4px; font-size: var(--text-lg); color: var(--ink); }
.pf-latest .small { color: var(--attention-ink); }
.pf-columns { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4); }
.pf-columns > .pf-team-panel { flex: 999 1 520px; min-width: 0; }
.pf-side { flex: 1 1 300px; min-width: 0; display: grid; gap: var(--space-4); }
.pf-side > .manage-section { margin: 0; padding: var(--space-4); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.pf-share { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 160px; }
.pf-bar { flex: 1; height: 8px; overflow: hidden; background: var(--line-soft); border-radius: 4px; }
.pf-bar > span { display: block; height: 8px; background: var(--accent); border-radius: 4px; }
.pf-pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); }

/* Inside a Teams tab (the Portfolio and Team hubs): the screen alone, no sidebar or top bar. */
.is-embedded .app { grid-template-columns: minmax(0, 1fr); }
.is-embedded .side, .is-embedded .topbar { display: none; }

/* Team: planned load (team.js, managers run the project list). */
.team-modes { margin-bottom: var(--space-4); }
.team-mode-body { display: grid; gap: var(--space-4); }
.team-mode-body > p { margin: 0; }
.pf-card[data-tone="neutral"] .pf-dot { background: var(--neutral-dot); }
.tl-table { min-width: 640px; }
.tl-table td:nth-child(2) { min-width: 0; }
.tl-load { display: inline-grid; grid-template-columns: minmax(80px, 1fr) auto; align-items: center; column-gap: var(--space-2); min-width: 160px; }
.tl-table th:nth-child(4), .tl-table td:nth-child(4) { white-space: nowrap; }
.tl-project > .spread { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.tl-load .tl-word { grid-column: 1 / -1; }
.tl-load[data-band="over"] .pf-bar > span { background: var(--danger-dot); }
.tl-load[data-band="over"] .tl-word, .tl-load[data-band="over"] strong { color: var(--danger-ink); }
.tl-load[data-band="full"] .pf-bar > span { background: var(--attention-dot); }
.tl-load[data-band="full"] .tl-word { color: var(--attention-ink); }
.tl-load[data-band="room"] .pf-bar > span { background: var(--success-dot); }
.tl-load[data-band="room"] .tl-word { color: var(--success-ink); }
.tl-load[data-band="unassigned"] .tl-word { color: var(--muted); }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-row-actions { display: inline-flex; gap: 6px; }
.tl-chip { padding: 2px 8px; font-size: var(--text-xs); color: var(--ink-2); background: var(--neutral-bg); border: 1px solid var(--neutral-line); border-radius: var(--radius-pill); white-space: nowrap; }
.tl-layout { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-4); }
.tl-main { flex: 999 1 600px; min-width: 0; }
.tl-panel { flex: 1 1 300px; min-width: 0; padding: var(--space-4); }
.tl-table tr.is-selected > td { background: var(--accent-soft); }
.tl-boards { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tl-panel-body { display: grid; gap: var(--space-4); }
.tl-panel-body h2 { margin: 0; font-size: var(--text-xl); }
.tl-panel-body h3 { margin: 0 0 var(--space-2); font-size: var(--text-md); display: flex; align-items: center; gap: var(--space-2); }
.tl-panel-body section > p { margin: 0; }
.tl-panel-head { display: flex; align-items: center; gap: var(--space-3); }
.tl-avatar { width: 44px; height: 44px; font-size: var(--text-md); }
.tl-panel-load { display: grid; gap: var(--space-1); padding: var(--space-3); background: var(--paper); border-radius: var(--radius-sm); }
.tl-panel-load .tl-load { min-width: 0; }
.tl-list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); }
.tl-project { display: grid; gap: 4px; padding: var(--space-2) var(--space-3); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.tl-project .pf-bar { height: 6px; }
.tl-project .pf-bar > span { height: 6px; }
.tl-not-counted { opacity: 0.75; }
.tl-panel-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tl-mine { margin-bottom: var(--space-4); padding: var(--space-4); }
.tl-edit { display: grid; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--line-soft); }
.tl-edit-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 96px auto; align-items: center; gap: var(--space-2); }
.tl-edit-row > select:first-child { grid-column: 1; }
.tl-edit-name { font-size: var(--text-md); }
.tl-edit-remove { white-space: nowrap; }
.tl-edit-row input, .tl-edit-row select { width: 100%; min-width: 0; }
@media (max-width: 560px) { .tl-edit-row { grid-template-columns: 1fr 1fr; } }

/* Importing the project sheet: the preview of what kAI would do. */
.imp-card { cursor: default; }
.imp-section { padding: 0; overflow: hidden; }
.imp-section > summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); cursor: pointer; list-style: none; }
.imp-section > summary::-webkit-details-marker { display: none; }
.imp-section > summary h2 { margin: 0; font-size: var(--text-lg); display: flex; align-items: center; gap: var(--space-2); }
.imp-section[open] > summary { border-bottom: 1px solid var(--line-soft); }
.imp-section > :not(summary) { padding: var(--space-3) var(--space-4); }
.imp-section > .pf-table-wrap { padding: 0; }
.imp-choices { display: grid; gap: var(--space-3); }
.imp-choice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--line-soft); }
.imp-choice:last-child { border-bottom: 0; padding-bottom: 0; }
.imp-choice select { min-width: 260px; max-width: 100%; }
.imp-table { min-width: 720px; }
.imp-changes { display: grid; gap: var(--space-3); }
.imp-change { padding: var(--space-3); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.imp-change-head { display: flex; align-items: center; gap: var(--space-2); }
.imp-lines { margin: var(--space-2) 0 0; padding-left: var(--space-6); display: grid; gap: 4px; font-size: var(--text-md); }
.imp-lines s { color: var(--muted); }
.imp-lines .is-conflict { color: var(--attention-ink); }
.imp-keep { display: block; margin-top: 2px; font-size: var(--text-sm); color: var(--attention-ink); }
.imp-missing { margin: var(--space-2) 0 0; padding: 0; list-style: none; display: grid; gap: var(--space-2); }
.imp-notes { padding: var(--space-4); }
.imp-notes h2 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.imp-footer { display: flex; justify-content: flex-end; gap: var(--space-2); }
.project-toolbar-end { display: flex; flex: 0 1 auto; align-items: center; gap: var(--space-3); min-width: 0; }
.manage-toolbar .project-toolbar-end input[type="search"] { width: 240px; min-width: 0; }
.project-mine { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--soft); font-size: var(--text-sm); white-space: nowrap; }
.project-list > button { gap: 6px; }
.project-row-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.project-row-head > .pill { flex: none; }
.project-row-line { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.project-row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); }
.project-faces { display: inline-flex; align-items: center; gap: 3px; }
.project-faces .avatar { width: 24px; height: 24px; font-size: 10px; }
.project-faces-more { margin-left: 4px; color: var(--soft); font-size: var(--text-xs); font-weight: 600; }
.project-detail > .banner { margin-top: var(--space-4); }
.project-reason { color: var(--ink-2); }
.project-latest h4 { margin: var(--space-4) 0 var(--space-1); color: var(--soft); font-size: var(--text-sm); font-weight: 600; }
.project-lines { margin: var(--space-2) 0 0; padding-left: 1.2em; line-height: 1.55; }
.project-lines li + li { margin-top: 4px; }
.project-person { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
.project-person .avatar { width: 28px; height: 28px; }
.project-person > span:last-child { display: grid; min-width: 0; }
.project-did { max-width: 36ch; }
.project-row-actions { display: inline-flex; gap: 2px; }
.project-task-list { display: grid; margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.project-task { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line-soft); }
.project-task:last-child { border-bottom: 0; }
.project-task > div { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.project-task-end { display: inline-flex; flex: none; align-items: center; gap: var(--space-1); }
.project-history > summary h3 { display: inline; margin: 0; }
.project-history-list { display: grid; gap: var(--space-4); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.project-history-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.project-chats { display: grid; max-height: 50vh; overflow: auto; }
.project-chat { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line-soft); }
.project-chat:last-child { border-bottom: 0; }
.project-chat > span { display: grid; gap: 2px; }

/* My Kai: one item in the nav, its sections as tabs under the page head (drawSubnav). */
.subnav { display: flex; gap: 2px; margin: 0 0 var(--space-4); overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.subnav[hidden] { display: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { position: relative; display: inline-flex; flex: none; align-items: center; gap: 6px; padding: var(--space-2) var(--space-3) 10px; color: var(--soft); font-size: var(--text-sm); font-weight: 600; text-decoration: none; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--accent-ink); }
.subnav a[aria-current="page"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, var(--brand-blue), var(--brand-violet)); }
.subnav .count { min-width: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-xs); line-height: 18px; text-align: center; }
.subnav .count[hidden] { display: none; }

/* Team: what each person is good at and how busy they are, laid out like a game's staff list (team.js). Each kind of
   work has a colour by its place in the list (data-hue); its name always says which it is. */
.team-roster, .team-row, .team-chip, .team-dot, .team-alloc-part, .team-best .llm-spec {
  --hue-0: var(--brand-blue); --hue-1: #e88b0e; --hue-2: var(--brand-violet); --hue-3: var(--success-dot);
  --hue-4: var(--brand-cyan); --hue-5: var(--danger-dot); --hue-6: #c11574; --hue-7: var(--neutral-dot);
}
[data-hue="0"] { --hue: var(--hue-0); } [data-hue="1"] { --hue: var(--hue-1); } [data-hue="2"] { --hue: var(--hue-2); }
[data-hue="3"] { --hue: var(--hue-3); } [data-hue="4"] { --hue: var(--hue-4); } [data-hue="5"] { --hue: var(--hue-5); }
[data-hue="6"] { --hue: var(--hue-6); } [data-hue="7"], [data-hue="other"] { --hue: var(--hue-7); }
.team-toolbar { flex-wrap: wrap; }
.team-toolbar-end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
.manage-toolbar .team-toolbar-end input[type="search"] { width: 220px; min-width: 0; }
.team-roster { display: grid; gap: var(--space-2); margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.team-row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(180px, 260px); align-items: center; gap: var(--space-3);
  width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow-xs); }
.team-row:hover { border-color: var(--line-button); background: var(--hover); }
.team-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.team-row-main { display: grid; gap: 6px; min-width: 0; }
.team-row-name { font-weight: 600; }
.team-row-side { display: grid; gap: 4px; justify-items: end; }
.team-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.team-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--card); font-size: var(--text-sm); }
.team-chip-name { color: var(--hue, var(--ink)); font-weight: 600; }
.team-chip-points { font-variant-numeric: tabular-nums; font-weight: 700; }
.team-chip-level { color: var(--soft); font-size: var(--text-xs); }
.team-load { display: grid; gap: 4px; justify-items: end; width: 100%; }
.team-load-track { display: block; width: 100%; height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: var(--neutral-bg); }
.team-load-track::before { content: ""; display: block; width: var(--done, 0%); height: 100%; border-radius: inherit; background: var(--tone, var(--info-dot)); }
.team-load[data-band="available"] { --tone: var(--success-dot); }
.team-load[data-band="balanced"] { --tone: var(--info-dot); }
.team-load[data-band="busy"] { --tone: var(--attention-dot); }
.team-load[data-band="overloaded"] { --tone: var(--danger-dot); }
.team-load[data-band="unknown"], .team-load[data-band="away"] { --tone: var(--neutral-dot); }
.team-back { margin: 0 0 var(--space-3); }
.team-card > .manage-section { margin-top: var(--space-5); }
.team-card h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.team-best .llm-spec dt { color: var(--hue, var(--soft)); font-weight: 600; }
.team-skills { display: grid; gap: 2px; }
.team-skill { border-bottom: 1px solid var(--line-soft); }
.team-skill > summary { display: grid; grid-template-columns: auto minmax(110px, 1.2fr) 52px minmax(120px, 2fr) 72px minmax(110px, 1fr);
  align-items: center; gap: var(--space-3); padding: var(--space-2) 0; color: var(--ink); font-weight: 400; }
.team-skill-name { font-weight: 600; }
.team-skill-level { color: var(--soft); font-size: var(--text-sm); }
.team-skill-points { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.team-bar { position: relative; display: block; height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: var(--neutral-bg); }
.team-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--done, 0%); background: var(--brand-gradient); }
.team-bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--done, 0%); width: var(--granted, 0%);
  background: repeating-linear-gradient(135deg, var(--brand-violet) 0 4px, var(--paused-bg) 4px 7px); }
.team-bar-trait { margin-top: 6px; }
.team-evidence { padding: 0 0 var(--space-3); }
.team-grants { margin: var(--space-2) 0 0; padding-left: 1.2em; color: var(--soft); }
.team-traits { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3); }
.team-trait { padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); }
.team-trait .label { color: var(--soft); font-size: var(--text-sm); font-weight: 600; }
.team-trait .value { margin-top: 4px; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.team-trait .value.muted { font-size: var(--text-md); font-weight: 400; }
.team-trait .hint { margin: 6px 0 0; color: var(--muted); font-size: var(--text-xs); }
.team-open { margin-top: var(--space-3); }
.team-alloc-block { margin-top: var(--space-4); }
.team-alloc { display: flex; gap: 2px; height: 14px; overflow: hidden; border-radius: var(--radius-pill); }
.team-alloc-part { flex: 1 1 0; min-width: 6px; background: var(--hue, var(--neutral-dot)); }
.team-legend { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); margin: var(--space-2) 0 0; padding: 0; list-style: none;
  color: var(--soft); font-size: var(--text-sm); }
.team-dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; background: var(--hue, var(--neutral-dot)); }
.team-flags { display: grid; gap: 4px; margin: var(--space-3) 0 0; padding: 0; list-style: none; color: var(--attention-ink); }
.team-flags li { display: flex; align-items: center; gap: var(--space-2); }
@media (max-width: 720px) {
  .team-row { grid-template-columns: auto minmax(0, 1fr); }
  .team-row-side { grid-column: 1 / -1; justify-items: stretch; }
  .team-load { justify-items: start; }
  .team-skill > summary { grid-template-columns: auto minmax(0, 1fr) auto auto; row-gap: 6px; }
  .team-skill > summary::before { grid-area: 1 / 1; }
  .team-skill-name { grid-area: 1 / 2; }
  .team-skill-level { grid-area: 1 / 3; }
  .team-skill-points { grid-area: 1 / 4; }
  .team-skill > summary .team-bar { grid-area: 2 / 2 / 3 / -1; }
  .team-skill > summary > .muted { grid-area: 3 / 2 / 4 / -1; }
  .manage-toolbar .team-toolbar-end input[type="search"] { width: 100%; }
}
@media (forced-colors: active) {
  .team-load-track, .team-bar, .team-alloc { border: 1px solid CanvasText; }
  .team-load-track::before, .team-bar::before, .team-alloc-part { background: Highlight; forced-color-adjust: none; }
  .team-bar::after { background: repeating-linear-gradient(135deg, Highlight 0 4px, Canvas 4px 7px); forced-color-adjust: none; }
}
.team-marks { display: inline-flex; margin: 0 6px; color: var(--tone-ink, var(--ink)); font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 700; }
.team-picks { display: grid; gap: var(--space-2); }
.team-pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); }
.team-pick .avatar { width: 28px; height: 28px; font-size: 11px; }
.team-pick-who { display: grid; min-width: 0; }
.team-pick-name { display: inline-flex; flex-wrap: wrap; align-items: baseline; font-weight: 600; }
.team-found { margin-bottom: var(--space-4); }
.team-found-areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.team-found-area h3, .team-found-lead h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.team-found-lead { margin-top: var(--space-4); }
.project-staff-head h3 { margin: 0; }
.project-staff-why { display: block; }
.project-staff-lead { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.project-staff-needs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2) var(--space-4); }
.project-staff-need { display: grid; gap: 4px; }
.team-requests { display: grid; gap: var(--space-3); }
.team-request { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); }
.team-request .manage-prose { margin: 0; }
.team-lines { margin: 0; padding-left: 1.2em; }
.team-concerns { color: var(--attention-ink); }
.team-files { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.team-suggestion { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--info-bg); }
.team-suggestion p { margin: 0 0 4px; }

/* Updates suggested from the daily sync (projects.js portfolioSuggestions) */
.pf-sync { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-color: var(--accent-soft); background: var(--accent-soft); }
.pf-sync-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; flex: none; }
.pf-sync-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.pf-sync-list { display: grid; gap: 14px; }
.pf-sync-item { display: grid; gap: 12px; padding: 16px 18px; }
.pf-sync-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.pf-sync-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.pf-sync-wide { grid-column: 1 / -1; }
.pf-sync-field { display: grid; gap: 4px; }
.pf-sync-field textarea { resize: vertical; }
.pf-sync-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.pf-sync-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.pf-sync-quote { margin: 0; font-style: italic; }
.pf-sync-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) {
  .pf-sync { flex-wrap: wrap; }
  .pf-sync-grid { grid-template-columns: minmax(0, 1fr); }
}
