:root {
  /* Helvia Live — palette monochrome anthracite (inspirée Cursor) */
  --primary: #1a1a1a;
  --primary-dark: #000000;
  --primary-light: #3d3d3d;
  --secondary: #6b6b6b;
  --brand-50: #f7f7f7;
  --brand-100: #ececec;
  --brand-200: #d4d4d4;
  --brand-400: #6b6b6b;
  --brand-500: #1a1a1a;
  --brand-600: #0d0d0d;
  --brand-700: #000000;
  --brand-800: #000000;
  --ink-50: #fafafa;
  --ink-100: #f5f5f5;
  --ink-200: #ebebeb;
  --ink-300: #d4d4d4;
  --ink-400: #8a8a8a;
  --ink-500: #535352;
  --ink-600: #3d3d3d;
  --ink-800: #1f1f1f;
  --ink-900: #0a0a0a;
  --wa: #25D366;
  --wa-dark: #128C7E;
  --gradient-brand: linear-gradient(135deg, #2a2a2a 0%, #050505 100%);
  --gradient-brand-soft: linear-gradient(135deg, rgba(26,26,26,0.08), rgba(26,26,26,0.02));
  --gradient-hero: linear-gradient(180deg, #fafafa 0%, #ffffff 60%);
  --surface: #ffffff;
  --bg: var(--ink-50);
  --text: var(--ink-900);
  --text-soft: var(--ink-500);
  --text-mute: var(--ink-400);
  --border: var(--ink-200);
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 4px 12px -2px rgba(0,0,0,0.08);
  --shadow-soft: 0 4px 12px -2px rgba(0,0,0,0.06);
  --shadow-glow: 0 24px 60px -12px rgba(0,0,0,0.35);
  --radius: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
@supports (height: 100dvh) {
  html, body, #app { height: 100dvh; }
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }

.app-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--gradient-hero);
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--brand-100);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@supports (padding-top: env(safe-area-inset-top)) {
  .safe-top { padding-top: env(safe-area-inset-top); }
  .safe-bottom { padding-bottom: env(safe-area-inset-bottom); }
}

/* ==================== AUTH ==================== */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: var(--gradient-hero);
  position: relative;
  overflow: hidden;
}
.auth-screen::before,
.auth-screen::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.auth-screen::before {
  width: 420px; height: 420px;
  top: -120px; right: -80px;
  background: rgba(0,0,0, 0.1);
}
.auth-screen::after {
  width: 360px; height: 360px;
  bottom: -100px; left: -60px;
  background: rgba(83, 83, 82, 0.08);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 2.25rem 1.75rem;
  box-shadow: var(--shadow-glow);
  position: relative;
  z-index: 1;
}
.auth-brand {
  display: flex; align-items: center; gap: 0.85rem;
  margin-bottom: 1.75rem;
}
.auth-brand-icon {
  width: 48px; height: 48px;
  background: var(--gradient-brand);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 8px 28px -6px rgba(0,0,0,0.45);
}
.auth-brand-text { flex: 1; min-width: 0; }
.auth-brand-title {
  font-weight: 800; font-size: 1.35rem; letter-spacing: -0.03em; line-height: 1;
  color: var(--ink-900);
}
.auth-brand-sub { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.25rem; }
.auth-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.68rem; font-weight: 700;
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
}
.auth-pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 6px rgba(0,0,0, 0.45);
}
.auth-title { font-size: 1.35rem; font-weight: 700; margin: 0 0 0.4rem; letter-spacing: -0.02em; color: var(--ink-900); }
.auth-desc { font-size: 0.9rem; color: var(--text-soft); margin: 0 0 1.25rem; line-height: 1.55; }

.auth-input {
  width: 100%; padding: 0.85rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font: inherit; font-size: 1rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 4px rgba(0,0,0, 0.1);
}
.auth-code {
  text-align: center;
  letter-spacing: 0.5em;
  font-weight: 700;
  font-size: 1.4rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.85rem 1.25rem;
  border: none; border-radius: 999px;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  transition: all 0.2s; width: 100%;
}
.btn-brand {
  background: var(--gradient-brand);
  color: white;
  box-shadow: 0 8px 28px -6px rgba(0,0,0,0.5);
}
.btn-brand:active { transform: scale(0.98); opacity: 0.95; }
.btn-brand:disabled {
  background: var(--ink-200);
  color: var(--ink-400);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-ghost { background: transparent; color: var(--text-soft); border-radius: 12px; }
.btn-ghost:active { background: var(--ink-100); }
.auth-error {
  margin: 0.4rem 0;
  font-size: 0.85rem; color: var(--danger);
  text-align: center; font-weight: 500;
}
.auth-foot { margin-top: 1rem; text-align: center; font-size: 0.75rem; color: var(--text-mute); }

/* ==================== SHELL ==================== */
.shell {
  display: flex; flex-direction: column;
  height: 100vh;
  background: var(--bg);
}
.shell-main {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* TopBar */
.topbar {
  background: var(--ink-900);
  color: white;
  padding: 0.55rem 0.6rem;
  display: flex; align-items: center; gap: 0.4rem;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
}
.topbar.gradient {
  background: linear-gradient(135deg, #ff2a3a 0%, #ee0111 55%, #c9000e 100%);
  box-shadow: 0 12px 30px -10px rgba(238,1,17,0.45);
}
.topbar .safe-extend {
  height: env(safe-area-inset-top, 0px);
  background: inherit;
  position: absolute; top: calc(-1 * env(safe-area-inset-top, 0px));
  left: 0; right: 0;
}
.topbar-back {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: white; border-radius: 50%;
  flex-shrink: 0;
}
.topbar-back:active { background: rgba(255,255,255,0.22); }
.topbar-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.topbar-title {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: 0.1rem;
}
.topbar-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-sub { font-size: 0.72rem; opacity: 0.82; }
.topbar-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.topbar-icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white; border-radius: 50%;
}
.topbar-icon-btn:active { background: rgba(255,255,255,0.2); }
.topbar-icon-btn.active-bot { background: rgba(255,255,255,0.22); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25); }

.topbar-line-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.65rem 0.4rem 0.4rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  color: white;
  font-family: inherit;
}
.topbar-line-btn:active:not(:disabled) { background: rgba(255,255,255,0.18); }
.topbar-line-btn:disabled { opacity: 1; cursor: default; }
.topbar-line-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
}
.topbar-line-text {
  flex: 1; min-width: 0;
  text-align: left;
  display: flex; flex-direction: column;
  gap: 0.05rem;
}
.topbar-line-num {
  font-weight: 700; font-size: 0.92rem; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-line-sub {
  font-size: 0.7rem; opacity: 0.78; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-line-chevron { flex-shrink: 0; opacity: 0.8; transition: transform 0.2s; }
.topbar-line-chevron.open { transform: rotate(180deg); }

.line-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0.6rem; right: 0.6rem;
  background: white;
  color: var(--text);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  z-index: 20;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.45rem;
  border: 1px solid var(--border);
  animation: slideDown 0.18s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.line-dropdown-item {
  width: 100%;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: 12px;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.line-dropdown-item:active { background: var(--ink-50); }
.line-dropdown-item.active { background: var(--brand-50); }
.line-dropdown-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.line-dropdown-text { flex: 1; min-width: 0; }
.line-dropdown-num { font-weight: 700; font-size: 0.92rem; font-family: ui-monospace, monospace; }
.line-dropdown-sub { font-size: 0.75rem; color: var(--text-soft); }
.line-dropdown-check { color: var(--brand-600); flex-shrink: 0; }

/* ==================== INBOX LIST ==================== */
.inbox-list {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
}
.search-bar {
  padding: 0.65rem 0.85rem;
  background: var(--ink-50);
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  font: inherit; font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--brand-300, var(--brand-400));
  box-shadow: 0 0 0 3px rgba(0,0,0, 0.1);
}

.conv-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left;
  transition: background 0.12s;
}
.conv-row:active { background: var(--brand-50); }
.conv-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gradient-brand);
  color: white; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(0,0,0, 0.18);
}
.conv-avatar.v1 { background: linear-gradient(135deg, #3d3d3d, #1a1a1a); }
.conv-avatar.v2 { background: linear-gradient(135deg, #535352, #2d2d2d); }
.conv-avatar.v3 { background: linear-gradient(135deg, #1a1a1a, #000000); }
.conv-avatar.v4 { background: linear-gradient(135deg, #8a8a8a, #535352); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.conv-name { font-weight: 600; font-size: 0.95rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 0.7rem; color: var(--text-soft); flex-shrink: 0; }
.conv-time.unread { color: var(--brand-600); font-weight: 700; }
.conv-bot {
  font-size: 0.62rem; color: var(--brand-700);
  background: var(--brand-50);
  padding: 0.08rem 0.45rem; border-radius: 999px;
  font-weight: 700; margin-right: 0.3rem;
  border: 1px solid var(--brand-100);
}
.conv-bottom { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; margin-top: 0.2rem; }
.conv-preview { font-size: 0.82rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.unread-badge {
  background: var(--gradient-brand);
  color: white;
  font-size: 0.68rem; font-weight: 700;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  min-width: 20px; text-align: center; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0, 0.22);
}

/* ==================== THREAD ==================== */
.thread-screen {
  display: flex; flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--ink-50);
  overflow: hidden;
}
.thread-bg {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0.75rem 0.5rem;
  background-color: var(--ink-50);
  background-image:
    linear-gradient(rgba(0,0,0, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}
.day-sep {
  text-align: center;
  margin: 0.5rem 0;
}
.day-sep span {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-soft);
  font-size: 0.72rem; font-weight: 600;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}
.msg-row { display: flex; padding: 0.12rem 0.4rem; }
.msg-row.out { justify-content: flex-end; }
.msg-bubble {
  max-width: 78%;
  padding: 0.5rem 0.7rem 0.35rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
  position: relative;
  word-wrap: break-word;
}
.msg-row.in .msg-bubble {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-row.out .msg-bubble {
  background: var(--brand-100);
  border: 1px solid var(--brand-200);
  border-bottom-right-radius: 4px;
}
.msg-text { white-space: pre-wrap; }
.msg-media-link {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--brand-700);
  font-weight: 600;
}
.msg-foot {
  display: inline-flex; align-items: center; gap: 0.2rem;
  float: right;
  margin-left: 0.65rem; margin-top: 0.2rem;
  font-size: 0.66rem; color: var(--text-soft);
}
.msg-by-bot { font-style: italic; color: var(--brand-600); font-weight: 600; }
.msg-status { color: var(--ink-400); }
.msg-status.read { color: var(--brand-500); }

.thread-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #78350f;
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid #fcd34d;
  flex-shrink: 0;
}
.thread-banner-btn {
  background: var(--ink-900); color: white; border: 0;
  padding: 0.35rem 0.75rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
}

.compose-wrap {
  padding: 0.55rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  background: white;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.45rem; align-items: flex-end;
  flex-shrink: 0;
}
.compose-input-wrap {
  flex: 1;
  background: var(--ink-50);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0.5rem 0.85rem;
  display: flex; align-items: center;
}
.compose-input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  min-height: 22px;
  max-height: 120px;
  line-height: 1.4;
  padding: 0;
  outline: none;
}
.compose-send {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white;
  border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0, 0.35);
}
.compose-send:active { transform: scale(0.94); }
.compose-send:disabled {
  background: var(--ink-200);
  box-shadow: none;
}
.compose-tpl {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand-600);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.compose-tpl:active { background: var(--brand-50); }

/* ==================== TEMPLATE PICKER ==================== */
.tpl-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9000;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.tpl-sheet {
  background: var(--ink-50);
  width: 100%; max-width: 540px;
  max-height: 85vh;
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: sheetUp 0.24s cubic-bezier(0.2,0.9,0.3,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--border);
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.tpl-sheet-head {
  padding: 0.9rem 1rem 0.55rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: white;
  border-radius: 20px 20px 0 0;
}
.tpl-sheet-title { font-weight: 700; font-size: 1rem; color: var(--ink-900); }
.tpl-sheet-close {
  background: var(--ink-100); border: 0; font-size: 1rem; color: var(--text-soft);
  cursor: pointer; width: 32px; height: 32px; border-radius: 50%;
}
.tpl-list {
  overflow-y: auto;
  padding: 0.65rem;
  display: flex; flex-direction: column; gap: 0.45rem;
}
.tpl-empty {
  padding: 2rem 1rem; text-align: center; color: var(--text-soft);
  font-size: 0.88rem; line-height: 1.5;
}
.tpl-row {
  text-align: left;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 0.3rem;
  box-shadow: var(--shadow-soft);
}
.tpl-row:active { background: var(--brand-50); border-color: var(--brand-200); }
.tpl-row-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.tpl-row-name { font-weight: 700; font-size: 0.92rem; }
.tpl-row-tag {
  font-size: 0.7rem; color: var(--brand-700);
  background: var(--brand-50); padding: 0.12rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--brand-100);
}
.tpl-row-body {
  font-size: 0.82rem; color: var(--text-soft);
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.tpl-form {
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.tpl-form-head { display: flex; justify-content: space-between; align-items: center; }
.tpl-back {
  background: transparent; border: 0; color: var(--brand-600);
  font-size: 0.9rem; cursor: pointer; padding: 0; font-weight: 600;
}
.tpl-name { font-weight: 700; font-size: 1.05rem; margin: 0.2rem 0 0.4rem; }
.tpl-vars { display: flex; flex-direction: column; gap: 0.5rem; }
.tpl-var { display: flex; flex-direction: column; gap: 0.2rem; }
.tpl-var span { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.tpl-var input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  background: white;
}
.tpl-var input:focus { outline: 2px solid var(--brand-400); outline-offset: -2px; }
.tpl-preview-label {
  font-size: 0.75rem; color: var(--text-soft); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 0.4rem;
}
.tpl-preview {
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-size: 0.9rem; line-height: 1.4;
  white-space: pre-wrap;
}
.tpl-send {
  background: var(--gradient-brand);
  color: white;
  border: 0;
  padding: 0.85rem;
  border-radius: 999px;
  font-weight: 700; font-size: 0.95rem;
  cursor: pointer;
  margin-top: 0.4rem;
  box-shadow: 0 8px 28px -6px rgba(0,0,0,0.5);
}
.tpl-send:disabled { background: var(--ink-200); box-shadow: none; cursor: not-allowed; }

/* ==================== STATES ==================== */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-soft);
  flex: 1;
}
.empty-icon {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--gradient-brand-soft);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  border: 1px solid var(--brand-100);
}
.empty-title { font-weight: 700; color: var(--text); margin-bottom: 0.3rem; font-size: 1.05rem; }
.empty-desc { font-size: 0.88rem; max-width: 280px; line-height: 1.55; }

/* ==================== TOAST ==================== */
.toast {
  position: fixed; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: white;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.25);
  z-index: 9999;
  animation: toastIn 0.25s ease;
  max-width: 90vw;
  text-align: center;
  line-height: 1.35;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--gradient-brand); }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ==================== DRAWER ==================== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 100;
  animation: fade 0.15s ease;
}
.drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 101;
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: slideUp 0.2s ease;
  max-height: 80vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.drawer-handle {
  width: 36px; height: 4px;
  background: var(--ink-300);
  border-radius: 2px;
  margin: 0.6rem auto 0.4rem;
}
.drawer h2 { font-size: 1.1rem; margin: 0.5rem 1rem 0.8rem; color: var(--ink-900); }
.drawer-row {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border);
  width: 100%;
  background: transparent; border-left: 0; border-right: 0; border-bottom: 0;
  text-align: left; font: inherit;
}
.drawer-row:active { background: var(--ink-50); }
.drawer-row-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.drawer-row-text { flex: 1; }
.drawer-row-label { font-weight: 600; font-size: 0.93rem; }
.drawer-row-desc { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.1rem; }
.drawer-row.danger .drawer-row-icon { background: #ffe4e6; color: var(--danger); }
.drawer-row.danger .drawer-row-label { color: var(--danger); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ==================== UTILS ==================== */
.spin { animation: spin 0.8s linear infinite; }
.scroll-y { flex: 1; overflow-y: auto; }
.app-root {
  display: flex; flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
@supports (height: 100dvh) { .app-root { height: 100dvh; } }
.app-root > * { flex: 1; min-height: 0; }
.app-root.has-bottom-nav .shell-main {
  padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

.inbox-foot {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-soft);
  padding: 1.25rem 1rem 1.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.conv-row-wrap { background: var(--surface); }

/* ==================== BOTTOM NAV ==================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr 84px 1fr 1fr;
  align-items: center;
  padding: 0 0.25rem 0;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.06);
  min-height: 64px;
  overflow: visible;
}
.nav-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.15rem;
  padding: 0.45rem 0.25rem 0.5rem;
  background: transparent;
  border: none;
  color: #9ca3af; /* gris si inactif */
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.nav-tab span { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.01em; }
.nav-tab svg { width: 24px; height: 24px; }
.nav-tab:active { opacity: 0.65; }
.nav-tab.active { color: #ee0111; } /* rouge Helvia si actif */
.nav-tab.active svg { stroke-width: 2.2; }

.nav-fab {
  width: 62px; height: 62px;
  margin: 0 auto;
  position: relative;
  top: -22px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white;
  border: 4px solid white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-fab:active { transform: scale(0.92); }
.nav-fab svg { width: 24px; height: 24px; }
.nav-fab-wrap {
  display: flex; flex-direction: column; align-items: center;
  min-width: 0;
}
.nav-fab-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-top: -14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  animation: fab-label-in 0.22s ease;
}
@keyframes fab-label-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nav-fab {
  animation: fab-morph 0.28s cubic-bezier(.34,1.56,.64,1);
}
@keyframes fab-morph {
  0%   { transform: scale(0.7) rotate(-30deg); opacity: 0.6; }
  60%  { transform: scale(1.08) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.fab-conversations { background: linear-gradient(135deg, #2a2a2a 0%, #050505 100%); }
.fab-calls         { background: linear-gradient(135deg, #1f4d3a 0%, #0f2a20 100%); }
.fab-contacts      { background: linear-gradient(135deg, #2a3550 0%, #0e1726 100%); }
.fab-account       { background: var(--gradient-brand); }

/* ==================== DIALER ==================== */
.dialer-wrap {
  display: flex; flex-direction: column;
  padding: 1rem 1.25rem 1.5rem;
  gap: 1rem;
}
.dialer-display {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  min-height: 64px;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.dialer-num {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.dialer-placeholder { color: var(--text-mute); font-weight: 400; font-size: 1.05rem; }
.dialer-back {
  background: transparent; border: 0;
  font-size: 1.5rem; color: var(--text-soft);
  padding: 0.5rem 0.75rem;
}
.dialer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  flex: 1;
  align-content: center;
}
.dialer-key {
  aspect-ratio: 1.4 / 1;
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform 0.1s, background 0.15s;
}
.dialer-key:active { transform: scale(0.95); background: var(--ink-100); }
.dialer-actions { display: flex; justify-content: center; padding-top: 0.5rem; }
.dialer-call {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  background: #10b981;
  color: white; border: 0;
  padding: 0.95rem 2.5rem;
  border-radius: 999px;
  font-size: 1rem; font-weight: 600;
  box-shadow: 0 8px 24px -6px rgba(16,185,129,0.5);
}
.dialer-call:disabled { background: var(--ink-300); box-shadow: none; }
.dialer-call svg { width: 18px; height: 18px; }

/* ==================== FORMS ==================== */
.form-field { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 0.4rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border 0.15s, box-shadow 0.15s;
}
.form-input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,0.08); }
.btn-block { width: 100%; }

/* ==================== STATUT ==================== */
.status-wrap { padding: 0.85rem 0.85rem 1.25rem; background: var(--ink-50); }
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}
.status-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem 0.85rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}
.status-card-val {
  font-size: 1.7rem; font-weight: 800; line-height: 1;
  color: var(--primary);
}
.status-card-lbl { font-size: 0.74rem; color: var(--text-soft); margin-top: 0.4rem; line-height: 1.3; }

.status-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.25rem;
}
.status-row {
  display: flex; align-items: center; gap: 0.7rem;
  background: white;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  margin-bottom: 0.35rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}
.status-row-main { flex: 1; min-width: 0; }
.status-row-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row-prev { font-size: 0.78rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row-time { font-size: 0.72rem; color: var(--text-soft); }
.status-empty {
  background: white;
  padding: 1.5rem 1rem;
  text-align: center;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-size: 0.88rem;
  border: 1px solid var(--border);
}
.status-line-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(0,0,0, 0.12);
  flex-shrink: 0;
  margin: 0 0.35rem;
}

/* ==================== SETTINGS ==================== */
.settings-profile {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1rem;
  background: white;
  border-bottom: 1px solid var(--border);
}
.settings-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 24px rgba(0,0,0, 0.2);
}
.settings-profile-info { flex: 1; min-width: 0; }
.settings-name { font-weight: 700; font-size: 1.05rem; }
.settings-mail { font-size: 0.85rem; color: var(--text-soft); }
.settings-group {
  background: white;
  margin-top: 0.65rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.settings-foot {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-mute);
  padding: 2rem 1rem;
}

/* ==================== FILTERS & CHANNELS ==================== */
.filter-bar {
  display: flex; gap: 0.4rem;
  padding: 0 0.85rem 0.65rem;
  overflow-x: auto;
  background: var(--ink-50);
  border-bottom: 1px solid var(--border);
}
.filter-pill {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font: inherit; font-size: 0.78rem; font-weight: 600;
}
.filter-pill.active {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
}
.conv-channel {
  display: inline-block;
  font-size: 0.62rem; font-weight: 700;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.conv-channel.ch-wa { background: #dcfce7; color: #166534; }
.conv-channel.ch-widget { background: var(--ink-100); color: var(--secondary); }
.conv-channel.ch-msg { background: #e0f2fe; color: #0369a1; }

/* ==================== APPELS ==================== */
.calls-list { padding: 0.25rem 0; }
.call-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-bottom: 1px solid var(--border);
  background: white;
}
.call-row-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--brand-50); color: var(--primary);
}
.call-row-icon.inbound { background: #ecfdf5; color: var(--success); }
.call-row-icon.outbound { background: var(--ink-100); color: var(--secondary); }
.call-row-icon.missed { background: #fef2f2; color: #dc2626; }
.call-row-main { flex: 1; min-width: 0; }
.call-row-name { font-weight: 600; font-size: 0.92rem; }
.call-row-meta { font-size: 0.76rem; color: var(--text-soft); margin-top: 0.15rem; }
.call-row-side { text-align: right; flex-shrink: 0; }
.call-row-time { font-size: 0.72rem; color: var(--text-soft); }
.call-row-vm {
  display: inline-block; margin-top: 0.2rem;
  font-size: 0.72rem; font-weight: 700; color: var(--brand-600);
  text-decoration: none;
}

/* ==================== CONTACTS ==================== */
.section-label {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-mute);
  padding: 0.75rem 0.95rem 0.35rem;
}
.contacts-list { padding-bottom: 1rem; }
.contact-row {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; text-align: left;
  padding: 0.7rem 0.95rem;
  border: none; border-bottom: 1px solid var(--border);
  background: white; font: inherit;
}
.contact-row:active:not(:disabled) { background: var(--brand-50); }
.contact-row:disabled { opacity: 0.85; cursor: default; }
.contact-row-main { flex: 1; min-width: 0; }
.contact-row-name { font-weight: 600; font-size: 0.92rem; }
.contact-row-sub { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-fav-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--ink-300); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.contact-fav-btn:active { background: var(--ink-100); }
.contact-fav-btn.on { color: #f59e0b; }

/* ==================== COMPTE ==================== */
.account-stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.account-stat-row strong { color: var(--brand-700); }

/* ==================== ACTIONS SHEET ==================== */
.action-sheet {
  background: white;
  width: 100%; max-width: 540px;
  border-radius: 20px 20px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: sheetUp 0.24s cubic-bezier(0.2,0.9,0.3,1);
}
.action-sheet-head {
  padding: 0.9rem 1rem 0.55rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.action-row {
  width: 100%; display: flex; align-items: center; gap: 0.85rem;
  padding: 0.95rem 1rem;
  border: none; border-bottom: 1px solid var(--border);
  background: white; text-align: left; font: inherit;
}
.action-row:active { background: var(--ink-50); }
.action-row-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--gradient-brand-soft);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.action-row-text { flex: 1; }
.action-row-label { font-weight: 700; font-size: 0.95rem; }
.action-row-desc { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.12rem; }

.thread-readonly-banner {
  padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: var(--brand-50);
  border-top: 1px solid var(--brand-100);
  color: var(--brand-800);
  font-size: 0.78rem; line-height: 1.45; text-align: center;
}

/* ==================== AUTH SPLASH (Helvia Red) ==================== */
.auth-splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
  background: #ee0111;
  background: radial-gradient(ellipse at top, #ff2a3a 0%, #ee0111 45%, #c9000e 100%);
  overflow: hidden;
}
.auth-splash-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.10), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0,0,0,0.18), transparent 50%);
  pointer-events: none;
}
.auth-splash-inner {
  position: relative;
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center;
  animation: splashFadeIn 0.6s ease-out;
}
@keyframes splashFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-splash-logo {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  animation: splashFloat 3.2s ease-in-out infinite;
}
@keyframes splashFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
.auth-splash-cross {
  display: flex; align-items: center; justify-content: center;
  color: white;
  background: transparent;
  border: 0;
}
.auth-splash-cross svg,
.auth-splash-cross img {
  width: 150px; height: 150px;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,0.3));
}
.auth-splash-tagline {
  color: rgba(255,255,255,0.82);
  font-size: 0.95rem;
  text-align: center;
  margin: 0 0 1.75rem;
  line-height: 1.45;
}
.auth-splash-tagline strong { color: white; font-weight: 700; }

.auth-splash-form {
  width: 100%;
  display: flex; flex-direction: column; gap: 0.8rem;
}
.auth-splash-input {
  width: 100%;
  padding: 0.95rem 1.05rem;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 14px;
  font-size: 16px; /* iOS no-zoom */
  font-family: inherit;
  color: white;
  outline: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
}
.auth-splash-input::placeholder { color: rgba(255,255,255,0.55); }
.auth-splash-input:focus {
  border-color: white;
  background: rgba(255,255,255,0.22);
}
.auth-splash-code {
  text-align: center;
  letter-spacing: 0.55em;
  font-size: 1.5rem !important;
  font-weight: 700;
  padding-left: 1.05rem; padding-right: 0.5rem;
}

.auth-splash-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.95rem 1rem;
  background: white;
  color: #c9000e;
  border: 0;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(0,0,0,0.25);
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}
.auth-splash-btn:active { transform: scale(0.98); }
.auth-splash-btn:disabled {
  background: rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.6);
  box-shadow: none;
  cursor: not-allowed;
}
.auth-splash-spinner {
  width: 1.1rem; height: 1.1rem;
  border: 2.5px solid rgba(201,0,14,0.25);
  border-top-color: #c9000e;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.auth-splash-link {
  background: transparent; border: 0;
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.4rem;
}
.auth-splash-error {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
}
.auth-splash-foot {
  margin-top: 2rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.auth-splash-foot:hover { opacity: 0.8; }
.auth-splash-wordmark-img {
  height: 14px;
  width: auto;
  display: block;
}

/* ==================== SLIDE TRANSITION ==================== */
.slide-in {
  animation: slideInRight 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes slideInRight {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* Cliquable */
.call-row {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.call-row:hover { background: rgba(0,0,0,0.025); }
.call-row:active { background: rgba(0,0,0,0.06); }

.call-row-vm-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ee0111;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(238,1,17,0.18);
  margin-top: 6px;
}

/* ==================== CALL DETAIL ==================== */
.call-detail {
  padding: 0 1rem 2rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.call-detail-hero {
  margin: 1rem 0 0.25rem;
  padding: 1.5rem 1rem 1.5rem;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  text-align: center;
}
.call-detail-iconbig {
  width: 72px; height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  background: linear-gradient(135deg, #4b5563, #1f2937);
  box-shadow: 0 10px 28px -8px rgba(0,0,0,0.3);
}
.call-detail-iconbig svg { width: 30px; height: 30px; }
.call-detail-hero.inbound .call-detail-iconbig { background: linear-gradient(135deg, #10b981, #047857); box-shadow: 0 10px 28px -8px rgba(16,185,129,0.45); }
.call-detail-hero.outbound .call-detail-iconbig { background: linear-gradient(135deg, #3b82f6, #1d4ed8); box-shadow: 0 10px 28px -8px rgba(59,130,246,0.45); }
.call-detail-hero.missed .call-detail-iconbig { background: linear-gradient(135deg, #ff2a3a, #c9000e); box-shadow: 0 10px 28px -8px rgba(238,1,17,0.5); }
.call-detail-peer {
  font-size: 1.35rem; font-weight: 700; color: var(--text);
  letter-spacing: 0.01em;
}
.call-detail-dir {
  margin-top: 0.35rem;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.call-detail-date {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-mute);
}

.call-detail-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow-soft);
}
.call-detail-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 0.65rem;
}
.call-detail-rows { display: flex; flex-direction: column; }
.call-detail-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--ink-100);
  font-size: 0.92rem;
}
.call-detail-row:last-child { border-bottom: 0; }
.call-detail-row span { color: var(--text-soft); }
.call-detail-row strong { color: var(--text); font-weight: 600; text-align: right; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-detail-row .mono { font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: 0.78rem; }
.call-detail-transcript {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

/* ==================== AUDIO PLAYER ==================== */
.audio-player {
  background: linear-gradient(135deg, #1f1f1f 0%, #0a0a0a 100%);
  border-radius: 16px;
  padding: 0.95rem 0.95rem 0.85rem;
  color: white;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.45);
}
.ap-top { display: flex; align-items: center; gap: 0.85rem; }
.ap-play {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 0;
  background: #ee0111;
  color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: 0 8px 22px -4px rgba(238,1,17,0.55);
  transition: transform 0.12s, background 0.15s;
}
.ap-play:active { transform: scale(0.94); background: #c9000e; }
.ap-play svg { width: 22px; height: 22px; }
.ap-info { flex: 1; min-width: 0; }
.ap-times {
  display: flex; justify-content: space-between;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.4rem;
}
.ap-progress {
  position: relative;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  cursor: pointer;
  overflow: visible;
}
.ap-progress-bar {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #ff3d4d, #ee0111);
  border-radius: 999px;
  transition: width 0.08s linear;
}
.ap-progress-thumb {
  position: absolute; top: 50%;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 3px rgba(238,1,17,0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.08s linear;
}
.ap-actions {
  margin-top: 0.85rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.ap-action {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.ap-action:active { background: rgba(255,255,255,0.18); }
.ap-action svg { width: 16px; height: 16px; }
.ap-dl { padding: 0.4rem; }
.ap-speeds {
  display: flex; gap: 0.25rem;
  background: rgba(255,255,255,0.06);
  padding: 0.2rem;
  border-radius: 999px;
}
.ap-speed {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.65);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.ap-speed.on { background: white; color: #0a0a0a; }

/* ==================== SEGMENTED CONTROL ==================== */
.seg-wrap {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.85rem 0.65rem;
}
.seg-control {
  display: flex;
  background: var(--ink-100);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.3rem;
  background: transparent;
  border: 0;
  padding: 0.5rem 0.4rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg-btn svg { width: 14px; height: 14px; }
.seg-btn:hover { color: #374151; }
.seg-btn.on {
  background: white;
  color: #ee0111;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.02);
}
.seg-btn.on svg { color: #ee0111; }

/* ==================== CALL ROW — directions ==================== */
.call-row { position: relative; }
.call-row::before {
  content: '';
  position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  opacity: 0; transition: opacity 0.15s;
}
.call-row.dir-inbound::before { background: #10b981; opacity: 1; }
.call-row.dir-outbound::before { background: #3b82f6; opacity: 1; }
.call-row.dir-missed::before { background: #ee0111; opacity: 1; }

.call-row-icon {
  position: relative;
}
.call-row-icon.inbound { background: rgba(16,185,129,0.12); color: #047857; }
.call-row-icon.outbound { background: rgba(59,130,246,0.12); color: #1d4ed8; }
.call-row-icon.missed { background: rgba(238,1,17,0.12); color: #c9000e; }

.call-row-name-text.missed { color: #c9000e; }

.call-row-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0 0.45rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.call-row-meta-sep::before { content: '·'; margin-right: 0.45rem; opacity: 0.5; }
.call-row-dir {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.6;
}
.tag-inbound { background: rgba(16,185,129,0.13); color: #047857; }
.tag-outbound { background: rgba(59,130,246,0.13); color: #1d4ed8; }
.tag-missed { background: rgba(238,1,17,0.13); color: #c9000e; }
