/* IQ Meet – mobile-first, high contrast */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --error: #f87171;
  --success: #4ade80;
  --voice-recording: #fb7185;
  --voice-recording-deep: #e11d48;
  --contact-card-accent: var(--primary);
  --contact-card-accent-selected: #fcd34d;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* One “screen” at a time in the scan flow (native app–style), not stacked cards */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.scan-flow {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 1 auto;
}

/* Form / success need remaining height for scroll; camera + scanning stay content-height */
.app--scan-screen-form .scan-flow,
.app--scan-screen-success .scan-flow {
  flex: 1 1 auto;
}

.scan-flow > .screen-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
  flex: 0 1 auto;
}

.scan-flow > #form-section.screen-panel:not(.hidden),
.scan-flow > #success-section.screen-panel:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
}

.screen-panel-title {
  flex-shrink: 0;
  margin: 0 0 0.75rem;
  padding: 0 0 0.65rem;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  border-bottom: 1px solid rgba(51, 65, 85, 0.85);
}

.screen-panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen-panel-body--scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-right: 0.15rem;
  margin-right: -0.15rem;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

.screen-panel-body--center {
  flex: 0 1 auto;
  justify-content: center;
}

.screen-panel-body--camera {
  flex: 0 1 auto;
}

/* Do not flex-grow the holder: extra height leaves empty black on iOS when <video> height:100% fails */
.screen-panel-body--camera .video-wrap {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-height: min(56dvh, 480px);
}

.screen-panel-body--camera .actions {
  flex-shrink: 0;
}

.screen-panel-body--camera #camera-error {
  flex-shrink: 0;
}

/* Off the camera step, drop the global slogan so each screen reads as its own page */
.app--scan-screen-camera .header-slogan {
  display: block;
}

.app--scan-screen-scanning .header-slogan,
.app--scan-screen-form .header-slogan,
.app--scan-screen-success .header-slogan {
  display: none;
}

.app--scan-screen-scanning .header,
.app--scan-screen-form .header,
.app--scan-screen-success .header {
  padding-bottom: 0.35rem;
}

.success-feedback-block {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid #334155;
  text-align: center;
}

.success-feedback-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.success-feedback-btn {
  display: inline-flex;
}

.header {
  text-align: center;
  padding: 0.5rem 0 1.5rem;
  margin-top: -0.5rem;
  flex-shrink: 0;
}

.header-title {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.header-slogan {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
  white-space: nowrap;
}


.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.scan-flow .screen-panel {
  margin-bottom: 0;
}

.panel.hidden,
.hidden {
  display: none;
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  max-height: min(50vh, 420px);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#canvas {
  display: none;
}

.actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.actions .btn {
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--muted);
}

.btn-secondary:hover {
  background: #334155;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* Extra scroll padding above bottom nav for primary actions inside scrollable screens */
.screen-panel-body--scroll .form-actions {
  margin-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  padding-bottom: 0.5rem;
}

/* Top logo: full width, safe spacing so it’s not cut off on mobile */
/* Top bar: logo + auth button top right */
.app-top-bar {
  position: relative;
  flex-shrink: 0;
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
  margin-left: -1rem;
  margin-right: -1rem;
  width: calc(100% + 2rem);
}

.app-top-bar .app-top-logo {
  padding-bottom: 1rem;
  margin-left: 0;
  margin-right: 0;
  width: 100%;
  text-align: center;
}

.btn-auth {
  font-size: 0.9rem;
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--muted);
}

.btn-auth:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* Login modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + 5rem + env(safe-area-inset-bottom, 0px));
}

.modal.hidden {
  display: none;
}

/* Above bottom nav (1100) so confirm / blockers capture full screen */
.modal.modal--stack-top {
  z-index: 1200;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
}

.modal-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--text);
}

.modal .form-actions {
  margin-bottom: 0;
}

.logout-confirm-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.logout-confirm-actions {
  margin-bottom: 0;
  margin-top: 0.25rem;
}

/* Contacts list modal */
.contacts-modal-content {
  max-width: min(100%, 420px);
  max-height: min(90vh, 640px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

.contacts-modal-content .modal-title {
  flex-shrink: 0;
}

.contacts-modal-status {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
  min-height: 1.25em;
}

.contacts-modal-status.contacts-modal-status--error {
  color: var(--error);
}

.contacts-modal-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.contacts-search {
  flex-shrink: 0;
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.55);
}

.contacts-search-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.contacts-search-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.contacts-search-input {
  flex: 1 1 140px;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #475569;
  border-radius: 8px;
}

.contacts-search-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.contacts-search-submit {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

.contacts-search-actions .contacts-search-clear {
  flex: 0 0 auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.contacts-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem 0.5rem;
}

/* Contacts pager: thumb-friendly, horizontal scroll for many page buttons on narrow screens */
.contacts-pagination {
  flex-shrink: 0;
  margin: 0.35rem 0 0;
  padding: 0.4rem 0 0;
  border-top: 1px solid rgba(51, 65, 85, 0.65);
}

.contacts-pagination-range {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.02em;
}

.contacts-pagination-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.contacts-pagination--single-page .contacts-pagination-bar {
  display: none;
}

.contacts-pagination-pages {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 0;
  scrollbar-width: thin;
}

.contacts-pagination-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  color: var(--text);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid #475569;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.contacts-pagination-btn--nav {
  min-width: 2.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  padding-bottom: 0.1rem;
}

.contacts-pagination-btn--page {
  min-width: 2.5rem;
  padding: 0 0.35rem;
}

.contacts-pagination-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-hover);
}

.contacts-pagination-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.contacts-pagination-btn.is-active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--primary);
  color: var(--primary);
  cursor: default;
}

.contacts-pagination-ellipsis {
  flex-shrink: 0;
  padding: 0 0.15rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.contacts-modal-actions {
  flex-shrink: 0;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #334155;
  margin-bottom: 0;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.profile-modal-scroll #profile-modal-editor {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.25rem;
}

.profile-modal-hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.profile-modal-actions {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.profile-add-phone-btn {
  margin-top: 0.5rem;
}

/* Saved contacts: business-card style list items */
.contact-list-card {
  margin-bottom: 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(51, 65, 85, 0.95);
  border-left: 3px solid var(--contact-card-accent);
  background: linear-gradient(165deg, #1b2639 0%, #141c2b 55%, #121a28 100%);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  transition: border-left-color 0.2s ease;
}

/* Expanded contact = selected: distinct left accent (cyan default, amber when open) */
.contact-list-card:has(.contact-list-card-details[open]) {
  border-left-color: var(--contact-card-accent-selected);
}

.contacts-list .contact-list-card--paged {
  margin-bottom: 0.5rem;
}

.contact-list-card:last-child {
  margin-bottom: 0;
}

/* Collapsible row: tap summary to expand full details (mobile-friendly density) */
.contact-list-card-details {
  margin: 0;
}

.contact-list-card-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  min-height: 2.75rem;
  -webkit-tap-highlight-color: transparent;
}

.contact-list-card-summary::-webkit-details-marker {
  display: none;
}

.contact-list-card-summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.2rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  flex-shrink: 0;
  transition: transform 0.18s ease;
  opacity: 0.85;
}

.contact-list-card-details[open] > .contact-list-card-summary::after {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}

.contact-list-card-summary-inner {
  flex: 1;
  min-width: 0;
}

/* Shown only when the contact row is expanded (see .contact-list-card-details[open]) */
.contact-list-card-remove-wrap {
  display: none;
  justify-content: flex-end;
  padding: 0 0.55rem 0.5rem;
}

.contact-list-card-details[open] .contact-list-card-remove-wrap {
  display: flex;
}

.contact-list-card-remove {
  margin: 0;
  padding: 0.1rem 0.2rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  opacity: 0.75;
  -webkit-tap-highlight-color: transparent;
}

.contact-list-card-remove:hover:not(:disabled) {
  opacity: 1;
  color: #fca5a5;
}

.contact-list-card-remove:disabled {
  opacity: 0.45;
  cursor: wait;
}

.contact-list-card-summary-name {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.02em;
}

.contact-list-card-summary-meta {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.contact-list-card-summary-date {
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.contact-list-card-body {
  padding: 0 0.65rem 0.65rem;
}

.contacts-list .contact-list-card-body .contact-bcard-details {
  gap: 0.35rem;
}

.contacts-list .contact-list-card-body .contact-bcard-row {
  font-size: 0.8125rem;
}

.contacts-list .contact-list-card-body .contact-bcard-notes {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.contact-bcard-face {
  padding: 1.1rem 1rem 1rem;
}

.contact-bcard-header {
  margin: 0;
}

.contact-bcard-name {
  margin: 0 0 0.2rem;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

.contact-bcard-title {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
}

.contact-bcard-company {
  margin: 0.2rem 0 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: #e2e8f0;
}

.contact-bcard-divider {
  height: 1px;
  margin: 0.75rem 0 0.65rem;
  background: linear-gradient(
    90deg,
    rgba(56, 189, 248, 0.35) 0%,
    rgba(51, 65, 85, 0.9) 45%,
    transparent 100%
  );
}

.contact-bcard-details {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.contact-bcard-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.contact-bcard-row--address {
  margin-top: 0.1rem;
}

.contact-bcard-row--notes {
  margin-top: 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(51, 65, 85, 0.85);
}

.contact-bcard-kind {
  flex: 0 0 auto;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  min-width: 3.25rem;
}

.contact-bcard-line {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--text);
  word-break: break-word;
}

.contact-bcard-line--link {
  text-decoration: none;
  color: var(--primary);
}

.contact-bcard-line--link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.contact-bcard-address {
  margin: 0;
  font-style: normal;
  white-space: pre-line;
  color: #cbd5e1;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.contact-bcard-notes {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre-wrap;
}

.contact-list-card .contact-bcard-face a {
  word-break: break-all;
}

/* Compact voice note inside contact cards */
.contact-list-card .contact-list-card-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.contact-list-card-actions {
  margin-top: 0;
  padding: 0.5rem 0.65rem 0.65rem;
  border-top: 1px solid rgba(51, 65, 85, 0.85);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.4rem;
}

.contacts-list .contact-list-card--paged .contact-list-card-actions {
  padding: 0.45rem 0.55rem 0.55rem;
}

.contact-list-card-actions .btn {
  width: 100%;
  margin: 0;
  min-height: 2.45rem;
  padding: 0.35rem 0.4rem;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* 3 or 1 action: lone button in last row uses full width */
.contact-list-card-actions .btn:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.contacts-list .contact-list-card--paged .contact-list-card-actions .btn {
  padding: 0.32rem 0.35rem;
  font-size: 0.7rem;
  min-height: 2.35rem;
}

.contact-list-card-voice {
  margin-top: 0;
  padding: 0.65rem 1rem 0;
  border-top: 1px solid rgba(51, 65, 85, 0.85);
}

.contacts-list .contact-list-card--paged .contact-list-card-voice {
  padding: 0.5rem 0.65rem 0;
}

.contacts-list .contact-list-card--paged .voice-note-hint {
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.voice-note-root {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #334155;
}

.voice-note-root--compact {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.voice-note-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.voice-note-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.voice-note-status {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  min-height: 1.2em;
  color: var(--muted);
}

.voice-note-status.voice-note-status--active {
  color: var(--text);
}

.voice-note-status.voice-note-status--success {
  color: var(--success);
}

.voice-note-status.voice-note-status--busy {
  color: var(--primary);
}

.voice-note-unsupported {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: #f87171;
}

.voice-note-transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.voice-note-transcript-header .voice-note-label,
.voice-note-transcript-header .contact-list-card-label {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.voice-note-delete-transcript {
  flex-shrink: 0;
  margin: 0;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 6px;
  background: transparent;
  color: #fca5a5;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.9;
}

.voice-note-delete-transcript:hover:not(:disabled) {
  opacity: 1;
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(248, 113, 113, 0.1);
}

.voice-note-delete-transcript:disabled {
  opacity: 0.45;
  cursor: wait;
}

.voice-note-delete-transcript.hidden {
  display: none;
}

.voice-note-transcripts-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.voice-note-transcripts-list.hidden {
  display: none;
}

.voice-note-transcript-item {
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(15, 23, 42, 0.5) 100%);
  border: 1px solid rgba(56, 189, 248, 0.12);
  border-radius: 12px;
}

.voice-note-transcript-wrap {
  margin-bottom: 0.85rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.08) 0%, rgba(15, 23, 42, 0.5) 100%);
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-left-width: 3px;
  border-left-color: var(--primary);
}

.voice-note-transcript {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
}

/* Recorder panel */
.voice-note-recorder-panel {
  position: relative;
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.85) 100%);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.voice-note-root--recording .voice-note-recorder-panel {
  border-color: rgba(251, 113, 133, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(251, 113, 133, 0.15),
    0 12px 40px -12px rgba(225, 29, 72, 0.35);
}

.voice-note-recording-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(225, 29, 72, 0.22) 0%, rgba(251, 113, 133, 0.08) 100%);
  border: 1px solid rgba(251, 113, 133, 0.35);
  animation: voice-note-banner-in 0.35s ease;
}

@keyframes voice-note-banner-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.voice-note-recording-banner.hidden {
  display: none;
}

.voice-note-recording-banner-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.voice-note-rec-pulse {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--voice-recording-deep);
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.55);
  animation: voice-note-pulse 1.25s ease-out infinite;
}

@keyframes voice-note-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(225, 29, 72, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0);
  }
}

.voice-note-rec-label {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fecdd3;
}

.voice-note-rec-waves {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  margin-left: 0.15rem;
}

.voice-note-rec-waves span {
  width: 3px;
  border-radius: 2px;
  background: var(--voice-recording);
  animation: voice-note-bar 0.9s ease-in-out infinite;
}

.voice-note-rec-waves span:nth-child(1) {
  height: 35%;
  animation-delay: 0s;
}

.voice-note-rec-waves span:nth-child(2) {
  height: 70%;
  animation-delay: 0.15s;
}

.voice-note-rec-waves span:nth-child(3) {
  height: 50%;
  animation-delay: 0.3s;
}

.voice-note-rec-waves span:nth-child(4) {
  height: 85%;
  animation-delay: 0.08s;
}

@keyframes voice-note-bar {
  0%,
  100% {
    transform: scaleY(0.45);
    opacity: 0.65;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

.voice-note-rec-timer {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.voice-note-record-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 52px;
  padding: 0.85rem 1.25rem;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.02em;
  color: var(--text);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.18) 0%, rgba(56, 189, 248, 0.06) 100%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.voice-note-record-toggle:active:not(:disabled) {
  transform: scale(0.98);
}

.voice-note-record-toggle:hover:not(:disabled):not(.voice-note-record-toggle--recording) {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.28) 0%, rgba(56, 189, 248, 0.1) 100%);
  border-color: rgba(125, 211, 252, 0.65);
}

.voice-note-record-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.voice-note-record-toggle--recording {
  color: #fff;
  background: linear-gradient(180deg, #fb7185 0%, #e11d48 100%);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 24px -4px rgba(225, 29, 72, 0.55);
}

.voice-note-record-toggle--recording:hover:not(:disabled) {
  background: linear-gradient(180deg, #fda4af 0%, #f43f5e 100%);
  border-color: rgba(255, 255, 255, 0.28);
}

.voice-note-record-toggle .voice-note-icon {
  display: block;
  flex-shrink: 0;
  opacity: 0.95;
}

.voice-note-record-toggle--recording .voice-note-icon--idle {
  display: none;
}

.voice-note-record-toggle:not(.voice-note-record-toggle--recording) .voice-note-icon--rec {
  display: none;
}

.voice-note-actions-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.voice-note-actions-secondary.hidden {
  display: none;
}

.voice-note-actions-secondary .btn {
  width: 100%;
  margin: 0;
}

.voice-note-preview {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.voice-note-preview.hidden {
  display: none;
}

.voice-note-preview audio {
  width: 100%;
  max-width: 100%;
  vertical-align: middle;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .voice-note-rec-pulse,
  .voice-note-rec-waves span,
  .voice-note-recording-banner {
    animation: none;
  }

  .voice-note-rec-pulse {
    box-shadow: none;
  }
}

.app-top-logo {
  padding-top: 0;
  padding-bottom: 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
  width: calc(100% + 2rem);
  text-align: center;
}

.app-top-logo a {
  display: inline-block;
  line-height: 0;
}

.app-top-logo .app-logo {
  width: auto;
  max-width: 480px;
  height: 128px;
  object-fit: contain;
  display: block;
}

@media (min-width: 600px) {
  .app-top-bar {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
  }
  .app-top-logo {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
  }
}

.form-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* Contacts modal: Download CSV + Close stay one row on narrow phones */
.contacts-modal-actions.form-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid #334155;
  border-radius: 8px;
}

.form-group select {
  cursor: pointer;
  appearance: auto;
}

.vcard-actions {
  margin: 0 0 1rem;
}

.vcard-actions .btn {
  width: 100%;
}

.vcard-actions .btn + .btn {
  margin-top: 0.5rem;
}

.vcard-sms-pick-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.followup-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.followup-options {
  margin-bottom: 1.25rem;
}

.followup-options .form-group {
  margin-bottom: 0.75rem;
}

.followup-options #btn-followup {
  margin-top: 0.5rem;
  width: 100%;
}

#success-section #btn-new-scan {
  width: 100%;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #64748b;
}

.form-group textarea {
  resize: vertical;
  min-height: 2.5rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 1rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 0.5rem;
  text-align: center;
}

.error p {
  margin: 0 0 1rem 0;
  font-weight: 500;
}

.error.hidden {
  display: none;
}

.success-msg {
  color: var(--success);
  font-weight: 500;
  margin-bottom: 1rem;
  text-align: center;
}

#success-section .btn {
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
}

.phone-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.phone-row select {
  width: 6rem;
  min-width: 5rem;
  padding: 0.5rem 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid #334155;
  border-radius: 8px;
}

.phone-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid #334155;
  border-radius: 8px;
}

@media (min-width: 600px) {
  #app {
    padding: 2rem;
  }
  .header h1 {
    font-size: 2rem;
  }
}

/* Tom Select dark theme adjustments */
.ts-wrapper {
  width: 100%;
}
.ts-wrapper .ts-control {
  background-color: var(--bg) !important;
  background-image: none !important;
  border: 1px solid #334155 !important;
  color: var(--text) !important;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  box-shadow: none !important;
}
.ts-wrapper .ts-control input {
  color: var(--text) !important;
  background: transparent !important;
}
.ts-wrapper.single .ts-control {
  padding-right: 2rem;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2) !important;
}
.ts-wrapper.ts-dropdown-active .ts-control {
  background-color: var(--bg) !important;
  border-radius: 8px !important;
}
/* Ensure the input element doesn't have its own white background */
.ts-wrapper .ts-control input {
  background: transparent !important;
  box-shadow: none !important;
}
.ts-dropdown {
  background-color: var(--surface) !important;
  border: 1px solid #334155 !important;
  color: var(--text) !important;
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: var(--shadow);
}
.ts-dropdown .option {
  padding: 0.65rem 0.85rem;
  transition: background 0.1s;
}
.ts-dropdown .active {
  background-color: #334155 !important;
  color: var(--primary) !important;
}
.ts-dropdown .option:hover {
  background-color: #334155 !important;
}
.ts-wrapper .ts-control::after {
  border-color: var(--muted) transparent transparent transparent !important;
}
.ts-wrapper.ts-dropdown-active .ts-control::after {
  border-color: transparent transparent var(--muted) transparent !important;
}

/* Tom Select in phone-row */
.phone-row .ts-wrapper {
  width: 6.5rem;
  min-width: 5.5rem;
}
.phone-row .ts-wrapper .ts-control {
  padding: 0.5rem 0.5rem;
  font-size: 0.95rem;
}

/* PWA-style bottom navigation (above modal backdrop so it stays tappable) */
.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: calc(3.5rem + env(safe-area-inset-bottom, 0px));
  padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 23, 42, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(51, 65, 85, 0.85);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
  max-width: 480px;
  margin: 0 auto;
}

.app-bottom-nav-tabs {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 0;
  flex: 1;
  max-width: 480px;
}

/* Terms / Privacy in modals (settings-style), not under the tab bar */
.modal-legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(51, 65, 85, 0.65);
}

.modal-content > .modal-legal-links {
  margin-top: 0.5rem;
}

/* Scan tab: Terms / Privacy below the active panel (camera, form, success, …) */
.main-scan-legal {
  flex-shrink: 0;
  margin-top: 0.65rem;
  margin-bottom: 0;
  padding-bottom: 0.15rem;
}

.contacts-modal-content .modal-legal-links {
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.contacts-modal-content .modal-legal-links.contacts-modal-legal-links {
  margin-top: 0.65rem;
  padding-bottom: 0.15rem;
}

/* Contacts modal: portrait phones — more list height, easier search + action targets */
@media (max-width: 480px) {
  #contacts-modal.modal {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(0.35rem, env(safe-area-inset-top));
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-bottom: calc(0.35rem + 4.25rem + env(safe-area-inset-bottom, 0px));
  }

  #contacts-modal .contacts-modal-content {
    max-width: none;
    width: 100%;
    max-height: calc(
      100dvh - 4.75rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    );
    min-height: 11rem;
    padding: 0.85rem 0.7rem 0.65rem;
    border-radius: 10px;
  }

  #contacts-modal .modal-title {
    margin-bottom: 0.5rem;
    font-size: 1.125rem;
  }

  #contacts-modal .contacts-modal-status {
    font-size: 0.8125rem;
    line-height: 1.35;
    margin-bottom: 0.45rem;
    word-break: break-word;
  }

  #contacts-modal .contacts-search {
    padding: 0.45rem 0.5rem;
    margin-bottom: 0.45rem;
  }

  #contacts-modal .contacts-modal-section-title {
    margin-bottom: 0.3rem;
  }

  #contacts-modal .contacts-search-actions {
    margin-top: 0.4rem;
    gap: 0.45rem;
  }

  #contacts-modal .contacts-pagination-range {
    font-size: 0.6875rem;
    line-height: 1.3;
  }

  #contacts-modal .contacts-modal-actions {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.45rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
  }

  #contacts-modal .contacts-modal-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 2.65rem;
  }

  #contacts-modal .contacts-modal-legal-links {
    margin-top: 0.4rem;
    padding-top: 0.5rem;
  }

  .contact-list-card-summary {
    padding: 0.55rem 0.6rem;
    min-height: 2.75rem;
  }

  .contacts-list .contact-list-card--paged .contact-list-card-voice {
    padding: 0.45rem 0.55rem 0;
  }

  .contacts-list .contact-list-card--paged .voice-note-hint {
    font-size: 0.68rem;
    margin-bottom: 0.4rem;
    line-height: 1.35;
  }

  .contacts-list .contact-list-card-body .contact-bcard-row {
    font-size: 0.78rem;
  }

  .contacts-list .contact-list-card-body .contact-bcard-notes {
    -webkit-line-clamp: 6;
  }
}

.modal-legal-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.modal-legal-link:hover {
  color: var(--primary);
}

.modal-legal-sep {
  color: var(--muted);
  font-size: 0.75rem;
  opacity: 0.45;
  user-select: none;
}

/* End-of-page legal on standalone HTML (not chrome) */
.standalone-legal-note {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(51, 65, 85, 0.55);
  font-size: 0.8rem;
  text-align: center;
  color: var(--muted);
}

.standalone-legal-note a {
  color: var(--muted);
  text-decoration: none;
}

.standalone-legal-note a:hover {
  color: var(--primary);
}

.app-bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 0;
  padding: 0.25rem 0.35rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
}

a.app-bottom-nav-item {
  text-decoration: none;
  box-sizing: border-box;
}

.app-bottom-nav-item:active {
  transform: scale(0.97);
}

.app-bottom-nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app-bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.app-bottom-nav-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.app-bottom-nav-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bottom-nav-item.is-active {
  color: var(--primary);
  background: rgba(56, 189, 248, 0.1);
}

/* Standalone pages (terms, privacy, feedback) still use .app-footer */
.app-footer {
  padding: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.legal-links {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
}

.privacy-link {
  color: var(--muted);
  text-decoration: none;
  opacity: 0.8;
}

.privacy-link:hover {
  opacity: 1;
  color: var(--primary);
}

.whatsapp-float {
  background-color: #25d366;
  color: #fff;
  border-radius: 50px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.whatsapp-float:hover {
  background-color: #128c7e;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.whatsapp-float svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 600px) {
  .whatsapp-float {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}
