/* The friends page fills the space beside the sidebar; the list and conversation scroll inside it. */
.shell-main:has(> .friends) { height: 100dvh; display: flex; flex-direction: column; }
.friends { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

/* Left column */
.side {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 16px 24px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.side-label {
  display: block;
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.at-field {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  border-radius: var(--r-pill);
  background: var(--raised);
}
.at-field:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.at-field > span { padding-left: 14px; color: var(--text-3); }
.at-field input { flex: 1; min-width: 0; border: 0; background: transparent; padding-left: 3px; outline: none; }

.add-row { display: flex; gap: 8px; }
.add-msg { min-height: 20px; margin: 8px 4px 0; font-size: 13px; }
.add-msg.is-error::before { content: "! "; font-weight: 700; }
.hint { margin: 2px 4px 0; color: var(--text-2); font-size: 13px; }
.hint strong { color: var(--text); font-weight: 600; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
  cursor: pointer;
}
button.person:hover { background: var(--panel); }
.person[aria-current="true"] { background: var(--raised); }
.person .who { flex: 1; min-width: 0; display: grid; }
.person .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .handle { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .badge { margin-left: 0; }
.person-actions { display: flex; gap: 6px; flex: none; }
.person-actions .btn { --control: 30px; padding: 0 10px; font-size: 13px; }

.avatar { flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.side-empty { margin: 0; padding: 4px; color: var(--text-2); font-size: 14px; }

/* Conversation */
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-live { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.thread-empty {
  margin: auto;
  max-width: 560px;
  padding: 24px;
  text-align: center;
}
.thread-empty h2 { margin: 0 0 10px; font: 800 30px/1.08 var(--display); font-stretch: 88%; letter-spacing: -0.01em; }
.thread-empty p { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.6; }

.thread-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.thread-who { flex: 1; min-width: 0; }
.thread-who h2 { margin: 0; font-size: 16px; }
.thread-who span { color: var(--text-2); font-size: 13px; }
.back { display: none; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.day { align-self: center; margin: 14px 0 6px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.msg { max-width: min(560px, 78%); display: grid; gap: 4px; }
.msg.mine { align-self: flex-end; justify-items: end; }
.bubble {
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--raised);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.msg.mine .bubble { background: var(--invert); color: var(--on-invert); box-shadow: none; }
.time { color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.msg.pending .bubble { opacity: .6; }

.review-card {
  display: grid;
  gap: 10px;
  width: min(380px, 100%);
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--text);
}
.review-card .rc-kind { color: var(--accent); font-size: 12px; font-weight: 650; }
.review-card .rc-name { font: 600 14px var(--mono); overflow-wrap: anywhere; }
.review-card .rc-meta { color: var(--text-2); font-size: 13px; }
.review-card .rc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.review-card .rc-done { color: var(--text-2); font-size: 13px; }

.composer { padding: 12px 20px 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.composer textarea { width: 100%; min-height: 44px; max-height: 180px; resize: none; line-height: 1.45; padding: 10px 12px; }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-msg { flex: 1; color: var(--text-2); font-size: 13px; }

/* Username claim */
.claim { min-height: 70vh; }
.claim-form { display: flex; gap: 8px; width: min(440px, 100%); margin-top: 8px; }
.form-error { margin: 0; font-size: 13px; font-weight: 600; }
.form-error::before { content: "! "; }

/* Dialog */
.sheet-wide { width: min(560px, calc(100vw - 32px)); }
.sheet form > p { margin: 0 0 16px; }
.field-row { display: grid; gap: 6px; margin-top: 14px; font-size: 14px; font-weight: 540; }
.field-row small { color: var(--text-2); font-weight: 400; }
.field-row textarea { resize: vertical; }
.pick { margin: 16px 0 0; padding: 0; border: 0; }
.pick ul { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; border-radius: var(--r-md); background: var(--panel); }
.pick li + li { border-top: 1px solid var(--line); }
.pick label { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.pick label:hover { background: var(--hover); }
.pick input { min-height: 0; width: 18px; height: 18px; accent-color: var(--invert); flex: none; }
.pick .pk-name { flex: 1; min-width: 0; font: 600 13px var(--mono); overflow-wrap: anywhere; }
.pick .pk-meta { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.sheet .form-error { margin-top: 12px; }

/* Conversation menu: remove, block, report */
.more { position: relative; margin-left: auto; }
.more-btn { width: 40px; padding: 0; justify-content: center; }
.more-btn svg { width: 18px; height: 18px; }
.more .menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  z-index: 20;
  min-width: 190px;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--raised);
  box-shadow: var(--shadow);
}
.more .menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.more .menu button:hover, .more .menu button:focus-visible { background: var(--hover); outline-offset: -2px; }

/* Delete on your own messages: shown on hover or focus, always on touch screens. */
.msg-delete {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  opacity: 0;
}
.msg:hover .msg-delete, .msg-delete:focus-visible { opacity: 1; }
.msg-delete:hover { color: var(--text); }
@media (hover: none) { .msg-delete { opacity: 1; } }

.reasons { display: grid; gap: 8px; margin: 4px 0 0; padding: 0; border: 0; }
.reasons legend { margin-bottom: 8px; font-size: 14px; font-weight: 540; }
.reasons label, .check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.reasons input, .check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--text); }
.check-row { margin-top: 14px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; }
  .layout.is-thread .side { display: none; }
  .layout:not(.is-thread) .thread { display: none; }
  .back { display: inline-flex; padding: 0 8px; }
  .thread-head { padding: 8px 12px; gap: 8px; }
  .messages { padding: 16px 12px; }
  .msg { max-width: 88%; }
  .composer { padding: 10px 12px 12px; }
  .claim-form { flex-direction: column; }
  .person-actions .btn { --control: 40px; }
}

/* Live session invitations */
.invite-card .rc-kind { display: inline-flex; align-items: center; gap: 8px; }
.invite-card .live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .invite-card .live-dot { animation: none; } }

/* Phones: the tab bar steps aside inside a conversation, like Messages. */
@media (max-width: 820px) {
  .shell:has(.friends) { padding-bottom: 0; }
  .shell-main:has(> .friends) { height: calc(100dvh - 64px - env(safe-area-inset-bottom)); }
  .shell:has(.layout.is-thread) .tabbar { display: none; }
  .shell-main:has(.layout.is-thread) { height: 100dvh; }
  .layout.is-thread .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (pointer: coarse) { .msg-delete { min-height: 32px; padding: 6px 8px; } }
