/* Friend page — companion dashboard, onboarding, and chat.
   Reuses chat.css for the shell (sidebar, panels, navbar); this file adds the
   Friend-specific surfaces. All colors come from the shared brand tokens so it
   tracks light/dark automatically. */

html[data-auth-check="pending"] #friend-app {
  visibility: hidden;
}

/* The plain `hidden` attribute is only a UA-level display:none, so any author
   `display` rule below (grid/flex on the panels, tabs, forms…) would override it
   and leave "hidden" elements visible. Force real hiding. */
[hidden] {
  display: none !important;
}

/* Own the shell's height + direction. The global `.app-shell` mobile rule flips
   to a column below 1000px, but chat.css only turns the sidebar into an
   off-canvas drawer at <=768px — so 768-1000px would stack a 252px sidebar on
   top and squish the page. Forcing row (higher #id specificity wins inside the
   media query) keeps it full-height; the drawer still works <=768px because the
   sidebar is position:fixed there and out of flow. */
#friend-app.app-shell {
  height: 100dvh;
  flex-direction: row;
}

/* ---- Layout ---- */
.friend-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.friend-main {
  flex: 1;
  min-height: 0;
  display: flex;
}
.friend-main [hidden] {
  display: none !important;
}
.friend-panel {
  flex: 1;
  min-height: 0;
}
.friend-today {
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.friend-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---- Navbar tabs ---- */
.friend-tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-soft);
  border-radius: var(--radius-pill);
  padding: 3px;
}
.friend-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-family: var(--font-ui, var(--font-main));
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.friend-tab .material-symbols-rounded {
  font-size: 18px;
}
.friend-tab:hover {
  color: var(--text);
}
.friend-tab.active {
  background: var(--surface);
  color: var(--text);
}

.friend-model-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.friend-model-picker select {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 10px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

/* ---- Sidebar friend card ---- */
.friend-sidebar-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) var(--space-2);
  padding: var(--space-3);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.friend-sidebar-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.friend-sidebar-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
}
.friend-sidebar-level {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---- Avatar ---- */
.friend-avatar {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(var(--accent-rgb), 0.14);
  border-radius: 50%;
}

/* ---- Onboarding ---- */
.friend-onboarding {
  flex: 1;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: var(--space-5);
}
.onb-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}
.onb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.onb-avatar {
  width: 52px;
  height: 52px;
  font-size: 28px;
}
.onb-dots {
  display: flex;
  gap: 6px;
}
.onb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background var(--dur-fast) var(--ease-out);
}
.onb-dot.on {
  background: var(--accent);
}
.onb-title {
  font-family: var(--font-display, var(--font-prose));
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0 0 var(--space-4);
  color: var(--text);
}
.onb-q {
  color: var(--text-muted);
  margin: 0 0 var(--space-3);
  font-size: 0.95rem;
}
.onb-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.onb-actions .btn-primary {
  margin-left: auto;
}

.friend-field {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui, var(--font-main));
  padding: 11px 13px;
  resize: vertical;
}
.friend-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}
.friend-field.field-error {
  border-color: var(--sent-neg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sent-neg) 20%, transparent);
}

.onb-suggests,
.onb-cadence {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-3);
}
.onb-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.onb-chip:hover {
  border-color: var(--border-strong);
}
.onb-chip.sel {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: var(--accent);
  color: var(--text);
}
.onb-mission-grid {
  display: grid;
  gap: 10px;
}
.onb-mission-grid.mini {
  grid-template-columns: 1fr 1fr;
  margin-top: var(--space-3);
}
.onb-mission {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-3);
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.onb-mission:hover {
  border-color: var(--border-strong);
}
.onb-mission .material-symbols-rounded {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--accent);
  font-size: 26px;
}
.onb-mission.sel {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
.onb-mission-label {
  font-weight: 700;
  color: var(--text);
}
.onb-mission-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.onb-tones {
  display: grid;
  gap: 10px;
}
.onb-tone {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.onb-tone:hover {
  border-color: var(--border-strong);
}
.onb-tone.sel {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}
.onb-tone-label {
  font-weight: 700;
  color: var(--text);
}
.onb-tone-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---- Check-in hero ---- */
.checkin-hero {
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--line-accent, rgba(var(--accent-rgb), 0.4));
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.checkin-hero.done {
  background: var(--surface);
  border-color: var(--border);
}
.checkin-top {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.checkin-from {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.checkin-question {
  margin: 4px 0 0;
  font-family: var(--font-display, var(--font-prose));
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--text);
}
.checkin-habits {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.checkin-label {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.checkin-habit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 13px 6px 10px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.checkin-habit:hover {
  border-color: var(--border-strong);
}
.checkin-habit input {
  accent-color: var(--accent);
}
.checkin-actions {
  display: flex;
  gap: 10px;
}

/* ---- Stat tiles ---- */
.friend-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
.stat-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.stat-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat-big {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.stat-emoji {
  font-size: 26px;
}
.stat-ring {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-soft) 0);
}
.stat-ring span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

/* ---- Sections & cards ---- */
.friend-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.friend-section-head h2 {
  font-size: 1.05rem;
  margin: 0;
  color: var(--text);
}
.friend-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px 5px 9px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-base) var(--ease-out);
}
.friend-add-btn:hover {
  border-color: var(--border-strong);
}
.friend-add-btn .material-symbols-rounded {
  font-size: 18px;
}
.friend-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.friend-empty {
  color: var(--text-faint);
  font-size: 0.9rem;
  margin: 0;
  padding: var(--space-3);
}
.friend-add-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.add-goal-row {
  display: flex;
  gap: 10px;
}

.habit-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}
.habit-card.done {
  border-color: rgba(var(--accent-rgb), 0.4);
}
.habit-toggle {
  flex: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-faint);
  display: grid;
  place-items: center;
  padding: 0;
  transition: color var(--dur-fast) var(--ease-out);
}
.habit-toggle:hover {
  color: var(--text-muted);
}
.habit-toggle .material-symbols-rounded {
  font-size: 30px;
}
.habit-toggle.on {
  color: var(--accent);
}
.habit-toggle.on:hover {
  color: var(--accent-deep, var(--accent));
}
.habit-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.habit-title {
  font-weight: 600;
  color: var(--text);
}
.habit-card.done .habit-title {
  color: var(--text-muted);
}
.habit-meta {
  font-size: 0.76rem;
  color: var(--text-faint);
}
.habit-streak {
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  white-space: nowrap;
}
.habit-remove {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.habit-card:hover .habit-remove,
.habit-card:focus-within .habit-remove {
  opacity: 1;
}
.habit-remove .material-symbols-rounded {
  font-size: 18px;
}

/* ---- Break / quit habit card (live clean timer + stats + graph) ---- */
.habit-card.break {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-4);
  padding: var(--space-4);
}
.brk-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.brk-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brk-timer-row {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) 0;
}
.brk-timer {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  font-weight: 600;
  color: var(--accent-strong, var(--accent));
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.brk-timer-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.brk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.brk-stat {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.brk-stat-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 0.92rem;
}
.brk-stat-label {
  font-size: 0.64rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.brk-graph {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brk-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
  padding: 6px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
}
.brk-bar {
  flex: 1;
  min-width: 5px;
  background: rgba(var(--accent-rgb), 0.38);
  border-radius: 3px 3px 0 0;
  transition: height var(--dur-slow) var(--ease-out);
}
.brk-bar.current {
  background: var(--accent-strong, var(--accent));
}
.brk-avg-line {
  position: absolute;
  left: 6px;
  right: 6px;
  border-top: 1px dashed var(--text-faint);
  pointer-events: none;
}
.brk-avg-line span {
  position: absolute;
  right: 0;
  top: -8px;
  font-size: 0.6rem;
  color: var(--text-muted);
  background: var(--surface-soft);
  padding: 0 3px;
}
.brk-graph-label {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-faint);
}
.brk-actions {
  display: flex;
}
.brk-relapse {
  flex: 1;
  justify-content: center;
  gap: 6px;
  color: var(--sent-neg);
  border-color: color-mix(in srgb, var(--sent-neg) 40%, transparent);
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.brk-relapse:hover {
  background: color-mix(in srgb, var(--sent-neg) 10%, transparent);
  border-color: color-mix(in srgb, var(--sent-neg) 60%, transparent);
}
.brk-relapse .material-symbols-rounded {
  font-size: 18px;
}
@media (max-width: 640px) {
  .brk-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.goal-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}
.goal-title {
  font-weight: 600;
  color: var(--text);
}
.goal-prog {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
}
.goal-bar {
  height: 8px;
  background: var(--surface-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.goal-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width var(--dur-slow) var(--ease-out);
}
.goal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.goal-mini {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}
.goal-mini:hover {
  border-color: var(--border-strong);
}
.goal-mini.primary {
  background: var(--accent);
  color: var(--on-accent, #fff);
  border-color: transparent;
}
.goal-mini.primary:hover {
  background: var(--accent-deep, var(--accent));
}
.goal-num {
  width: 68px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 5px 8px;
  font: inherit;
}
.goal-remove {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 5px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.goal-remove:hover {
  color: var(--sent-neg);
  background: color-mix(in srgb, var(--sent-neg) 10%, transparent);
}
.goal-remove .material-symbols-rounded {
  font-size: 18px;
}

/* ---- Chat ---- */
.friend-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}
.fmsg-day {
  text-align: center;
  margin: var(--space-3) 0 var(--space-2);
}
.fmsg-day span {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-weight: 600;
}
.fmsg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  outline: none;
}
.fmsg.user {
  justify-content: flex-end;
}
.favatar {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: rgba(var(--accent-rgb), 0.14);
  border-radius: 50%;
}
.fmsg-body {
  display: flex;
  flex-direction: column;
  max-width: 76%;
  min-width: 0;
}
.fmsg.user .fmsg-body {
  align-items: flex-end;
}
.fmsg.friend .fmsg-body {
  align-items: flex-start;
}
.fbubble {
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  font-family: var(--font-ui, var(--font-main)), sans-serif;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}
.fmsg.friend .fbubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-xs);
}
.fmsg.user .fbubble {
  background: var(--accent);
  color: var(--on-accent, #fff);
  border-bottom-right-radius: var(--radius-xs);
}
.fmsg.user .fbubble a {
  color: inherit;
  text-decoration: underline;
}
.fmsg-time {
  display: none;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  margin-top: 4px;
  padding: 0 4px;
}
.fmsg.show-time .fmsg-time {
  display: block;
}
/* Only the newest message animates in (avoids re-animating the list on render). */
.fmsg:last-child .fbubble {
  animation: fmsg-in 0.22s var(--ease-out, ease);
}
@keyframes fmsg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fmsg:last-child .fbubble {
    animation: none;
  }
}
.ftyping {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}
.ftyping i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: ftype 1s infinite ease-in-out;
}
.ftyping i:nth-child(2) {
  animation-delay: 0.15s;
}
.ftyping i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes ftype {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.friend-composer-wrap {
  border-top: 1px solid var(--border);
  padding: var(--space-4);
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}
.friend-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 8px 8px 8px 15px;
}
.friend-composer:focus-within {
  border-color: var(--accent);
}
.friend-composer textarea {
  flex: 1;
  border: 0;
  background: transparent;
  resize: none;
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui, var(--font-main));
  max-height: 160px;
  padding: 6px 0;
}
.friend-composer textarea:focus {
  outline: none;
}
.friend-composer button {
  flex: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent, #fff);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease-out);
}
.friend-composer button:hover:not(:disabled) {
  background: var(--accent-deep, var(--accent));
}
.friend-composer button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.friend-composer-hint {
  margin: 8px 4px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}
.friend-composer-hint a {
  color: var(--accent);
}

@media (max-width: 640px) {
  .friend-stats {
    grid-template-columns: 1fr;
  }
  .friend-today {
    padding: var(--space-4);
  }
  .fmsg-body {
    max-width: 86%;
  }
}

/* ---- DM inbox (sidebar) ---- */
.friend-inbox {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.friend-inbox-empty {
  color: var(--text-faint);
  font-size: 0.85rem;
  padding: var(--space-4);
  text-align: center;
}
.dm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  outline: none;
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.dm-row:hover {
  background: rgba(var(--on-rgb), 0.05);
}
.dm-row.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.3);
}
.dm-row:focus-visible {
  border-color: var(--accent);
}
.dm-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: rgba(var(--accent-rgb), 0.14);
  border-radius: 50%;
}
.dm-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dm-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.dm-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-time {
  flex: none;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}
.dm-preview {
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Unread: bold name, brighter preview, accent dot. */
.dm-row.unread .dm-name {
  color: var(--text);
  font-weight: 700;
}
.dm-row.unread .dm-preview {
  color: var(--text-soft);
  font-weight: 600;
}
.dm-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.dm-del {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: none;
  place-items: center;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.dm-row:hover .dm-del,
.dm-row:focus-within .dm-del {
  display: grid;
}
.dm-del:hover {
  color: var(--sent-neg);
  background: color-mix(in srgb, var(--sent-neg) 10%, transparent);
}
.dm-del .material-symbols-rounded {
  font-size: 16px;
}

/* ---- Thread header (navbar) + delete ---- */
.friend-thread-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.friend-thread-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.friend-avatar.xs {
  width: 28px;
  height: 28px;
  font-size: 15px;
}
.friend-avatar.sm {
  width: 34px;
  height: 34px;
  font-size: 18px;
}
.friend-avatar.lg {
  width: 64px;
  height: 64px;
  font-size: 32px;
}
.friend-icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.friend-icon-btn:hover {
  color: var(--sent-neg);
  background: color-mix(in srgb, var(--sent-neg) 10%, transparent);
}
.friend-icon-btn .material-symbols-rounded {
  font-size: 19px;
}

/* ---- Empty state + habit/goal empty line ---- */
.friend-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6);
}
.friend-empty-state h1 {
  font-family: var(--font-display, var(--font-prose));
  font-size: 1.5rem;
  margin: 0;
  color: var(--text);
}
.friend-empty-state p {
  color: var(--text-muted);
  margin: 0;
  max-width: 320px;
}
.friend-empty-line {
  color: var(--text-faint);
  font-size: 0.9rem;
  margin: 0;
  padding: var(--space-3);
}

/* ---- Living document (what the friend knows about you) ---- */
.friend-notes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 10px 9px 12px;
}
.note-ico {
  flex: none;
  font-size: 16px;
  color: var(--accent);
  opacity: 0.7;
}
.note-text {
  flex: 1;
  min-width: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.4;
}
.note-remove {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 3px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.note-item:hover .note-remove,
.note-item:focus-within .note-remove {
  opacity: 1;
}
.note-remove:hover {
  color: var(--sent-neg);
  background: color-mix(in srgb, var(--sent-neg) 10%, transparent);
}
.note-remove .material-symbols-rounded {
  font-size: 16px;
}

/* The navbar can get tight on small screens — let the thread name truncate first. */
@media (max-width: 560px) {
  .friend-thread-name {
    max-width: 30vw;
  }
  .friend-tabs .friend-tab {
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .friend-tab, .onb-chip, .onb-mission, .onb-tone, .onb-dot, .checkin-habit,
  .habit-toggle, .habit-remove, .goal-mini, .goal-remove, .goal-bar span,
  .brk-bar, .brk-relapse, .friend-add-btn, .friend-composer button,
  .friend-icon-btn, .dm-row, .dm-del, .note-remove {
    transition: none;
  }
  .ftyping i {
    animation: none;
  }
}
