/* Urdu Nastaliq, bundled (SIL Open Font License, see fonts/NotoNastaliqUrdu-OFL.txt) */
@font-face {
  font-family: "Dorpus Nastaliq";
  src: url("/fonts/NotoNastaliqUrdu.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* Dorpus — ChatGPT-style local research shell (no external assets) */

:root {
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --sidebar: #f3f3f3;
  --sidebar-ink: #0d0d0d;
  --sidebar-muted: #6b6b6b;
  --sidebar-hover: #e8e8e8;
  --ink: #0d0d0d;
  --ink-muted: #6b6b6b;
  --accent: #0d0d0d;
  --accent-hover: #2a2a2a;
  --accent-soft: #efefef;
  --user-bubble: #e8f0fe;
  --user-ink: #0d0d0d;
  --assistant-bg: transparent;
  --send: #0b57d0;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --ok: #0f7b3a;
  --ok-bg: #e8f7ee;
  --warn: #9a6700;
  --warn-bg: #fff8e8;
  --err: #c62828;
  --err-bg: #fdecea;
  --partial: #875200;
  --partial-bg: #fff1e0;
  --unavailable: #6b6b6b;
  --unavailable-bg: #f0f0f0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --composer-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --font: "Segoe UI Variable", "Segoe UI", Candara, Calibri, sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-mono: Consolas, "Courier New", monospace;
  --focus: 0 0 0 3px rgba(13, 13, 13, 0.2);
  --sidebar-w: 52px;
  --sidebar-w-open: 248px;
  --messages-w: 280px;
  --chat-max: 48rem;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  z-index: 1000;
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

button,
input,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Shell */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  min-width: 0;
  overflow: hidden;
}

.app-shell.messages-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--messages-w);
}

.app-shell.sidebar-expanded {
  grid-template-columns: var(--sidebar-w-open) minmax(0, 1fr);
}

.app-shell.sidebar-expanded.messages-open {
  grid-template-columns: var(--sidebar-w-open) minmax(0, 1fr) var(--messages-w);
}

/* Sidebar — narrow ChatGPT-style icon rail */

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: 0.75rem 0.45rem;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  overflow: hidden;
  transition: transform 0.2s ease;
  z-index: 30;
  border-right: 1px solid var(--border);
}

.rail-top,
.rail-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.rail-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  margin-bottom: 0.35rem;
}

.rail-btn {
  appearance: none;
  width: 2.55rem;
  height: 2.55rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #444;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.rail-btn:hover,
.rail-btn.active,
.rail-btn.nav-item.active {
  background: #fff;
  color: #111;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.rail-meta {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.rail-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e07a2f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.35rem;
}

/* Legacy unused brand bits kept harmless */
.sidebar-brand,
.tagline,
.local-badge,
.btn-sidebar-primary,
.sidebar-nav,
.sidebar-footer {
  display: none;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.nav-item {
  /* rail buttons also use .nav-item */
}

.page-header {
  margin-bottom: var(--space-4);
}

.page-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-transform: none;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: var(--space-3) var(--space-4);
  background: #fff;
  margin-bottom: var(--space-3);
}

.page-card h3 {
  margin: 0 0 var(--space-2);
  font-size: 0.95rem;
}

.hint.light,
.field-note,
.view-panel .hint {
  color: var(--ink-muted);
}

.index-progress {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f7f7;
}

.index-progress-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: baseline;
  margin-bottom: var(--space-2);
  font-size: 0.9rem;
}

.index-progress-track {
  height: 0.45rem;
  border-radius: 999px;
  background: #e5e5e5;
  overflow: hidden;
}

.index-progress-bar {
  height: 100%;
  width: 0%;
  background: #111;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.index-progress-detail {
  margin: var(--space-2) 0 0;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.page-book-list {
  max-height: none;
  overflow: visible;
  gap: 0.45rem;
}

.book-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: #fff;
}

.book-row.selected {
  border-color: #111;
  background: #f5f5f5;
}

.book-row-main {
  min-width: 0;
}

.book-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}

.book-row-title strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.book-row .book-meta {
  margin: 0.15rem 0 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-row-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
}

.book-row-actions .btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
}

.danger-text {
  color: var(--err) !important;
}

.ingest-report.light {
  background: #fafafa;
  border: 1px solid var(--border);
  color: var(--ink);
}

.ingest-report.light dt {
  color: var(--ink-muted);
}

.status-list.light .status-item {
  background: #fafafa;
  border: 1px solid var(--border);
}

.status-list.light .status-item .label {
  color: var(--ink);
}

.status-list.light .status-item .detail {
  color: var(--ink-muted);
}

.page-book-list .book-card {
  display: none;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--unavailable-bg);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

/* Main stage */

.main-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elevated);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: 0.55rem var(--space-5);
  border-bottom: 0;
  background: transparent;
  z-index: 20;
  min-height: 3.25rem;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  justify-self: start;
}

.brand-word,
.topbar-title span:first-child {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.topbar-mark {
  display: none;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border-radius: 6px;
  margin-right: -0.15rem;
}

body.is-guest .topbar-mark {
  display: block;
}

.topbar-sub {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: #f3f3f3;
  justify-self: center;
}

.mode-pill-active,
.mode-pill-muted {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.mode-pill-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mode-pill-muted {
  color: var(--ink-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-self: end;
}

.topbar-link {
  color: var(--ink-muted);
  font-weight: 600;
}

.app-shell:has(.view-chat.active.is-empty) .topbar-actions {
  opacity: 0.55;
}

.mobile-only {
  display: none;
}

.stage-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.view.active {
  display: flex;
}

.view-panel {
  overflow: auto;
  padding: var(--space-5);
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
}

.view-panel h2 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
}

/* Chat — ChatGPT centered column */

.view-chat {
  position: relative;
}

.view-chat.is-empty {
  justify-content: center;
  padding-bottom: 8vh;
}

.view-chat.is-empty .chat-thread {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0;
}

.view-chat.is-empty .chat-footer {
  padding-top: 1.5rem;
  background: transparent;
}

.view-chat.is-empty .composer-suggestions {
  display: flex;
}

.view-chat:not(.is-empty) .composer-suggestions {
  display: none;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) var(--space-3);
  scroll-behavior: smooth;
  min-width: 0;
}

.chat-column {
  max-width: var(--chat-max);
  margin: auto auto 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.chat-empty {
  margin: 0 auto;
  text-align: center;
  color: var(--ink-muted);
  width: 100%;
  max-width: var(--chat-max);
  padding: 0 1rem;
}

.chat-empty-greeting {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.chat-empty-sub,
.chat-empty p {
  display: none;
}

.chat-empty-brand {
  display: none;
}

.chat-turn {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chat-bubble {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  width: 100%;
}

.chat-bubble.user {
  grid-template-columns: 1fr;
  justify-items: end;
}

.avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: #111;
  color: #fff;
  margin-top: 0.15rem;
  font-family: var(--font-display);
}

.chat-bubble.assistant .avatar {
  background: transparent;
  overflow: hidden;
}

.chat-bubble.assistant .avatar img {
  width: 100%;
  height: 100%;
  display: block;
}

.bubble-body {
  min-width: 0;
  max-width: 100%;
}

.chat-bubble.user .bubble-body {
  background: var(--user-bubble);
  color: var(--user-ink);
  padding: 0.75rem 1.05rem;
  border-radius: 22px;
  max-width: min(85%, 36rem);
}

.chat-bubble.assistant {
  padding-right: 0.5rem;
}

.chat-bubble.assistant .bubble-body {
  padding-top: 0.1rem;
}

.chat-role {
  display: none;
}

.chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  max-width: 100%;
}

.chat-bubble.assistant .chat-text {
  padding-top: 0.15rem;
}

.chat-text.is-typing::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1.1em;
  margin-left: 0.12em;
  vertical-align: text-bottom;
  background: var(--ink);
  animation: caret-blink 1s steps(1) infinite;
}

@keyframes caret-blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.citation-list {
  margin: var(--space-3) 0 0;
  padding-left: 1.1rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.citation-list li {
  margin-bottom: 0.35rem;
}

.chat-meta-line {
  margin-top: var(--space-2);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.chat-footer {
  width: 100%;
  padding: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 34%);
}

.typing-bar {
  max-width: var(--chat-max);
  margin: 0 auto;
  width: 100%;
  padding: 0.35rem 1.25rem 0.55rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.typing-bar .typing-label {
  min-width: 0;
}

.typing-dots {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: pulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* Composer — ChatGPT pill input */

.composer {
  padding: 0 var(--space-4) 1rem;
  background: transparent;
}

.composer-shell {
  max-width: var(--chat-max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: 0.7rem 0.7rem 0.7rem 1.2rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 28px;
  box-shadow: var(--composer-shadow);
}

.composer-shell textarea {
  flex: 1;
  border: 0;
  resize: none;
  max-height: 10rem;
  min-height: 1.5rem;
  padding: 0.45rem 0;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
  font-size: 1rem;
}

.composer-shell textarea:focus {
  outline: none;
  box-shadow: none;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topk-inline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.topk-inline input {
  width: 3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.4rem;
  text-align: center;
}

.composer-suggestions {
  max-width: var(--chat-max);
  margin: 0.85rem auto 0;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 0.25rem;
}

.suggestion-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #f7f7f8;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.3;
}

.suggestion-chip:hover {
  background: #efefef;
}

.composer-footnote {
  max-width: var(--chat-max);
  margin: 0.55rem auto 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.view-chat.is-empty .composer-footnote {
  display: none;
}

.messages-drawer {
  border-left: 1px solid var(--border);
  background: #f7f7f8;
  padding: var(--space-3);
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.messages-drawer[hidden] {
  display: none !important;
}

.messages-drawer .drawer-header {
  margin-bottom: 0.15rem;
}

.messages-drawer .drawer-header h2 {
  flex: 1 1 auto;
}

.messages-drawer .team-side-unread {
  margin-right: auto;
}

.messages-drawer .team-side-list {
  margin: 0.15rem 0 0;
  flex: 1 1 auto;
}

.messages-drawer .team-side-item.active {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.messages-drawer .chat-history-empty {
  margin: 0.35rem 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.drawer-header h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.messages-drawer .hint,
.messages-hint {
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin: 0 0 var(--space-3);
  line-height: 1.35;
}

/* Buttons */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

a.btn {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

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

.btn-primary {
  background: #fff;
  color: #111;
}

.btn-primary:hover:not(:disabled) {
  background: #f3f3f3;
}

.btn-sidebar-primary {
  width: 100%;
  background: #2f2f2f;
  color: #fff;
  text-align: left;
  border-radius: 12px;
}

.btn-sidebar-primary:hover:not(:disabled) {
  background: #3a3a3a;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  color: inherit;
  border-color: transparent;
}

.sidebar .btn-ghost {
  color: var(--sidebar-muted);
}

.sidebar .btn-ghost:hover:not(:disabled) {
  background: var(--sidebar-hover);
  color: #fff;
}

.btn-danger {
  background: var(--err);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a61f1f;
}

.btn-send {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  background: var(--send);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  background: #0842a0;
}

.btn-send:disabled {
  opacity: 0.35;
}

.btn-block {
  width: 100%;
  margin-top: var(--space-3);
}

.icon-btn {
  font-size: 1.1rem;
  padding: 0.35rem 0.55rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.btn-row.compact {
  margin-bottom: var(--space-2);
}

.btn-stack {
  display: grid;
  gap: var(--space-2);
}

.sidebar .btn-secondary,
.sidebar .btn-primary {
  border-radius: 10px;
  justify-self: stretch;
}

.sidebar .btn-secondary {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: #fff;
}

.sidebar .btn-primary {
  background: #fff;
  color: #111;
}

/* Forms */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field.grow {
  grid-column: 1 / -1;
}

.field span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.field input,
.field textarea {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  background: #fff;
  color: var(--ink);
}

.view-search .field-note,
.view-panel .field-note,
.view-panel .hint {
  color: var(--ink-muted);
}

/* Semantic search — centered, ChatGPT-like */

.search-panel {
  max-width: 44rem;
  padding-top: 1.75rem;
}

.search-header {
  margin-bottom: 1.35rem;
}

.search-header h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font);
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.search-lead {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 36rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.search-query-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--composer-shadow);
}

.search-query-bar input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.55rem 0;
  font-size: 1rem;
  color: var(--ink);
}

.search-query-bar input:focus {
  outline: none;
  box-shadow: none;
}

.search-query-bar .btn-primary {
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  flex-shrink: 0;
}

.search-filters {
  display: grid;
  grid-template-columns: 5.5rem 1fr 1fr;
  gap: 0.75rem;
}

.search-filters .field-compact input {
  text-align: center;
}

.search-filters .field input {
  border-radius: 12px;
  border-color: var(--border);
  padding: 0.55rem 0.7rem;
}

.search-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.search-form-footer .field-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  max-width: 28rem;
}

.search-results {
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .search-query-bar {
    border-radius: 18px;
    flex-wrap: wrap;
    padding: 0.65rem;
  }

  .search-query-bar input {
    width: 100%;
    padding: 0.35rem 0.35rem 0.55rem;
  }

  .search-query-bar .btn-primary {
    width: 100%;
  }

  .search-filters {
    grid-template-columns: 1fr;
  }

  .search-form-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Status / library in sidebar */

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.status-item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: flex-start;
  padding: var(--space-2);
  border-radius: 10px;
  background: #111;
}

.status-item .label {
  font-weight: 600;
  font-size: 0.85rem;
}

.status-item .detail {
  display: block;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  margin-top: 0.15rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-ready { background: var(--ok-bg); color: var(--ok); }
.badge-unavailable { background: var(--unavailable-bg); color: var(--unavailable); }
.badge-not-installed { background: var(--unavailable-bg); color: var(--unavailable); }
.badge-partial { background: var(--partial-bg); color: var(--partial); }
.badge-error { background: var(--err-bg); color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ocr { background: var(--partial-bg); color: var(--partial); }
.badge-native { background: var(--ok-bg); color: var(--ok); }
.badge-indexed { background: var(--ok-bg); color: var(--ok); }
.badge-failed { background: var(--err-bg); color: var(--err); }
.badge-deleted { background: var(--unavailable-bg); color: var(--unavailable); }

.book-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  overflow: auto;
  flex: 1;
}

.book-card {
  border: 1px solid #2f2f2f;
  border-radius: 12px;
  padding: var(--space-3);
  background: #111;
}

.book-card.selected {
  border-color: #fff;
  background: #1d1d1d;
}

.book-card-top {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.book-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #fff;
}

.book-meta {
  margin: 0.35rem 0 0;
  color: var(--sidebar-muted);
  font-size: 0.78rem;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.empty-state {
  color: var(--ink-muted);
  padding: var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: #fff;
  font-size: 0.9rem;
}

.sidebar .empty-state {
  background: #111;
  border-color: #333;
  color: var(--sidebar-muted);
}

/* Sources / search results */

.source-list {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  max-width: 100%;
}

.source-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.source-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.source-card-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}

.source-label {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.source-score {
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.source-title {
  margin: 0;
  font-size: 0.92rem;
}

.source-meta {
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin: 0 0 0.4rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.passage {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: var(--font);
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  max-width: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: visible;
}

.passage.collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  max-height: 4.1rem;
  white-space: normal;
}

.source-card-actions {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.25rem;
}

.btn-compact {
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.btn-compact:hover:not(:disabled) {
  color: var(--ink);
  background: var(--accent-soft);
}

.badge-sm {
  padding: 0.05rem 0.4rem;
  font-size: 0.68rem;
  border-radius: 999px;
}

.result-summary {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.refusal-box {
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border-radius: 12px;
  background: var(--warn-bg);
  border: 1px solid #ecd89a;
  color: var(--ink);
}

.ingest-report {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid #333;
  border-radius: 12px;
  background: #111;
  font-size: 0.85rem;
  color: #e5e5e5;
}

.ingest-report h3 {
  margin: 0 0 var(--space-2);
  font-size: 0.95rem;
}

.ingest-report dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  margin: 0;
}

.ingest-report dt {
  color: var(--sidebar-muted);
}

.ingest-report dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.progress {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: #2a2a2a;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* Desktop: frameless chrome + compact sync control */
body.is-desktop .topbar {
  -webkit-app-region: drag;
  app-region: drag;
  padding-right: 0.35rem;
}

body.is-desktop .topbar button,
body.is-desktop .topbar a,
body.is-desktop .topbar select,
body.is-desktop .topbar input,
body.is-desktop .mode-pill,
body.is-desktop .model-menu,
body.is-desktop .branch-switch,
body.is-desktop .topbar-actions {
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.desktop-sync-chip {
  position: relative;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #ffffff 0%, #f6f7f9 100%);
  color: #3a4454;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.desktop-sync-chip[hidden] {
  display: none !important;
}

.desktop-sync-chip:hover {
  color: #111827;
  border-color: rgba(15, 23, 42, 0.14);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

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

.desktop-sync-chip .desktop-sync-glyph {
  display: block;
}

.desktop-sync-chip .desktop-sync-dot {
  position: absolute;
  top: 0.28rem;
  right: 0.28rem;
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 2px #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.desktop-sync-chip.is-pending .desktop-sync-dot,
.desktop-sync-chip.is-offline .desktop-sync-dot,
.desktop-sync-chip.is-error .desktop-sync-dot {
  opacity: 1;
  transform: scale(1);
}

.desktop-sync-chip.is-pending .desktop-sync-dot {
  background: #d97706;
}

.desktop-sync-chip.is-offline .desktop-sync-dot,
.desktop-sync-chip.is-error .desktop-sync-dot {
  background: #b45309;
}

.desktop-sync-chip.is-syncing .desktop-sync-glyph {
  animation: desktop-sync-spin 0.9s linear infinite;
}

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

.desktop-win-controls {
  display: inline-flex;
  align-items: stretch;
  margin-left: 0.15rem;
  border-left: 1px solid rgba(15, 23, 42, 0.06);
  padding-left: 0.15rem;
}

.desktop-win-controls[hidden] {
  display: none !important;
}

.desktop-win-btn {
  width: 2.55rem;
  height: 2.2rem;
  border: 0;
  background: transparent;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
}

.desktop-win-btn:hover {
  background: rgba(15, 23, 42, 0.06);
  color: #111827;
}

.desktop-win-btn.is-close:hover {
  background: #e81123;
  color: #fff;
}

/* Frameless window chrome on the sign-in screen (app shell is hidden). */
.auth-win-controls {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 95;
  margin: 0;
  border-left: 0;
  padding: 0.35rem 0.35rem 0 0;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.team-msg.is-queued {
  opacity: 0.78;
}

.team-msg.is-queued .team-msg-time {
  font-style: italic;
}

/* Notifications */

.notification-area {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 300;
  display: grid;
  gap: var(--space-2);
  width: min(26rem, calc(100vw - 32px));
  pointer-events: none;
}

.notification-area:empty {
  display: none;
}

.notification {
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  animation: toast-in 0.18s ease-out;
  align-items: center;
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.notification.error {
  background: var(--err-bg);
  border-color: #f3c0bb;
  color: var(--err);
}

.notification.info {
  background: var(--accent-soft);
  border-color: var(--border);
  color: var(--ink);
}

.notification.success {
  background: var(--ok-bg);
  border-color: #b7e2c8;
  color: var(--ok);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Modals — modern centered sheets */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-elevated);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: var(--space-5);
  animation: modal-in 0.18s ease-out;
}

.modal-card.wide {
  width: min(820px, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
}

.modal-body p {
  margin-top: 0;
}

.confirm-list {
  margin: 0 0 var(--space-4);
  padding-left: 1.2rem;
}

.page-meta {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-3);
}

.page-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: var(--font);
  font-size: 0.95rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-4);
  max-height: 60vh;
  overflow-x: hidden;
  overflow-y: auto;
  max-width: 100%;
}

/* Responsive */

@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
  }

  .app-shell,
  .app-shell.messages-open,
  .app-shell.sidebar-collapsed,
  .app-shell.sidebar-collapsed.messages-open {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-105%);
  }

  .app-shell.sidebar-open .sidebar {
    transform: none;
    pointer-events: auto;
  }

  .messages-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(92vw, var(--messages-w));
    z-index: 40;
    box-shadow: var(--shadow);
  }

  .view-chat.is-empty .chat-empty {
    padding-top: 2rem;
  }
}

@media (max-width: 720px) {
  .book-row {
    grid-template-columns: auto 1fr;
  }

  .book-row-actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

/* ---------------------------------------------------------------------------
   Hadith sources (sunnah.com)
   --------------------------------------------------------------------------- */
.check-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3) var(--space-3);
  margin: var(--space-3) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}
.check-grid legend {
  font-size: 0.8rem;
  color: var(--ink-muted);
  padding: 0 var(--space-1);
}
.check-grid label {
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
}
.hadith-error { color: var(--err); }
.badge-hadith { background: var(--accent-soft); color: var(--ink); }
.hadith-grade {
  margin: 0 0 var(--space-2);
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.hadith-texts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.hadith-texts.collapsed {
  max-height: 9.5rem;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.hadith-text p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  line-height: 1.5;
}
.hadith-text p[dir="rtl"] {
  text-align: right;
  font-size: 1.02rem;
  line-height: 1.9;
}
.hadith-text-ar p {
  font-family: "Traditional Arabic", "Amiri", "Scheherazade New", "Segoe UI", serif;
  font-size: 1.12rem;
}
.hadith-text-ur p {
  font-family: var(--font-urdu);
  font-size: 0.86rem; /* same as the other translations in this panel */
  line-height: 2.3;
}
.hadith-lang {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 2px;
}
.citation-list a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
#hadith-progress + #hadith-collection-list,
#hadith-collection-list { margin-top: var(--space-4); }


/* ===========================================================================
   Layout v2: collapsible sidebar, model menu, section tabs, voice, actions
   =========================================================================== */

.app-shell {
  transition: grid-template-columns 0.18s ease;
}

.sidebar {
  align-items: stretch;
  padding: 0.55rem 0.4rem;
  width: auto;
}

.rail-top,
.rail-bottom {
  align-items: stretch;
  gap: 0.15rem;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.2rem;
  margin-bottom: 0.35rem;
}

.rail-btn {
  width: 100%;
  height: 2.2rem;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 0 0.55rem;
  font: inherit;
  font-size: 0.88rem;
  white-space: nowrap;
}

.rail-icon {
  flex: none;
}

.rail-label,
.rail-brand,
.rail-close {
  display: none;
}

/* Collapsed: logo; on hover it turns into the "open sidebar" icon (like ChatGPT) */
.rail-toggle .rail-toggle-icon {
  display: none;
}

body.is-guest .app-shell:not(.sidebar-expanded) .rail-toggle .rail-logo {
  display: none;
}

body.is-guest .app-shell:not(.sidebar-expanded) .rail-toggle .rail-toggle-icon {
  display: block;
}

.rail-toggle:hover .rail-logo,
.rail-toggle:focus-visible .rail-logo {
  display: none;
}

.rail-toggle:hover .rail-toggle-icon,
.rail-toggle:focus-visible .rail-toggle-icon {
  display: block;
}

.rail-logo {
  width: 1.35rem;
  height: 1.35rem;
}

.rail-avatar {
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.68rem;
  align-self: center;
}

/* Expanded sidebar */
.sidebar-expanded .rail-head {
  justify-content: space-between;
  padding-left: 0.45rem;
}

.sidebar-expanded .rail-toggle {
  display: none;
}

.sidebar-expanded .rail-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  font-size: 0.95rem;
}

.rail-brand-home {
  display: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  padding: 0.2rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
}

body.is-guest .rail-brand-mark,
body.is-guest .rail-brand-name {
  display: none;
}

body.is-guest .app-shell.sidebar-expanded .rail-brand-home {
  display: inline;
}

body.is-guest .rail-brand-home:hover,
body.is-guest .rail-brand-home[aria-current="true"] {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.sidebar-expanded .rail-close {
  display: flex;
  width: 2.2rem;
  padding: 0;
}

.sidebar-expanded .rail-btn:not(.rail-close) {
  justify-content: flex-start;
}

.sidebar-expanded .rail-label {
  display: inline;
}

.sidebar-expanded .rail-meta {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  margin: 0 0.55rem 0.35rem;
  font-size: 0.78rem;
  color: var(--sidebar-muted);
}

.sidebar-expanded .rail-avatar {
  align-self: flex-start;
  margin-left: 0.45rem;
}

/* Model menu in the header */
.model-menu {
  position: relative;
}

.model-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  border-radius: 9px;
  cursor: pointer;
}

.model-button:hover,
.model-button[aria-expanded="true"] {
  background: var(--accent-soft);
}

.model-button svg {
  color: var(--ink-muted);
}

.model-list {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  min-width: 17rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 50;
}

.model-option {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.1rem 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}

.model-option:hover,
.model-option:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.model-option[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.model-option-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.model-option-note {
  grid-column: 1;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.model-option-check {
  grid-row: 1 / span 2;
  grid-column: 2;
  visibility: hidden;
}

.model-option[aria-selected="true"] .model-option-check {
  visibility: visible;
}

/* Chat / Library tabs: always visible, switch both ways */
.mode-pill {
  display: inline-flex;
}

.mode-tab {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

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

.mode-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Voice input */
.voice-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.icon-round {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-muted);
  border: 0;
}

.icon-round:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--ink);
}

.icon-round.is-listening {
  background: #fdecea;
  color: #c62828;
  animation: dorpus-pulse 1.2s ease-in-out infinite;
}

@keyframes dorpus-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, 0); }
}

.voice-lang {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.1rem;
  border-radius: 6px;
  cursor: pointer;
}

.voice-lang:hover {
  background: var(--accent-soft);
}

.voice-tools.unsupported .voice-lang {
  display: none;
}

/* Actions under an answer, and on source cards */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  margin-top: 0.35rem;
}

.icon-action {
  appearance: none;
  width: 1.9rem;
  height: 1.9rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-action:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.icon-action.is-active {
  color: var(--ink);
}

.icon-action.is-active svg {
  fill: currentColor;
  fill-opacity: 0.15;
}

.icon-action.is-done {
  color: var(--ok);
}

.source-card-top .icon-action {
  margin-left: auto;
}

/* Mobile: the expanded sidebar slides over the page */
@media (max-width: 960px) {
  .app-shell.sidebar-expanded,
  .app-shell.sidebar-expanded.messages-open,
  .app-shell.messages-open {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-open .sidebar {
    width: var(--sidebar-w-open);
    box-shadow: var(--shadow);
  }

  .model-list {
    min-width: 14rem;
  }
}

/* ===========================================================================
   Roles: admin-only controls are hidden from normal users
   =========================================================================== */
body:not(.is-admin) [data-admin-only] {
  display: none !important;
}

.rail-btn[hidden] {
  display: none;
}

[data-feature][hidden],
[data-member-only][hidden] {
  display: none !important;
}

/* ===========================================================================
   Platform: sign in / create account, account button, My library
   =========================================================================== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 90; /* below .modal (100) so the super-admin sign-in opens on top */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 16px;
  background: linear-gradient(180deg, #f6f7f9 0%, #ffffff 60%);
  -webkit-app-region: drag;
  app-region: drag;
}

.auth-gate .auth-card,
.auth-gate .auth-back,
.auth-gate .desktop-win-btn,
.auth-gate input,
.auth-gate button,
.auth-gate label,
.auth-gate a {
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.auth-gate[hidden],
.auth-card[hidden] {
  display: none;
}

body.auth-pending .app-shell {
  visibility: hidden;
}

/* Guest overview uses the same dashboard, with different contents. */
body.is-guest #chat-form,
body.is-guest #home-widgets,
body.is-guest #chat-loading,
body.is-guest .messages-drawer,
body.is-guest #btn-toggle-messages,
body.is-guest .model-menu,
body.is-guest .mode-pill,
body.is-guest #btn-clear-chat,
body.is-guest #btn-chat-history,
body.is-guest .rail-ai,
body.is-guest #chat-history,
body.is-guest #account-menu {
  display: none !important;
}

body.is-guest .view-chat.is-empty {
  justify-content: flex-start;
  padding-top: 0;
  padding-bottom: 0;
}

body.is-guest .view-chat.is-empty .chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

body.is-guest .view-chat.is-empty .chat-footer {
  display: none;
}

body.is-guest .chat-empty {
  max-width: none;
  padding: 0;
}

body.is-guest .guest-top-actions:not([hidden]) {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

body.is-guest .guest-top-actions .guest-go,
body.is-guest .guest-top-actions .guest-quiet {
  padding: 0.4rem 0.85rem;
  font-size: 0.86rem;
}

body.is-guest .app-shell:has(.view-chat.active.is-empty) .topbar-actions {
  opacity: 1;
}

.guest-nav {
  display: none;
  width: 100%;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 0.2rem 0.15rem;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.app-shell.sidebar-expanded .guest-nav:not([hidden]) {
  display: flex;
}

body.is-guest .sidebar {
  justify-content: flex-start;
}

body.is-guest .rail-bottom {
  margin-top: auto;
}

.guest-nav-label {
  display: none;
}

.guest-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.guest-nav-list button {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-ink, #222);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  border-radius: 9px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.guest-nav-list button:hover,
.guest-nav-list button[aria-current="true"] {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.guest-dash {
  width: 100%;
  margin: 0;
  text-align: left;
}

.chat-empty .guest-dash p {
  display: block;
}

.guest-wrap {
  width: min(68rem, calc(100% - 2.4rem));
  margin: 0 auto;
}

.guest-section {
  scroll-margin-top: 0.75rem;
  padding: 2.4rem 0;
}

.guest-section-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.guest-section-lead {
  margin: 0.55rem auto 0;
  max-width: 36rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.guest-go,
.guest-quiet {
  appearance: none;
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

.guest-go {
  border: 0;
  background: var(--send);
  color: #fff;
}

.guest-go:hover {
  filter: brightness(1.08);
}

.guest-quiet {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--ink);
}

.guest-quiet:hover {
  background: var(--accent-soft);
}

.guest-hero {
  padding: 1.75rem 0 0;
  overflow: visible;
  background: #fff;
}

.guest-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 30rem) minmax(0, 1fr);
  gap: 1.25rem 1rem;
  align-items: center;
  width: min(78rem, calc(100% - 1.2rem));
  margin-left: max(1.2rem, calc((100% - 78rem) / 2 + 1.2rem));
  margin-right: 0;
  padding-bottom: 2.6rem;
}

.guest-hero-copy {
  max-width: 34rem;
  padding-right: 0.5rem;
  position: relative;
  z-index: 1;
}

.guest-hero-title {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.55rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.12;
  color: var(--ink);
}

.guest-hero-text {
  margin: 0.85rem 0 0;
  color: var(--ink-muted);
  font-size: 1.02rem;
  line-height: 1.55;
  max-width: 34rem;
}

.guest-hero-actions {
  margin-top: 1.2rem;
}

.guest-hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.guest-hero-notes li {
  position: relative;
  padding-left: 0.9rem;
}

.guest-hero-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--send);
}

.guest-hero-visual {
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  justify-self: end;
  width: min(56rem, 148%);
  transform: translateX(6%) scale(1.08);
  transform-origin: left center;
  margin-block: -0.75rem;
  position: relative;
  z-index: 0;
}

.guest-hero-stack {
  position: relative;
  width: 100%;
  container-type: inline-size;
  container-name: hero-stack;
}

.guest-hero-main {
  position: relative;
  z-index: 1;
  border-radius: 18px;
  overflow: hidden;
}

.guest-hero-main-img,
.guest-hero-main img {
  width: 100%;
  height: auto;
  min-height: 22rem;
  display: block;
  object-fit: contain;
  object-position: center;
}

.guest-hero-float {
  position: absolute;
  z-index: 2;
  background: #fff;
  border: 1px solid rgba(13, 13, 13, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 18px 40px rgba(20, 28, 45, 0.16),
    0 2px 0 rgba(255, 255, 255, 0.7) inset;
  pointer-events: none;
}

.guest-hero-float img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 0;
  object-fit: contain;
  object-position: top center;
}

.guest-hero-float-assistant {
  /* Track hero stack width (no rem cap that freezes while hero shrinks) */
  width: 20%;
  width: 20cqi;
  max-width: none;
  left: 14%;
  right: auto;
  top: 8%;
  transform: rotate(-5deg);
  z-index: 3;
  overflow: hidden;
  animation: guest-hero-float-a 5.5s ease-in-out infinite;
}

.guest-hero-float-assistant img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: top center;
}

.guest-hero-float-chat {
  /* Match left float size; track hero stack width */
  width: 20%;
  width: 20cqi;
  max-width: none;
  right: auto;
  left: 68%;
  bottom: auto;
  top: 30%;
  transform: rotate(3deg);
  z-index: 3;
  overflow: hidden;
  animation: guest-hero-float-b 6.2s ease-in-out infinite;
}

.guest-hero-float-chat img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  object-position: left top;
}

@keyframes guest-hero-float-a {
  0%,
  100% {
    transform: rotate(-5deg) translateY(0);
  }
  50% {
    transform: rotate(-5deg) translateY(-8px);
  }
}

@keyframes guest-hero-float-b {
  0%,
  100% {
    transform: rotate(3deg) translateY(0);
  }
  50% {
    transform: rotate(3deg) translateY(7px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .guest-hero-float-assistant,
  .guest-hero-float-chat {
    animation: none;
  }
}

.guest-workflow-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: top center;
  display: block;
  background: #fff;
}


.guest-workflows {
  background: #f7f7f8;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.guest-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin: 1.35rem auto 0;
  padding: 0.3rem;
  width: fit-content;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.guest-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

.guest-tab.is-active,
.guest-tab[aria-selected="true"] {
  background: var(--send);
  color: #fff;
}

.guest-workflow-stage {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 1.1rem 1.1rem 1.1rem;
}

.guest-workflow-media {
  margin: 0;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #f3f3f3;
  aspect-ratio: 16 / 9;
  min-width: 0;
}

.guest-workflow-copy {
  padding: 0.15rem 0.15rem 0;
  min-width: 0;
  text-align: left;
}

.guest-workflow-copy h3 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.guest-workflow-copy p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.guest-feature-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 1rem;
  margin-top: 1.5rem;
  align-items: stretch;
}

.guest-feature-card {
  background: #f7f7f8;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.9rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 2px rgba(20, 28, 45, 0.04);
}

/* Left cards size to their content; they define the row heights. */
.guest-feature-card.is-wide,
.guest-feature-card.is-compact {
  align-self: start;
  height: auto;
}

.guest-feature-card.is-wide {
  grid-column: 1;
  grid-row: 1;
}

.guest-feature-card.is-tall {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: stretch;
  min-height: 0;
}

.guest-feature-card.is-compact {
  grid-column: 1;
  grid-row: 2;
}

.guest-feature-media {
  margin: 0 0 0.85rem;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  flex: 0 0 auto;
  line-height: 0;
}

.guest-feature-media img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  object-position: top center;
  background: #fff;
}

/* Tall card matches left-column height; image fills that slot (full width, crop bottom). */
.guest-feature-card.is-tall .guest-feature-media {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0.85rem;
  overflow: hidden;
  background: #fff;
}

.guest-feature-card.is-tall .guest-feature-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
}

.guest-feature-card.is-tall h3,
.guest-feature-card.is-tall p {
  flex: 0 0 auto;
}

.guest-feature-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

.guest-feature-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.guest-cta {
  width: 100%;
  scroll-margin-top: 0.75rem;
  padding: 3.2rem 0;
  background: #f3f3f3;
  color: var(--ink);
  text-align: center;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.guest-cta-inner {
  max-width: 52rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guest-cta h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.guest-cta-inner > p {
  margin: 0.65rem auto 0;
  max-width: 32rem;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.guest-cta-actions {
  justify-content: center;
  margin-top: 1.35rem;
}

.guest-store-badges {
  margin-top: 1.15rem;
}

.guest-store-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.7rem 0.85rem;
}

.guest-store-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 160px;
  width: 160px;
  height: 40px;
  line-height: 0;
  overflow: hidden;
  border-radius: 6px;
  cursor: default;
  user-select: none;
  pointer-events: none;
}

.guest-store-badge.is-live {
  cursor: pointer;
  pointer-events: auto;
}

.guest-store-badge img {
  display: block;
  width: 160px;
  height: 40px;
  max-width: none;
  object-fit: contain;
}

.guest-store-note {
  margin: 0.55rem 0 0;
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.guest-store-badges-cta {
  width: 100%;
  margin-top: 1.65rem;
  padding-top: 1.35rem;
  border-top: 1px solid rgba(13, 13, 13, 0.08);
}

.guest-store-badges-cta .guest-store-row,
.guest-store-badges-foot .guest-store-row {
  justify-content: center;
}

.guest-store-badges-cta .guest-store-note,
.guest-store-badges-foot .guest-store-note {
  text-align: center;
}

.guest-store-badges-foot {
  width: min(52rem, 100%);
  margin: 0 auto 0.35rem;
}

.guest-cta .guest-go {
  background: var(--send);
  color: #fff;
}

.guest-cta .guest-quiet {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--ink);
}

.guest-cta .guest-quiet:hover {
  background: var(--accent-soft);
}

.guest-security {
  background: #fff;
}

.guest-point-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.5rem;
}

.guest-point-card {
  background: #f7f7f8;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.15rem 1.2rem;
  min-width: 0;
}

.guest-point-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

.guest-point-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.guest-pricing {
  background: #f3f3f3;
  border-top: 1px solid var(--border);
  padding-top: 3rem;
  padding-bottom: 3.4rem;
}

.guest-public-ask {
  background: #fff;
  border-top: 1px solid var(--border);
  padding-top: 3rem;
  padding-bottom: 3.4rem;
}

.guest-public-ask-wrap {
  max-width: 72rem;
}

.guest-public-ask-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(16rem, 1fr);
  gap: 1.5rem 1.75rem;
  margin-top: 1.65rem;
  align-items: center;
}

.guest-public-ask-media {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(13, 13, 13, 0.08);
  background: #f3f3f3;
  box-shadow:
    0 18px 40px rgba(20, 28, 45, 0.1),
    0 2px 0 rgba(255, 255, 255, 0.7) inset;
}

.guest-public-ask-media img,
.guest-public-ask-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  object-position: top center;
}

.guest-public-ask-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.guest-public-ask-points li {
  position: relative;
  padding: 0.15rem 0 0.15rem 1.85rem;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.45;
  font-weight: 550;
}

.guest-public-ask-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 1.15rem;
  height: 1.15rem;
  background: center / contain no-repeat url("/brand/guest/check-square.png");
}

.guest-price-wrap {
  max-width: 68rem;
}

.guest-price-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
  margin-top: 1.85rem;
  align-items: stretch;
}

.guest-price-card {
  position: relative;
  background: #fff;
  border: 1px solid rgba(13, 13, 13, 0.06);
  border-radius: 22px;
  padding: 1.7rem 1.45rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  box-shadow: 0 10px 28px rgba(20, 28, 45, 0.05);
  overflow: hidden;
}

.guest-price-card.is-featured {
  background:
    radial-gradient(120% 90% at 10% -10%, rgba(11, 87, 208, 0.22), transparent 55%),
    radial-gradient(90% 70% at 90% 0%, rgba(11, 87, 208, 0.12), transparent 50%),
    #fff;
  border-color: rgba(11, 87, 208, 0.14);
  box-shadow:
    0 0 0 1px rgba(11, 87, 208, 0.08),
    0 16px 36px rgba(11, 87, 208, 0.1);
}

.guest-price-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.guest-price-text {
  margin: 0.55rem 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  min-height: 2.8em;
}

.guest-price-amount {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  margin: 1.25rem 0 1.15rem;
}

.guest-price-value {
  font-size: clamp(2rem, 3.2vw, 2.55rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.guest-price-period {
  color: var(--ink-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.guest-price-cta {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.45rem 0.45rem 1.15rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(90deg, #3d7ef0 0%, var(--send) 55%, #0846a8 100%);
  box-shadow: 0 10px 22px rgba(11, 87, 208, 0.22);
}

.guest-price-cta:hover {
  filter: brightness(1.05);
}

.guest-price-cta-label {
  text-align: left;
}

.guest-price-cta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: #0a2540;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  flex: 0 0 auto;
}

.guest-price-note {
  margin: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.guest-price-included {
  margin: 1.35rem 0 0.55rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.guest-price-list {
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1 1 auto;
}

.guest-price-list li {
  position: relative;
  padding: 0.42rem 0 0.42rem 1.85rem;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
}

.guest-price-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42rem;
  width: 1.15rem;
  height: 1.15rem;
  background: center / contain no-repeat url("/brand/guest/check-square.png");
}

.guest-price-list li::after {
  content: none;
}

.guest-foot {
  width: 100%;
  margin: 0;
  scroll-margin-top: 0.75rem;
  padding: 1.65rem 1.35rem 1.7rem;
  border-top: 1px solid var(--border);
  background: #f3f3f3;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guest-foot-copy {
  margin: 0.85rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(13, 13, 13, 0.08);
  width: min(46rem, 100%);
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .guest-hero-grid,
  .guest-point-grid,
  .guest-price-grid,
  .guest-public-ask-stage {
    grid-template-columns: 1fr;
  }

  .guest-price-card.is-featured {
    transform: none;
  }

  .guest-price-grid {
    gap: 0.95rem;
  }

  .guest-feature-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .guest-feature-card.is-tall,
  .guest-feature-card.is-wide,
  .guest-feature-card.is-compact {
    grid-column: auto;
    grid-row: auto;
    align-self: stretch;
  }

  .guest-feature-card.is-tall .guest-feature-media {
    position: relative;
    flex: 0 0 auto;
    min-height: 20rem;
    aspect-ratio: 4 / 5;
  }

  .guest-feature-card.is-tall .guest-feature-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top left;
  }

  .guest-hero-grid {
    width: min(68rem, calc(100% - 2.4rem));
    margin: 0 auto;
    gap: 1.5rem;
    padding-bottom: 1.8rem;
  }

  .guest-hero-visual {
    width: min(36rem, 100%);
    max-width: none;
    transform: none;
    margin-block: 0;
    justify-self: center;
  }

  .guest-hero-main-img,
  .guest-hero-main img {
    min-height: 0;
  }

  .guest-hero-float-assistant {
    width: 22%;
    width: 22cqi;
    left: 10%;
    right: auto;
    top: 6%;
  }

  .guest-hero-float-chat {
    width: 22%;
    width: 22cqi;
    right: auto;
    left: 64%;
    bottom: auto;
    top: 28%;
  }

  .guest-tabs {
    border-radius: 14px;
  }
}


body.auth-open {
  overflow: hidden;
}

.auth-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 28px 20px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 18px;
}

.auth-brand h1 {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
}

.auth-tagline {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--accent-soft);
  border-radius: 999px;
  margin-bottom: 18px;
}

.auth-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form[hidden] {
  display: none;
}

.auth-form .field input {
  font: inherit;
}

.auth-submit {
  width: 100%;
  height: auto;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
}

.auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-error {
  margin: 0;
  min-height: 1.1em;
  color: var(--err);
  font-size: 0.88rem;
}

.auth-foot {
  margin: 16px 0 0;
  text-align: center;
}

.auth-back {
  margin: 1rem 0 0;
  text-align: center;
}

.auth-back .link-btn {
  font-size: 0.92rem;
}

/* Desktop clinic: no guest landing to return to */
body.is-desktop .auth-back {
  display: none;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-decoration: underline;
  cursor: pointer;
}

.app-picker {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.app-picker legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 6px;
  padding: 0;
}

.app-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.app-card:has(input:checked) {
  border-color: var(--send);
  background: #f3f7fe;
}

.app-card.is-soon {
  cursor: default;
  opacity: 0.6;
}

.app-card input {
  margin-top: 3px;
  accent-color: var(--send);
}

.app-card-body {
  display: grid;
  gap: 2px;
}

.app-card-title {
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.app-card-ur {
  font-family: var(--font-urdu);
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--ink-muted);
}

.app-card-text {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.app-card-badge {
  justify-self: start;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--unavailable-bg);
  color: var(--unavailable);
}

.account-label {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.account-label > span,
.account-label > small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-label > small {
  color: var(--sidebar-muted);
  font-size: 0.72rem;
}

.file-btn {
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border-strong);
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.file-btn input[type="file"]:disabled {
  cursor: not-allowed;
}

.mylib-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.mylib-main {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.mylib-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mylib-error {
  color: var(--err);
  font-size: 0.82rem;
}

.badge-private {
  background: #eef2ff;
  color: #3b4fb8;
}

.mylib-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.mylib-status.is-ready {
  background: var(--ok-bg);
  color: var(--ok);
}

.mylib-status.is-processing {
  background: var(--warn-bg);
  color: var(--warn);
}

.mylib-status.is-failed {
  background: var(--err-bg);
  color: var(--err);
}

@media (max-width: 520px) {
  .auth-card {
    padding: 22px 18px 16px;
  }
  .mylib-item {
    flex-wrap: wrap;
  }
}

.admin-open-warning {
  font-size: 0.78rem;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

.modal-card.narrow {
  max-width: 24rem;
}

.admin-form .field input {
  width: 100%;
}

#admin-error {
  color: var(--err);
  min-height: 1.2em;
}

/* ===========================================================================
   Explore: collections → books → hadith
   =========================================================================== */
:root {
  --font-arabic: "Traditional Arabic", "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Arabic Typesetting", "Segoe UI", serif;
  --font-urdu: "Dorpus Nastaliq", "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Urdu Typesetting", serif;
  --explore-accent: #2f6b4f;
}

.explore-panel {
  max-width: 980px;
  padding-bottom: 4rem;
}

.explore-hero h2 {
  font-size: 1.45rem;
  margin: 0.25rem 0 0.2rem;
}

.explore-lead {
  margin: 0 0 1rem;
  color: var(--ink-muted);
}

.explore-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
  background: #fafafa;
}

.explore-jump-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.explore-jump select,
.explore-jump input,
.explore-filter {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
}

.explore-jump input {
  width: 7rem;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.collection-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.collection-card:hover,
.collection-card:focus-visible {
  border-color: var(--explore-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.collection-card-titles {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.collection-en {
  font-weight: 650;
  font-size: 1rem;
}

.collection-ar,
.collection-head-ar,
.book-index-ar {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  color: var(--explore-accent);
}

.collection-meta {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin: 0;
}

.explore-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin: 0.25rem 0 1rem;
  color: var(--ink-muted);
}

.explore-crumbs a {
  color: var(--explore-accent);
  text-decoration: none;
}

.explore-crumbs a:hover {
  text-decoration: underline;
}

.crumb-current {
  color: var(--ink);
}

.collection-head,
.book-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
  margin-bottom: 1rem;
}

.collection-head-titles {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.collection-head h2,
.book-head h2 {
  margin: 0;
  font-size: 1.4rem;
}

.collection-head-ar {
  margin: 0;
  font-size: 1.6rem;
}

.book-head-num {
  margin: 0 0 0.15rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--explore-accent);
}

.explore-filter {
  width: 100%;
  max-width: 22rem;
  margin-bottom: 0.75rem;
}

.book-index {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.book-index li + li {
  border-top: 1px solid var(--border);
}

.book-index-row {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
}

.book-index-row:hover,
.book-index-row:focus-visible {
  background: #f6f8f7;
}

.book-index-num {
  font-weight: 650;
  color: var(--explore-accent);
  text-align: center;
}

.book-index-title {
  font-weight: 550;
}

.book-index-ar {
  font-size: 1.1rem;
}

.book-index-range {
  font-size: 0.78rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.lang-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.86rem;
}

.lang-toggles-label {
  font-weight: 600;
  color: var(--ink-muted);
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

.hadith-chapter {
  font-size: 1rem;
  margin: 1.6rem 0 0.6rem;
  padding-left: 0.6rem;
  border-left: 3px solid var(--explore-accent);
}

.xh-entry {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1.1rem 0.7rem;
  margin-bottom: 0.9rem;
  background: #fff;
  scroll-margin-top: 1rem;
}

.xh-entry.is-focused {
  border-color: var(--explore-accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.12);
}

.xh-entry-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.hadith-number {
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--explore-accent);
  text-decoration: none;
}

.hadith-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.xh-lang {
  margin: 0.55rem 0;
}

.xh-lang p {
  margin: 0;
}

.xh-narrator {
  font-weight: 600;
  margin-bottom: 0.25rem !important;
}

/* All translations (English, Urdu, Bangla) share one size; Arabic is the original. */
.explore-panel {
  --translation-size: 1rem;
}

.xh-en .xh-text,
.xh-bn .xh-text {
  font-size: var(--translation-size);
}

.xh-en .xh-text {
  line-height: 1.65;
}

.xh-ar .xh-text {
  font-family: var(--font-arabic);
  font-size: 1.45rem;
  line-height: 2.1;
  text-align: right;
}

.xh-ur .xh-text {
  font-family: var(--font-urdu);
  font-size: var(--translation-size);
  line-height: 2.5;
  text-align: right;
  word-spacing: 0.05em;
}

.xh-missing {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.xh-missing [lang="ur"] {
  font-family: var(--font-urdu);
  font-size: 0.95rem;
  line-height: 2.2;
}

.xh-inline-ar {
  font-family: var(--font-arabic);
  font-size: 1.15em;
  unicode-bidi: isolate;
}

/* Urdu anywhere else (chat answers, notes) */
:lang(ur) {
  font-family: var(--font-urdu);
}

.xh-bn .xh-text {
  line-height: 1.8;
}

.xh-lang + .xh-lang {
  border-top: 1px dashed var(--border);
  padding-top: 0.55rem;
}

.hadith-refs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.9rem;
  margin: 0.7rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.hadith-refs dt {
  color: var(--ink-muted);
}

.hadith-refs dd {
  margin: 0;
}

.hadith-refs a {
  color: var(--explore-accent);
}

.explore-more {
  display: block;
  margin: 0.5rem auto 1rem;
}

.book-pager {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.book-pager a:only-child {
  margin-left: auto;
}

.view#view-explore .view-panel {
  overflow-y: auto;
}

@media (max-width: 720px) {
  .book-index-row {
    grid-template-columns: 2.2rem 1fr;
  }

  .book-index-ar,
  .book-index-range {
    grid-column: 2;
  }

  .xh-ar .xh-text {
    font-size: 1.3rem;
  }
}

.model-button {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .topbar {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    gap: 0.4rem;
  }

  .topbar-title .brand-word {
    display: none;
  }

  .mode-tab {
    padding: 0.35rem 0.65rem;
  }
}

.book-index-ar:empty {
  display: none;
}

/* ===========================================================================
   Step 2: Teach (lessons, khutbahs, quizzes), Team, invitations
   =========================================================================== */
.auth-tabs[hidden] {
  display: none;
}

.invite-intro {
  margin: 0;
  font-weight: 600;
}

.teach-panel {
  max-width: 54rem;
  margin: 0 auto;
}

.teach-header h2 {
  margin: 0 0 4px;
}

.teach-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--accent-soft);
  border-radius: 999px;
  margin: 12px 0;
}

.teach-tab {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.teach-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.teach-tab[hidden] {
  display: none;
}

.teach-form {
  display: grid;
  gap: 12px;
}

.teach-form[hidden] {
  display: none;
}

.teach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.teach-row .field {
  flex: 1 1 10rem;
}

.teach-row .field-compact {
  flex: 0 0 6.5rem;
}

.teach-row .field.grow {
  flex: 2 1 16rem;
}

.field select {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.teach-or {
  margin: -4px 0 0;
}

.teach-output {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.teach-toolbar {
  justify-content: flex-end;
}

.teach-doc {
  line-height: 1.65;
}

.teach-doc h3 {
  font-size: 1.05rem;
  margin: 1rem 0 0.35rem;
}

.teach-doc h4 {
  font-size: 0.95rem;
  margin: 0.8rem 0 0.3rem;
}

.teach-doc p {
  margin: 0.35rem 0;
}

.teach-doc ul,
.teach-doc ol {
  margin: 0.3rem 0 0.6rem;
  padding-inline-start: 1.4rem;
}

.teach-doc.lang-ur {
  font-family: var(--font-urdu);
  line-height: 2.2;
}

.teach-doc.lang-ar {
  font-family: var(--font-arabic);
  font-size: 1.1rem;
}

.teach-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-family: var(--font);
}

.teach-sources h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.quiz-list {
  margin: 0;
  padding-inline-start: 1.4rem;
  display: grid;
  gap: 18px;
}

.quiz-question {
  font-weight: 600;
  margin: 0 0 8px;
}

.quiz-options {
  display: grid;
  gap: 6px;
}

.quiz-option {
  text-align: start;
  font: inherit;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.quiz-option:hover {
  background: #f7f7f7;
}

.quiz-q.answered .quiz-option.is-correct,
.show-answers .quiz-option.is-correct {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.quiz-q.answered .quiz-option.picked:not(.is-correct) {
  border-color: var(--err);
  background: var(--err-bg);
}

.quiz-feedback {
  margin: 6px 0 0;
  font-size: 0.9rem;
  min-height: 0;
}

.quiz-ref {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.team-subhead {
  font-size: 0.95rem;
  margin: 18px 0 8px;
}

.team-subhead[hidden] {
  display: none;
}

.team-role {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
  font: inherit;
  background: #fff;
}

.team-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.team-pill.is-owner {
  background: #eef2ff;
  color: #3b4fb8;
}

.invite-result {
  margin-top: 10px;
}

.invite-result[hidden] {
  display: none;
}

.invite-link-row {
  display: flex;
  gap: 8px;
}

.invite-link-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  background: #f8f8f8;
}

@media print {
  .sidebar,
  .topbar,
  .notification-area,
  .messages-drawer,
  .no-print,
  .quiz-feedback {
    display: none !important;
  }
  .view:not(#view-teach) {
    display: none !important;
  }
  .page-card {
    border: 0;
    padding: 0;
  }
  .quiz-option {
    border: 0;
    padding: 0.1rem 0;
  }
  .quiz-option.is-correct {
    background: none !important;
  }
}

.teach-quote {
  margin: 0.4rem 0;
  padding: 0.5rem 0.9rem;
  border-inline-start: 3px solid var(--explore-accent, #2f6b4f);
  background: #f7faf8;
  border-radius: 8px;
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  line-height: 1.9;
}

/* ===========================================================================
   Quran: Explore pages, source badge
   =========================================================================== */
.badge-quran {
  background: #e9f5ef;
  color: #1f6b48;
}

.quran-card {
  display: block;
  margin-bottom: 16px;
  border-color: #cfe5d8;
  background: linear-gradient(135deg, #f4fbf7, #ffffff);
}

.quran-hero-ar {
  font-family: var(--font-arabic);
  font-size: 2rem;
  margin: 0;
}

.surah-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 10px;
}

.surah-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  background: #fff;
}

.surah-card:hover {
  border-color: var(--explore-accent);
}

.surah-num {
  width: 2rem;
  height: 2rem;
  flex: 0 0 2rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.surah-names {
  display: grid;
  flex: 1;
  min-width: 0;
}

.surah-en {
  font-weight: 600;
}

.surah-tr {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.surah-ar {
  font-family: var(--font-arabic);
  font-size: 1.3rem;
}

.surah-head {
  text-align: center;
  margin: 8px 0 18px;
}

.surah-head-ar {
  font-family: var(--font-arabic);
  font-size: 2.2rem;
  margin: 0;
  font-weight: 400;
}

.surah-head-en {
  color: var(--ink-muted);
  margin: 4px 0 0;
}

.verse-list {
  display: grid;
  gap: 0;
}

.verse {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.verse-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.verse-key {
  font-weight: 700;
  color: var(--explore-accent);
}

.verse-link {
  color: var(--ink-muted);
}

.verse-ar {
  font-family: var(--font-arabic);
  font-size: 1.75rem;
  line-height: 2.3;
  margin: 8px 0;
}

.verse-tr p {
  margin: 2px 0 8px;
  font-size: var(--translation-size, 1rem);
  line-height: 1.7;
}

.verse-tr-ur p {
  font-family: var(--font-urdu);
  line-height: 2.2;
}

.quran-attribution {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ===========================================================================
   Clinic: reception settings, requests, leaflets
   =========================================================================== */
.check-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.field textarea {
  font: inherit;
}

.request-item.is-new {
  border-color: var(--send);
  background: #f5f8fe;
}

.request-item.is-closed {
  opacity: 0.6;
}

.draft-banner {
  margin: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  font-size: 0.85rem;
}

.leaflet-review {
  margin-top: 1.2rem;
  font-family: var(--font);
  color: var(--ink-muted);
}

@media print {
  .view:not(#view-teach):not(#view-leaflets) {
    display: none !important;
  }
}

.badge-drug {
  background: #eef4ff;
  color: #1d4ed8;
}

/* ===========================================================================
   Account menu (bottom-left) and Settings
   =========================================================================== */
/* Claude-style account row: avatar · name · plan ⌄, plus an apps shortcut. */
.acct {
  position: relative;
  width: 100%;
  margin-top: 0.25rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.acct-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.acct-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.4rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.acct-btn:hover,
.acct-btn[aria-expanded="true"],
.acct-apps:hover {
  background: rgba(0, 0, 0, 0.05);
}

.acct-btn:focus-visible,
.acct-apps:focus-visible,
.acct-item:focus-visible {
  outline: 2px solid #9ec5ff;
  outline-offset: 1px;
}

.acct-avatar {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d9d6cf;
  color: #3b3a36;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.acct-avatar.is-admin {
  background: #1f2937;
  color: #fff;
}

.acct-text {
  display: none;
  min-width: 0;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
}

.acct-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acct-plan {
  color: var(--ink-muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acct-plan:not(:empty)::before {
  content: "· ";
}

.acct-chev {
  display: none;
  flex: none;
  color: var(--ink-muted);
}

.acct-apps {
  display: none;
  flex: none;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  place-items: center;
}

.sidebar-expanded .acct-text {
  display: flex;
}

.sidebar-expanded .acct-chev {
  display: block;
}

.sidebar-expanded .acct-apps {
  display: grid;
}

.app-shell:not(.sidebar-expanded) .acct-btn {
  justify-content: center;
  padding: 0.3rem;
}

.acct-menu {
  position: fixed;
  z-index: 220;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.acct-menu[hidden] {
  display: none;
}

.acct-email {
  padding: 0.45rem 0.6rem 0.4rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.acct-item[hidden] {
  display: none;
}

.acct-item:hover,
.acct-item.open {
  background: #f2f2f0;
}

.acct-item svg {
  flex: none;
  color: #3b3a36;
}

.acct-label {
  flex: 1;
  min-width: 0;
}

.acct-kbd {
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.acct-more {
  color: var(--ink-muted);
}

.acct-sep[hidden] {
  display: none;
}

.acct-sep {
  height: 1px;
  margin: 0.3rem 0.35rem;
  background: var(--border);
}

.acct-sub-note {
  margin: 0.2rem 0.6rem 0.35rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.acct-check {
  visibility: hidden;
  color: var(--ink);
  font-weight: 700;
}

.acct-item[aria-checked="true"] .acct-check {
  visibility: visible;
}

#btn-admin {
  display: none !important;
}

.acct-local {
  margin: -0.15rem 0.6rem 0.35rem;
  font-size: 0.74rem;
  color: #8a5a00;
}

.acct-local.warn {
  color: var(--err, #c62828);
  font-weight: 600;
}

/* Usage and plans */
.usage-sections {
  display: grid;
  gap: 1rem;
}

.usage-card h3 {
  margin: 0 0 0.4rem;
}

.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.usage-row:first-of-type {
  border-top: 0;
}

.usage-left {
  display: grid;
  gap: 0.1rem;
}

.usage-label {
  font-weight: 600;
}

.usage-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.usage-value {
  font-size: 1rem;
  white-space: nowrap;
}

.usage-bar {
  height: 6px;
  margin: -0.2rem 0 0.5rem;
  border-radius: 999px;
  background: #eeeeec;
  overflow: hidden;
}

.usage-bar span {
  display: block;
  height: 100%;
  background: #1f2937;
  border-radius: inherit;
}

.usage-bar.warn span {
  background: #c2410c;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.plan-card.current {
  border-color: #1f2937;
  box-shadow: 0 0 0 1px #1f2937 inset;
}

.plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-head h3 {
  margin: 0;
}

.plan-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #1f2937;
  color: #fff;
}

.plan-meta {
  margin: 0.35rem 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.plan-price {
  margin: 0.45rem 0 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.admin-billing {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.admin-billing h3 {
  margin: 0;
  font-size: 0.95rem;
}

.admin-billing h4 {
  margin: 0 0 0.35rem;
}

.admin-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.admin-section-title {
  display: grid;
  gap: 0.15rem;
}

.admin-section-head .hint {
  margin: 0;
  max-width: 42rem;
}

.admin-filter {
  width: min(18rem, 100%);
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: min(28rem, 70vh);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.admin-table th,
.admin-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--accent-soft);
  font-weight: 650;
}

.admin-table tbody tr:hover {
  background: #fafafa;
}

.admin-table .admin-clinic {
  white-space: normal;
  min-width: 9rem;
  max-width: 14rem;
}

.admin-table .admin-usage {
  white-space: normal;
  min-width: 11rem;
  max-width: 16rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.admin-table .admin-over {
  color: #8a1f1f;
  font-weight: 650;
}

.admin-table input,
.admin-table select {
  width: 100%;
  min-width: 4.25rem;
  max-width: 8.5rem;
  padding: 0.28rem 0.4rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.admin-table input.admin-wide {
  min-width: 8rem;
  max-width: 16rem;
}

.admin-table .btn {
  padding: 0.28rem 0.65rem;
  font-size: 0.8rem;
}

body.is-superadmin-session #settings-chat,
body.is-superadmin-session #settings-prefs .field.grow {
  display: none;
}

.plan-list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
}

.info-body h4 {
  margin: 1rem 0 0.35rem;
}

.info-body h4:first-child {
  margin-top: 0;
}

.info-body p,
.info-body li {
  line-height: 1.55;
}

.info-body ul {
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
}

.btn-row.tight {
  margin-top: 0.2rem;
}

.settings-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}

.settings-facts dt {
  color: var(--ink-muted);
  font-weight: 600;
}

.settings-facts dd {
  margin: 0;
}

.field input[readonly] {
  background: #f6f6f6;
  color: var(--ink-muted);
}

.public-page-card .hint {
  margin: 0 0 0.6rem;
}

.invite-link-row[hidden] {
  display: none;
}

/* Narrow screens: section tabs get their own scrollable row under the title. */
@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "menu title actions" "tabs tabs tabs";
    row-gap: 0.4rem;
    padding: 0.5rem 0.75rem;
  }
  #btn-toggle-sidebar { grid-area: menu; }
  .topbar-title { grid-area: title; min-width: 0; overflow: hidden; }
  .topbar-actions { grid-area: actions; }
  .mode-pill {
    grid-area: tabs;
    justify-self: start;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .mode-pill::-webkit-scrollbar { display: none; }
  .mode-tab { flex: none; white-space: nowrap; }
  .model-button { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.check-count {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.check-have {
  color: #0f6e5b;
  font-weight: 700;
}

/* Clinic details: photo, opening-hours rows, doctor cards */
.pf-photo-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.pf-photo,
.pf-doctor-photo {
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #e8f3ee;
  color: #0f6e5b;
  font-weight: 700;
}

.pf-photo {
  width: 5rem;
  height: 5rem;
  font-size: 1.4rem;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.pf-photo img,
.pf-doctor-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pf-photo-actions {
  display: grid;
  gap: 0.2rem;
}

.pf-upload {
  cursor: pointer;
}

.pf-block {
  margin: 0.4rem 0 0.6rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.pf-block legend {
  padding: 0 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.pf-rows,
.pf-doctors {
  display: grid;
  gap: 0.5rem;
}

.pf-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) 2fr auto;
  gap: 0.5rem;
  align-items: center;
}

.pf-doctor {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfbfa;
}

.pf-doctor-photo {
  width: 3.2rem;
  height: 3.2rem;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
}

.pf-doctor-photo:hover:not(:disabled) {
  box-shadow: 0 0 0 2px #0f6e5b;
}

.pf-doctor-fields {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 0.6fr;
  gap: 0.45rem;
}

.pf-row input,
.pf-doctor-fields input {
  width: 100%;
  min-width: 0;
}

.pf-remove {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.pf-remove:hover {
  background: #fdecea;
  color: var(--err);
}

.pf-add {
  margin-top: 0.4rem;
}

.pf-doctor-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.pf-doctor-foot .field-compact input {
  width: 5rem;
}

@media (max-width: 720px) {
  .pf-doctor-fields {
    grid-template-columns: 1fr 1fr;
  }
  .pf-row {
    grid-template-columns: 1fr auto;
  }
  .pf-row input:nth-child(2) {
    grid-column: 1;
  }
}

.pf-row input,
.pf-doctor-fields input {
  font: inherit;
  font-size: 0.92rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  background: #fff;
  color: var(--ink);
}

.pf-row input:disabled,
.pf-doctor-fields input:disabled {
  background: #f6f6f6;
  color: var(--ink-muted);
}

/* Clinic branch switcher (top bar) */
.branch-switch {
  display: inline-flex;
  align-items: center;
}
.branch-switch[hidden] {
  display: none;
}
.branch-switch select {
  font: inherit;
  font-size: 0.8rem;
  max-width: 11rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: inherit;
  cursor: pointer;
}
.branch-switch select:disabled {
  cursor: default;
  opacity: 0.85;
}
/* The branch matters on clinic screens, not while chatting. */
.app-shell:has(#view-chat.active) .branch-switch,
.app-shell:has(#view-messages.active) .branch-switch {
  display: none;
}

/* "Log in as": shown while an owner/admin views the app as a staff member */
.viewas-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  padding: 0.45rem 1rem;
  background: var(--warn-bg);
  color: var(--warn);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  text-align: center;
}
.viewas-bar[hidden] {
  display: none;
}
.viewas-btn {
  font-size: 0.82rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
}
.team-act {
  font-size: 0.82rem;
  white-space: nowrap;
}
/* Topbar Messages toggle */
.topbar-messages {
  position: relative;
  padding-right: 1.35rem;
}

.topbar-messages-badge {
  position: absolute;
  top: 0.1rem;
  right: 0.15rem;
}

.topbar-messages-badge[hidden] {
  display: none;
}

.topbar-messages[aria-pressed="true"] {
  background: rgba(0, 0, 0, 0.06);
}
.brand-word { white-space: nowrap; }
.model-menu[hidden] {
  display: none;
}

/* Top menu: never overlap the title; scroll sideways when there are many screens */
.topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.mode-pill {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.mode-pill::-webkit-scrollbar {
  display: none;
}

.mode-pill .mode-tab {
  flex: none;
  white-space: nowrap;
}

/* Chat history in the sidebar (like ChatGPT) */
.chat-history {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  margin: 0.6rem 0 0.4rem;
  padding: 0 0.1rem;
}

.sidebar-expanded .chat-history:not([hidden]) {
  display: block;
}

.sidebar-expanded .rail-chats {
  display: none;
}

.chat-history-group {
  margin: 0.85rem 0 0.25rem;
  padding: 0 0.55rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--sidebar-muted, #777);
  text-transform: none;
  letter-spacing: 0;
}

.chat-history-group:first-child {
  margin-top: 0.2rem;
}

.chat-history-empty {
  margin: 0.4rem 0.55rem;
  font-size: 0.8rem;
  color: var(--sidebar-muted, #777);
}

.chat-history-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 9px;
}

.chat-item:hover,
.chat-item.menu-open,
.chat-item:focus-within {
  background: rgba(0, 0, 0, 0.05);
}

.chat-item.active {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.chat-item-open {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--sidebar-ink, #222);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  padding: 0.42rem 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.chat-item-more {
  appearance: none;
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  margin-right: 0.15rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #555;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.chat-item:hover .chat-item-more,
.chat-item.active .chat-item-more,
.chat-item.menu-open .chat-item-more,
.chat-item-more:focus-visible {
  opacity: 1;
}

.chat-item-more:hover {
  background: rgba(0, 0, 0, 0.07);
}

.chat-item-menu {
  position: absolute;
  right: 0.2rem;
  top: 100%;
  z-index: 40;
  min-width: 8.5rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
}

.chat-menu-btn {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  padding: 0.42rem 0.6rem;
  cursor: pointer;
  color: #222;
}

.chat-menu-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.chat-menu-btn.danger {
  color: #b42318;
}

.chat-item-rename {
  width: 100%;
  margin: 0.1rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 8px;
  font: inherit;
  font-size: 0.86rem;
}

/* "Chat with" menu (top left): the AI or a team member */
.model-button {
  position: relative;
}

.convo-badge {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

.convo-badge[hidden] {
  display: none;
}

.model-list .convo-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.convo-avatar {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8eef7;
  color: #2b3a55;
  font-size: 0.7rem;
  font-weight: 700;
}

.convo-avatar.is-ai {
  background: #111;
  color: #fff;
}

.convo-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.convo-text .model-option-name,
.convo-text .model-option-note {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-unread {
  flex: none;
  min-width: 1.3rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3rem;
  text-align: center;
}

.convo-group {
  list-style: none;
  margin: 0.45rem 0.6rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-muted);
}

.convo-note {
  list-style: none;
  margin: 0.2rem 0.6rem 0.45rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  max-width: 17rem;
}

.model-list {
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  min-width: 17rem;
}

/* Team chat (direct messages) */
.view-messages.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 1rem 0.75rem;
}

.team-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
}

.team-avatar {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8eef7;
  color: #2b3a55;
  font-weight: 700;
  font-size: 0.85rem;
}

.team-head-text h2 {
  margin: 0;
  font-size: 1.05rem;
}

.team-head-text p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.team-thread {
  flex: 1 1 auto;
  min-height: 12rem;
  overflow-y: auto;
  padding: 1rem 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.team-empty {
  margin: auto;
  color: var(--ink-muted);
  text-align: center;
}

.team-day {
  align-self: center;
  margin: 0.6rem 0 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: #f1f1f1;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.team-msg {
  max-width: 75%;
  padding: 0.5rem 0.75rem 0.35rem;
  border-radius: 16px;
  background: #f1f3f6;
  align-self: flex-start;
}

.team-msg.mine {
  align-self: flex-end;
  background: #e6efff;
}

.team-msg-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.93rem;
  line-height: 1.45;
}

.team-msg-time {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  color: var(--ink-muted);
  text-align: right;
}

.team-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.team-composer textarea {
  flex: 1 1 auto;
  border: 0;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0;
  max-height: 160px;
  background: transparent;
}

.team-note {
  margin: 0.4rem 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

#team-input,
#team-input:focus {
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  min-height: 0;
}

@media (max-width: 1100px) {
  .topbar-title {
    overflow: visible;
  }
  .model-list {
    max-width: calc(100vw - 24px);
  }
}

/* Sidebar sections: AI chats and team messages */
.side-section[hidden] {
  display: none;
}

.side-section + .side-section {
  margin-top: 0.9rem;
}

.side-head {
  margin: 0.2rem 0 0.15rem;
  padding: 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sidebar-ink, #222);
  letter-spacing: 0;
  text-transform: none;
}

.side-accordion .side-head {
  margin: 0.35rem 0 0;
  padding: 0;
}

.side-accordion-btn {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.side-accordion-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.side-accordion-label {
  flex: 1 1 auto;
  min-width: 0;
}

.side-accordion-chev {
  flex: none;
  color: var(--sidebar-muted, #777);
  transition: transform 0.15s ease;
}

.side-accordion-btn[aria-expanded="true"] .side-accordion-chev {
  transform: rotate(90deg);
}

.side-accordion-panel[hidden] {
  display: none;
}

.team-side-list {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
}

.team-side-item {
  border-radius: 9px;
}

.team-side-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.team-side-item.active {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.team-side-open {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  color: var(--sidebar-ink, #222);
}

.team-side-avatar {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8eef7;
  color: #2b3a55;
  font-size: 0.66rem;
  font-weight: 700;
}

.team-side-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.team-side-name,
.team-side-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team-side-name {
  font-size: 0.86rem;
}

.team-side-item.has-unread .team-side-name {
  font-weight: 700;
}

.team-side-label {
  font-size: 0.72rem;
  color: var(--sidebar-muted, #777);
}

.team-side-unread,
.rail-badge {
  flex: none;
  min-width: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
}

.rail-messages {
  position: relative;
}

.rail-badge {
  position: absolute;
  top: 0.05rem;
  right: 0.05rem;
  min-width: 1rem;
  line-height: 1rem;
  font-size: 0.6rem;
  padding: 0 0.2rem;
}

.rail-badge[hidden] {
  display: none;
}

/* The "chat with" menu belongs to chatting: only on the Chat (and team message) screens. */
.app-shell:not(:has(#view-chat.active, #view-messages.active)) .model-menu {
  display: none;
}

.mode-pill[hidden] {
  display: none;
}

/* Every screen's content uses the same width as Appointments. */
.stage-body .view > .view-panel {
  max-width: 1180px;
  padding: 20px 24px 48px;
}

@media (max-width: 760px) {
  .stage-body .view > .view-panel {
    padding: 14px 12px 40px;
  }
}

/* Semantic search as a card (in My library / Library) */
.search-card .search-header h3 {
  margin: 0 0 4px;
}

.search-card {
  margin-bottom: var(--space-4, 1rem);
}

/* Top bar: title row first, the section tabs on their own centred row below it. */
.topbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "menu title actions" "tabs tabs tabs";
  row-gap: 0.35rem;
}

#btn-toggle-sidebar { grid-area: menu; }
.topbar-title { grid-area: title; }
.topbar-actions { grid-area: actions; }

.mode-pill {
  grid-area: tabs;
  justify-self: center;
  max-width: 100%;
}

/* Chat and team messages use the same content width as the other screens. */
#view-chat {
  --chat-max: 1132px;
}

#view-chat .home-widgets {
  max-width: calc(var(--chat-max) + 2rem);
}

.view-messages.active {
  max-width: 1180px;
  padding: 0 24px 0.75rem;
}

/* Scrollbars stay hidden until the pointer is over that region. */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
*:hover {
  scrollbar-color: rgba(15, 23, 20, 0.35) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 999px;
}
*:hover::-webkit-scrollbar-thumb {
  background-color: rgba(15, 23, 20, 0.35);
}
