/*
 * imessage.css — the messaging "skin": conversation list, thread, bubbles,
 * composer, context menu, sheets, alerts, popovers and the secondary views
 * (tags, contexts, tasks, search, settings). Swapping this file plus the
 * list/thread modules is how a later phase re-skins the app.
 */

/* ------------------------------------------------------------ avatar */

.avatar {
  --size: 44px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--avatar-color, var(--gray));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: calc(var(--size) * 0.4);
  letter-spacing: 0;
  line-height: 1;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.avatar.initials {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.08));
}
.avatar.emoji {
  font-size: calc(var(--size) * 0.52);
  background: color-mix(in srgb, var(--avatar-color) 22%, var(--bg-elevated));
}

/* ------------------------------------------------------------ conversation list */

.list-scroll { padding-left: var(--safe-left); padding-right: var(--safe-right); }

.search-wrap { padding: 0 16px 8px; }
.search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--text-2);
  font-size: 17px;
  text-align: left;
}
.search-field .icon { width: 18px; height: 18px; }

.conv-list { position: relative; }
.conv-item {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}
.conv-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 0 16px;
  min-height: 76px;
  color: var(--text);
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  transition: background-color 120ms;
}
.conv-row:active { background: var(--highlight); }
.conv-main {
  flex: 1;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 16px 10px 0;
  border-bottom: 0.5px solid var(--sep);
}
.conv-item:last-child .conv-main { border-bottom-color: transparent; }
.conv-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.conv-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-2);
  font-size: 15px;
  letter-spacing: -0.24px;
}
.conv-meta .chev { width: 14px; height: 14px; color: var(--text-3); margin-left: 2px; }
.conv-meta .pin-glyph { width: 13px; height: 13px; color: var(--orange); margin-right: 2px; }
.conv-preview {
  margin-top: 1px;
  color: var(--text-2);
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.24px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-height: 40px;
}
.draft-label { color: var(--red); }

.app.split .conv-row[aria-current="page"] { background: var(--selected); color: #fff; border-radius: 12px; margin: 0 8px; padding-left: 8px; }
.app.split .conv-row[aria-current="page"] .conv-main { border-bottom-color: transparent; }
.app.split .conv-row[aria-current="page"] .conv-preview,
.app.split .conv-row[aria-current="page"] .conv-meta,
.app.split .conv-row[aria-current="page"] .conv-meta .chev,
.app.split .conv-row[aria-current="page"] .draft-label { color: rgba(255, 255, 255, 0.85); }

/* Swipe actions */
.conv-actions {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  z-index: 0;
}
.conv-actions button {
  width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
.conv-actions button .icon { width: 22px; height: 22px; }
.conv-actions .act-pin { background: var(--orange); }
.conv-actions .act-archive { background: #5856d6; }
.conv-actions .act-delete { background: var(--red); }
.conv-item:not(.swipe-open) .conv-actions { visibility: hidden; }
.conv-row.swiping { transition: none; }
.conv-row.settling { transition: transform 260ms var(--ease), background-color 120ms; }

.archived-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  color: var(--blue);
  font-size: 15px;
}
.archived-toggle .chev { width: 16px; height: 16px; }
.conv-list.archived .conv-row { opacity: 0.85; }

/* ------------------------------------------------------------ overlays */

#overlay-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.overlay {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--vv-height, 100dvh);
  pointer-events: auto;
  display: flex;
}
.scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 260ms ease-out;
}
.overlay.open .scrim { opacity: 1; }
.overlay.popover .scrim { background: transparent; }

/* Action sheet */
.overlay.action-sheet { align-items: flex-end; justify-content: center; }
.as-panel {
  position: relative;
  width: min(100% - 16px, 420px);
  margin: 0 auto calc(8px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(110%);
  transition: transform 300ms var(--ease);
}
.overlay.action-sheet.open .as-panel { transform: translateY(0); }
.as-group {
  border-radius: 14px;
  overflow: hidden;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
}
.as-header { padding: 14px 16px; text-align: center; border-bottom: 0.5px solid var(--sep); }
.as-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.as-message { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.as-btn {
  display: block;
  width: 100%;
  min-height: 57px;
  padding: 0 16px;
  font-size: 20px;
  color: var(--blue);
  letter-spacing: 0.38px;
}
.as-btn + .as-btn { border-top: 0.5px solid var(--sep); }
.as-btn:active { background: var(--highlight); }
.as-btn.destructive { color: var(--red); }
.as-btn.cancel { font-weight: 600; background: var(--bg-elevated); }

/* Alert */
.overlay.alert { align-items: center; justify-content: center; }
.alert-box {
  position: relative;
  width: 270px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  text-align: center;
  transform: scale(1.12);
  opacity: 0;
  transition: transform 260ms var(--ease), opacity 200ms;
}
.overlay.alert.open .alert-box { transform: scale(1); opacity: 1; }
.overlay.closing .alert-box { transform: scale(1); opacity: 0; }
.alert-text { padding: 19px 16px 20px; }
.alert-title { font-size: 17px; font-weight: 600; line-height: 22px; }
.alert-message { font-size: 13px; line-height: 18px; margin-top: 4px; letter-spacing: -0.08px; }
.alert-buttons { display: flex; border-top: 0.5px solid var(--sep); }
.alert-buttons.col { flex-direction: column; }
.alert-btn { flex: 1; min-height: 44px; font-size: 17px; color: var(--blue); }
.alert-buttons.row .alert-btn + .alert-btn { border-left: 0.5px solid var(--sep); }
.alert-buttons.col .alert-btn + .alert-btn { border-top: 0.5px solid var(--sep); }
.alert-btn:active { background: var(--highlight); }
.alert-btn.preferred { font-weight: 600; }
.alert-btn.destructive { color: var(--red); }

/* Form sheet (card) */
.overlay.form-sheet { align-items: flex-end; justify-content: center; }
.sheet-panel {
  position: relative;
  width: 100%;
  max-height: calc(100% - var(--safe-top) - 12px);
  display: flex;
  flex-direction: column;
  background: var(--bg-sheet);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 340ms var(--ease);
}
.overlay.form-sheet.open .sheet-panel { transform: translateY(0); }
.sheet-grabber {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--fill-2);
  margin: 6px auto 0;
}
.sheet-nav {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 50px;
  padding: 0 8px;
}
.sheet-title { font-weight: 600; font-size: 17px; text-align: center; }
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.sheet-body .group { margin-left: 16px; margin-right: 16px; }
.sheet-body .group-header { padding-left: 32px; padding-right: 32px; }
.form-pad { padding: 0 16px; }
@media (min-width: 768px) {
  .overlay.form-sheet { align-items: center; }
  .sheet-panel {
    width: 540px;
    max-height: min(680px, calc(100% - 80px));
    border-radius: 14px;
    transform: translateY(40px);
    opacity: 0;
    transition: transform 300ms var(--ease), opacity 200ms;
  }
  .overlay.form-sheet.open .sheet-panel { transform: none; opacity: 1; }
  .sheet-grabber { display: none; }
}

/* Project form */
.sheet-avatar { display: flex; justify-content: center; padding: 8px 0 20px; }
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
  margin: 12px 16px 0;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-cell);
}
.emoji-choice {
  height: 44px;
  border-radius: 10px;
  font-size: 26px;
  line-height: 1;
}
.emoji-choice[aria-pressed="true"] { background: var(--fill); }
.emoji-input {
  height: 44px;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background: var(--fill);
  text-align: center;
  font-size: 22px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 0; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 0 var(--bg-sheet);
  transition: box-shadow 150ms;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg-sheet), 0 0 0 5px var(--swatch); }

/* Popover menu */
.popover-menu {
  position: fixed;
  border-radius: 13px;
  overflow: hidden;
  background: var(--menu-bg);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow);
  transform: scale(0.6);
  opacity: 0;
  transition: transform 260ms var(--ease), opacity 160ms;
}
.overlay.popover.open .popover-menu { transform: scale(1); opacity: 1; }
.pm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  font-size: 17px;
  text-align: left;
}
.pm-item + .pm-item { border-top: 0.5px solid var(--sep); }
.pm-item:active, .pm-item:focus-visible { background: var(--highlight); outline: none; }
.pm-item .icon { width: 21px; height: 21px; }
.pm-item.destructive { color: var(--red); }

/* Toast HUD */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom) + var(--kb-offset, 0px));
  z-index: 200;
  max-width: calc(100% - 48px);
  padding: 10px 18px;
  border-radius: 20px;
  background: rgba(30, 30, 32, 0.9);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms, transform 200ms var(--ease);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.emoji-input { grid-column: span 2; font-size: 17px; }
.emoji-input:not(:placeholder-shown) { font-size: 24px; background: var(--fill-2); }

/* ------------------------------------------------------------ thread */

.thread-view { --thread-top: 100px; --thread-bottom: 52px; }
.thread-view > .nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
.thread-nav {
  min-height: calc(62px + var(--safe-top));
  padding-bottom: 4px;
  background: var(--bar-bg);
}
.thread-title {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  max-width: 56vw;
  padding: 4px 8px 0;
  color: var(--text);
}
.thread-title:active { opacity: 0.6; }
.thread-avatar { display: inline-flex; min-height: 40px; }
.thread-name {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  max-width: 100%;
  font-size: 11px;
  line-height: 13px;
  letter-spacing: 0.06px;
}
.thread-name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-name .chev { width: 10px; height: 10px; color: var(--text-3); }

.thread-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--thread-top);
  padding-bottom: calc(var(--thread-bottom) + 8px);
}
.thread-empty {
  padding: 72px 40px 0;
  text-align: center;
  color: var(--text-2);
  font-size: 15px;
}
.thread-empty p + p { font-size: 13px; margin-top: 6px; color: var(--text-3); }

.loader { display: flex; justify-content: center; padding: 14px 0; }
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--fill-2);
  border-top-color: var(--text-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.msgs { padding: 4px 0 0; }
.msg {
  padding: 0 calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left));
  margin-top: 8px;
}
.msg.grouped { margin-top: 2px; }
.sep {
  margin: 16px 0 10px;
  text-align: center;
  font-size: 11px;
  line-height: 13px;
  color: var(--text-2);
  letter-spacing: 0.06px;
}
.sep strong { font-weight: 600; }
.msg:first-child .sep { margin-top: 6px; }

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.msg.out .msg-row { justify-content: flex-end; }

.bubble {
  position: relative;
  max-width: min(76%, 34em);
  padding: 7px 12px 8px;
  border-radius: var(--radius);
  font-size: 17px;
  line-height: 22px;
  letter-spacing: -0.41px;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: default;
  z-index: 0; /* stacking context so the tail sits under the text */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 160ms var(--ease), opacity 200ms;
}
.bubble.out { background: var(--bubble-out); color: var(--bubble-out-text); }
.bubble.in { background: var(--bubble-in); color: var(--bubble-in-text); }
.bubble:focus-visible { outline-offset: 3px; border-radius: var(--radius); }
.bubble:active { transform: scale(0.985); }

/* Tail: a masked pseudo-element that inherits the bubble color. */
.bubble.tail::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 26px;
  height: 21px;
  background: inherit;
  pointer-events: none;
  z-index: -1;
}
.bubble.out.tail::before {
  right: -6px;
  -webkit-mask-image: radial-gradient(14px 21px at 100% 0, transparent 98%, #000 100%);
  mask-image: radial-gradient(14px 21px at 100% 0, transparent 98%, #000 100%);
}
.bubble.in.tail::before {
  left: -6px;
  -webkit-mask-image: radial-gradient(14px 21px at 0 0, transparent 98%, #000 100%);
  mask-image: radial-gradient(14px 21px at 0 0, transparent 98%, #000 100%);
}
.msg.out .msg-row:has(.tail) { padding-right: 0; }

.bubble.jumbo {
  background: none;
  padding: 0 2px;
  font-size: 48px;
  line-height: 56px;
  letter-spacing: 0;
}

.bubble a { color: inherit; }
.bubble a.url { text-decoration: underline; text-underline-offset: 2px; }
.bubble a.tag, .bubble a.mention { font-weight: 600; }
.bubble.in a.tag, .bubble.in a.mention, .bubble.in a.url { color: var(--blue); }
.bubble.out a.tag, .bubble.out a.mention { color: #fff; }
.bubble .prio { font-weight: 700; color: var(--orange); letter-spacing: 0; }
.bubble.out .prio { color: #fff; }

.pin-badge {
  position: absolute;
  top: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  box-shadow: 0 0 0 2px var(--bg);
}
.pin-badge .icon { width: 12px; height: 12px; }
.bubble.out .pin-badge { left: -7px; }
.bubble.in .pin-badge { right: -7px; }

.task-toggle {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 7px;
  border-radius: 50%;
  border: 2px solid var(--text-3);
  color: transparent;
  transition: background-color 160ms, border-color 160ms, transform 160ms var(--ease);
}
.task-toggle::after { content: ""; position: absolute; inset: -10px; }
.task-toggle .icon { width: 15px; height: 15px; }
.task-toggle:active { transform: scale(0.88); }
.msg.done .task-toggle { background: var(--blue); border-color: var(--blue); color: #fff; }
.msg.done .bubble { opacity: 0.5; }
.msg.done .bubble .text-body { text-decoration: line-through; }

.msg-caption {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 13px;
  color: var(--text-2);
  letter-spacing: 0.06px;
}
.msg.out .msg-caption { justify-content: flex-end; }
.msg-caption .due.overdue { color: var(--red); font-weight: 600; }

.msg.just-sent .bubble { animation: pop-in 280ms var(--ease); }
@keyframes pop-in {
  from { transform: translateY(14px) scale(0.92); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.bubble.flash { animation: flash 1.4s ease-out; }
@keyframes flash {
  0%, 100% { filter: none; transform: none; }
  15% { transform: scale(1.06); filter: brightness(0.82) saturate(1.2); }
  45% { transform: none; filter: brightness(0.88); }
}

/* ------------------------------------------------------------ composer */

.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 6px calc(12px + var(--safe-right)) calc(6px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: var(--bar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.kb-open .composer { padding-bottom: 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  min-height: 36px;
  padding: 0 3px 0 13px;
  border-radius: 18px;
  border: 1px solid var(--sep-opaque);
  background: var(--bg);
}
.composer-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  max-height: 146px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 17px;
  line-height: 22px;
  overflow-y: hidden;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-input:focus, .composer-input:focus-visible { outline: none; }
.send-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 3px 0 3px 6px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  animation: send-in 180ms var(--ease);
}
.send-btn .icon { width: 19px; height: 19px; }
.send-btn:active { opacity: 0.7; }
@keyframes send-in { from { transform: scale(0.4); opacity: 0; } }

.edit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 2px 6px;
  padding: 6px 4px 6px 12px;
  border-left: 3px solid var(--blue);
  font-size: 13px;
}
.edit-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.edit-label { color: var(--blue); font-weight: 600; }
.edit-preview { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-cancel {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-2);
}
.edit-cancel .icon { width: 16px; height: 16px; }
.composer.editing .composer-field { border-color: var(--blue); }

/* Autocomplete popover */
.suggest {
  position: absolute;
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  bottom: calc(100% + 6px);
  max-width: 420px;
  border-radius: 13px;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 0.5px solid var(--sep);
  box-shadow: var(--shadow);
}
.suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  font-size: 17px;
  text-align: left;
}
.suggest-item + .suggest-item { border-top: 0.5px solid var(--sep); }
.suggest-item[aria-selected="true"] { background: var(--highlight); }
.suggest-item.create .suggest-label { color: var(--blue); }
.suggest-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-meta { color: var(--text-2); font-size: 15px; flex: none; }

/* ------------------------------------------------------------ bubble context menu */

.overlay.msg-menu .scrim {
  background: rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
}
:root[data-theme="dark"] .overlay.msg-menu .scrim { background: rgba(0, 0, 0, 0.45); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .overlay.msg-menu .scrim { background: rgba(0, 0, 0, 0.45); }
}
.msg-menu-layer { position: absolute; inset: 0; pointer-events: none; }
.msg-menu-layer > * { pointer-events: auto; }
.bubble.lifted {
  z-index: 1;
  transition: transform 260ms var(--ease), box-shadow 260ms;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.overlay.msg-menu.open .bubble.lifted { transform: scale(1.03); }
.overlay.msg-menu.closing .bubble.lifted { transform: none; box-shadow: none; opacity: 0; transition: opacity 200ms; }
.callout-wrap {
  position: fixed;
  z-index: 2;
  opacity: 0;
  transform: translateY(6px) scale(0.92);
  transition: opacity 180ms, transform 240ms var(--ease);
}
.callout-wrap.below { transform: translateY(-6px) scale(0.92); }
.overlay.msg-menu.open .callout-wrap { opacity: 1; transform: none; }
.callout {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(28, 28, 30, 0.94);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
:root[data-theme="dark"] .callout { background: rgba(72, 72, 74, 0.96); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout { background: rgba(72, 72, 74, 0.96); }
}
.callout-item {
  position: relative;
  min-height: 40px;
  padding: 0 12px;
  color: #fff;
  font-size: 15px;
  letter-spacing: -0.24px;
  white-space: nowrap;
}
.callout-item + .callout-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-left: 0.5px solid rgba(255, 255, 255, 0.28);
}
.callout-item:active, .callout-item:focus-visible { background: rgba(255, 255, 255, 0.16); outline: none; }
.callout-item.destructive { color: #ff6961; }
.callout-arrow {
  position: absolute;
  top: 100%;
  width: 0;
  height: 0;
  margin-left: -8px;
  border: 8px solid transparent;
  border-top-color: rgba(28, 28, 30, 0.94);
  border-bottom: 0;
}
.callout-wrap.below .callout-arrow {
  top: auto;
  bottom: 100%;
  border-top: 0;
  border-bottom: 8px solid rgba(28, 28, 30, 0.94);
}
:root[data-theme="dark"] .callout-arrow { border-top-color: rgba(72, 72, 74, 0.96); }
:root[data-theme="dark"] .callout-wrap.below .callout-arrow { border-bottom-color: rgba(72, 72, 74, 0.96); border-top-color: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout-arrow { border-top-color: rgba(72, 72, 74, 0.96); }
  :root:not([data-theme="light"]) .callout-wrap.below .callout-arrow { border-bottom-color: rgba(72, 72, 74, 0.96); border-top-color: transparent; }
}
@media (max-width: 360px) {
  .callout-item { padding: 0 9px; font-size: 14px; }
}

/* Move picker */
.move-preview { display: flex; justify-content: flex-end; padding: 4px 20px 16px; }
.move-preview .bubble { max-width: 85%; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pick-row .avatar { margin: -4px 0; }
.callout:focus { outline: none; }

/* ------------------------------------------------------------ tasks view */

.chips {
  display: flex;
  gap: 8px;
  padding: 2px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--fill);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--blue); color: #fff; }
.chip-count { font-size: 13px; opacity: 0.7; }

.task-section { padding: 0 0 6px; }
.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 16px calc(16px + var(--safe-right)) 6px calc(16px + var(--safe-left));
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.35px;
}
.task-section.overdue .section-title { color: var(--red); }
.section-count { font-size: 15px; font-weight: 500; color: var(--text-2); }
.tasks-alldone { padding: 20px 16px 4px; color: var(--text-2); font-size: 15px; text-align: center; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px calc(8px + var(--safe-right)) 6px calc(16px + var(--safe-left));
}
.task-row .task-toggle { margin: 9px 0 0; }
.task-row.done .task-toggle { background: var(--blue); border-color: var(--blue); color: #fff; }
.task-row.completing .task-toggle { transform: scale(1.12); }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-body .bubble {
  display: inline-block;
  max-width: 100%;
  cursor: pointer;
}
.task-row.done .bubble { opacity: 0.5; }
.task-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 4px 0 0 4px;
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
}
.task-meta .avatar { font-size: 10px; }
.task-project { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.task-due { flex: none; }
.task-due.overdue { color: var(--red); font-weight: 600; }
.task-info {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--blue);
}
.task-info .icon { width: 22px; height: 22px; }

.completed-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 18px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  font-size: 17px;
  font-weight: 600;
  color: var(--text-2);
}
.completed-toggle .chev { width: 16px; height: 16px; }

/* Task sheet */
.task-sheet .move-preview.in { justify-content: flex-start; }
.cell-sub { display: block; font-size: 13px; color: var(--blue); margin-top: 1px; }
.cell-sub:empty { display: none; }
.cell-sub.overdue { color: var(--red); }

/* ------------------------------------------------------------ tags, contexts, search */

.tags-seg { margin: 4px 0 4px; }
.tag-cell .tag-hash { color: var(--text-2); font-weight: 600; width: 14px; text-align: center; }
.cell-kind { display: block; font-size: 13px; color: var(--text-2); }
.ctx-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gray);
  color: #fff;
}
.ctx-icon .icon { width: 18px; height: 18px; }
.ctx-icon.person { background: #5856d6; }
.ctx-icon.project { background: var(--blue); }
.ctx-icon.topic { background: var(--orange); }
.ctx-icon.big { width: 64px; height: 64px; }
.ctx-icon.big .icon { width: 34px; height: 34px; }

.list-head { padding-bottom: 6px; }
.list-sub { padding: 0 16px; color: var(--text-2); font-size: 15px; }
.ctx-head { padding: 16px 0 8px; }
.ctx-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.ctx-name { font-size: 26px; font-weight: 700; letter-spacing: 0.3px; }
.ctx-group { margin-top: 16px; }
.ctx-kind { margin-top: 14px; }

.results { padding: 4px 0; }
.result-row {
  display: flex;
  gap: 10px;
  padding: 8px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  cursor: pointer;
}
.result-row:active { background: var(--highlight); }
.result-row .avatar { margin-top: 2px; }
.result-main { flex: 1; min-width: 0; }
.result-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-2);
}
.result-project { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-time { flex: none; }
.result-bubble { display: flex; }
.result-bubble .bubble { max-width: 100%; cursor: pointer; }
.result-bubble .bubble mark {
  background: #ffd60a;
  color: #000;
  border-radius: 3px;
  padding: 0 1px;
}

.search-bar {
  flex: none;
  padding: 8px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  border-bottom: 0.5px solid var(--sep);
}
.search-field.live { cursor: text; color: var(--text-2); }
.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 17px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search-input:focus-visible { outline: none; }
.search-count { padding: 12px 16px 0; font-size: 13px; color: var(--text-2); }
.search-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 4px;
  font-size: 17px;
  font-weight: 600;
}
.search-group-title .avatar { font-size: 11px; }
.search-hint { padding-top: 48px; }
.result-row.compact { padding-left: calc(46px + var(--safe-left)); padding-top: 4px; }
.result-row.compact .result-top { justify-content: flex-end; margin-bottom: 2px; }

/* ------------------------------------------------------------ settings */

.seg-cell { padding-top: 8px; padding-bottom: 8px; }
.seg-cell .segmented { flex: 1; }
