.nav-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.nav-toggle,
.nav-drawer-head,
.nav-actions,
.nav-backdrop {
  display: none;
}

.nav-backdrop[hidden] {
  display: none !important;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: none;
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.chat-layout.activity-visible {
  grid-template-columns: 300px minmax(0, 1fr) 320px;
}

.chat-panel {
  min-width: 0;
  padding: 18px;
}

.hero-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  margin-bottom: 16px;
}

.compact-field {
  margin: 0;
}

.hero-card h2,
.workspace-head h2 {
  margin: 0;
  font-family: var(--font-serif);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-toolbar {
  justify-content: flex-start;
}

.status-button {
  padding: 0.52rem 0.9rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #bda07a;
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.error,
.status-dot.disconnected {
  background: var(--danger);
}

.robot-grid,
.message-feed {
  display: grid;
  gap: 12px;
}

.message-feed {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.robot-card,
.activity-card,
.message-card {
  min-width: 0;
  padding: 14px;
}

.robot-card {
  display: grid;
  gap: 10px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  white-space: normal;
}

.robot-card.selected {
  border-color: rgba(182, 93, 47, 0.35);
  background: rgba(255, 247, 238, 0.94);
}

.robot-head,
.message-meta,
.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.robot-head,
.message-meta {
  min-width: 0;
  align-items: flex-start;
}

.robot-identity {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.robot-version {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  font-size: 0.78rem;
}

.card-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.robot-meta,
.robot-key,
.activity-target,
.card-content {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.robot-key {
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86rem;
}

.message-meta .muted,
.robot-head .pill {
  flex: 0 0 auto;
}

.workspace-head {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.workspace-head-actions {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-strip {
  flex-wrap: wrap;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: clamp(420px, 62vh, 760px);
  min-width: 0;
  overflow-y: auto;
  padding: 24px 14px 12px;
  margin-bottom: 16px;
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.92), rgba(244, 236, 223, 0.84)),
    radial-gradient(circle at top right, rgba(182, 93, 47, 0.08), transparent 30%);
}

.composer {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.composer .field {
  position: relative;
}

.mention-picker {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 5;
  display: grid;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
}

.mention-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.mention-option.active {
  border-color: rgba(182, 93, 47, 0.35);
  background: rgba(255, 247, 238, 0.96);
}

.attachment-tools {
  display: grid;
  gap: 10px;
}

.attachment-preview {
  display: grid;
  gap: 10px;
}

.attachment-preview-grid,
.attachment-list {
  display: grid;
  gap: 10px;
}

.attachment-toolbar {
  flex-wrap: wrap;
}

.attachment-toolbar .is-recording {
  color: #fff7ef;
  border-color: rgba(143, 66, 25, 0.6);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.attachment-chip {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(88, 61, 35, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.attachment-chip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attachment-remove {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
}

.attachment-remove:hover {
  text-decoration: underline;
}

.image-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(88, 61, 35, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  text-decoration: none;
  color: inherit;
}

.image-thumb {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(239, 232, 223, 0.8);
}

.image-caption {
  font-size: 0.84rem;
  color: var(--muted);
}

.audio-card,
.attachment-link {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(88, 61, 35, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.audio-meta,
.message-attachment-note {
  font-size: 0.84rem;
  color: var(--muted);
}

.audio-player {
  width: 100%;
}

.attachment-link {
  text-decoration: none;
  color: inherit;
}

.conversation .empty-card {
  margin: auto;
  max-width: 540px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(88, 61, 35, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  line-height: 1.8;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-row.outgoing .message-avatar {
  order: 2;
}

.message-row.outgoing .message-bubble {
  order: 1;
}

.message-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(88, 61, 35, 0.12);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
}

.message-avatar.outgoing {
  color: #fff7ef;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.message-avatar.incoming {
  color: #f4fff8;
  background: linear-gradient(135deg, #3a8d61, #2d7e54);
}

.message-avatar.user-reply {
  color: #fffdf7;
  background: linear-gradient(135deg, #0d6d86, #0b5377);
}

.message-avatar.room {
  background: linear-gradient(135deg, rgba(88, 61, 35, 0.16), rgba(112, 86, 62, 0.1));
}

.message-bubble {
  position: relative;
  max-width: min(78%, 760px);
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(88, 61, 35, 0.12);
  box-shadow: 0 14px 26px rgba(83, 49, 18, 0.08);
}

.message-bubble::after {
  position: absolute;
  bottom: 12px;
  width: 12px;
  height: 12px;
  content: "";
  background: inherit;
  border-bottom: inherit;
}

.message-bubble.outgoing {
  margin-left: auto;
  border-bottom-right-radius: 8px;
  color: #fff9f2;
  background: linear-gradient(135deg, rgba(182, 93, 47, 0.96), rgba(143, 66, 25, 0.96));
}

.message-bubble.outgoing::after {
  right: -6px;
  border-right: inherit;
  transform: rotate(-45deg);
}

.message-bubble.incoming {
  margin-right: auto;
  border-bottom-left-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.message-bubble.user-reply {
  margin-right: auto;
  border-bottom-left-radius: 8px;
  border-color: rgba(8, 101, 130, 0.26);
  background: linear-gradient(135deg, rgba(228, 248, 255, 0.98), rgba(208, 239, 250, 0.96));
}

.message-bubble.incoming::after {
  left: -6px;
  border-left: inherit;
  transform: rotate(45deg);
}

.message-bubble.user-reply::after {
  left: -6px;
  border-left: inherit;
  transform: rotate(45deg);
}

.message-bubble.room {
  max-width: min(84%, 820px);
  background: rgba(250, 246, 238, 0.96);
}

.message-bubble.room::after {
  left: -6px;
  border-left: inherit;
  transform: rotate(45deg);
}

.message-meta {
  margin-bottom: 10px;
}

.message-meta-main {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 auto;
}

.message-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.message-kind {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  background: rgba(88, 61, 35, 0.1);
}

.message-kind.outgoing {
  color: var(--accent-strong);
  background: rgba(255, 247, 238, 0.22);
}

.message-kind.incoming {
  color: var(--success);
  background: rgba(45, 126, 84, 0.12);
}

.message-kind.user-reply {
  color: #0b6680;
  background: rgba(11, 102, 128, 0.14);
}

.message-kind.room {
  color: var(--muted);
  background: rgba(88, 61, 35, 0.08);
}

.message-status {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  border: 1px solid rgba(88, 61, 35, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
}

.message-status.status-queued,
.message-status.status-scheduled {
  background: rgba(255, 248, 230, 0.95);
  color: #8f6400;
}

.message-status.status-sent,
.message-status.status-delivered,
.message-status.status-replied {
  background: rgba(233, 247, 239, 0.95);
  color: #1f7a47;
}

.message-status.status-received,
.message-status.status-processing {
  background: rgba(235, 242, 255, 0.95);
  color: #2d5ea8;
}

.message-status.status-stored {
  background: rgba(244, 238, 231, 0.92);
  color: #7f6a52;
}

.message-time {
  white-space: nowrap;
}

.message-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border: 1px solid rgba(88, 61, 35, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  padding: 0.24rem 0.62rem;
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}

.message-copy:hover {
  background: rgba(255, 255, 255, 0.92);
}

.message-copy:disabled {
  cursor: default;
  opacity: 0.78;
}

.message-bubble.outgoing .message-time,
.message-bubble.outgoing .card-title,
.message-bubble.outgoing .message-status,
.message-bubble.outgoing .message-route,
.message-bubble.outgoing .message-content {
  color: #fff9f2;
}

.message-bubble.user-reply .message-route,
.message-bubble.user-reply .message-content {
  color: #114054;
}

.message-bubble.user-reply .message-copy {
  border-color: rgba(8, 101, 130, 0.18);
  background: rgba(255, 255, 255, 0.72);
}

.message-bubble.user-reply .message-copy:hover {
  background: rgba(255, 255, 255, 0.92);
}

.activity-card.user-reply-activity {
  border-color: rgba(8, 101, 130, 0.18);
  background: linear-gradient(180deg, rgba(244, 252, 255, 0.98), rgba(233, 247, 252, 0.96));
}

.message-bubble.outgoing .message-copy {
  border-color: rgba(255, 249, 242, 0.32);
  background: rgba(255, 249, 242, 0.16);
  color: #fff9f2;
}

.message-bubble.outgoing .message-copy:hover {
  background: rgba(255, 249, 242, 0.24);
}

.message-route {
  margin-bottom: 10px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  opacity: 0.84;
}

.message-content {
  min-width: 0;
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.75;
}

.card-content {
  min-width: 0;
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.75;
}

.message-content.is-collapsed,
.card-content.is-collapsed {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  cursor: pointer;
}

.message-content.is-collapsed {
  position: relative;
}

.message-content.is-collapsed::after,
.card-content.is-collapsed::after {
  position: absolute;
  inset: auto 0 0 0;
  height: 2.2rem;
  content: "";
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 251, 244, 0.96));
}

.message-bubble.outgoing .message-content.is-collapsed::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(153, 74, 31, 0.98));
}

.card-content.is-collapsed::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 251, 244, 0.98));
}

.message-expand {
  margin-top: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.message-expand:hover {
  text-decoration: underline;
}

.message-bubble.outgoing .message-expand {
  color: #fff9f2;
}

.empty-card {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-layout.activity-visible {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .nav-header {
    flex: 1 1 auto;
  }

  .nav-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
  }

  .topbar-toolbar {
    display: none;
  }

  .nav-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(86vw, 360px);
    max-width: calc(100vw - 28px);
    overflow-y: auto;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-112%);
    transition: transform 220ms ease, opacity 180ms ease, visibility 0s linear 220ms;
  }

  .nav-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 220ms ease, opacity 180ms ease;
  }

  .nav-drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }

  .nav-actions {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
  }

  .nav-actions .button-ghost {
    display: inline-flex;
    width: 100%;
    align-items: center;
    justify-content: center;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(44, 33, 23, 0);
    backdrop-filter: none;
    transition: opacity 180ms ease, background 180ms ease, backdrop-filter 180ms ease;
  }

  .nav-backdrop:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
    background: rgba(44, 33, 23, 0.28);
    backdrop-filter: blur(3px);
  }

  .chat-panel {
    padding: 16px;
  }

  .workspace-head-actions {
    justify-content: stretch;
  }

  .workspace-head-actions .button-ghost,
  .composer .button {
    width: 100%;
  }

  .conversation {
    height: clamp(360px, 58vh, 620px);
    padding: 18px 10px 10px;
  }

  .message-row {
    gap: 8px;
  }

  .message-avatar {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    font-size: 0.76rem;
  }

  .message-bubble,
  .message-bubble.room {
    max-width: 100%;
    padding: 14px;
  }

  .message-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
