:root {
  --bg: #f7f9f8;
  --surface: #ffffff;
  --text: #14231f;
  --muted: #65736e;
  --line: #dce5e1;
  --green: #24855b;
  --green-soft: #e8f5ef;
  --amber: #a76812;
  --amber-soft: #fff3d9;
  --red: #b83434;
  --red-soft: #fde8e8;
  --blue: #266ba8;
  --blue-soft: #e8f2fb;
  --shadow: 0 16px 40px rgba(20, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 20px 92px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.load-pill {
  min-width: 104px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: right;
  box-shadow: var(--shadow);
}

.load-pill span {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.load-pill small {
  color: var(--muted);
}

.panel {
  display: block;
}

[hidden] {
  display: none !important;
}

.capture-card,
.state-column,
.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.capture-card {
  padding: 18px;
}

.capture-card label {
  display: block;
  margin-bottom: 12px;
  font-size: 1.2rem;
  font-weight: 750;
}

textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 16px;
  border: 1px solid #bfcac5;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1.45;
}

textarea:focus,
input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(36, 133, 91, 0.18);
}

.capture-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
}

.primary-button {
  padding: 0 22px;
  background: var(--green);
  color: white;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
}

.success-message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--green);
  font-weight: 700;
}

.section-block {
  margin-top: 26px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.92rem;
}

.event-list,
.timeline-list {
  display: grid;
  gap: 10px;
}

.event-row,
.loop-row,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px 14px;
}

.event-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.event-row strong,
.loop-row strong {
  display: block;
  margin-bottom: 5px;
}

.review-event {
  margin-bottom: 10px;
}

.review-note {
  margin-top: 7px;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 700;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.badge {
  align-self: start;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: capitalize;
}

.badge.request,
.badge.observation,
.badge.commitment {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.completion {
  background: var(--green-soft);
  color: var(--green);
}

.badge.information,
.badge.conversation,
.badge.scheduled {
  background: var(--blue-soft);
  color: var(--blue);
}

.today-grid,
.review-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.state-column {
  min-height: 220px;
  padding: 15px;
}

.state-column > div {
  display: grid;
  gap: 10px;
}

.loop-row {
  box-shadow: none;
}

.priority-critical {
  border-left: 4px solid var(--red);
}

.priority-high {
  border-left: 4px solid var(--amber);
}

.priority-medium {
  border-left: 4px solid var(--blue);
}

.priority-low {
  border-left: 4px solid var(--green);
}

.timeline-heading {
  align-items: center;
}

.search-box {
  display: grid;
  gap: 5px;
  width: min(360px, 100%);
}

.search-box input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #bfcac5;
  border-radius: 8px;
  background: white;
}

.review-layout {
  grid-template-columns: 1fr 1fr;
}

.review-card {
  padding: 16px;
}

.review-card.wide {
  grid-column: 1 / -1;
}

dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  margin: 0;
}

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

dd {
  margin: 0;
  font-weight: 800;
}

.meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3ebe7;
}

.meter div {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.tab {
  min-width: 92px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--green);
  color: white;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

/* ========== LAB PANEL ========== */

.lab-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.lab-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.lab-card h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.lab-card-wide {
  grid-column: 1 / -1;
}

.breakdown-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.probe-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.probe-stat-sep {
  color: var(--line);
}

.badge.conf-badge {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 700;
}

/* ========== DELETE BUTTON ========== */

.delete-btn {
  min-height: unset;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  flex-shrink: 0;
}

.delete-btn:hover {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.flag-btn {
  min-height: unset;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
  font-size: .75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  flex-shrink: 0;
  opacity: 0.5;
}
.flag-btn:hover, .flag-btn.flagged {
  opacity: 1;
  border-color: #ffaa44;
  background: rgba(255,170,68,.12);
}
.event-row.user-flagged {
  border-left: 3px solid #ffaa44;
}

/* event-badges: stacks badge + conf + delete button vertically/horizontally */
.event-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* ========== SETTINGS PANEL ========== */

.settings-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.settings-card h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.settings-group {
  display: grid;
  gap: 14px;
}

.settings-group label {
  display: grid;
  gap: 4px;
}

.settings-group span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.settings-group small {
  color: var(--muted);
  font-size: 0.8rem;
}

.settings-input,
.settings-select,
.settings-range {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.95rem;
}

.settings-input:focus,
.settings-select:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(36, 133, 91, 0.1);
}

.settings-range {
  height: 6px;
  padding: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.time-input {
  display: flex;
  gap: 10px;
  align-items: center;
}

.time-input input[type="checkbox"],
.time-input input[type="time"],
.time-input select {
  flex: 1;
}

.test-button,
.add-button,
.secondary-button,
.danger-button {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  transition: all 200ms ease;
}

.test-button:hover {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
}

.add-button {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.add-button:hover {
  background: var(--green);
  color: white;
}

.secondary-button {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
}

.secondary-button:hover {
  background: var(--blue);
  color: white;
}

.danger-button {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.danger-button:hover {
  background: var(--red);
  color: white;
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  grid-column: 1 / -1;
}

.family-member-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
}

.member-info {
  flex: 1;
}

.member-info strong {
  display: block;
}

.member-info small {
  color: var(--muted);
  font-size: 0.8rem;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-badge.success {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.error {
  background: var(--red-soft);
  color: var(--red);
}

/* ========== VOICE CAPTURE ========== */

.voice-capture-button {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
}

.voice-capture-button:hover {
  background: var(--green);
  transform: scale(1.05);
}

.voice-capture-button.recording {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(36, 133, 91, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(36, 133, 91, 0);
  }
}

.voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 20px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 700;
}

.voice-status.recording .recording-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 49%, 100% {
    opacity: 1;
  }
  50%, 99% {
    opacity: 0.3;
  }
}

.voice-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 60px;
  margin: 12px 0;
}

.waveform-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
}

.bar {
  width: 3px;
  height: 20px;
  background: var(--green);
  border-radius: 2px;
  animation: wave 0.6s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% {
    height: 8px;
  }
  50% {
    height: 30px;
  }
}

.transcribing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--blue);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.voice-permission-banner {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.voice-permission-banner p {
  margin: 0;
  color: var(--amber);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ========== MODAL ========== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 300ms ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

.modal-content label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
}

/* ========== NOTIFICATIONS ========== */

.notification {
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 4px solid var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.notification.error {
  border-left-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.notification.success {
  border-left-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.notification.warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */

@media (max-width: 820px) {
  .app-shell {
    padding: 18px 14px 88px;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 2.4rem;
  }

  .today-grid,
  .review-layout,
  .settings-layout,
  .memory-grid,
  .lab-layout {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .timeline-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabbar {
    justify-content: stretch;
  }

  .tab {
    min-width: 0;
    flex: 1;
    padding: 0 8px;
    font-size: 0.85rem;
  }

  .modal-content {
    width: 95%;
  }

  .time-input {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ========== PHASE 2 — FAMILY PANEL ========== */

/* Member list */
.member-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s;
}

.member-card:hover {
  border-color: var(--accent);
}

/* Avatar circle with colored background */
.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}

.member-avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.member-avatar-md { width: 36px; height: 36px; font-size: 0.82rem; }
.member-avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
}

.member-role {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: capitalize;
}

.member-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.member-loop-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.member-view-btn {
  font-size: 0.8rem;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.member-view-btn:hover {
  background: var(--surface-2, #1e2025);
}

/* Invite banner */
.invite-banner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
}

.invite-banner h4 {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.invite-code-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.invite-code-row strong {
  font-size: 1.5rem;
  letter-spacing: 0.2em;
  font-family: var(--font-mono, monospace);
}

.invite-code-row button {
  font-size: 0.78rem;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.invite-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Loop card additions */
.loop-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.loop-body {
  flex: 1;
  min-width: 0;
}

.loop-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.assign-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.7;
}

.assign-btn:hover {
  opacity: 1;
  border-color: var(--accent);
}

.assignee-pip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

.assignee-label {
  color: var(--accent);
}

/* Assignee picker (appears below loop card) */
.assignee-picker-wrapper {
  padding: 8px 0 4px;
}

.assignee-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.assignee-pill {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.assignee-pill.picker-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent, #7c6bff);
}

.assignee-pill.picker-clear {
  background: var(--surface-2, #2a2d35);
  color: var(--muted);
  font-size: 0.85rem;
}

.assignee-pill:hover {
  opacity: 0.85;
}

.muted-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ========== PHASE 3 — FAMILY MEMORY / FACTS + Q&A ========== */

/* Facts search */
.facts-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.facts-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Facts list */
.facts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Individual fact card */
.fact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}

.fact-key {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 2px;
}

.fact-value {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.fact-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.fact-domain-badge {
  font-size: 0.72rem;
  background: var(--surface-2, #1e2025);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--muted);
}

.fact-date {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}

/* Q&A answer bubble (appears below capture input) */
.qa-answer-bubble {
  background: var(--surface);
  border: 1px solid var(--accent, #7c6bff);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 10px;
}

.qa-answer-bubble.qa-no-result {
  border-color: var(--line);
}

.qa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent, #7c6bff);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.qa-answer-bubble.qa-no-result .qa-header {
  color: var(--muted);
}

.qa-close-btn {
  font-size: 0.75rem;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.qa-body {
  font-size: 0.87rem;
  color: var(--muted);
  margin: 0;
}

.qa-fact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qa-fact-item {
  font-size: 0.88rem;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
}

.qa-domain {
  margin-left: auto;
  flex-shrink: 0;
}

.qa-searching {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

/* ========== MOBILE TOUCH UX ========== */

/* Global: eliminate tap flash, improve responsiveness on all clickable things */
button,
.tab,
.member-card,
.loop-row,
.fact-card,
.event-row,
.assignee-pill,
.member-view-btn,
.assign-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Momentum scrolling on panels */
.panel {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Prevent iOS from zooming in on inputs (requires font-size >= 16px) */
input,
textarea,
select {
  font-size: max(16px, 1em);
}

/* Make search input safe — override only on desktop where 16px is too large */
@media (min-width: 641px) {
  input,
  select {
    font-size: 0.9rem;
  }
  textarea {
    font-size: 1rem;
  }
}

/* Mobile: larger touch targets + comfortable spacing */
@media (max-width: 640px) {
  /* Tab bar */
  .tab {
    min-height: 52px;
    font-size: 0.9rem;
    padding: 0 10px;
  }

  /* Buttons */
  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* Loop rows — more breathing room */
  .loop-row {
    padding: 14px 16px;
    gap: 14px;
  }

  /* Member cards */
  .member-card {
    padding: 14px 16px;
    gap: 16px;
  }

  /* Fact cards */
  .fact-card {
    padding: 12px 14px;
  }

  /* Assignee pills — slightly larger on mobile */
  .assignee-pill {
    width: 36px;
    height: 36px;
    font-size: 0.78rem;
  }

  /* Capture textarea */
  #captureInput {
    min-height: 80px;
  }

  /* Invite code row — stack on very small screens */
  .invite-code-row {
    flex-wrap: wrap;
  }

  /* Section headings — tighter on mobile */
  .section-heading {
    gap: 8px;
  }

  /* Q&A answer bubble — full-width on mobile */
  .qa-answer-bubble {
    border-radius: 8px;
  }

  /* AI Q&A answer text */
  .qa-ai-answer {
    font-size: 0.9rem;
  }

  /* Lab layout: single column on mobile (already handled but ensure it) */
  .lab-layout {
    grid-template-columns: 1fr;
  }
}

/* AI Q&A answer styling (all breakpoints) */
.qa-ai-answer {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 10px;
}

.qa-answer-bubble.qa-ai {
  border-color: var(--green, #22c55e);
}

.qa-answer-bubble.qa-ai .qa-header {
  color: var(--green, #22c55e);
}

.qa-facts-detail {
  margin-top: 4px;
}

.qa-facts-summary {
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

/* ========== #3 LOOP COMPLETE BUTTON ========== */

.complete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--green, #22c55e);
  background: transparent;
  color: var(--green, #22c55e);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.complete-btn:hover {
  background: var(--green, #22c55e);
  color: #fff;
}

@keyframes loopFadeOut {
  to { opacity: 0; transform: translateX(40px); }
}

.loop-completing {
  animation: loopFadeOut 0.35s ease forwards;
}

/* ========== #4 DECISIONS PANEL ========== */

.decisions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.decision-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid #8b5cf6;
  border-radius: 8px;
  padding: 10px 14px;
}

.decision-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.decision-context {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 3px;
}

.decision-meta {
  margin-top: 6px;
}

.decision-date {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ========== #5 PROFILE EDITOR ========== */

.profile-editor {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.profile-editor-avatar {
  flex-shrink: 0;
}

.profile-editor-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-name-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.profile-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-swatch.swatch-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent, #4f7cff);
}

.profile-save-btn {
  align-self: flex-start;
  padding: 8px 20px;
}

.profile-save-msg {
  font-size: 0.82rem;
  margin: 0;
  min-height: 1em;
}

/* ========== #6 DAILY BRIEF CARD ========== */

.brief-card {
  background: linear-gradient(135deg, #1a1f2b 0%, #171a21 100%);
  border: 1px solid #2a3a5a;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.brief-card.brief-loading {
  border-color: var(--line);
}

.brief-header {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7c9fff;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brief-badge {
  font-size: 0.65rem;
  background: #1e3060;
  color: #7c9fff;
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.05em;
}

.brief-body {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
}
