/* EIOS Bridge Rooms — Application Styles
 * Mobile-first, SDK v3.3 compliant, no framework
 * Author: Eyean (EOU0222) | 2026-05-18
 */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&display=swap');
@import url('./tokens.css');

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: var(--color-accent-light); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select {
  font: inherit;
  color: inherit;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* ── App Shell ─────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Top Bar (mobile header) ────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: 52px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}
.top-bar__logo {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-accent-light);
  letter-spacing: 0.05em;
}
.top-bar__entity {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: var(--space-4);
  padding-bottom: calc(var(--nav-height) + var(--space-4));
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom Navigation (mobile) ─────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  transition: color var(--dur-fast) var(--ease-out);
  min-height: 44px;  /* Touch target */
  padding: var(--space-2) 0;
}
.bottom-nav__item--active {
  color: var(--color-accent-light);
}
.bottom-nav__icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bottom-nav__label {
  font-size: 10px;
  font-weight: var(--weight-medium);
}

/* ── Desktop Layout ─────────────────────────────────────── */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
  }
  .top-bar {
    display: none;
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--nav-width);
    height: 100dvh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--color-border);
    padding: var(--space-6) 0 var(--space-4);
  }
  .bottom-nav__item {
    flex: unset;
    flex-direction: row;
    justify-content: flex-start;
    padding: var(--space-3) var(--space-6);
    gap: var(--space-3);
    font-size: var(--text-sm);
    border-radius: 0;
  }
  .bottom-nav__item--active {
    background: rgba(99,102,241,0.1);
  }
  .bottom-nav__label {
    font-size: var(--text-sm);
  }
  .bottom-nav__logo {
    padding: 0 var(--space-6) var(--space-6);
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    color: var(--color-accent-light);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
    display: block;
  }
  .nav-spacer { flex: 1; }
  .main-content {
    margin-left: var(--nav-width);
    padding: var(--space-6);
    padding-bottom: var(--space-6);
  }
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: all var(--dur-fast) var(--ease-out);
  min-height: 36px;
  white-space: nowrap;
}
.btn--primary {
  background: var(--color-accent);
  color: white;
}
.btn--primary:hover { background: var(--color-accent-light); }
.btn--secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn--secondary:hover { background: var(--color-surface-3); }
.btn--ghost {
  color: var(--color-text-muted);
}
.btn--ghost:hover { color: var(--color-text); background: var(--color-surface-2); }
.btn--sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); min-height: 44px; }
.btn--icon { padding: var(--space-2); min-width: 44px; min-height: 44px; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.card:hover { border-color: var(--color-border-light); box-shadow: var(--shadow-sm); }
.card--interactive { cursor: pointer; }
.card--interactive:hover { box-shadow: var(--shadow-md); }
.card__header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.card__body { padding: var(--space-4); }
.card__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--live     { color: var(--color-live);     background: rgba(34,197,94,0.12); }
.badge--detached { color: var(--color-detached);  background: rgba(245,158,11,0.12); }
.badge--active   { color: var(--color-active);    background: rgba(34,197,94,0.12); }
.badge--paused   { color: var(--color-paused);    background: rgba(96,165,250,0.12); }
.badge--archived { color: var(--color-archived);  background: rgba(107,114,128,0.12); }
.badge--stopped  { color: var(--color-stopped);   background: rgba(239,68,68,0.12); }
.badge--live::before { animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.4); }
}

/* ── Room Cards ──────────────────────────────────────────── */
.room-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;  /* Prevent grid blowout from nowrap children */
  overflow: hidden;
}
.room-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}
.room-card__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.room-card__icon {
  font-size: var(--text-xl);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.room-card__info { flex: 1; min-width: 0; }
.room-card__name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-card__title {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.room-card__badge { margin-left: auto; flex-shrink: 0; }
.room-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.room-card__meta-item { display: flex; align-items: center; gap: 4px; }
.room-card__actor {
  font-size: var(--text-xs);
  color: var(--color-accent-light);
  font-family: var(--font-mono);
}
.room-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}
.room-card__chat-btn {
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  flex: 1;
  justify-content: center;
}
.room-card__pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: var(--space-2) var(--space-2);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-faint);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.room-card__pin-btn:hover { color: var(--color-text-muted); background: var(--color-surface-3); }
.room-card__pin-btn--active { color: var(--color-warning, #f59e0b); }
.room-card--pinned { border-left: 3px solid var(--color-warning, #f59e0b); }

/* ── Bulk select ─────────────────────────────────────────── */
.room-card--selected-bulk {
  outline: 2px solid var(--color-accent-light);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--color-accent-light) 8%, var(--color-surface));
}
.room-card__checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-accent-light);
  background: var(--color-surface);
  margin-right: var(--space-2);
  flex-shrink: 0;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.room-card--selected-bulk .room-card__checkbox {
  background: var(--color-accent-light);
  border-color: var(--color-accent-light);
  color: white;
}
.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.bulk-action-bar__count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex: 1;
}
.bulk-action-bar__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Grid ────────────────────────────────────────────────── */
.rooms-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 640px) {
  .rooms-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .rooms-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
  .rooms-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.toolbar__search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.toolbar__search input {
  width: 100%;
  padding-left: 36px;
}
.toolbar__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}
.toolbar__sort {
  padding: var(--space-2) var(--space-3);
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  cursor: pointer;
  flex-shrink: 0;
}
.toolbar__filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.filter-chip {
  padding: var(--space-2) var(--space-3);
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.filter-chip:hover { border-color: var(--color-accent); color: var(--color-accent-light); }
.filter-chip--active {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
  color: var(--color-accent-light);
}

/* ── Stats Bar ───────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-item__value {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
  color: var(--color-text);
}
.stat-item__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Section Header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.section-header__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.section-header__count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
  flex-wrap: wrap;
}
.pagination__btn {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  min-width: 36px;
  text-align: center;
  transition: all var(--dur-fast) var(--ease-out);
}
.pagination__btn:hover { border-color: var(--color-accent); color: var(--color-accent-light); }
.pagination__btn--active {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
  color: var(--color-accent-light);
}
.pagination__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination__info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  padding: 0;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: var(--space-4); }
}
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp var(--dur-base) var(--ease-out);
}
@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-xl);
    max-width: 540px;
    margin: auto;
    max-height: 85dvh;
  }
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
}
.modal__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.modal__body { padding: var(--space-5); }
.modal__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  background: var(--color-surface-2);
}

/* ── Detail Panel (slide-in) ─────────────────────────────── */
.detail-panel {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
}
.detail-panel__backdrop {
  flex: 1;
  background: rgba(0,0,0,0.5);
  cursor: pointer;
}
.detail-panel__content {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  animation: slideInRight var(--dur-base) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.detail-panel__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.detail-panel__body {
  flex: 1;
  padding: var(--space-5);
  overflow-y: auto;
}

/* ── Form ────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}
.form-label span { color: var(--color-crimson); margin-left: 2px; }
.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--color-crimson);
}
input.error, textarea.error, select.error {
  border-color: var(--color-crimson);
}

/* ── Room Type Grid ──────────────────────────────────────── */
.room-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.room-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-align: center;
}
.room-type-option:hover {
  border-color: var(--color-accent);
  background: rgba(99,102,241,0.05);
}
.room-type-option--selected {
  border-color: var(--color-accent);
  background: rgba(99,102,241,0.1);
}
.room-type-option__emoji { font-size: var(--text-xl); }
.room-type-option__label {
  font-size: 11px;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  line-height: 1.2;
}

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: slideInRight var(--dur-base) var(--ease-out);
  pointer-events: all;
  max-width: 320px;
}
.toast--success { border-left: 3px solid var(--color-live); }
.toast--error   { border-left: 3px solid var(--color-crimson); }
.toast--info    { border-left: 3px solid var(--color-accent); }

/* ── Loading States ──────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  color: var(--color-text-muted);
  flex-direction: column;
  gap: var(--space-3);
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
  gap: var(--space-3);
  color: var(--color-text-muted);
}
.empty-state__icon { font-size: 3rem; opacity: 0.4; }
.empty-state__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.empty-state__desc { font-size: var(--text-sm); max-width: 320px; }

/* ── Content Lists ───────────────────────────────────────── */
.content-list { display: flex; flex-direction: column; gap: var(--space-2); }
.content-item {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.content-item__icon {
  font-size: var(--text-base);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-3);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.content-item__body { flex: 1; min-width: 0; }
.content-item__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content-item__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Activity View ───────────────────────────────────────── */
.activity-section-title {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.content-item--clickable {
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.content-item--clickable:hover { background: var(--color-surface-3); border-color: var(--color-border-strong, #334155); }
.actor-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}
.actor-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.actor-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-3);
  border-bottom: 1px solid var(--color-border);
}
.actor-card__icon { font-size: var(--text-base); }
.actor-card__name { font-size: var(--text-sm); font-weight: var(--weight-medium); flex: 1; }
.actor-card__count {
  font-size: var(--text-xs);
  color: white;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: var(--weight-medium);
}
.actor-card__rooms { padding: var(--space-2); }
.actor-card__room {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--dur-fast);
}
.actor-card__room:hover { background: var(--color-surface-3); }
.actor-card__chat-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.actor-card__room:hover .actor-card__chat-btn { opacity: 1; }

/* ── Type Breakdown ──────────────────────────────────────── */
.type-breakdown { display: flex; flex-direction: column; gap: var(--space-2); }
.type-bar-row { display: flex; align-items: center; gap: var(--space-2); }
.type-bar-label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  width: 90px;
  flex-shrink: 0;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.type-bar-track {
  flex: 1;
  height: 8px;
  background: var(--color-surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.type-bar-fill {
  height: 100%;
  background: var(--color-accent-light);
  border-radius: 4px;
  min-width: 3px;
  transition: width var(--dur-slow, 0.3s) ease;
}
.type-bar-count {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Section Tabs (detail view) ──────────────────────────── */
.section-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}
.section-tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  cursor: pointer;
}
.section-tab:hover { color: var(--color-text); }
.section-tab--active {
  color: var(--color-accent-light);
  border-bottom-color: var(--color-accent);
}

/* ── Inline Edit ─────────────────────────────────────────── */
.inline-edit {
  position: relative;
  cursor: pointer;
}
.inline-edit:hover .inline-edit__trigger { opacity: 1; }
.inline-edit__trigger {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
  position: absolute;
  right: 0;
  top: 0;
  font-size: var(--text-xs);
  color: var(--color-accent-light);
}

/* ── Auth Screen ─────────────────────────────────────────── */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-6);
  background: var(--color-bg);
}
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.auth-card__logo {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-accent-light);
  margin-bottom: var(--space-2);
}
.auth-card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }
/* ── Theme Toggle ──────────────────────────────────────── */
#theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}
#theme-toggle:active {
  transform: scale(0.92);
}

/* ── Chat View ─────────────────────────────────────────────── */
.chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
  max-height: 70vh;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
  scroll-behavior: smooth;
}

.chat-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-faint);
  padding: var(--space-4);
  font-size: var(--text-sm);
  justify-content: center;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.chat-bubble {
  max-width: 85%;
  align-self: flex-end;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-lg) var(--radius-sm) var(--radius-lg) var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  animation: bubble-in var(--dur-fast) var(--ease-out);
}
/* User sent message (right side) */
.chat-bubble--sent {
  align-self: flex-end;
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
  border-radius: var(--radius-lg) var(--radius-sm) var(--radius-lg) var(--radius-lg);
}
/* Agent / LLM response (left side) */
.chat-bubble--agent {
  align-self: flex-start;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg);
}
.chat-bubble--agent .chat-bubble__sender {
  color: var(--color-live);
}
.chat-bubble--new { animation: bubble-in 200ms var(--ease-out); }

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

.chat-bubble__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}
.chat-bubble__sender {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--color-accent-light);
  font-weight: var(--weight-semibold);
}
.chat-bubble__time {
  font-size: 10px;
  color: var(--color-text-faint);
  margin-left: auto;
}
.chat-bubble__relay {
  font-size: 10px;
  color: var(--color-text-faint);
}
.chat-bubble__content {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text);
  word-break: break-word;
}
.chat-code {
  background: var(--color-surface-3);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow-x: auto;
  white-space: pre-wrap;
  margin: var(--space-1) 0 0;
}

/* Markdown rendering — agent message content */
.chat-inline-code {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--color-accent-light);
}
.chat-heading {
  font-weight: 700;
  line-height: 1.3;
  margin: var(--space-3) 0 var(--space-1);
  color: var(--color-text);
}
.chat-h1 { font-size: var(--text-lg); }
.chat-h2 { font-size: var(--text-base); }
.chat-h3 { font-size: var(--text-sm); }
.chat-list {
  padding-left: var(--space-5);
  margin: var(--space-1) 0;
  list-style-type: disc;
}
.chat-list--ordered { list-style-type: decimal; }
.chat-list__item {
  margin: 2px 0;
  line-height: 1.5;
}
.chat-hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-3) 0;
}
.chat-link {
  color: var(--color-accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-link:hover {
  opacity: 0.8;
}
/* Ensure agent bubble content renders block elements correctly */
.chat-bubble--agent .chat-bubble__content {
  line-height: 1.6;
}
.chat-bubble--agent .chat-bubble__content strong { font-weight: 700; }
.chat-bubble--agent .chat-bubble__content em { font-style: italic; }
.chat-bubble--agent .chat-bubble__content del { text-decoration: line-through; opacity: 0.7; }

/* Typing indicator */
.chat-typing {
  max-width: 80px;
  align-self: flex-start;
  padding: var(--space-2) var(--space-3);
}
.chat-typing__dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}
.chat-typing__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typing-dot 1.2s infinite ease-in-out;
}
.chat-typing__dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Agent activity lines */
.chat-activity-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding: var(--space-1) var(--space-2);
  border-left: 2px solid var(--color-border);
  font-style: italic;
  align-self: flex-start;
  max-width: 95%;
}
.chat-activity-icon { font-size: 12px; }
.chat-activity-time { margin-left: auto; flex-shrink: 0; }

/* Stream status bar */
.chat-stream-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  min-height: 28px;
}
.chat-stream-indicator {
  font-size: 8px;
  transition: color var(--dur-base);
}
.chat-stream-indicator--live        { color: var(--color-live); }
.chat-stream-indicator--connecting  { color: var(--color-gold); animation: pulse 1.5s ease-in-out infinite; }
.chat-stream-indicator--reconnecting{ color: var(--color-gold); animation: pulse 1s ease-in-out infinite; }
.chat-stream-indicator--error       { color: var(--color-crimson); }
.chat-stream-indicator--closed      { color: var(--color-archived); }
.chat-stream-reconnect {
  font-size: var(--text-xs);
  color: var(--color-accent-light);
  background: none;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  cursor: pointer;
}

/* Input area */
.chat-input-area {
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}
.chat-input-wrapper {
  flex: 1;
  position: relative;
}
.chat-textarea {
  width: 100%;
  resize: none;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3) var(--space-5);
  color: var(--color-text);
  transition: border-color var(--dur-fast);
}
.chat-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  outline: none;
}
.chat-input-meta {
  position: absolute;
  bottom: var(--space-1);
  right: var(--space-2);
  display: flex;
  gap: var(--space-3);
  align-items: center;
  pointer-events: none;
}
.chat-char-count { font-size: 10px; color: var(--color-text-faint); }
.chat-draft-saved { font-size: 10px; color: var(--color-accent-light); }

.chat-send-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Chat Toolbar (hint + case buttons + AI toggle) ─────── */
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}
.chat-hint-text {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin: 0;
}
.chat-case-btns {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}
.chat-case-btn {
  min-width: 32px;
  min-height: 32px;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-faint);
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.chat-case-btn:hover,
.chat-case-btn:active {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-accent);
}
.chat-llm-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  cursor: pointer;
}
.chat-llm-toggle input {
  accent-color: var(--color-accent-light);
  width: 14px;
  height: 14px;
}

/* ── Expanded compose mode (mobile full-screen input) ───── */
.chat-input-area--expanded .chat-textarea {
  max-height: 55vh;
  min-height: 30vh;
}
.chat-view--expanded .chat-messages {
  display: none;
}
.chat-view--expanded .chat-stream-bar {
  display: none;
}

/* ── Room Groups ──────────────────────────────────────────── */
.group-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.group-picker {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: bubble-in 150ms var(--ease-out);
}
.group-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.group-picker__list {
  margin-bottom: var(--space-2);
  max-height: 160px;
  overflow-y: auto;
}
.group-picker__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  transition: background var(--dur-fast);
  min-height: 36px;
}
.group-picker__item:hover { background: var(--color-surface-2); }
.group-picker__item--active { font-weight: var(--weight-medium); }
.group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.group-check {
  margin-left: auto;
  color: var(--color-live);
  font-size: 12px;
}
.group-picker__create {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
}
.group-picker__input {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text);
  min-height: 32px;
}

/* ── @mention Autocomplete ────────────────────────────────── */
.mention-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  animation: bubble-in 150ms var(--ease-out);
  margin-bottom: var(--space-1);
}
.mention-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: background var(--dur-fast);
  min-height: 40px;
}
.mention-item:hover,
.mention-item--selected {
  background: var(--color-surface-2);
}
.mention-type-icon { flex-shrink: 0; font-size: 14px; }
.mention-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  flex: 1;
}
.mention-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-faint);
  flex-shrink: 0;
}

/* ── Reactions ────────────────────────────────────────────── */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
.chat-reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--dur-fast);
  min-height: 28px;
  line-height: 1;
}
.chat-reaction-btn:hover {
  background: var(--color-surface-3);
  border-color: var(--color-accent);
}
.chat-reaction-count {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
}
.chat-react-trigger {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  color: var(--color-text-faint);
  min-height: 24px;
  min-width: 28px;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}
.chat-react-trigger:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
/* Show trigger on mobile/touch without hover */
@media (hover: none) {
  .chat-react-trigger { opacity: 0.5 !important; }
}
.chat-reaction-picker {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  margin-top: var(--space-1);
  z-index: 10;
  animation: bubble-in 150ms var(--ease-out);
}
.chat-reaction-picker__btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast);
  min-height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-reaction-picker__btn:hover {
  background: var(--color-surface-2);
}

/* ── Presence System ──────────────────────────────────────── */
.presence-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}
.presence-count {
  font-size: 10px;
  color: var(--color-live);
  font-weight: var(--weight-medium);
  display: flex;
  align-items: center;
  gap: 4px;
}
.presence-count::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-live);
  animation: pulse-live 2s infinite;
}
.presence-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: var(--weight-bold);
  color: white;
  font-family: var(--font-mono);
  border: 2px solid var(--color-bg);
  flex-shrink: 0;
}
.presence-dot--lg {
  width: 32px;
  height: 32px;
  font-size: 11px;
}
.presence-dot--overflow {
  background: var(--color-surface-3);
  color: var(--color-text-faint);
  font-size: 9px;
}
.presence-avatars {
  display: flex;
  gap: -4px;
}
.presence-avatars .presence-dot + .presence-dot {
  margin-left: -8px;
}
.presence-actor-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  min-height: 40px;
}
.presence-actor-row + .presence-actor-row {
  border-top: 1px solid var(--color-border);
}
.presence-actor-info { flex: 1; min-width: 0; }
.presence-actor-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence-actor-meta { font-size: 10px; color: var(--color-text-faint); }
.presence-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Rooms Split Layout ───────────────────────────────────── */
.rooms-layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.rooms-list-pane {
  flex: 1;
  min-width: 0;
}
/* Right pane hidden on mobile — only shows on wide screens when split */
.rooms-detail-pane {
  display: none;
}
.rooms-detail-pane__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  color: var(--color-text-faint);
  text-align: center;
  padding: var(--space-8);
}
/* Selected room card highlight */
.room-card--selected {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.25);
}

@media (min-width: 768px) {
  .rooms-layout--split {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) minmax(320px, 3fr);
    gap: 0;
    height: 100%;
    min-height: 100%;
  }
  .rooms-layout--split .rooms-list-pane {
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding-right: 0;
  }
  .rooms-layout--split .rooms-detail-pane {
    display: block;
    overflow-y: auto;
    padding: var(--space-4);
    position: sticky;
    top: 0;
    max-height: calc(100vh - var(--header-height, 0px));
  }
  /* Non-split wide: show empty right pane as hint */
  .rooms-layout:not(.rooms-layout--split) .rooms-detail-pane {
    display: none;
  }
  /* When split, detail-panel inside pane should not be fixed overlay */
  .rooms-layout--split .rooms-detail-pane .detail-panel {
    position: relative;
    inset: unset;
  }
  .rooms-layout--split .rooms-detail-pane .detail-panel__backdrop {
    display: none;
  }
  .rooms-layout--split .rooms-detail-pane .detail-panel__content {
    position: relative;
    width: 100%;
    height: auto;
    max-width: none;
    border-radius: var(--radius-lg);
    animation: none;
    box-shadow: none;
    border: 1px solid var(--color-border);
  }
}

/* ── Search View ──────────────────────────────────────────── */
.search-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.search-header {
  padding: var(--space-4) 0 var(--space-3);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  z-index: 1;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: var(--space-3);
}
.search-input-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--color-text-faint);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  height: 44px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-10) 0 var(--space-10);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.search-clear-btn {
  position: absolute;
  right: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-faint);
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  min-width: 32px;
  min-height: 32px;
  transition: color var(--dur-fast);
}
.search-clear-btn:hover { color: var(--color-text); }
.search-scopes {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.search-scopes::-webkit-scrollbar { display: none; }
.search-scope {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition: all var(--dur-fast);
}
.search-scope--active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding-bottom: var(--space-8);
}
.search-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) 0;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  justify-content: center;
}
.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0 var(--space-3);
}
.search-results-count {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast);
  min-height: 56px;
}
.search-result-item:hover,
.search-result-item:focus {
  background: var(--color-surface-2);
  outline: none;
}
.search-result-icon {
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.search-result-body { flex: 1; min-width: 0; }
.search-result-name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-title {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-meta {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-tags {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: 2px;
}
.search-highlight {
  background: rgba(99,102,241,0.2);
  color: var(--color-accent-light);
  border-radius: 2px;
  padding: 0 2px;
}
.search-home {
  padding-top: var(--space-4);
}
.search-tips {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-5);
}
.search-tips-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-2);
}
.search-kbd {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
}
.search-history { margin-top: var(--space-2); }
.search-history-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) 0;
}
.search-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  text-align: left;
  min-height: 36px;
  transition: background var(--dur-fast);
}
.search-history-item:hover { background: var(--color-surface-2); }

/* ── Profile View ─────────────────────────────────────────── */
.profile-view {
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: var(--space-8);
}
.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark, #4338ca));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: white;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.profile-entity-id {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-accent-light);
}
.profile-entity-type {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.profile-section {
  margin-bottom: var(--space-5);
}
.profile-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.profile-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
  min-height: 44px;
}
.profile-setting-row:last-child { border-bottom: none; }
.profile-setting-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.profile-setting-desc {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 1px;
}
.profile-toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  min-height: 32px;
  min-width: 32px;
  justify-content: center;
}

/* ── Command Palette ──────────────────────────────────────── */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 1000);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  padding: 10vh var(--space-4) 0;
}
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.cmd-palette-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
  overflow: hidden;
  animation: palette-in 150ms var(--ease-out);
}
@keyframes palette-in {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.cmd-palette-input {
  flex: 1;
  background: none;
  border: none;
  font-size: var(--text-base);
  color: var(--color-text);
  min-height: 36px;
}
.cmd-palette-input::placeholder { color: var(--color-text-faint); }
.cmd-palette-input:focus { outline: none; }
.cmd-esc-hint {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}
.cmd-palette-results {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-1) 0;
}
.cmd-palette-hint {
  padding: var(--space-3) var(--space-4);
}
.cmd-hint-row {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.cmd-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--dur-fast);
  min-height: 44px;
}
.cmd-result-item:hover,
.cmd-result-item--focused {
  background: var(--color-surface-2);
}
.cmd-result-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.cmd-result-name {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-result-title {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  flex-shrink: 0;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-result-type {
  font-size: 10px;
  color: var(--color-text-faint);
  background: var(--color-surface-3);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  flex-shrink: 0;
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.monospace { font-family: var(--font-mono); }
.text-muted { color: var(--color-text-muted); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }
.w-full { width: 100%; }

/* ── Mobile UX Improvements (2026-05-19, EOU0222)
 * Target: <768px viewports — rooms.ecp.xrayvu.com
 * Issues fixed:
 *   1. Section tabs truncated — tighter padding + scroll hint
 *   2. Stat values slightly oversized on small screens
 *   3. Chat textarea too small — increase min-height for comfortable input
 *   4. Room list header stats — compact on narrow screens
 * ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {

  /* 1. Section tabs — tighter padding so all tabs fit without clipping */
  .section-tabs {
    /* Hide scrollbar but keep scroll functionality */
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Fade right edge to hint at scrollable content */
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }
  .section-tabs::-webkit-scrollbar { display: none; }

  .section-tab {
    padding: var(--space-2) var(--space-3);  /* 0.5rem 0.75rem vs 0.75rem 1rem */
    font-size: var(--text-xs);               /* 12px vs 14px */
  }

  /* 2. Stat values — slightly smaller on mobile */
  .stat-item__value {
    font-size: var(--text-lg);   /* 1.125rem vs 1.25rem */
  }

  /* Room list hero stats (399 ROOMS etc) */
  .stats-overview .stat-value,
  .hero-stats .stat-value {
    font-size: var(--text-xl);   /* keep prominent but note not text-2xl */
  }

  /* 3. Chat textarea — big comfortable mobile input + prevent iOS zoom */
  .chat-textarea {
    min-height: 80px;
    max-height: 40vh;   /* don't fight virtual keyboard */
    font-size: 16px;    /* iOS Safari: ≥16px prevents auto-zoom on focus */
  }

  /* Notes textarea in room detail */
  textarea {
    min-height: 80px;
    font-size: 16px;    /* prevent iOS zoom */
  }

  /* 3b. Case buttons — bigger touch targets on mobile */
  .chat-case-btn {
    min-width: 40px;
    min-height: 40px;
    font-size: 13px;
    padding: 6px 8px;
  }
  .chat-toolbar {
    gap: var(--space-2);
  }

  /* 4. Room card metadata — secondary info smaller */
  .room-card__meta,
  .room-card__stats {
    font-size: 11px;
  }

  /* Tighten room card padding */
  .room-card {
    padding: var(--space-3);
  }

  /* Reduce room list header spacing */
  .toolbar {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }

  /* Tighter top-bar */
  .top-bar {
    padding: 0 var(--space-3);
  }
}

@media (max-width: 480px) {
  /* Extra small — aggressive space savings */

  .section-tab {
    padding: var(--space-2) var(--space-2);
    font-size: 11px;
  }

  .stat-item__value {
    font-size: var(--text-base);  /* 1rem */
  }

  .stat-item__label {
    font-size: 10px;
  }

  /* Keep chat input big */
  .chat-textarea {
    min-height: 80px;
  }
}

/* ── Terminal Tab ──────────────────────────────────────────── */
.terminal-tab {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
}
.terminal-tab__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.terminal-tab__room {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.terminal-tab__controls { display: flex; gap: var(--space-2); }
.terminal-status {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}
.terminal-status--connecting {
  background: color-mix(in srgb, var(--color-warning, #f59e0b) 12%, transparent);
  color: var(--color-warning, #f59e0b);
}
.terminal-status--connected {
  background: color-mix(in srgb, var(--color-live) 12%, transparent);
  color: var(--color-live);
}
.terminal-status--disconnected {
  background: color-mix(in srgb, var(--color-archived) 12%, transparent);
  color: var(--color-archived);
}
.xterm-container {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0d1117;
  min-height: 200px;
}
.terminal-output {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #e6edf3;
  background: #0d1117;
  padding: var(--space-3);
  margin: 0;
  min-height: 200px;
  max-height: 350px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal-input-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.terminal-input {
  flex: 1;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text);
  min-height: 44px;
}
.terminal-input:focus {
  outline: none;
  border-color: var(--color-accent-light);
}
.terminal-tab__note {
  text-align: center;
  padding: var(--space-1) 0;
}

/* ── Rich Terminal Input (RTI) ────────────────────────────────── */
.rich-terminal-input {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.rti-toolbar {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.rti-btn {
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 38px;
  min-height: 28px;
  touch-action: manipulation;
  transition: background 0.1s;
}
.rti-btn:hover { background: var(--color-surface-hover, #2a2a3e); color: var(--color-text); }
.rti-btn--danger { border-color: #c84b4b; }
.rti-btn--danger:hover { background: #3a1a1a; }
.rti-emoji-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: 4px var(--space-2);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}
.rti-emoji-label {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-right: 4px;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.rti-emoji-btn {
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
  touch-action: manipulation;
  transition: background 0.1s, border-color 0.1s;
}
.rti-emoji-btn:hover,
.rti-emoji-btn:active { background: var(--color-surface-hover, #2a2a3e); border-color: var(--color-border); }
.rti-emoji-bar--hidden { display: none; }
.rti-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 180px;
  resize: none;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  line-height: 1.5;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.rti-textarea:focus {
  outline: none;
  border-color: var(--color-accent-light);
}
.rti-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.rti-char-count {
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  min-width: 30px;
}
.rti-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.rti-hint {
  font-size: 11px;
  color: var(--color-text-muted);
}
@media (max-width: 600px) {
  .rti-btn { min-width: 44px; min-height: 44px; padding: 6px 10px; font-size: 13px; }
  .rti-textarea { font-size: 16px; min-height: 60px; } /* 16px prevents iOS zoom */
  .rti-hint { display: none; }
}

@media (max-width: 640px) {
  .terminal-output {
    font-size: 11px;
    min-height: 150px;
    max-height: 250px;
  }
}

/* ── Transcript Tab ────────────────────────────────────────── */
.transcript-tab { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-3); }
.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.transcript-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
}
.transcript-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface);
}
.transcript-msg { display: flex; flex-direction: column; gap: 2px; }
.transcript-msg--agent { align-items: flex-start; }
.transcript-msg--user { align-items: flex-end; }
.transcript-msg__meta {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.transcript-msg--user .transcript-msg__meta { flex-direction: row-reverse; }
.transcript-msg__sender { font-weight: var(--weight-medium); color: var(--color-text-muted); }
.transcript-msg__content {
  font-size: var(--text-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  max-width: 90%;
}
.transcript-msg--agent .transcript-msg__content {
  background: color-mix(in srgb, var(--color-accent-light) 8%, var(--color-surface-2));
}

/* ── Artifact type filter chips ──────────────────────────────── */
.art-type-chip--active {
  background: var(--color-accent-light) !important;
  color: var(--color-surface) !important;
  border-color: var(--color-accent-light) !important;
}
