* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(31, 35, 41, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.topbar .feed-inner {
  padding-top: var(--s-3);
  padding-left: 24px;
  padding-right: 24px;
}

.app-title-wrap {
  display: grid;
  gap: 2px;
}

.app-title {
  margin: 0;
  padding: 0 0 var(--s-3);
  font-size: clamp(34px, 5vw, 52px);
  line-height: 0.95;
  color: #d64040;
  font-weight: 800;
  letter-spacing: 0.04em;
  transform: scaleX(1.5);
  transform-origin: left center;
  width: fit-content;
}

.app-subtitle {
  color: #f3f6fa;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  padding-bottom: var(--s-3);
}

.feed {
  padding: var(--s-3);
}

.feed-inner {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--s-4);
  margin-bottom: var(--s-4);
}

.header-actions-bar {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
}

.header-actions-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-left: auto;
}

.header-row,
.hdr-row {
  display: grid;
  gap: var(--s-2);
}

.header-row--top {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.header-row--controls {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  }

.header-brand {
  min-width: 0;
}

.header-avatar-chip {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.header-btn {
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: 14px;
}

.header-search {
  flex: 1;
  min-width: 220px;
  height: 30px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hdr-row-actions {
  justify-content: flex-start;
}

.lookup-title,
.auth-title {
  font-size: var(--fs-md);
  font-weight: 700;
}

.auth-subtitle,
.lookup-helper,
.lookup-diagnostic,
.status-text,
.contacts-tab-subtitle {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.lookup-helper-error,
.lookup-diagnostic-error,
.error {
  color: #cb3a31;
}

.auth-row,
.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
}

.input,
.auth-input,
.lookup-input,
.comm-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  min-height: 42px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.btn,
.primary-btn,
.secondary-btn {
  border-radius: var(--r-md);
  min-height: 42px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn--primary,
.primary-btn {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.btn--header-signout {
  background: #6f8091;
  border-color: #6f8091;
  color: #fff;
}

.btn--ghost,
.secondary-btn {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 8px;
  text-decoration: underline;
  cursor: pointer;
}

.contacts-tabs {
  display: flex;
  gap: var(--s-2);
}

.contacts-tabs--header {
  align-items: end;
  gap: 6px;
  margin-bottom: 0;
}

.contacts-tab-btn {
  min-height: 34px;
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  background: #c7d1c7;
  padding: 6px 14px;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}

.tab-btn {
  font-size: 1rem;
  padding: 12px 18px;
}

.contacts-tab-btn.tab-btn {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 1rem;
}

.contacts-tab-btn.active {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
  position: relative;
  top: 1px;
}

.contacts-pager {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: 5px;
}

.contacts-pager .btn {
  min-height: 21px;
  padding: 4px 7px;
  font-size: 0.72rem;
  border-radius: 10px;
  background: #bcc9bc;
  border-color: #a8b6a8;
  color: #314131;
}

.lookup-match-list {
  display: grid;
  gap: var(--s-2);
}

.lookup-match-btn {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.current-contact-list {
  display: grid;
  gap: var(--s-3);
}

.contacts-feed-panel {
  margin-top: 0;
  border-top-left-radius: 0;
}

.hidden {
  display: none;
}

.input-notfound {
  border-color: #cb3a31;
  box-shadow: inset 0 0 0 1px #cb3a31;
}

.input-ambiguous {
  border-color: #b7861d;
  box-shadow: inset 0 0 0 1px #b7861d;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(9, 17, 28, 0.35);
  display: grid;
  place-items: center;
  padding: var(--s-3);
}

.modal-card {
  width: min(760px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-3);
}

.attachment-viewer-modal {
  width: min(900px, 100%);
}

.attachment-viewer {
  min-height: 280px;
  max-height: 70vh;
  overflow: auto;
  display: grid;
  place-items: center;
  background: #f7fafc;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2);
}

.attachment-preview-image {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
}

.attachment-preview-frame {
  width: 100%;
  min-height: 65vh;
  border: 0;
  background: #fff;
}

.auth-panel {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-3);
}

.auth-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.modal-toggle-row,
.modal-actions,
.feed-quick-add-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.modal-actions {
  justify-content: flex-end;
}

@media (min-width: 768px) {
  .feed {
    padding: var(--s-4);
  }

  .auth-row,
  .lookup-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
}

@media (max-width: 767px) {
  .topbar .feed-inner {
    padding-left: 16px;
    padding-right: 16px;
  }

  .header-row--controls {
    grid-template-columns: 1fr;
  }

  .header-actions-right {
    align-items: flex-end;
  }
}

/* Force smaller sizing for sticky header action buttons only. */
.pbs-header .header-btn {
  font-size: 0.78rem !important;
  padding: 6px 10px !important;
  min-height: 30px !important;
  border-radius: 14px !important;
}

.quick-add-mic-btn {
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.quick-add-channel-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-add-channel-picker.is-error {
  animation: quick-add-blink 0.45s ease;
}

.quick-add-channel-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.quick-add-channel-btn.is-selected {
  border: 2px solid #1f6feb;
  box-shadow: 0 0 0 1px rgba(31, 111, 235, 0.12);
}

.quick-add-channel-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

@keyframes quick-add-blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.35;
  }
}

.modal-toggle-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  margin-right: 6px;
  vertical-align: middle;
}

.modal-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
