/* EPIC Outlook Add-in — dark "Liquid Glass" theme.
   Adapted from the design bundle: stage / phone / status-bar dev chrome
   removed; the task pane fills its host directly. */

:root {
  /* Tokens shared across light/dark — kept for completeness */
  --ink: #f4f1ea;
  --paper: #0b0d12;
  --rule: rgba(255, 255, 255, 0.08);
  --muted: #8a8578;
  --accent: #ff6a48;

  /* Outlook + EPIC */
  --outlook: #4aa3ff;
  --outlook-deep: #2b7fd6;
  --ok: #34d97a;
  --warn: #ff9b3d;
  --urgent: #ff5b5f;
  --epic: #8aa6dd;
  --gold: #e7b94a;
  --purple: #b794f6;

  /* iOS dark + glass */
  --ios-bg-0: #07080c;
  --ios-bg-1: #0d1018;
  --ios-text: #f1ecdf;
  --ios-secondary: rgba(241, 236, 223, 0.55);
  --ios-tertiary: rgba(241, 236, 223, 0.32);
  --ios-blue: #5aa9ff;
  --ios-blue-soft: rgba(90, 169, 255, 0.18);

  /* Glass tokens */
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-strong: rgba(255, 255, 255, 0.085);
  --glass-bg-deep: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-edge-top: rgba(255, 255, 255, 0.18);
  --glass-edge-bottom: rgba(0, 0, 0, 0.45);
  --glass-blur: 28px;
  --glass-sat: 180%;

  --pane-rule: rgba(255, 255, 255, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
}

body {
  /* Emoji fonts appended after the text fonts — the browser picks each
     font per-codepoint, so emoji codepoints fall through to a color
     emoji font even on Windows/Linux setups where the system default
     doesn't supply one automatically. */
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter Tight",
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
    sans-serif;
  color: var(--ios-text);
  /* Dark base + radial color washes so glass surfaces have something to refract */
  background:
    radial-gradient(ellipse at 0% 0%, rgba(90, 169, 255, 0.20) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(255, 106, 72, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 0%, rgba(180, 148, 246, 0.10) 0%, transparent 55%),
    linear-gradient(180deg, var(--ios-bg-1) 0%, var(--ios-bg-0) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

#root {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Subtle film grain so glass refraction has something to bite */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 30% 70%, rgba(90, 169, 255, 0.08), transparent 60%),
    radial-gradient(circle at 80% 30%, rgba(255, 106, 72, 0.06), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* Liquid-glass refraction filter (optional opt-in via .glass-refract). */
.glass-refract { filter: url(#liquidGlass); }


/* ── Auth prompt (signed-out state) ───────────────────────────── */
.auth-prompt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.auth-prompt h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-prompt p {
  color: var(--ios-secondary);
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 260px;
}
.auth-prompt .btn-primary {
  background: linear-gradient(180deg, rgba(90, 169, 255, 0.95), rgba(43, 127, 214, 0.95));
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  color: #fff;
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.35),
    0 6px 18px -4px rgba(43, 127, 214, 0.55);
}
.auth-prompt .btn-primary:active { transform: scale(0.98); }
.error-text {
  color: var(--urgent);
  font-size: 12px;
  display: none;
  margin-top: 8px;
}

/* ── Outlook header — frosted glass over the brand color ──────── */
.outlook-header {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, rgba(43, 127, 214, 0.55), rgba(43, 127, 214, 0.42));
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  color: #fff;
  padding: 8px 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  min-height: 44px;
  position: relative;
  z-index: 4;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    0 1px 0 rgba(0, 0, 0, 0.4);
}
.outlook-header .leading {
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0.95;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
}
.outlook-header .title-stack { flex: 1; line-height: 1.2; min-width: 0; }
.outlook-header .small {
  font-size: 10px;
  opacity: 0.85;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.outlook-header .trailing {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.95;
}
.outlook-header .trailing:active { background: rgba(255, 255, 255, 0.18); }

/* ── Pane (scroll body) ───────────────────────────────────────── */
.pane {
  flex: 1;
  background: transparent;
  padding: 12px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(241, 236, 223, 0.78);
  font-weight: 700;
  margin: 6px 6px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-label .count {
  font-size: 11px;
  color: var(--ios-secondary);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ── Glass card — the cornerstone surface ─────────────────────── */
.card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 16px;
  overflow: hidden;
  border: 0.5px solid var(--glass-border);
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom),
    0 8px 28px -10px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.4);
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 40%;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

.av-wrap { position: relative; flex-shrink: 0; }

.avatar-xl, .avatar-lg, .avatar-md {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  /* Needed so the absolute-positioned .av-img anchors to the avatar bubble.
     overflow:hidden also clips the photo to the bubble's rounded corners. */
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 1px 3px rgba(0, 0, 0, 0.25);
}
.avatar-xl { width: 64px; height: 64px; font-size: 22px; border-radius: 16px; }
.avatar-lg { width: 38px; height: 38px; font-size: 14px; border-radius: 11px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; border-radius: 9px; }
.detail-hero .avatar-xl { box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), 0 4px 12px rgba(0,0,0,0.4); }
.av-a { background: linear-gradient(135deg, #ff6a48, #d97757); }
.av-b { background: linear-gradient(135deg, #4a6491, #2b3a55); }
.av-c { background: linear-gradient(135deg, #34d97a, #107c10); }
.av-d { background: linear-gradient(135deg, #b794f6, #5b21b6); }

/* When a SharePoint headshot has finished loading, swap the gradient
   for the photo. The img is always rendered (when a URL is available)
   so the browser can start the fetch immediately; it's hidden until
   onLoad fires, leaving the initials monogram visible during the
   CDN download. */
.avatar-photo { background: transparent; padding: 0; }
.av-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
  opacity: 0;
  transition: opacity 140ms ease-out;
}
.av-img.loaded { opacity: 1; }

/* ── Recipient row ───────────────────────────────────────────── */
.recip-row {
  display: flex;
  align-items: center;
  gap: 12px;
  /* Same dimensions as the hero / sender row — flush-left 60×60 photo. */
  height: 60px;
  padding: 0 14px 0 0;
  border-bottom: 1px solid var(--pane-rule);
  cursor: pointer;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  position: relative;
  z-index: 1;
}
.recip-row .avatar-xl {
  width: 60px;
  height: 60px;
  font-size: 15px;
  border-radius: 0;
}
.recip-row:last-child { border-bottom: none; }

/* "Show N more" / "Show less" toggle inside the Recipients card.
   Full-width row, centered iOS-blue label — matches the visual weight
   of the rows above without competing with them. */
.recipients-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ios-blue);
  letter-spacing: 0.01em;
  position: relative;
  z-index: 1;
}
.recipients-toggle:active { background: rgba(255, 255, 255, 0.04); }
/* When the toggle follows a recipient row, the row's bottom border becomes
   the divider — kill the toggle's implicit top border so we don't double up. */
.recip-row + .recipients-toggle { border-top: 0; }

/* ── Connections tab strip ────────────────────────────────────── */
/* Segmented-control look (rounded outer bg + border) that scrolls
   horizontally when its tabs don't all fit. Each tab sits at its
   natural width so long labels ("Businesses") aren't truncated.
   Scrollbar hidden to keep the segmented-control feel. */
.connections-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 3px;
  border: 0.5px solid var(--glass-border);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.connections-tabs::-webkit-scrollbar { display: none; }
.connections-tab {
  flex-shrink: 0;
  padding: 7px 11px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ios-secondary);
  background: transparent;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.connections-tab:hover { color: var(--ios-text); }
.connections-tab.on {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 60%),
    rgba(255, 255, 255, 0.08);
  color: var(--ios-text);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.2);
}
.connections-tab-count {
  font-size: 10px;
  opacity: 0.6;
}
.recip-row:hover,
.recip-row:active { background: rgba(255, 255, 255, 0.04); }
.recip-info { flex: 1; min-width: 0; }
.recip-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ios-text);
  min-width: 0;
}
.recip-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.recip-detail {
  font-size: 11px;
  color: var(--ios-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.role-tag.from { background: rgba(255, 106, 72, 0.18); color: var(--accent); }
.role-tag.to { background: rgba(74, 163, 255, 0.18); color: var(--outlook); }
.role-tag.cc { background: rgba(255, 255, 255, 0.06); color: var(--ios-secondary); }
.chev {
  color: var(--ios-tertiary);
  font-size: 17px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Connection / search row ─────────────────────────────────── */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--pane-rule);
  cursor: pointer;
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: background 0.12s;
  position: relative;
  z-index: 1;
}
.row:last-child { border-bottom: none; }
.row:active, .row:hover { background: rgba(255, 255, 255, 0.04); }
.row.skeleton {
  cursor: default;
  pointer-events: none;
}
.row.skeleton:hover, .row.skeleton:active { background: transparent; }
.row.selected, .row.selected:hover { background: var(--ios-blue-soft); }
.row.just-added { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%   { background: rgba(90, 169, 255, 0.32); box-shadow: inset 0 0 0 1px rgba(90, 169, 255, 0.5); }
  100% { background: transparent; box-shadow: inset 0 0 0 1px transparent; }
}
.row-info { flex: 1; min-width: 0; }
.row-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ios-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row.selected .row-title { color: var(--ios-blue); }
.row-meta {
  font-size: 11px;
  color: var(--ios-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.row-meta .ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta .urgent { color: var(--urgent); font-weight: 600; }
.ref {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--epic);
  background: rgba(138, 166, 221, 0.14);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
/* Status pill — surfaced on EntityRow when a case is closed (and could
   be extended for other states later). Muted gray treatment so it
   recedes vs. the colored ref pill. */
.status-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.status-pill.closed {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ios-tertiary);
}
.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ios-tertiary);
  flex-shrink: 0;
}

/* Hover tooltip — used by useHoverTooltip in components.tsx. Rendered
   via portal to document.body so it escapes any parent overflow:hidden.
   `left`/`top` are set inline (mouse-target coords); the transform
   centers horizontally on that point. */
.hover-tooltip {
  position: fixed;
  transform: translateX(-50%);
  max-width: 280px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ios-text);
  pointer-events: none;
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    0 6px 18px -4px rgba(0, 0, 0, 0.55);
  z-index: 10000;
  /* Long titles wrap rather than overflow the viewport. */
  white-space: normal;
  word-break: break-word;
}

/* Per-entity emoji shown in row leading position. Matches a 34px row
   footprint so alignment stays consistent across cards. */
.type-emoji {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
}

/* ── Add-connection row (subtle tinted glass) ─────────────────── */
/* Adopted from the Layout B `.lb-add-row` spec — tinted glass instead
   of a saturated gradient so it reads as a continuation of the tab
   strip above it, not a competing CTA. Label adapts to the active
   tab (Add case / Add account / Add business / Add record / Add
   connection for "All"). */
.add-connection-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(90, 169, 255, 0.08);
  border-radius: 12px;
  border: 0.5px solid rgba(90, 169, 255, 0.20);
  color: var(--ios-blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: background 140ms ease, border-color 140ms ease;
}
.add-connection-btn:hover {
  background: rgba(90, 169, 255, 0.12);
  border-color: rgba(90, 169, 255, 0.30);
}
.add-connection-btn:active { transform: scale(0.99); }
.add-connection-btn .icn {
  width: 22px;
  height: 22px;
  background: rgba(90, 169, 255, 0.20);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}
.add-connection-btn .text {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Center variant — icon + label group centered, used by the
   "Open in EPIC" affordance on ConnectionDetail where the button is
   a one-off action rather than a row-style CTA. */
.add-connection-btn.center-text {
  justify-content: center;
}
.add-connection-btn.center-text .text {
  flex: 0 0 auto;
  text-align: center;
}

/* ── Empty state ──────────────────────────────────────────────── */
.empty {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 16px;
  padding: 22px 18px 16px;
  text-align: center;
  border: 0.5px solid var(--glass-border);
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom);
}
.empty-emoji {
  font-size: 36px;
  line-height: 1;
  margin: 0 auto 10px;
}
.empty-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ios-text);
}
.empty-title.subtle {
  font-weight: 500;
  color: var(--ios-secondary);
  margin-bottom: 0;
}
.empty-sub {
  font-size: 12px;
  color: var(--ios-secondary);
  line-height: 1.45;
  max-width: 240px;
  margin: 0 auto;
}

/* ── Type chip strip ──────────────────────────────────────────── */
.chip-strip-wrap {
  margin: 0 -14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.chip-strip-wrap::-webkit-scrollbar { display: none; }

.chip-strip {
  display: flex;
  gap: 8px;
  padding: 4px 14px 8px;
  width: max-content;
}

.type-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 18px;
  /* Solid translucent tint — was using backdrop-filter, but chips inside
     a horizontal scroll container interact badly with the compositor,
     causing the active-state gradient to render incorrectly after a
     chip scrolls out and back into view. The glass card behind the
     strip already provides the frosted look. */
  background: var(--glass-bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--ios-text);
  border: 0.5px solid var(--glass-border);
  flex-shrink: 0;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
}
.type-chip.on {
  background: linear-gradient(180deg, rgba(90, 169, 255, 0.95), rgba(43, 127, 214, 0.95));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.4),
    0 4px 14px -3px rgba(43, 127, 214, 0.5);
}
.chip-emoji {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Search bar ───────────────────────────────────────────────── */
.search-bar {
  background: rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: text;
  border: 0.5px solid var(--glass-border);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.10);
}
.search-bar .icn { color: var(--ios-tertiary); display: flex; align-items: center; }
.search-bar input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: var(--ios-text);
  font-family: inherit;
  min-width: 0;
}
.search-bar input::placeholder { color: var(--ios-tertiary); }
.search-bar .clear {
  margin-left: auto;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.25);
  color: var(--ios-bg-0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ios-tertiary);
  font-weight: 600;
  padding: 8px 14px 6px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid var(--pane-rule);
}

/* ── Create-new row ───────────────────────────────────────────── */
.create-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: rgba(90, 169, 255, 0.06);
  border-bottom: 1px solid var(--pane-rule);
  cursor: pointer;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  position: relative;
  z-index: 1;
}
.create-row:hover { background: rgba(90, 169, 255, 0.12); }
.create-row:disabled { cursor: default; opacity: 0.7; }
.create-row:disabled:hover { background: rgba(90, 169, 255, 0.06); }
.create-row.loading .plus {
  animation: spin 1.1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.create-row .plus {
  width: 32px;
  height: 32px;
  background: rgba(90, 169, 255, 0.20);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ios-blue);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.18);
}
.create-row .text { flex: 1; }
.create-row .label {
  font-size: 13px;
  color: var(--ios-blue);
  font-weight: 600;
  line-height: 1.2;
}
.create-row .hint {
  font-size: 11px;
  color: var(--ios-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.create-row .chev { color: var(--ios-blue); font-size: 17px; flex-shrink: 0; }

/* ── Radio + already-linked badge ─────────────────────────────── */
.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
}
.radio.on {
  background: var(--ios-blue);
  border-color: var(--ios-blue);
  color: #fff;
  box-shadow: 0 0 10px rgba(90, 169, 255, 0.4);
}
.radio.on svg { width: 12px; height: 12px; }
.already {
  font-size: 10px;
  color: var(--ok);
  font-weight: 700;
  background: rgba(52, 217, 122, 0.16);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Bottom action bar — heaviest glass ───────────────────────── */
.bottom-bar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 60%),
    rgba(13, 16, 24, 0.55);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  backdrop-filter: blur(32px) saturate(200%);
  padding: 12px 14px 14px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.10);
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  position: relative;
  z-index: 5;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
}
.btn {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.98); }
.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ios-text);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.18),
    inset 0 -0.5px 0 rgba(0, 0, 0, 0.2);
}
.btn.primary {
  background: linear-gradient(180deg, rgba(90, 169, 255, 0.95), rgba(43, 127, 214, 0.95));
  color: #fff;
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.35),
    inset 0 -0.5px 0 rgba(0, 0, 0, 0.25),
    0 6px 18px -4px rgba(43, 127, 214, 0.55);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
}
.btn.primary:disabled, .btn.primary.disabled {
  background: rgba(90, 169, 255, 0.22);
  color: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.08);
  cursor: not-allowed;
}

/* ── Toast — full liquid glass ────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.10);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  backdrop-filter: blur(28px) saturate(200%);
  color: var(--ios-text);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 14px;
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 0.5px 0 rgba(255, 255, 255, 0.25),
    inset 0 -0.5px 0 rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 30;
  animation: toast-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast .check {
  width: 18px;
  height: 18px;
  background: var(--ok);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}
.toast .check svg { width: 12px; height: 12px; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Detail screen ────────────────────────────────────────────── */
.detail-hero {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 16px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  border: 0.5px solid var(--glass-border);
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom);
}
.detail-hero-emoji {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 4px;
}
.detail-hero h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  font-family: inherit;
  color: var(--ios-text);
}
.detail-hero .meta-line {
  font-size: 12px;
  color: var(--ios-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kv-list {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 16px;
  overflow: hidden;
  border: 0.5px solid var(--glass-border);
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom);
}
.kv {
  padding: 11px 14px;
  border-bottom: 1px solid var(--pane-rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ios-secondary); }
.kv .v {
  color: var(--ios-text);
  font-weight: 500;
  text-align: right;
}
/* Small muted prefix shown before a v's main content. Used on Start/End
   rows in case detail to label whether the date is the actual or
   scheduled one. */
.kv .kv-prefix {
  color: var(--ios-tertiary);
  font-weight: 400;
  margin-right: 2px;
  text-transform: lowercase;
}

/* Block layout for long-form values (AI summary, remarks). The value
   wraps onto its own line below the key instead of fighting for
   horizontal space. */
.kv.kv-block {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.kv .v-block {
  text-align: left;
  font-weight: 400;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Endpoint row — emoji + title + (optional) role pill on the value side. */
.kv.kv-endpoint .v-endpoint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.kv.kv-endpoint .endpoint-emoji {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.kv.kv-endpoint .endpoint-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.kv.kv-endpoint .endpoint-role {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ios-secondary);
  flex-shrink: 0;
}

/* ── Compact contact hero (horizontal layout) ─────────────────── */
.contact-hero {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 16px;
  /* Fixed card height = avatar height. No vertical padding so the headshot
     fills the card top-to-bottom; no left padding so it flushes the edge.
     overflow:hidden clips the avatar to the card's rounded corners. */
  height: 60px;
  padding: 0 14px 0 0;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border: 0.5px solid var(--glass-border);
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom),
    0 8px 28px -10px rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.4);
  position: relative;
}
a.contact-hero.is-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
a.contact-hero.is-link:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}
a.contact-hero.is-link:hover .ext-icon { color: var(--ios-text); }
a.contact-hero.is-link:focus-visible {
  outline: 2px solid var(--ios-blue);
  outline-offset: 2px;
}
.contact-hero h2 {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.contact-hero h2 .contact-hero-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.contact-hero .ext-icon {
  color: var(--ios-tertiary);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 120ms ease;
}
.contact-hero .avatar-xl {
  width: 60px;
  height: 60px;
  font-size: 15px;
  border-radius: 0 0 0 0;
}

/* Rating badge rendered inside .av-wrap by the Avatar component. Sits at
   the bottom-right corner of the headshot, with a dark ring that punches
   it out against the photo so it reads cleanly on any background. */
.av-wrap .rating-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(15, 18, 28, 0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 2;
}
/* Larger, more inset badge whenever the avatar is xl-size (hero + the
   60×60 sender/recipient rows). Sibling selector targets any .rating-badge
   that follows an .avatar-xl in the same .av-wrap. */
.av-wrap .avatar-xl ~ .rating-badge {
  width: 14px;
  height: 14px;
  bottom: 4px;
  right: 4px;
  border-width: 2px;
}
.rating-banned    { background: var(--urgent); }
.rating-bad       { background: var(--warn); }
.rating-average   { background: var(--ios-blue); }
.rating-excellent { background: var(--ok); }

.contact-hero-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* Tightened so ref + name + role line all fit in the 60px card without
     getting clipped at the top or bottom edge. */
  gap: 2px;
}
.contact-hero h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-family: inherit;
  color: var(--ios-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-hero .meta-line {
  font-size: 12px;
  line-height: 1.2;
  color: var(--ios-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.contact-hero .meta-line .dot {
  width: 3px;
  height: 3px;
  background: var(--ios-tertiary);
  border-radius: 50%;
  flex-shrink: 0;
}
.contact-hero .meta-line .ref {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--epic);
  background: rgba(138, 166, 221, 0.16);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.contact-hero .meta-line .not-in-epic {
  font-size: 10px;
  font-weight: 700;
  color: var(--ios-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Hero pill (used inside detail-hero) ─────────────────────── */
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 10px;
  margin-top: 2px;
}
.hero-tag.in-epic {
  background: rgba(52, 217, 122, 0.14);
  color: var(--ok);
}
.hero-tag.in-epic svg { width: 10px; height: 10px; }
.hero-tag.unknown {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ios-secondary);
}

/* ── Two-line field row (label + value) ──────────────────────── */
.field {
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--pane-rule);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.field:last-child { border-bottom: none; padding-bottom: 13px; }
.field:active { background: rgba(255, 255, 255, 0.04); }
.field-label {
  font-size: 10px;
  color: rgba(241, 236, 223, 0.78);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-value {
  font-size: 14px;
  color: var(--ios-text);
  font-weight: 500;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.field-tag {
  font-size: 9px;
  font-weight: 700;
  color: var(--ios-blue);
  background: rgba(90, 169, 255, 0.18);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field-tag.sms {
  color: var(--ok);
  background: rgba(52, 217, 122, 0.16);
}

/* Skeleton placeholder rows — shown while ContactDetail's fetchContact
   is in flight, so the user doesn't see fake mock data. Same .field
   shape so the layout doesn't jump when real rows replace them. */
.field.skeleton {
  cursor: default;
}
.field.skeleton:hover,
.field.skeleton:active {
  background: transparent;
}
.skel-bar {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel-label {
  width: 50px;
  height: 9px;
  vertical-align: middle;
}
.skel-value {
  width: 60%;
  height: 13px;
  margin-top: 6px;
}
@keyframes skel-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── Compact recent-email row ────────────────────────────────── */
.recent-row {
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-bottom: 1px solid var(--pane-rule);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.recent-row:last-child { border-bottom: none; }
.recent-row:active { background: rgba(255, 255, 255, 0.04); }
.recent-subject {
  font-size: 13px;
  color: var(--ios-text);
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-meta {
  font-size: 11px;
  color: var(--ios-secondary);
}

/* ── Quick action row (icon + label, glass card row) ─────────── */
.quick-row {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--pane-rule);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.quick-row:last-child { border-bottom: none; }
.quick-row:active { background: rgba(255, 255, 255, 0.04); }
.quick-row .quick-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(90, 169, 255, 0.18);
  color: var(--ios-blue);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.2);
}
.quick-row .quick-label {
  flex: 1;
  font-size: 14px;
  color: var(--ios-text);
  font-weight: 500;
}

.danger-row {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--urgent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid rgba(255, 91, 95, 0.25);
  width: 100%;
  font-family: inherit;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.08);
}

/* ── Footer (sign-out) ───────────────────────────────────────── */
.footer {
  padding: 8px 14px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--ios-tertiary);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.footer button {
  background: none;
  border: 0;
  color: var(--ios-blue);
  font-size: 11px;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
}

/* ── More-menu (toolbar overflow popover) ─────────────────────── */
.more-menu-wrap { position: relative; display: flex; align-items: center; }
.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(28, 32, 44, 0.94);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid var(--glass-border);
  border-radius: 12px;
  min-width: 220px;
  z-index: 30;
  box-shadow:
    inset 0 0.5px 0 var(--glass-edge-top),
    inset 0 -0.5px 0 var(--glass-edge-bottom),
    0 12px 28px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  padding: 4px 0;
}
.more-menu-item {
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  font-family: inherit;
  color: var(--ios-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.more-menu-item + .more-menu-item {
  border-top: 1px solid var(--pane-rule);
}
.more-menu-item:not(:disabled):hover,
.more-menu-item:not(:disabled):focus-visible {
  background: rgba(90, 169, 255, 0.14);
  color: var(--ios-text);
  outline: none;
}
.more-menu-item:not(:disabled):active { background: rgba(90, 169, 255, 0.22); }
.more-menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
