/* Field Notes — Field palette + Editorial type
   Mobile-first. Top bar (sticky) → main (scrolls) → bottom nav (sticky). */

:root {
  /* Field palette (paper + olive) */
  --paper:   #f5f0e3;
  --card:    #fffdf5;
  --card-2:  #faf6ea;
  --ink:     #1a1814;
  --ink-2:   #3a342c;
  --muted:   #766d5b;
  --muted-2: #9a9180;
  --rule:    #e6dfcc;
  --rule-2:  #d4cab2;
  --accent:      #5d6f3b;
  --accent-soft: #e3e6cf;
  --accent-ink:  #2f3a1c;
  --field:   #f0ead8;
  --chip:    #ece5d0;
  --danger:  #a8442a;
  --shadow:  0 1px 0 rgba(60,50,30,0.04), 0 8px 24px -16px rgba(60,50,30,0.18);

  /* Type — Editorial */
  --font-display: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-body:    "Inter Tight", -apple-system, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, Menlo, monospace;
  --display-tracking: -0.015em;

  --radius:    14px;
  --radius-sm: 10px;

  --topbar-h:    56px;
  --bottomnav-h: 60px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  background: var(--paper);
  /* Use 100% so iOS Safari address-bar collapse doesn't change layout height */
  height: 100%;
  /* Lock the page horizontally so it feels fixed/native on phones — no
     left/right pan or rubber-band when something overflows by a hair.
     `clip` (not `hidden`) avoids making the page a scroll container, so the
     sticky top bar + composer keep working. */
  overflow-x: clip;
  /* Stop Safari's landscape text-inflation; pairs with the 16px input rule. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
  /* iOS Safari zooms the whole page on focus when a control's computed
     font-size is < 16px — and never zooms back out on blur, which reads as
     the viewport "shifting." max() keeps the 16px floor without shrinking
     anything deliberately larger. */
  font-size: max(16px, 1em);
}

a { color: var(--accent); }
a:hover { color: var(--accent-ink); }

.fn-num    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.fn-mono   { font-family: var(--font-mono); }
.fn-display{ font-family: var(--font-display); letter-spacing: var(--display-tracking); line-height: 1.1; }

.muted     { color: var(--muted); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  display: inline-block;
}

/* ─── Top bar ─── */
.app-top {
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
}

/* Top bar should not host horizontal tabs on mobile — they live in bottom nav */
.topnav { display: none; }

.topbar-end {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--rule-2);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-2);
  cursor: pointer;
}
.menu-btn:hover { background: var(--card-2); }

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  min-width: 240px;
  padding: 6px;
  z-index: 40;
}
.user-menu[hidden] { display: none; }
.user-menu-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
}
.user-menu-head .avatar { width: 36px; height: 36px; font-size: 13px; }
.user-menu-who { min-width: 0; }
.user-menu-name { font-weight: 600; font-size: 14px; }
.user-menu-email { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-2);
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--card-2); }
.user-menu-item-on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.user-menu-form { margin: 0; }
.user-menu-item-button { color: var(--danger); }

/* ─── Main + bottom nav layout ─── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
}

.bottom-nav {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  display: flex;
}
.bottom-nav-item {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0;
  color: var(--muted-2);
  padding: 8px 0;
  text-decoration: none;
  cursor: pointer;
}
.bottom-nav-icon {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 34px;
  border-radius: 10px;
  transition: background .15s, color .15s;
}
.bottom-nav-item-on .bottom-nav-icon {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.bottom-nav-item-on { color: var(--accent-ink); }
.bottom-nav-label {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ─── Toasts ─── */
.toasts {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: 90%;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-in 180ms ease-out;
}
.toast-alert { background: #f3d9cf; color: #5c2010; }
.toast-out { animation: toast-out 180ms ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast-out { animation: none; }
}

/* ─── Page header ─── */
.page-header {
  padding: 16px 16px 12px;
}
.page-header .eyebrow { margin-bottom: 4px; }
.page-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
  line-height: 1.15;
}
.page-header > div + div { margin-top: 6px; }

/* ─── Cards / forms ─── */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.section {
  padding: 0 16px 14px;
}

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font: inherit;
  font-size: max(16px, 1em); /* keep ≥16px so iOS doesn't focus-zoom (font shorthand resets it) */
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent);
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23766d5b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.primary-btn,
button.primary-btn,
input.primary-btn,
input[type="submit"].primary-btn,
.btn.primary {
  background: var(--ink);
  color: var(--card);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.005em;
}
.primary-btn:hover { background: var(--ink-2); }

.accent-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.accent-btn:hover { background: var(--accent-ink); }

.ghost-btn,
a.ghost-btn,
button.ghost-btn {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.ghost-btn:hover { background: var(--card-2); color: var(--ink); }
.ghost-btn-danger { color: var(--danger); border-color: rgba(168,68,42,0.3); }
.ghost-btn-danger:hover { background: #f6e1d6; }

.inline-form { display: inline; margin: 0; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Stack: forms use this */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack .row { margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.field-inline input[type="checkbox"] { width: auto; margin: 0; }

.errors {
  background: #f6e1d6;
  border: 1px solid #e1bca6;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: #5c2010;
  font-size: 13px;
}
.errors ul { margin: 0; padding-left: 18px; }

/* ─── Chat composer (pinned just under topbar) ─── */
.composer {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--rule-2);
  padding: 8px 14px;
}
.composer-shell {
  background: var(--card);
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  padding: 4px 4px 4px 12px;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 10%, transparent);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.composer-row textarea {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px 0;
  min-height: 24px;
  max-height: 140px;
  resize: none;
  font-size: max(16px, 1em); /* ≥16px so focusing the chat box doesn't zoom iOS */
  line-height: 1.4;
  box-shadow: none;
  border-radius: 0;
}
.composer-row textarea::placeholder { color: var(--muted); }
.composer-row textarea:focus { border: 0; box-shadow: none; outline: none; }

.send-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: none;
}
.send-btn:hover { background: var(--accent-ink); }

/* ─── Tally chips (today, horizontal scroll) ─── */
.tally-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 16px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  scrollbar-width: none;
}
.tally-chips::-webkit-scrollbar { display: none; }
.tally-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  flex: none;
}
.tally-chip-zero {
  background: transparent;
  border-color: var(--rule);
  opacity: 0.55;
}
.tally-chip .cat-dot { width: 7px; height: 7px; border-radius: 50%; }
.tally-chip-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.tally-chip-num {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─── Chat layout ─── */
.chat-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-thread {
  padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-thread .empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.bubble-row { display: flex; }
.bubble-row-user { justify-content: flex-end; }
.bubble-row-assistant { justify-content: flex-start; }

.bubble {
  max-width: 86%;
  border-radius: 14px;
}
.bubble-user {
  background: var(--card-2);
  border: 1px solid var(--rule);
  padding: 10px 13px;
}
.bubble-assistant {
  background: transparent;
  padding: 4px 0;
}
.bubble-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
  gap: 10px;
}
.bubble-author {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.bubble-user .bubble-author { color: var(--ink-2); }
.bubble-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
}
.bubble-body { font-size: 14.5px; line-height: 1.42; color: var(--ink); overflow-wrap: anywhere; }
.bubble-body p { margin: 0; }
.bubble-body p + p { margin-top: 6px; }

.bubble-activities {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.activity-line {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex; align-items: center; gap: 8px;
}
.activity-desc { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink); }
.activity-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex: none;
}

.assistant-error {
  align-self: flex-start;
  max-width: 86%;
  background: #f6e1d6;
  border: 1px solid #e1bca6;
  color: #5c2010;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ─── Pending "Thinking…" bubble ─── */
.typing-dots {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-3px); opacity: 1; }
}

/* ─── Week pager ─── */
.week-nav {
  padding: 0 16px 14px;
  display: flex; gap: 8px; align-items: center;
}
.week-nav .ghost-btn { padding: 7px 10px; font-size: 12.5px; }
.week-pick {
  flex: 1;
  display: flex;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
}
.week-pick-input {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}
.week-pick-input:focus { box-shadow: none; }
.week-rel {
  padding: 0 16px 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0;
}

/* ─── Sparkline tally card (My Week) ─── */
.tally-card {
  padding: 16px;
}
.tally-card-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.tally-card-total {
  display: flex; align-items: baseline; gap: 8px; margin-top: 4px;
}
.tally-card-bignum {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}
.tally-card-sub {
  color: var(--muted);
  font-size: 13px;
}

.tally-grid-head {
  display: grid;
  grid-template-columns: minmax(0,1fr) 52px 84px 32px;
  align-items: center;
  gap: 10px;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--rule);
}
.tally-grid-head > div {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.tally-day-letters {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.tally-day-letters span {
  text-align: center;
}
.tally-grid-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 52px 84px 32px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.tally-grid-row:last-child { border-bottom: 0; }
.tally-row-name {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.tally-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tally-row-num {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}
.tally-row-pct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  text-align: right;
}

/* Sparkline */
.spark {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  align-items: end;
  height: 28px;
}
.spark-col { display: flex; flex-direction: column; align-items: stretch; height: 100%; justify-content: flex-end; }
.spark-bar {
  border-radius: 2px 2px 0 0;
  min-height: 3px;
  opacity: 0.92;
}
.spark-bar.empty { background: var(--rule) !important; opacity: 0.6; }
.spark-day {
  display: none;
}

/* ─── Day groups (My Week) ─── */
.day-groups { display: flex; flex-direction: column; }
.day-group {
  padding: 0 16px 12px;
}
.day-group .card { padding: 14px 16px; }
.day-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.day-group-day {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
}
.day-group-date {
  color: var(--muted);
  font-size: 13px;
}
.day-group-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-2);
}
.day-group-list { display: flex; flex-direction: column; }

.activity-row {
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  display: flex; gap: 12px;
}
.activity-row:first-child { border-top: 0; padding-top: 4px; }
.activity-row .cat-dot { margin-top: 6px; }
.activity-row-main {
  flex: 1; min-width: 0;
  display: flex; gap: 12px;
}
.activity-row-desc-line {
  display: flex; justify-content: space-between; gap: 8px;
  align-items: baseline;
}
.row-action {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}
.row-action-danger { color: var(--muted); }
.row-action-danger:hover { color: var(--danger); }
.cat-dot { display: inline-block; border-radius: 50%; flex: none; margin-top: 6px; }
.activity-line .cat-dot,
.bubble-activities .cat-dot,
.tally-chip .cat-dot,
.legend-item .cat-dot,
.member-count .cat-dot,
.member-detail-list .cat-dot { margin-top: 0; }
.message-error { background: #f6e1d6 !important; border-color: #e1bca6 !important; color: #5c2010 !important; }
.message-error .bubble-author { color: #5c2010; }
.activity-row-text { flex: 1; min-width: 0; }
.activity-row-desc {
  font-size: 14px; font-weight: 500; color: var(--ink);
  word-wrap: break-word;
}
.activity-row-meta {
  display: flex; flex-wrap: wrap; gap: 2px 10px;
  margin-top: 4px;
  font-size: 11.5px; color: var(--muted);
}
.activity-row-meta span { font-family: var(--font-mono); }
.activity-row-actions {
  display: flex; gap: 12px; align-items: center;
  margin-top: 6px;
}
.activity-row-actions form { display: contents; }
.activity-row-actions .ghost-btn { padding: 4px 8px; font-size: 11.5px; }

/* ─── People compact list ─── */
.people-search-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 14px;
  border: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--card-2);
  color: var(--ink);
  box-sizing: border-box;
}
.people-search-input:focus { outline: none; border-color: var(--accent); }
.people-list-item { border-top: 1px solid var(--rule); }
.people-list-item:first-child { border-top: 0; }
.people-list-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 10px 0;
  color: inherit;
  text-decoration: none;
}
.people-list-link:hover .people-list-name { color: var(--accent); }
.people-list-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
}
.people-list-descriptor { font-weight: 400; font-size: 12px; }
.people-list-tags { font-weight: 400; font-size: 12px; font-style: italic; }
.people-list-meta { font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.people-sort-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.people-sort-link {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-2);
  text-decoration: none;
  white-space: nowrap;
}
.people-sort-link:hover { color: var(--accent); }
.people-sort-link.is-active { color: var(--ink); font-weight: 600; }

/* ─── Empty state ─── */
.empty-state {
  padding: 32px 16px;
  text-align: center;
}
.empty-state p { margin: 0 0 6px; color: var(--ink-2); }
.empty-state p.muted { color: var(--muted); font-size: 13px; }

/* ─── Home dashboard ─── */
.dash-view { padding-top: 4px; }
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 16px 14px;
}
@media (min-width: 720px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .dash-span { grid-column: 1 / -1; }
}
.dash-card { display: flex; flex-direction: column; gap: 14px; }
.dash-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.dash-week-range { font-size: 12px; }
.dash-scope { font-size: 12px; }
.dash-subtitle { font-size: 13px; margin: 0; max-width: 52ch; }
.dash-empty { font-size: 13px; padding: 2px 0; }

/* Week so far */
.dash-week-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
}
.dash-week-type { display: flex; flex-direction: column; gap: 7px; }
.dash-week-type-top { display: flex; align-items: center; gap: 6px; }
.dash-week-type-label { font-size: 12.5px; color: var(--muted); }
.dash-week-type-num {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: var(--display-tracking);
}

/* Legend */
.dash-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.dash-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}

/* Ten-week trend (stacked columns) */
.dash-trend-chart {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  align-items: end;
}
.dash-trend-week {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 0;
}
.dash-trend-col {
  height: 120px; width: 100%; max-width: 22px;
  display: flex; align-items: flex-end;
}
.dash-trend-stack {
  width: 100%;
  display: flex; flex-direction: column-reverse;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  min-height: 2px;
}
.dash-trend-seg { width: 100%; }
.dash-trend-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted-2);
  white-space: nowrap;
}
.dash-trend-week.is-current .dash-trend-label { color: var(--accent-ink); font-weight: 600; }
.dash-trend-week.is-current .dash-trend-col { border-bottom: 2px solid var(--accent); }

/* People widgets */
.dash-people { list-style: none; margin: 0; padding: 0; }
.dash-person {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}
.dash-person:last-child { border-bottom: 0; padding-bottom: 0; }
.dash-person:first-child { padding-top: 0; }
.dash-person-name { color: var(--ink); text-decoration: none; font-weight: 500; }
.dash-person-name:hover { color: var(--accent-ink); }
.dash-person-meta {
  font-size: 12px; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dash-card .dash-person--extra { display: none; }
.dash-card.is-expanded .dash-person--extra { display: flex; }
.dash-more {
  align-self: flex-start;
  background: none; border: 0; padding: 4px 0;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--accent-ink); cursor: pointer;
}
.dash-more:hover { text-decoration: underline; }

/* On-dashboard badge in admin event-type list */
.key-tag-on { color: var(--accent-ink); background: var(--accent-soft); }

/* ─── Team page ─── */
.team-summary {
  padding: 16px;
}
.team-summary-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px;
}
.team-summary-num {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  margin-top: 4px;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}
.team-summary-num .muted-tail {
  font-size: 18px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.team-summary-side .num {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  margin-top: 4px;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}

.stacked-bar {
  display: flex;
  gap: 2px;
  height: 8px;
  width: 100%;
  margin-top: 14px;
}
.stacked-bar-empty {
  background: var(--rule);
  border-radius: 2px;
}
.stacked-seg {
  border-radius: 2px;
  min-width: 2px;
}

.team-summary-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-top: 14px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.legend-item .cat-dot { width: 8px; height: 8px; margin-top: 0; }
.legend-num {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
}
.legend-label {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.legend-pct {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
}

.member-grid {
  display: flex; flex-direction: column;
}
.member-card {
  padding: 14px 16px;
  position: relative;
}
.member-card-me {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}
.member-card-head {
  display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--rule);
  flex: none;
  font-family: var(--font-body);
}
.member-card-name { flex: 1; min-width: 0; }
.member-name {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
}
.me-tag, .admin-tag {
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.me-tag { background: var(--ink); color: var(--card); }
.admin-tag { background: var(--accent-soft); color: var(--accent-ink); }
.member-card-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 2px;
}
.member-total {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--display-tracking);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.member-total .muted {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}
.member-card .stacked-bar { margin-top: 12px; height: 6px; }
.member-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 6px;
  margin-top: 10px;
}
.member-count {
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.member-count .cat-dot { width: 6px; height: 6px; margin-top: 0; }
.member-count-num {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.member-count-label {
  display: none;
}

.member-minutes {
  margin-top: 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--muted);
}
.member-card-foot {
  display: flex; justify-content: flex-end; margin-top: 10px;
}
.member-card-foot .ghost-btn {
  border: 0;
  color: var(--accent);
  padding: 4px 0;
  font-size: 12.5px;
  font-weight: 500;
}
.member-card-foot .ghost-btn:hover { background: transparent; color: var(--accent-ink); }

/* Member detail */
.member-detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }
.member-detail .member-detail-day { padding: 8px 0; }
.member-detail-day-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px;
}
.member-detail-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.member-detail-list .activity-line { padding: 6px 10px; align-items: flex-start; }
.activity-note { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }

/* ─── Admin tabs (pill segments) ─── */
.admin-subnav {
  padding: 0 16px 14px;
  display: flex;
  gap: 6px;
}
.admin-subnav .ghost-btn {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}
.admin-subnav .ghost-btn.seg-on {
  background: var(--card);
  border-color: var(--ink-2);
  color: var(--ink);
  font-weight: 600;
}

.key-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted-2);
  background: var(--field);
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 4px;
  font-weight: 500;
}
.signup-link {
  margin: 0;
  padding: 10px 12px;
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  word-break: break-all;
}

/* ─── Auth ─── */
.auth-shell {
  padding: 8px 16px 24px;
}
.auth-card {
  max-width: 420px;
  margin: 24px auto 12px;
  padding: 24px 16px;
}
.auth-card h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: var(--display-tracking);
}
.auth-card .card { padding: 16px; }
.auth-card .field { margin-bottom: 12px; }
.auth-foot {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 16px 16px;
}
.auth-foot a { color: var(--accent); text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

/* ─── Desktop polish ─── */
@media (min-width: 720px) {
  .content { max-width: 720px; margin: 0 auto; width: 100%; }
  .app-top { max-width: 720px; margin: 0 auto; width: 100%; }
  .auth-card { padding: 32px 0; }
}

/* Hide the legacy chat-form id positioning — composer is in flow now */
#chat-form { display: contents; }

/* Old chat-layout used a grid; reset just in case */
.chat-col { display: contents; }
.thread { padding: 0; }

/* Old aside tally — hidden, replaced by tally-chips */
aside.tally { display: none; }

/* ─── Person chips & picker ─── */
.person-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--chip);
  color: var(--ink-2);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
}
.person-chip.needs-review {
  background: #f0e4c0;
  color: var(--ink);
}
.review-flag {
  font-size: 10px;
  color: var(--accent-ink);
  font-weight: 700;
}

/* People field on the event edit form */
.people-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}
.person-chip-wrap {
  display: inline-flex;
  align-items: stretch;
}
.person-chip-wrap .person-chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.person-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chip);
  color: var(--muted);
  border: none;
  border-left: 1px solid var(--card-2);
  border-radius: 0 6px 6px 0;
  padding: 0 7px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.person-chip-remove:hover { color: var(--danger); background: var(--card-2); }
.person-add { position: relative; display: inline-block; }
.person-chip-add {
  color: var(--accent-ink);
  background: transparent;
  border: 1px dashed var(--rule-2);
}
.person-chip-add:hover { background: var(--card-2); }

/* Team / Mine filter pills (person show) */
.filter-pills { display: inline-flex; gap: 6px; }
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule-2);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.4;
}
.filter-pill:hover { background: var(--card-2); }
.filter-pill-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* Clickable event line + person name on the chat thread */
.activity-desc-link { text-decoration: none; cursor: pointer; }
.activity-desc-link:hover { text-decoration: underline; }
.person-chip-link { text-decoration: none; color: var(--ink-2); }
.person-chip-link:hover { background: var(--card-2); }

/* Inline person-picker buttons */
.did-you-mean-btn {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-family: var(--font-body);
  border: 1px solid var(--rule-2);
  background: var(--card); color: var(--ink-2);
  cursor: pointer; line-height: 1.4; white-space: nowrap;
}
.did-you-mean-btn:hover { background: var(--card-2); }
.did-you-mean-yes { border-color: var(--accent-ink); color: var(--accent-ink); }
.did-you-mean-yes:hover { background: var(--card-2); }

.candidate-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; vertical-align: top; gap: 1px; }
.candidate-last-activity { font-size: 10.5px; color: var(--muted-2); padding-left: 2px; }

.person-swap {
  position: relative;
  display: inline-block;
}

.person-picker-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  max-width: 280px;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
}
/* Opens upward when there isn't room below the trigger */
.person-picker-panel-up {
  top: auto;
  bottom: calc(100% + 4px);
}

.person-picker-input {
  width: 100%;
  border: 1px solid var(--rule-2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: max(16px, 13px);
  background: var(--field);
  outline: none;
}
.person-picker-input:focus {
  border-color: var(--accent);
}

.person-picker-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
}

.picker-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.35;
}
.picker-option:hover { background: var(--chip); }
.picker-option-new { color: var(--accent); font-style: italic; }
