/* ==========================================================================
   Shared components for the chat page: avatar, buttons, switcher, pills,
   progress segments, modals, release-notes entries.
   Tokens (colour, radius, motion) come from tokens.css. Nothing here loops:
   motion is one-shot (entrance, hover, press), and tokens.css already stops
   all of it under prefers-reduced-motion.
   ========================================================================== */

/* ---- Avatar ---- */
.mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---- Identity block (title + status line) ---- */
.brand { min-width: 0; line-height: 1.25; }
.brand strong { display: block; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.brand-org { font-weight: 500; color: var(--text-secondary); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---- Buttons ---- */
.ghost-btn, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.ghost-btn:hover, .btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  color: var(--text-primary);
}
.ghost-btn:active, .btn-ghost:active { transform: scale(0.97); }
.ghost-btn .ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Quiet monospace chips for operator facts (session id, build) */
.meta-chip {
  min-height: 30px;
  padding: 0 9px;
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
.meta-chip:hover { background: var(--bg-subtle); border-color: var(--border); }

/* ---- Chat | Dashboard switcher ---- */
.nav-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.nav-switch-item {
  min-height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-switch-item:hover { color: var(--text-primary); }
.nav-switch-item.is-active { background: var(--brand); color: #fff; }

/* ---- Pills ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}
.pill.live, .badge-live {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-strong);
}
.pill.live::before, .pill.is-offline::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.pill.is-offline {
  background: var(--kb-soft);
  border-color: var(--kb-border);
  color: var(--kb-accent);
}

/* ---- Six-step progress: decorative, the words carry the meaning ---- */
.step-progress {
  flex: none;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  padding: 0 16px 10px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}
.step-progress i {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: #dbe3df;
  transition: background var(--dur-med) var(--ease-out);
}
.step-progress i.is-done { background: var(--brand); }
.step-progress i.is-now { background: linear-gradient(90deg, var(--brand) 0 45%, #dbe3df 45% 100%); }

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeUp var(--dur-fast) var(--ease-out);
}
.modal-backdrop[hidden] { display: none !important; }
/* Sheets follow the visible area (shared/viewport.js), so the keyboard never covers them. */
html.has-vv .modal-backdrop { top: var(--vvt); bottom: auto; height: var(--vvh); }
html.has-vv .modal, html.has-vv .modal-card { max-height: calc(var(--vvh) * 0.92); }
.modal, .modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-popover);
  animation: popIn var(--dur-med) var(--ease-out);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head strong { font-size: 16px; font-weight: 600; color: var(--text-primary); text-wrap: balance; }
.modal-body {
  padding: 14px 20px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

/* ---- Release-notes entries ---- */
.ver-entry {
  margin-top: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.ver-entry h3, .ver-entry h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.ver-entry .vnum {
  display: inline-flex;
  padding: 2px 9px;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
}
.ver-date { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.ver-entry ul { margin: 6px 0 0; padding-left: 18px; }
.ver-entry li { margin: 4px 0; font-size: 13.5px; line-height: 1.5; }

/* ---- Small screens: dialogs become bottom sheets ---- */
@media (max-width: 600px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal, .modal-card {
    max-width: none;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: var(--safe-b);
    animation: sheetIn var(--dur-med) var(--ease-out);
  }
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Touch: nothing interactive under 44px ---- */
@media (pointer: coarse) {
  .ghost-btn, .btn-ghost { min-height: var(--touch); padding: 0 16px; }
  .meta-chip { min-height: var(--touch); }
  .nav-switch-item { min-height: var(--touch); padding: 0 18px; }
  .modal-head { min-height: 56px; }
}
