/* =============================================================================
 * birdtext — BrassHelm Company OS skin
 * Personal SMS / voicemail platform for Cameron
 *
 * Visual language matches app.brasshelm.com (company-os theme.css):
 * light #f6f6f8 canvas, white surfaces, Inter, purple #7c3aed accent,
 * soft borders, 8-14px radii, restrained shadows.
 * ========================================================================== */

:root {
  /* --- Canvas + surfaces (company-os: --bg / --surface) ------------------ */
  --paper:       #f6f6f8;   /* app background */
  --paper-alt:   #ffffff;   /* panels / cards / surface */
  --paper-deep:  #f1f1f4;   /* hover surfaces */
  --paper-dark:  #e9e9ee;   /* pressed / active surfaces */
  --rule:        #e9e9ee;   /* standard borders */
  --rule-soft:   #f0f0f3;   /* even softer rules */
  --rule-strong: #dcdce3;   /* border-strong (inputs, buttons) */

  /* --- Ink (company-os: --text / --muted / --faint) ----------------------- */
  --ink:         #18181b;   /* primary text */
  --ink-2:       #27272e;   /* secondary text */
  --ink-3:       #71717a;   /* tertiary / meta text */
  --ink-4:       #a1a1aa;   /* placeholders, disabled */

  /* --- Accent (company-os purple) ----------------------------------------- */
  --brass:       #7c3aed;   /* primary actions, active states */
  --brass-hot:   #6d28d9;   /* hover on accent */
  --brass-deep:  #6d28d9;   /* pressed / accent text */
  --brass-soft:  #ddd0fb;   /* accent borders */
  --brass-wash:  #f1ecfe;   /* accent-soft backgrounds */

  /* --- Functional colors (company-os green/amber/red) --------------------- */
  --oxblood:     #dc2626;   /* danger, destructive */
  --oxblood-hot: #b91c1c;
  --oxblood-soft:#fde8e8;
  --moss:        #0f9d6b;   /* success, call-connected */
  --moss-hot:    #0c8a5e;
  --moss-soft:   #e7f7f0;
  --amber:       #b45309;   /* notes, warnings */
  --amber-soft:  #fdf0dc;
  --sky:         #7c3aed;   /* informational -> folded into accent */
  --sky-soft:    #f1ecfe;

  /* --- Type system: Inter everywhere, tabular numerals for figures -------- */
  --font-display:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-sans:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* --- Geometry (company-os: --r 8 / --r-md 10 / --r-lg 14) --------------- */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --hairline: 1px;
  --thick-rule: 1px;

  /* --- Shadows (company-os shadow-sm / shadow-md) -------------------------- */
  --shadow-press: 0 0 0 0 transparent;
  --shadow-lift:  0 1px 2px rgba(24, 24, 27, 0.06);
  --shadow-stamp: 0 6px 24px rgba(24, 24, 27, 0.10);
}

/* =============================================================================
 * Reset + base
 * ========================================================================== */

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

* { text-shadow: none; }

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
}

a { color: var(--brass); text-decoration: none; }
a:hover { color: var(--brass-deep); text-decoration: underline; }

::selection {
  background: var(--brass-wash);
  color: var(--ink);
}

/* =============================================================================
 * Global layout
 *
 * White sidebar panel (conversation list) beside a soft-gray chat canvas,
 * matching the company-os shell: white shell-sidebar, --bg content.
 * ========================================================================== */

.app-container {
  display: flex;
  height: 100vh;
  max-height: 100vh;
}

.sidebar {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--paper-alt);
  border-right: var(--hairline) solid var(--rule);
  overflow: hidden;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  overflow: hidden;
}

/* =============================================================================
 * Sidebar header + masthead
 *
 * Matches the company-os nav-brand: purple rounded brand mark + name + sub.
 * ========================================================================== */

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: var(--hairline) solid var(--rule);
  background: var(--paper-alt);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  text-align: left;
  padding: 0 0 16px;
  border-bottom: var(--hairline) solid var(--rule);
  margin-bottom: 16px;
  position: relative;
}

.masthead::before {
  content: "B";
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brass);
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
  font-weight: 700;
  font-size: 15px;
}

.masthead-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
  user-select: none;
}

.masthead-title span { color: var(--ink); }

.masthead-sub {
  font-size: 12.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  margin-top: 1px;
}

/* User info bar, sitting below the masthead */
.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.user-avatar { display: none; }

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s ease;
  user-select: none;
}

.user-name:hover  { color: var(--brass-deep); }
.user-name:active { color: var(--brass); }

.user-status {
  font-size: 11.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--moss);
  margin-top: 2px;
}
.user-status::before {
  content: "●";
  color: var(--moss);
  font-size: 8px;
  vertical-align: 1px;
  margin-right: 5px;
}

.privacy-toggle-btn {
  width: 32px;
  height: 32px;
  border: var(--hairline) solid var(--rule-strong);
  background: var(--paper-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.privacy-toggle-btn:hover {
  background: #fafafb;
  border-color: var(--ink-4);
}

.privacy-toggle-btn .privacy-icon {
  width: 16px;
  height: 16px;
  color: var(--ink-3);
}

.logout-btn {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
}

.logout-btn:hover {
  background: var(--oxblood-soft);
  border-color: transparent;
  color: var(--oxblood);
}

/* Search + buttons row */
.search-new-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-bar {
  width: 100%;
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-bar::placeholder {
  color: var(--ink-4);
  font-style: normal;
}
.search-bar:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-wash);
}

.button-row {
  display: flex;
  gap: 6px;
}

.new-message-btn {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
  white-space: nowrap;
}

.new-message-btn:hover {
  background: #fafafb;
  border-color: var(--ink-4);
  color: var(--ink);
}

/* =============================================================================
 * Conversation list
 * ========================================================================== */

.conversations {
  flex: 1;
  overflow-y: auto;
  background: var(--paper-alt);
}

.conversation-item {
  padding: 13px 20px;
  border-bottom: var(--hairline) solid var(--rule-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
}

.conversation-item:hover {
  background: #fafafb;
}

.conversation-item.active {
  background: var(--brass-wash);
}

.conversation-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--brass);
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
  /* Override JS-injected inline colors: uniform accent-soft mark,
   * matching the company-os brand-mark treatment. */
  background: var(--brass-wash) !important;
  color: var(--brass-deep) !important;
  filter: none;
}

.conversation-details {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.contact-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-time {
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  flex-shrink: 0;
}

.last-message {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* Unread emphasis (if .unread class gets applied) */
.conversation-item.unread .contact-name { color: var(--ink); }
.conversation-item.unread .last-message {
  color: var(--ink);
  font-weight: 600;
}

.conversation-item .unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brass);
  flex-shrink: 0;
  box-shadow: none;
}

/* =============================================================================
 * Chat area: header, messages, input
 * ========================================================================== */

.chat-header {
  padding: 18px 28px;
  border-bottom: var(--hairline) solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper-alt);
}

.chat-header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.chat-header-name {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.chat-header-phone {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.15s ease;
  user-select: none;
}

.chat-header-phone::before { content: "· "; color: var(--rule-strong); }
.chat-header-phone:hover { color: var(--brass); }

.delete-conversation-btn {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.delete-conversation-btn:hover {
  background: var(--oxblood-soft);
  border-color: transparent;
  color: var(--oxblood);
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--paper);
}

/* =============================================================================
 * Message bubbles — soft cards
 *
 * Inbound: white surface with a soft border.
 * Outbound: accent-soft purple with an accent-tinted border.
 * ========================================================================== */

.message {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.outbound {
  align-self: flex-end;
  align-items: flex-end;
}

.message.inbound {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  font-family: var(--font-sans);
  color: var(--ink);
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: var(--shadow-lift);
}

.message.inbound .message-bubble {
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule);
}

.message.outbound .message-bubble {
  background: var(--brass-wash);
  border: var(--hairline) solid var(--brass-soft);
}

/* Notes — amber ink, like a margin annotation */
.message.note {
  align-self: flex-end;
  align-items: flex-end;
}
.message.note .message-bubble {
  background: var(--amber-soft);
  border: var(--hairline) solid #f5dcae;
  color: var(--ink);
  font-style: normal;
}
.message.note .message-bubble::before {
  content: "Note";
  display: inline-block;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber);
  margin-right: 8px;
}

/* Inline verification code chip — a tappable badge inside the message bubble
 * that copies the code to the clipboard on click. */
.verification-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  color: var(--brass-deep);
  background: var(--brass-wash);
  border: var(--hairline) solid var(--brass-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: all;
  transition: all 0.15s ease;
  position: relative;
}

.verification-chip::after {
  content: "COPY";
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin-left: 12px;
  vertical-align: middle;
}

.verification-chip:hover {
  background: var(--brass-soft);
  border-color: var(--brass);
  color: var(--brass-deep);
}

.verification-chip:active {
  transform: scale(0.97);
}

/* Voicemail "listen" link inside a message bubble. */
.voicemail-link {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--brass-deep);
  text-decoration: none;
  border-bottom: 1px dashed var(--brass-soft);
  padding-bottom: 1px;
}
.voicemail-link:hover {
  color: var(--brass);
  border-bottom-style: solid;
}

.message-timestamp {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  padding: 0 4px;
}

.message.outbound .message-timestamp { color: var(--ink-4); }
.message.inbound  .message-timestamp { color: var(--ink-4); }

/* =============================================================================
 * Message input
 * ========================================================================== */

.message-input-area {
  padding: 18px 28px 20px;
  border-top: var(--hairline) solid var(--rule);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--paper-alt);
}

.message-input {
  flex: 1;
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  resize: none;
  min-height: 46px;
  max-height: 140px;
  transition: border-color 0.12s, box-shadow 0.12s;
  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.message-input::-webkit-scrollbar { display: none; }

.message-input::placeholder {
  color: var(--ink-4);
  font-style: normal;
}

.message-input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-wash);
}

.send-btn {
  width: 46px;
  height: 46px;
  background: var(--brass);
  border: var(--hairline) solid var(--brass);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow-lift);
}

.send-btn:hover:not(:disabled) {
  background: var(--brass-hot);
  border-color: var(--brass-hot);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0.5px);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: #ffffff;
}

.note-btn {
  width: 46px;
  height: 46px;
  background: var(--amber-soft);
  border: var(--hairline) solid #f0d8a8;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  flex-shrink: 0;
  margin-right: 6px;
}

.note-btn:hover:not(:disabled) {
  background: #fbe8c9;
}

.note-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.note-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--amber);
}

/* =============================================================================
 * Empty state
 * ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-3);
  text-align: center;
  padding: 40px;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  stroke: var(--brass);
  opacity: 0.5;
}

.empty-state-text {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  font-style: normal;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.empty-state-subtext {
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
}

/* =============================================================================
 * Loading spinner
 * ========================================================================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--ink-3);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.spinner {
  border: 2px solid var(--rule);
  border-top-color: var(--brass);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
  margin-right: 12px;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================================================
 * Scrollbars
 * ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-4);
  background-clip: padding-box;
}

/* =============================================================================
 * Modal overlay + card — white card, soft border, company-os shadow
 * ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: none;
}

.modal-overlay.show {
  display: flex;
  animation: overlayFade 0.18s ease;
}

@keyframes overlayFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--paper-alt);
  color: var(--ink);
  padding: 26px 28px 22px;
  max-width: 520px;
  width: 100%;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-stamp);
  animation: modalStamp 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

@keyframes modalStamp {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  margin-bottom: 18px;
  padding-bottom: 0;
  border-bottom: none;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-style: normal;
  color: var(--ink-3);
  line-height: 1.45;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 0;
  border-top: none;
}

.modal-btn {
  flex: 1;
  padding: 9px 14px;
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: all 0.12s ease;
}

.modal-btn-primary {
  background: var(--brass);
  color: #ffffff;
  border-color: var(--brass);
}
.modal-btn-primary:hover {
  background: var(--brass-hot);
  border-color: var(--brass-hot);
}
.modal-btn-primary:active {
  transform: translateY(0.5px);
}

.modal-btn-secondary {
  background: var(--paper-alt);
  color: var(--ink);
  border-color: var(--rule-strong);
}
.modal-btn-secondary:hover {
  background: #fafafb;
  border-color: var(--ink-4);
}

/* Destructive modal action (replaces the old inline red gradients) */
.modal-btn-danger {
  background: var(--oxblood-soft);
  color: var(--oxblood);
  border-color: transparent;
}
.modal-btn-danger:hover {
  background: #fbd5d5;
}

/* Warning modal action (replaces the old inline orange gradient) */
.modal-btn-warn {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: transparent;
}
.modal-btn-warn:hover {
  background: #fbe8c9;
}

/* Modal form inputs */
.modal input[type="text"],
.modal input[type="tel"],
.modal input[type="password"],
.modal textarea,
.modal select,
#createContactForm input,
#editContactForm input {
  width: 100%;
  padding: 10px 12px !important;
  background: var(--paper-alt) !important;
  border: var(--hairline) solid var(--rule-strong) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--ink) !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus,
#createContactForm input:focus,
#editContactForm input:focus {
  outline: none !important;
  border-color: var(--brass) !important;
  box-shadow: 0 0 0 3px var(--brass-wash);
}

.modal input::placeholder,
.modal textarea::placeholder,
#createContactForm input::placeholder,
#editContactForm input::placeholder {
  color: var(--ink-4) !important;
  font-style: normal;
}

.modal label,
#createContactForm label,
#editContactForm label {
  display: block !important;
  font-family: var(--font-sans) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  color: var(--ink-4) !important;
  margin-bottom: 7px !important;
  text-shadow: none !important;
}

/* Contact list inside modals */
.contact-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 16px 0;
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper-alt);
}

.contact-list-item {
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.1s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: var(--hairline) solid var(--rule-soft);
  background: transparent;
  border-radius: 0;
}
.contact-list-item:last-child { border-bottom: none; }
.contact-list-item:hover { background: #fafafb; }

.contact-list-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--brass-wash) !important;
  color: var(--brass-deep) !important;
  filter: none;
}

/* The JS-rendered contact list items have 2–3 child divs after the avatar:
 *   1st (nth-child 2): name + phone wrapper — should claim all remaining width
 *   2nd (nth-child 3): action buttons (spam/edit/delete) — fixed width, no shrink
 * We target by child position to avoid needing classes in the JS templates. */
.contact-list-item > div:nth-child(2) {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
}

.contact-list-item > div:nth-child(3) {
  flex: 0 0 auto;
  overflow: visible;
}

.contact-list-item-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-list-item-phone {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Blur-last-name span (used by privacy mode) should inherit color + be inline. */
.contact-list-item-name .blur-last-name,
.contact-name .blur-last-name {
  display: inline;
  color: inherit;
}

/* Modal tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: var(--hairline) solid var(--rule);
}

.modal-tab {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}

.modal-tab:hover { color: var(--ink); }

.modal-tab.active {
  color: var(--brass-deep);
  border-bottom-color: var(--brass);
}

/* =============================================================================
 * Toast notifications
 * ========================================================================== */

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--paper-alt);
  color: var(--ink);
  border: var(--hairline) solid var(--rule);
  border-left-width: 4px;
  border-left-color: var(--brass);
  padding: 13px 16px;
  box-shadow: var(--shadow-stamp);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastSlideIn 0.25s ease;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.toast.hiding {
  animation: toastSlideOut 0.25s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  to { opacity: 0; transform: translateX(20px); }
}

.toast.success { border-left-color: var(--moss); }
.toast.success .toast-icon { color: var(--moss); }

.toast.info { border-left-color: var(--brass); }
.toast.info .toast-icon { color: var(--brass); }

.toast.error { border-left-color: var(--oxblood); }
.toast.error .toast-icon { color: var(--oxblood); }

.toast-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content { flex: 1; }

.toast-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 2px;
  color: var(--ink);
}

.toast-message {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-3);
}

.toast-close {
  background: none;
  border: none;
  color: var(--ink-4);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.toast-close:hover { color: var(--oxblood); }

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  animation: toastProgress 4s linear forwards;
  background: var(--brass);
}

.toast.success .toast-progress { background: var(--moss); }
.toast.info    .toast-progress { background: var(--brass); }
.toast.error   .toast-progress { background: var(--oxblood); }

@keyframes toastProgress {
  to { transform: scaleX(0); }
}

/* =============================================================================
 * Phone dialer — floating panel, company-os card treatment
 * ========================================================================== */

.phone-toggle {
  position: fixed;
  right: 0;
  top: 200px;
  width: 48px;
  height: 56px;
  background: var(--brass);
  border: var(--hairline) solid var(--brass);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  box-shadow: var(--shadow-stamp);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 101;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s;
}

.phone-toggle.open { right: 200px; }

.phone-toggle:hover {
  background: var(--brass-hot);
}

.phone-toggle svg {
  width: 20px;
  height: 20px;
  fill: #ffffff;
}

.phone-sidebar {
  position: fixed;
  right: -200px;
  top: 76px;
  width: 200px;
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule);
  border-right: none;
  padding: 14px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  z-index: 100;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-stamp);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.phone-sidebar.open { right: 0; }

.phone-sidebar::before {
  content: "Dialer";
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  text-align: center;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: var(--hairline) solid var(--rule);
}

.phone-contact-selector {
  width: 100%;
  padding: 7px 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--paper-alt);
  color: var(--ink);
  cursor: pointer;
}
.phone-contact-selector:hover { border-color: var(--brass); }
.phone-contact-selector:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-wash); }
.phone-contact-selector option {
  background: var(--paper-alt);
  color: var(--ink);
}

.phone-display {
  width: 100%;
  padding: 10px 8px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--paper);
  color: var(--ink);
  min-height: 38px;
}
.phone-display::placeholder {
  color: var(--ink-4);
  font-style: normal;
}

.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.dial-btn {
  padding: 0;
  height: 44px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--paper-alt);
  color: var(--ink);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: var(--shadow-lift);
}

.dial-btn:hover {
  background: var(--brass-wash);
  border-color: var(--brass-soft);
}

.dial-btn:active {
  background: var(--brass-soft);
  transform: translateY(0.5px);
}

.call-controls {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
}

.call-btn,
.hangup-btn,
.clear-btn {
  flex: 1;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s ease;
}

.call-btn {
  background: var(--moss);
  color: #ffffff;
  border-color: var(--moss);
}
.call-btn:hover  { background: var(--moss-hot); }
.call-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hangup-btn {
  background: var(--oxblood);
  color: #ffffff;
  border-color: var(--oxblood);
}
.hangup-btn:hover { background: var(--oxblood-hot); }

.clear-btn {
  background: var(--paper-alt);
  color: var(--ink-2);
  border-color: var(--rule-strong);
}
.clear-btn:hover {
  background: #fafafb;
  border-color: var(--ink-4);
}

.call-status {
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  background: var(--paper);
  border: var(--hairline) solid var(--rule);
  border-radius: var(--radius-sm);
  min-height: 28px;
}

.call-status.calling {
  background: var(--amber-soft);
  border-color: transparent;
  color: var(--amber);
  animation: statusPulse 1.5s ease-in-out infinite;
}

.call-status.connected {
  background: var(--moss-soft);
  border-color: transparent;
  color: var(--moss);
}

.call-status.error {
  background: var(--oxblood-soft);
  border-color: transparent;
  color: var(--oxblood);
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* Pulsing animation for the main phone toggle when ringing */
@keyframes phonePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.35), 0 0 0 0 rgba(124, 58, 237, 0.45);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.35), 0 0 0 14px rgba(124, 58, 237, 0);
  }
}

.phone-ringing { animation: phonePulse 1.4s ease-in-out infinite; }

/* =============================================================================
 * AI draft modal
 * ========================================================================== */

.ai-draft-modal {
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
}

.ai-draft-form {
  margin-bottom: 20px;
}

.ai-draft-form .form-group {
  margin-bottom: 16px;
}

.ai-draft-form label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  margin-bottom: 6px;
}

.ai-draft-form input,
.ai-draft-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.ai-draft-form input::placeholder,
.ai-draft-form textarea::placeholder {
  color: var(--ink-4);
  font-style: normal;
}

.ai-draft-form input:focus,
.ai-draft-form textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-wash);
}

.ai-draft-form textarea {
  resize: vertical;
  min-height: 70px;
  font-family: var(--font-sans);
}

.ai-draft-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--ink-3);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.ai-draft-results { margin-top: 20px; }

.ai-draft-results-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
  margin-bottom: 12px;
}

.ai-draft-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.ai-draft-card {
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.12s ease;
  box-shadow: var(--shadow-lift);
}

.ai-draft-card:hover {
  background: var(--brass-wash);
  border-left-color: var(--brass-hot);
}

.ai-draft-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-draft-card-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brass-deep);
}

.ai-draft-card-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-4);
}

.ai-draft-card-text {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

.ai-draft-refinement {
  padding-top: 16px;
  border-top: var(--hairline) solid var(--rule);
}

.ai-draft-refinement .form-group { margin-bottom: 10px; }

.ai-draft-refinement input {
  width: 100%;
  padding: 10px 12px;
  background: var(--paper-alt);
  border: var(--hairline) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.ai-draft-refinement input::placeholder {
  color: var(--ink-4);
  font-style: normal;
}

.ai-draft-refinement input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-wash);
}

/* =============================================================================
 * Privacy mode — no special styles needed, JS swaps text content
 * ========================================================================== */
body.privacy-mode .privacy-icon-visible { display: none !important; }
body.privacy-mode .privacy-icon-hidden  { display: block !important; }

/* =============================================================================
 * Responsive: narrow the sidebar on small screens
 * ========================================================================== */

@media (max-width: 860px) {
  .sidebar { width: 340px; }
  .messages-container { padding: 22px 20px; }
  .chat-header { padding: 16px 20px; }
  .message-input-area { padding: 16px 20px 18px; }
}

@media (max-width: 640px) {
  .sidebar { width: 100%; border-right: none; }
  .chat-area { display: none; }
  .app-container.has-selection .sidebar { display: none; }
  .app-container.has-selection .chat-area { display: flex; }
}
