:root {
  --page: #eef1f0;
  --panel: #ffffff;
  --panel-muted: #f6f8f7;
  --panel-strong: #e9edeb;
  --text: #18201e;
  --text-soft: #596460;
  --text-faint: #8a9490;
  --line: #dfe4e1;
  --line-strong: #cbd3cf;
  --accent: #08796b;
  --accent-strong: #075f55;
  --accent-soft: #e5f3f0;
  --blue: #2766c7;
  --blue-soft: #eaf1fc;
  --amber: #9b691d;
  --amber-soft: #fff4de;
  --danger: #b5382d;
  --danger-soft: #fff0ee;
  --shadow: 0 10px 28px rgba(29, 42, 48, 0.1);
  --nav-width: 68px;
  --list-width: 312px;
  --ai-width: 352px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(8, 127, 114, 0.34);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.hidden {
  display: none !important;
}

.spinning {
  animation: spin 0.8s linear infinite;
}

.mobile-only {
  display: none !important;
}

.mobile-nav {
  display: none;
}

.workspace-shell {
  width: 100vw;
  height: 100dvh;
  min-height: 600px;
  display: grid;
  grid-template-columns: var(--nav-width) var(--list-width) minmax(460px, 1fr) var(--ai-width);
  background: var(--panel);
}

.global-nav {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border-right: 1px solid #27312e;
  color: #dce4e1;
  background: #111716;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #e6bf76;
  border-radius: 8px;
  color: #17201d;
  background: #e0ae56;
  text-decoration: none;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.nav-tools,
.nav-bottom {
  display: grid;
  gap: 8px;
}

.nav-tools {
  margin-top: 28px;
}

.nav-bottom {
  margin-top: auto;
}

.nav-button,
.profile-button {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #aebdc1;
  background: transparent;
}

.nav-button:hover,
.nav-button.active {
  color: #ffffff;
  background: #26302d;
}

.profile-button {
  color: #17332e;
  background: #cde9e2;
  font-weight: 800;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border: 1px solid #17272c;
  border-radius: 50%;
  background: #e26754;
}

.conversation-pane,
.ai-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  background: var(--panel);
}

.conversation-pane {
  grid-template-rows: auto auto 1fr auto;
  border-right: 1px solid var(--line);
}

.pane-header,
.ai-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.pane-header h1,
.ai-header h2 {
  font-size: 18px;
  line-height: 1.2;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  background: var(--panel);
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--panel-muted);
}

.icon-button.small {
  width: 32px;
  height: 32px;
}

.icon-button.small svg {
  width: 16px;
  height: 16px;
}

.conversation-controls {
  display: grid;
  gap: 12px;
  padding: 14px 14px 10px;
}

.search-field {
  height: 38px;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-faint);
  background: var(--panel-muted);
}

.search-field:focus-within {
  border-color: #81c9c0;
  background: var(--panel);
}

.search-field input {
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 13px;
}

.search-field input::placeholder {
  color: var(--text-faint);
}

.search-field kbd {
  min-width: 21px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-faint);
  background: var(--panel);
  font-family: inherit;
  font-size: 10px;
  text-align: center;
}

.filter-tabs,
.ai-tabs {
  display: flex;
  align-items: center;
}

.filter-tabs {
  gap: 4px;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.role-switch a {
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.role-switch a.active {
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(29, 42, 48, 0.08);
}

.filter-tab {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--text-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.filter-tab:hover,
.filter-tab.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.conversation-list {
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 12px;
}

.conversation-item {
  position: relative;
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  background: transparent;
}

.conversation-item:hover {
  background: var(--panel-muted);
}

.conversation-item.active {
  background: var(--accent-soft);
}

.conversation-item.active::before {
  position: absolute;
  left: -8px;
  width: 3px;
  height: 36px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  content: "";
}

.avatar,
.contact-avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #294148;
  background: #dce8eb;
  font-size: 14px;
  font-weight: 800;
}

.avatar {
  width: 42px;
  height: 42px;
}

.avatar.tone-2,
.contact-avatar.tone-2 {
  color: #6c4213;
  background: #f4e1c8;
}

.avatar.tone-3,
.contact-avatar.tone-3 {
  color: #315e43;
  background: #d8eadf;
}

.avatar.tone-4,
.contact-avatar.tone-4 {
  color: #635184;
  background: #e8e0f2;
}

.conversation-copy {
  min-width: 0;
}

.conversation-title,
.conversation-preview {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conversation-title strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.managed-badge {
  flex: 0 0 auto;
  color: var(--accent);
}

.managed-badge svg {
  width: 13px;
  height: 13px;
}

.conversation-preview {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 12px;
}

.conversation-preview span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  min-width: 30px;
  display: grid;
  justify-items: end;
  gap: 7px;
  align-self: stretch;
  padding-top: 2px;
}

.conversation-time {
  color: var(--text-faint);
  font-size: 10px;
}

.unread-count {
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  color: #ffffff;
  background: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-faint);
  text-align: center;
  font-size: 13px;
}

.empty-state svg {
  width: 24px;
  height: 24px;
}

.sync-footer {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--line);
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 11px;
}

.sync-indicator > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.sync-indicator.live > span {
  background: var(--accent);
}

.sync-indicator.offline > span {
  background: var(--text-faint);
}

.chat-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  background: #f3f5f4;
}

.chat-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.contact-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.contact-heading {
  min-width: 0;
}

.contact-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.contact-heading h2 {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-heading p {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-strong);
  font-size: 10px;
}

.presence > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.chat-actions {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.conversation-status {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 7px 14px;
  color: var(--text-faint);
  font-size: 10px;
}

.conversation-status > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-strong);
}

.conversation-status svg {
  width: 13px;
  height: 13px;
}

.message-list {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 12px clamp(18px, 5vw, 68px) 22px;
}

.message-row {
  max-width: min(72%, 610px);
  display: grid;
  gap: 4px;
  align-self: flex-start;
}

.message-row.mine {
  align-self: flex-end;
}

.message-bubble {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 8px 2px;
  background: var(--panel);
  box-shadow: 0 2px 5px rgba(29, 42, 48, 0.04);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.mine .message-bubble {
  border-color: #b9ded8;
  border-radius: 8px 8px 2px 8px;
  background: var(--accent-soft);
}

.message-foot {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-faint);
  font-size: 9px;
}

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

.message-foot svg {
  width: 12px;
  height: 12px;
}

.ai-origin {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent-strong);
}

.typing-state {
  width: 54px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 18px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.typing-state span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: typing 1s infinite ease-in-out;
}

.typing-state span:nth-child(2) { animation-delay: 0.15s; }
.typing-state span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.composer {
  margin: 0 clamp(14px, 3vw, 38px) 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(29, 42, 48, 0.08);
}

.draft-source {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px 5px 11px;
  border-bottom: 1px solid #c7e5e0;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 10px;
}

.draft-source span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.draft-source svg {
  width: 13px;
  height: 13px;
}

.draft-source button {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  color: var(--accent-strong);
  background: transparent;
}

.composer textarea {
  width: 100%;
  max-height: 140px;
  min-height: 48px;
  display: block;
  resize: none;
  border: 0;
  outline: 0;
  padding: 13px 14px 6px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.composer-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 7px 7px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer .icon-button {
  border-color: transparent;
}

.ai-quick-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}

.ai-quick-button svg {
  width: 14px;
  height: 14px;
}

.send-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
}

.send-button:hover {
  background: var(--accent-strong);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.send-button svg {
  width: 16px;
  height: 16px;
}

.ai-pane {
  grid-template-rows: auto auto 1fr;
  border-left: 1px solid var(--line);
  background: #fbfcfb;
}

.ai-header {
  padding-left: 18px;
}

.managed-switch {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.managed-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 10px;
  background: #cbd4d8;
  transition: background 160ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  content: "";
  transition: transform 160ms ease;
}

.managed-switch input:checked + .switch-track {
  background: var(--accent);
}

.managed-switch input:checked + .switch-track::after {
  transform: translateX(15px);
}

.managed-switch input:focus-visible + .switch-track {
  outline: 2px solid rgba(8, 127, 114, 0.34);
  outline-offset: 2px;
}

.ai-tabs {
  min-height: 43px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.ai-tab {
  position: relative;
  height: 43px;
  padding: 0 13px;
  border: 0;
  color: var(--text-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.ai-tab.active {
  color: var(--text);
}

.ai-tab.active::after {
  position: absolute;
  right: 11px;
  bottom: -1px;
  left: 11px;
  height: 2px;
  background: var(--accent);
  content: "";
}

.ai-content {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading.compact {
  margin-bottom: 9px;
}

.section-heading h3 {
  font-size: 13px;
}

.section-heading p,
.freshness {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 10px;
}

.generation-state {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #b9ded8;
  border-radius: 8px;
  background: var(--accent-soft);
}

.generation-state div {
  display: grid;
  gap: 3px;
}

.generation-state strong {
  color: var(--accent-strong);
  font-size: 11px;
}

.generation-state span:last-child {
  color: var(--text-soft);
  font-size: 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid #9fd1ca;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.reply-suggestions {
  display: grid;
  gap: 9px;
}

.reply-card {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.reply-card:hover {
  border-color: #a9d8d2;
}

.reply-card-head,
.reply-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reply-label {
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 800;
}

.risk-badge {
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 800;
}

.risk-badge.medium {
  color: var(--amber);
  background: var(--amber-soft);
}

.reply-card p {
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}

.reply-reason {
  min-width: 0;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apply-reply {
  min-height: 27px;
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid #a9d8d2;
  border-radius: 6px;
  color: var(--accent-strong);
  background: var(--panel);
  font-size: 10px;
  font-weight: 800;
}

.apply-reply:hover {
  color: #ffffff;
  background: var(--accent);
}

.risk-strip {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--accent-strong);
}

.risk-strip > svg {
  width: 17px;
  height: 17px;
}

.risk-strip div {
  display: grid;
  gap: 3px;
}

.risk-strip strong {
  font-size: 10px;
}

.risk-strip span {
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.4;
}

.risk-strip.warn {
  color: var(--amber);
}

.context-section {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.context-section:first-child {
  padding-top: 0;
}

.context-section:last-child {
  border-bottom: 0;
}

.summary-text {
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.65;
}

.fact-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 11px;
}

.fact-list dt {
  color: var(--text-faint);
}

.fact-list dd {
  margin: 0;
  color: var(--text);
  text-align: right;
}

.boundary-list {
  display: grid;
  gap: 8px;
}

.boundary-list span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-soft);
  font-size: 11px;
}

.boundary-list svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 320px;
  padding: 10px 13px;
  border: 1px solid #a9d8d2;
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 11px;
}

.toast.error {
  border-color: #efbcb6;
  color: var(--danger);
}

.settings-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(23, 33, 38, 0.38);
}

.settings-dialog header,
.settings-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}

.settings-dialog header { border-bottom: 1px solid var(--line); }
.settings-dialog footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.settings-dialog h2 { font-size: 17px; }

.settings-content {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.settings-content label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.settings-content input,
.settings-content select,
.settings-content textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  color: var(--text);
  background: var(--panel);
  font-size: 12px;
  resize: vertical;
}

.settings-content input:focus,
.settings-content select:focus,
.settings-content textarea:focus { border-color: #81c9c0; }

.settings-status {
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.5;
}

.primary-action,
.secondary-action {
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.primary-action { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.secondary-action { border: 1px solid var(--line); color: var(--text-soft); background: var(--panel); }

body[data-user-role="contact_user"] .ai-pane,
body[data-user-role="contact_user"] [data-open-ai],
body[data-user-role="contact_user"] #quickGenerate,
body[data-user-role="contact_user"] #openSettings,
body[data-user-role="contact_user"] [data-filter="managed"],
body[data-user-role="contact_user"] .mobile-nav [data-mobile-target="ai"],
body[data-user-role="contact_user"] #conversationMode {
  display: none !important;
}

body[data-user-role="contact_user"] .workspace-shell {
  grid-template-columns: var(--nav-width) var(--list-width) minmax(460px, 1fr);
}

@media (max-width: 1180px) {
  :root {
    --list-width: 280px;
    --ai-width: 320px;
  }

  .message-list {
    padding-right: 28px;
    padding-left: 28px;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .desktop-only,
  .global-nav {
    display: none;
  }

  .mobile-only { display: grid !important; }
  .mobile-nav { display: grid; }

  body[data-user-role="contact_user"] .mobile-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  body[data-user-role="contact_user"] .workspace-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-shell {
    min-height: 520px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 58px;
  }

  .conversation-pane,
  .chat-pane,
  .ai-pane {
    grid-column: 1;
    grid-row: 1;
    border: 0;
  }

  body[data-mobile-view="conversations"] .chat-pane,
  body[data-mobile-view="conversations"] .ai-pane,
  body[data-mobile-view="chat"] .conversation-pane,
  body[data-mobile-view="chat"] .ai-pane,
  body[data-mobile-view="ai"] .conversation-pane,
  body[data-mobile-view="ai"] .chat-pane {
    display: none;
  }

  .mobile-nav {
    z-index: 10;
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .mobile-nav button {
    min-width: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    color: var(--text-faint);
    background: transparent;
    font-size: 9px;
  }

  .mobile-nav button.active {
    color: var(--accent-strong);
  }

  .mobile-nav svg {
    width: 19px;
    height: 19px;
  }

  .conversation-pane,
  .ai-pane {
    width: 100%;
  }

  .message-list {
    padding-right: 18px;
    padding-left: 18px;
  }

  .message-row {
    max-width: 84%;
  }

  .ai-content {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }

  .toast {
    right: 12px;
    bottom: 70px;
    left: 12px;
    max-width: none;
  }
}

/* Commercial IM primitives: directory views, groups and rich messages. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.directory-item {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .055);
  color: #eff4f1;
  text-align: left;
  background: transparent;
}

.directory-item:hover { background: rgba(255, 255, 255, .055); }
.directory-item > svg { width: 16px; height: 16px; color: #77837d; }

.directory-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.directory-copy strong,
.directory-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-copy strong { font-size: 12px; }
.directory-copy small { color: #7f8a85; font-size: 10px; }

.avatar.group-avatar,
.contact-avatar.group-avatar {
  color: #f0ca7e;
  background: #4a3a21;
}

.avatar.group-avatar svg { width: 17px; height: 17px; }
.contact-avatar.group-avatar svg { width: 21px; height: 21px; }
.presence > svg { width: 13px; height: 13px; }

.conversation-kind-tabs {
  display: grid;
	grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border: 1px solid #d5dcd6;
  border-radius: 7px;
  background: #eef1ee;
}

.conversation-kind-tabs button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 5px;
  color: #68736e;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
}

.conversation-kind-tabs button.active {
  color: #1b2421;
  background: #fff;
  box-shadow: 0 2px 8px rgba(17, 23, 21, .08);
}

.conversation-kind-tabs svg { width: 15px; height: 15px; }
.conversation-fields { display: grid; gap: 14px; }

.member-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.member-picker legend {
  margin-bottom: 7px;
  color: #59645f;
  font-size: 11px;
  font-weight: 800;
}

#groupMemberList {
  max-height: 210px;
  overflow-y: auto;
  border: 1px solid #cbd2cc;
  border-radius: 7px;
  background: #fff;
}

.member-option {
  min-height: 54px;
  display: grid !important;
  grid-template-columns: 18px 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px !important;
  padding: 7px 10px;
  border-bottom: 1px solid #e2e6e2;
}

.member-option:last-child { border-bottom: 0; }
.member-option input { width: 15px !important; height: 15px; }
.member-option .avatar { width: 34px; height: 34px; font-size: 11px; }
.member-option > span:last-child { min-width: 0; display: grid; gap: 2px; }
.member-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.member-option small { overflow: hidden; color: #7d8883; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.member-picker-empty { margin: 0; padding: 22px 12px; color: #7d8883; text-align: center; font-size: 11px; }

.virtual-character-list {
	max-height: min(430px, 55vh);
	overflow-y: auto;
	border: 1px solid #cbd2cc;
	border-radius: 7px;
	background: #fff;
}

.virtual-character-row {
	min-height: 78px;
	display: grid;
	grid-template-columns: 38px minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
	padding: 10px;
	border-bottom: 1px solid #e2e6e2;
}

.virtual-character-row:last-child { border-bottom: 0; }
.virtual-avatar { color: #f2d287; background: #3d3425; }
.virtual-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.virtual-avatar svg { width: 17px; height: 17px; }

.virtual-character-copy {
	min-width: 0;
	display: grid;
	gap: 3px;
}

.virtual-character-copy strong,
.virtual-character-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.virtual-character-copy strong { color: #1d2824; font-size: 12px; }
.virtual-character-copy small { max-width: 300px; color: #75807b; font-size: 10px; }
.virtual-character-details { border: 0; padding: 3px 0; color: var(--accent); background: transparent; font-size: 11px; cursor: pointer; text-align: left; }
.virtual-character-detail-text { display: block; margin-top: 4px; color: #75807b; font-size: 10px; line-height: 1.45; }

.virtual-character-actions { display: flex; align-items: center; gap: 6px; }
.secondary-action.compact { min-height: 30px; padding: 5px 8px; font-size: 10px; }
.secondary-action.compact svg { width: 13px; height: 13px; }
.virtual-group-action { display: flex; align-items: center; gap: 4px; }
.virtual-group-action select { width: 112px; min-height: 30px; padding: 4px 7px; font-size: 10px; }

@media (max-width: 640px) {
	.virtual-character-row { grid-template-columns: 36px minmax(0, 1fr); }
	.virtual-character-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.upload-state {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-bottom: 1px solid #ded4c0;
  color: #74571f;
  background: #f6ead2;
  font-size: 10px;
}

.upload-state .spinner { width: 13px; height: 13px; border-width: 2px; }
.composer .icon-button.recording { color: #fff; background: #a94442; }

.message-bubble.image,
.message-bubble.voice,
.message-bubble.file { padding: 4px; overflow: hidden; }

.image-message {
  width: min(320px, 58vw);
  min-width: 120px;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #79847f;
  background: #e8ece8;
}

.image-message img { width: 100%; height: 100%; display: block; object-fit: cover; }

.voice-message {
  width: min(280px, 58vw);
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px;
}

.voice-message > svg { width: 18px; height: 18px; }
.voice-message audio { width: 100%; height: 34px; }

.file-message {
  width: min(300px, 64vw);
  min-height: 58px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border: 0;
  border-radius: 5px;
  color: #28332f;
  text-align: left;
  background: #f1f4f0;
}

.file-message > span:first-child {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #856622;
  background: #ead8b4;
}

.file-message > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.file-message strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.file-message small { color: #78837e; font-size: 9px; }
.file-message svg { width: 17px; height: 17px; }
.message-row.mine .file-message { color: #edf3ef; background: #2c3834; }
.message-row.mine .file-message small { color: #a6b0ab; }
.message-row.mine .voice-message audio { color-scheme: dark; }
.system-message { color: #66716c; font-size: 11px; font-style: italic; }
.attachment-loading .spinner { width: 18px; height: 18px; border-width: 2px; }
.message-sender { padding: 0 3px; color: #7c8782; font-size: 9px; }

@media (max-width: 560px) {
  .image-message { width: min(250px, 68vw); }
  .file-message, .voice-message { width: min(250px, 70vw); }
}

@media (max-width: 520px) {
  .workspace-shell {
    min-height: 100dvh;
  }

  .pane-header,
  .ai-header,
  .chat-header {
    min-height: 64px;
  }

  .chat-header {
    padding-right: 10px;
    padding-left: 10px;
  }

  .chat-actions {
    gap: 4px;
  }

  .message-list {
    padding: 8px 12px 16px;
  }

  .message-row {
    max-width: 90%;
  }

  .composer {
    margin: 0 8px 9px;
  }

  .ai-quick-button {
    width: 30px;
    overflow: hidden;
    padding: 0;
    justify-content: center;
    color: var(--accent-strong);
    font-size: 0;
  }

  .search-field kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Account entry */
.session-loading .public-landing,
.session-loading .workspace-shell { visibility: hidden; }
.session-authenticated .public-landing { display: none; }
.session-authenticated .workspace-shell { display: grid; }
.session-anonymous .workspace-shell { display: none; }
body.session-anonymous,
body.register-page { overflow-y: auto; }
.danger-action { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; margin-right: auto; padding: 7px 10px; border: 0; color: #ae4337; background: transparent; font-size: 11px; font-weight: 800; }
.danger-action svg { width: 15px; height: 15px; }
.workspace-empty { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--text-soft); background: var(--panel-muted); text-align: center; }
.workspace-empty > span { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); background: var(--panel); }
.workspace-empty > span svg { width: 24px; height: 24px; }
.workspace-empty h2 { font-size: 16px; }
.workspace-empty p { color: var(--text-faint); font-size: 10px; }
.workspace-empty button { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; padding: 7px 12px; border: 0; border-radius: 7px; color: #fff; background: var(--accent); font-size: 11px; font-weight: 800; }
.workspace-empty button svg, #createConversation svg { width: 15px; height: 15px; }
.chat-pane.no-conversation > :not(.workspace-empty) { visibility: hidden; }
.settings-status.error { color: #ae4337; }

/* Immersive account entry, adapted to ChatAid's communication product. */
.auth-screen {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 42vw);
  overflow: hidden;
  color: #f4f7f6;
  background: #111716;
}

.auth-media,
.auth-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.auth-media {
  z-index: -3;
  object-fit: cover;
  object-position: center 48%;
  filter: saturate(.78) contrast(1.03);
  animation: authMediaEnter 1.2s ease-out both;
}

.auth-overlay {
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(12, 18, 16, .88) 0%, rgba(12, 18, 16, .72) 35%, rgba(12, 18, 16, .34) 62%, rgba(12, 18, 16, .78) 100%),
    linear-gradient(180deg, rgba(10, 15, 14, .35) 0%, transparent 50%, rgba(10, 15, 14, .76) 100%);
}

.auth-brand-panel {
  min-width: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 36px clamp(34px, 6vw, 96px);
  color: #f4f7f6;
  background: transparent;
}

.auth-brand,
.mobile-auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
}

.auth-brand > span,
.mobile-auth-brand > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(250, 213, 142, .8);
  border-radius: 8px;
  color: #19211f;
  background: #e0ae56;
  box-shadow: 0 8px 28px rgba(10, 15, 14, .24);
}

.auth-brand svg,
.mobile-auth-brand svg { width: 19px; height: 19px; stroke-width: 2.1; }
.auth-brand strong,
.mobile-auth-brand strong { display: flex; align-items: baseline; gap: 7px; font-size: 18px; }
.auth-brand small,
.mobile-auth-brand small { color: rgba(255, 255, 255, .58); font-size: 9px; font-weight: 800; }

.auth-brand-copy {
  position: static;
  z-index: auto;
  width: min(600px, 100%);
  margin: auto 0;
  padding: 56px 0;
  animation: authCopyEnter .85s cubic-bezier(.16, 1, .3, 1) both;
}

.auth-kicker,
.auth-section-label {
  display: block;
  color: #efc77f;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-kicker { margin-bottom: 16px; }
.auth-brand-copy h1 { color: #fff; font-size: clamp(48px, 6vw, 82px); line-height: 1; }
.auth-brand-copy .auth-statement { margin-top: 20px; color: rgba(255, 255, 255, .88); font-size: clamp(18px, 2vw, 26px); line-height: 1.5; }

.auth-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 34px;
  color: rgba(238, 244, 241, .68);
  font-size: 11px;
}

.auth-capabilities span { display: inline-flex; align-items: center; gap: 7px; }
.auth-capabilities svg { width: 15px; height: 15px; color: #efc77f; }

.auth-credit {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: rgba(236, 243, 239, .42);
  font-size: 9px;
}

.auth-credit a { color: inherit; text-decoration: none; }
.auth-credit a:hover { color: rgba(255, 255, 255, .72); }

.auth-form-panel {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px clamp(28px, 5vw, 76px) 32px 28px;
}

.auth-card {
  width: min(410px, 100%);
  max-height: calc(100svh - 64px);
  overflow-y: auto;
  padding: 28px 30px 24px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  color: #f3f6f5;
  background: rgba(16, 22, 20, .84);
  box-shadow: 0 24px 70px rgba(4, 8, 7, .38);
  backdrop-filter: blur(24px) saturate(1.12);
  -webkit-backdrop-filter: blur(24px) saturate(1.12);
  scrollbar-width: thin;
  animation: authPanelEnter .8s cubic-bezier(.16, 1, .3, 1) .08s both;
}

.mobile-auth-brand { display: none; }
.auth-card header { margin: 2px 0 22px; }
.auth-section-label { margin-bottom: 9px; }
.auth-card h2 { color: #fff; font-size: 25px; }
.auth-card header p { margin-top: 7px; color: rgba(232, 238, 235, .56); font-size: 12px; }

#authForm { display: grid; gap: 15px; }
#authForm > label { display: grid; gap: 7px; color: rgba(235, 241, 238, .72); font-size: 10px; font-weight: 800; }

.auth-input {
  width: 100%;
  height: 44px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 7px;
  color: rgba(230, 238, 234, .45);
  background: rgba(255, 255, 255, .055);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.auth-input.password-input { grid-template-columns: 18px minmax(0, 1fr) 32px; padding-right: 5px; }
.auth-input:hover { border-color: rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .07); }
.auth-input:focus-within { border-color: rgba(224, 174, 86, .66); background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 3px rgba(224, 174, 86, .1); }
.auth-input > svg { width: 15px; height: 15px; }

#authForm .auth-input input {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 12px;
}

#authForm .auth-input input:focus { border: 0; box-shadow: none; }
#authForm .auth-input input::placeholder { color: rgba(232, 239, 235, .34); }
.password-input button { width: 32px; height: 36px; display: grid; place-items: center; border: 0; color: rgba(232, 239, 235, .42); background: transparent; }
.password-input button:hover { color: #fff; }
.password-input button svg { width: 16px; height: 16px; }

.registration-note {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(224, 174, 86, .18);
  border-radius: 6px;
  color: rgba(239, 222, 190, .72);
  background: rgba(224, 174, 86, .07);
  font-size: 10px;
  line-height: 1.55;
}

.registration-note svg { width: 14px; height: 14px; margin-top: 1px; color: #e0ae56; }
.auth-row { display: flex; align-items: center; color: rgba(232, 239, 235, .58); font-size: 10px; }
.auth-row label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.auth-row input { width: 14px; height: 14px; accent-color: #e0ae56; }

.auth-submit {
  width: 100%;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1px;
  border: 1px solid #e4b867;
  border-radius: 7px;
  color: #18201e;
  background: #e0ae56;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(224, 174, 86, .13);
  transition: background-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.auth-submit:hover:not(:disabled) { background: #e8bc6d; transform: translateY(-1px); box-shadow: 0 10px 28px rgba(224, 174, 86, .2); }
.auth-submit:disabled { cursor: wait; opacity: .72; }
.auth-submit svg { width: 16px; height: 16px; }
.submit-loader { display: none; }
.auth-submit.submitting .submit-arrow { display: none; }
.auth-submit.submitting .submit-loader { display: block; animation: spin .8s linear infinite; }

.auth-error { padding: 9px 10px; border: 1px solid rgba(235, 128, 111, .3); border-radius: 6px; color: #ffc0b6; background: rgba(181, 56, 45, .12); font-size: 10px; line-height: 1.5; }
.auth-card-footer { display: grid; gap: 10px; margin-top: 20px; color: rgba(232, 239, 235, .34); font-size: 9px; text-align: center; }
.admin-entry { margin-top: 0; color: rgba(232, 239, 235, .45); font-size: 10px; }
.admin-entry a { margin-left: 4px; color: #efc77f; font-weight: 800; text-decoration: none; }
.admin-entry a:hover { color: #ffe0a6; }

@keyframes authPanelEnter { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes authCopyEnter { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes authMediaEnter { from { opacity: .4; transform: scale(1.025); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 820px) {
  .auth-screen { display: block; overflow-y: auto; }
  .auth-brand-panel { display: none; }
  .auth-media { position: fixed; object-position: 48% center; }
  .auth-overlay { position: fixed; background: rgba(10, 15, 14, .76); }
  .auth-form-panel { min-height: 100svh; padding: 24px 20px; }
  .auth-card { max-height: none; padding: 26px 24px 22px; background: rgba(15, 21, 19, .88); }
  .mobile-auth-brand { display: flex; margin-bottom: 38px; }
}

@media (max-width: 420px) {
  .auth-form-panel { padding: 16px 12px; }
  .auth-card { padding: 24px 20px 20px; }
  .auth-card h2 { font-size: 23px; }
  .mobile-auth-brand { margin-bottom: 30px; }
}

/* Public landing, login dialog, and dedicated registration page. */
.public-landing,
.register-screen {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  overflow: hidden;
  color: #f4f7f6;
  background: #111716;
}

.public-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(28px, 5vw, 76px);
}

.public-actions,
.public-cta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.public-register-link,
.public-login-button,
.public-primary-action,
.public-secondary-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.public-register-link { padding: 0 8px; color: rgba(255, 255, 255, .78); }
.public-register-link:hover { color: #fff; }
.public-login-button { padding: 0 17px; border: 1px solid rgba(255, 255, 255, .24); color: #fff; background: rgba(12, 18, 16, .35); backdrop-filter: blur(12px); }
.public-login-button:hover { border-color: rgba(255, 255, 255, .46); background: rgba(12, 18, 16, .56); }
.public-login-button svg,
.public-primary-action svg { width: 16px; height: 16px; }

.public-hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 120px clamp(32px, 8vw, 124px) 190px;
}

.public-copy {
  width: min(700px, 72vw);
  animation: authCopyEnter .85s cubic-bezier(.16, 1, .3, 1) both;
}

.public-copy h1 { color: #fff; font-size: clamp(58px, 8vw, 112px); line-height: .95; }
.public-copy > p { max-width: 620px; margin-top: 22px; color: rgba(255, 255, 255, .88); font-size: 20px; line-height: 1.65; }
.public-cta { margin-top: 34px; }
.public-primary-action { padding: 0 20px; border: 1px solid #e4b867; color: #18201e; background: #e0ae56; }
.public-primary-action:hover { background: #e8bc6d; transform: translateY(-1px); }
.public-secondary-action { padding: 0 17px; border: 1px solid rgba(255, 255, 255, .18); color: #fff; background: rgba(255, 255, 255, .05); }
.public-secondary-action:hover { border-color: rgba(255, 255, 255, .36); background: rgba(255, 255, 255, .1); }

.public-capabilities {
  position: absolute;
  left: clamp(28px, 5vw, 76px);
  right: clamp(28px, 5vw, 76px);
  bottom: 26px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid rgba(255, 255, 255, .16);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: rgba(10, 15, 14, .32);
  backdrop-filter: blur(14px);
}

.public-capabilities > span {
  min-width: 0;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 3px 10px;
  padding: 18px 22px;
  border-right: 1px solid rgba(255, 255, 255, .12);
}

.public-capabilities > span:last-child { border-right: 0; }
.public-capabilities i,
.public-capabilities svg { grid-row: 1 / 3; width: 18px; height: 18px; margin-top: 2px; color: #efc77f; }
.public-capabilities strong { font-size: 12px; }
.public-capabilities small { grid-column: 2; overflow: hidden; color: rgba(238, 244, 241, .56); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.public-landing > .auth-credit { position: absolute; right: clamp(28px, 5vw, 76px); bottom: 9px; z-index: 3; display: block; color: rgba(236, 243, 239, .42); font-size: 9px; text-decoration: none; }
.public-landing > .auth-credit:hover { color: rgba(255, 255, 255, .72); }

.auth-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  color: #f3f6f5;
  background: rgba(16, 22, 20, .97);
  box-shadow: 0 28px 90px rgba(4, 8, 7, .56);
  backdrop-filter: blur(24px) saturate(1.12);
  scrollbar-width: thin;
}

.auth-dialog::backdrop { background: rgba(5, 10, 9, .7); backdrop-filter: blur(8px); }
.auth-dialog[open] { animation: authDialogEnter .24s cubic-bezier(.16, 1, .3, 1) both; }
.auth-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 26px 28px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.auth-dialog-header h2,
.register-panel h2 { margin-top: 7px; color: #fff; font-size: 24px; }
.auth-dialog-header p,
.register-panel header > p { margin-top: 7px; color: rgba(232, 238, 235, .56); font-size: 12px; }
.auth-dialog-close { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid rgba(255, 255, 255, .1); border-radius: 6px; color: rgba(232, 239, 235, .62); background: rgba(255, 255, 255, .05); }
.auth-dialog-close:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.auth-dialog-close svg { width: 16px; height: 16px; }

.auth-dialog #authForm { display: grid; gap: 15px; padding: 24px 28px 4px; }
.auth-dialog #authForm > label,
#registerForm > label { display: grid; gap: 7px; color: rgba(235, 241, 238, .72); font-size: 10px; font-weight: 800; }
.auth-dialog .auth-card-footer { display: grid; gap: 9px; margin: 0; padding: 18px 28px 22px; color: rgba(232, 239, 235, .38); font-size: 9px; text-align: center; }
.auth-dialog .auth-card-footer p { margin: 0; font-size: 10px; }
.auth-dialog .auth-card-footer a,
.register-footer a { color: #efc77f; font-weight: 800; text-decoration: none; }
.auth-dialog .auth-card-footer a:hover,
.register-footer a:hover { color: #ffe0a6; }

.register-screen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(440px, 42vw); }
.register-brand { position: absolute; top: 32px; left: clamp(30px, 6vw, 92px); z-index: 3; }
.register-copy { align-self: center; z-index: 2; max-width: 650px; padding: 120px clamp(38px, 7vw, 112px); }
.register-copy h1 { color: #fff; font-size: clamp(40px, 5vw, 68px); line-height: 1.16; }
.register-copy p { margin-top: 20px; color: rgba(255, 255, 255, .72); font-size: 16px; }
.register-panel { z-index: 2; align-self: center; width: min(430px, calc(100% - 48px)); max-height: calc(100svh - 48px); overflow-y: auto; margin: 24px auto; padding: 26px 30px 24px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 8px; background: rgba(16, 22, 20, .9); box-shadow: 0 24px 70px rgba(4, 8, 7, .38); backdrop-filter: blur(24px); scrollbar-width: thin; }
.register-panel header { margin-bottom: 22px; }
.register-back { display: none; align-items: center; gap: 6px; margin-bottom: 24px; color: rgba(232, 239, 235, .62); font-size: 11px; text-decoration: none; }
.register-back svg { width: 15px; height: 15px; }
#registerForm { display: grid; gap: 15px; }
#registerForm .auth-input input { min-width: 0; width: 100%; height: 100%; padding: 0; border: 0; outline: 0; color: #fff; background: transparent; font-size: 12px; }
#registerForm .auth-input input::placeholder { color: rgba(232, 239, 235, .34); }
.register-footer { margin-top: 20px; color: rgba(232, 239, 235, .5); font-size: 10px; text-align: center; }

@keyframes authDialogEnter { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 820px) {
  .public-header { padding: 20px; }
  .public-register-link { display: none; }
  .public-hero { align-items: flex-end; padding: 110px 24px 205px; }
  .public-copy { width: min(100%, 620px); }
  .public-copy h1 { font-size: 58px; }
  .public-copy > p { font-size: 16px; }
  .public-capabilities { left: 20px; right: 20px; bottom: 24px; }
  .public-capabilities > span { padding: 15px 14px; }
  .public-capabilities small { display: none; }
  .public-landing > .auth-credit { display: none; }
  .register-screen { display: block; overflow-y: auto; }
  .register-screen .auth-media,
  .register-screen .auth-overlay { position: fixed; }
  .register-copy,
  .register-brand { display: none; }
  .register-panel { width: min(430px, calc(100% - 32px)); max-height: none; margin: 16px auto; background: rgba(15, 21, 19, .92); }
  .register-back { display: inline-flex; }
}

@media (max-width: 420px) {
  .public-header .auth-brand > span { width: 34px; height: 34px; }
  .public-header .auth-brand strong { font-size: 16px; }
  .public-login-button { min-height: 38px; padding: 0 13px; }
  .public-hero { padding: 96px 18px 198px; }
  .public-copy h1 { font-size: 50px; }
  .public-copy > p { margin-top: 17px; font-size: 15px; }
  .public-cta { align-items: stretch; flex-direction: column; gap: 9px; margin-top: 26px; }
  .public-primary-action,
  .public-secondary-action { width: 100%; }
  .public-capabilities { left: 12px; right: 12px; }
  .public-capabilities > span { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 6px; }
  .public-capabilities i,
  .public-capabilities svg { width: 15px; height: 15px; margin: 0; }
  .public-capabilities strong { font-size: 10px; }
  .auth-dialog { width: calc(100vw - 24px); max-height: calc(100svh - 24px); }
  .auth-dialog-header { padding: 22px 20px 18px; }
  .auth-dialog #authForm { padding: 20px 20px 4px; }
  .auth-dialog .auth-card-footer { padding-inline: 20px; }
  .register-panel { width: calc(100% - 24px); padding: 24px 20px 22px; }
}

/* Dramalink workspace */
:root {
  --page: #e8ebe8;
  --panel: #fcfdfb;
  --panel-muted: #f2f4f1;
  --panel-strong: #e6eae6;
  --text: #171d1b;
  --text-soft: #58625e;
  --text-faint: #87918c;
  --line: #dce1dc;
  --line-strong: #c7cec8;
  --accent: #0b7b6d;
  --accent-strong: #075f55;
  --accent-soft: #e2f1ed;
  --gold: #d9a84f;
  --gold-soft: #f7edd9;
  --ink: #111715;
  --ink-raised: #19201e;
  --ink-line: #2a3430;
  --shadow: 0 16px 40px rgba(17, 23, 21, .14);
  --nav-width: 78px;
  --list-width: 326px;
  --ai-width: 366px;
}

.session-authenticated {
  color: var(--text);
  background: var(--ink);
}

.workspace-shell {
  background: var(--page);
}

.global-nav {
  position: relative;
  padding: 20px 14px 16px;
  border-right-color: var(--ink-line);
  background: var(--ink);
}

.global-nav::after {
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 112px;
  background: var(--gold);
  content: "";
}

.workspace-brand {
  display: grid;
  justify-items: center;
  gap: 7px;
}

.workspace-brand > span {
  color: rgba(239, 224, 195, .54);
  font-size: 8px;
  font-weight: 900;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-color: #edc97f;
  color: #18201d;
  background: var(--gold);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .2);
}

.nav-tools { margin-top: 34px; }
.nav-tools, .nav-bottom { gap: 10px; }

.nav-button,
.profile-button {
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  color: #8f9a95;
}

.nav-button:hover,
.nav-button.active {
  border-color: #35403c;
  color: #f5f8f6;
  background: #222a27;
}

.nav-button.active::before {
  position: absolute;
  left: -15px;
  width: 3px;
  height: 22px;
  background: var(--gold);
  content: "";
}

.profile-button {
  border-color: rgba(217, 168, 79, .35);
  color: #251d0f;
  background: var(--gold);
}

.conversation-pane {
  border-right-color: var(--ink-line);
  color: #eef3f0;
  background: var(--ink-raised);
}

.conversation-pane .pane-header {
  min-height: 82px;
  padding: 17px 18px;
  border-bottom-color: var(--ink-line);
  background: #171e1b;
}

.conversation-pane .eyebrow {
  color: #d9b774;
}

.conversation-pane .pane-header h1 {
  color: #f7f9f8;
  font-size: 20px;
}

.conversation-pane .icon-button {
  border-color: #36403c;
  color: #d7dfdb;
  background: #222a27;
}

.conversation-pane .icon-button:hover {
  border-color: #d1ab65;
  color: #f2cc83;
  background: #2a322f;
}

.conversation-controls {
  gap: 13px;
  padding: 16px 14px 12px;
}

.conversation-pane .search-field {
  height: 40px;
  border-color: #343e3a;
  color: #7f8c86;
  background: #111715;
}

.conversation-pane .search-field:focus-within {
  border-color: #9d834f;
  background: #151c19;
  box-shadow: 0 0 0 3px rgba(217, 168, 79, .08);
}

.conversation-pane .search-field input { color: #eff4f1; }
.conversation-pane .search-field input::placeholder { color: #707b76; }

.conversation-pane .search-field kbd {
  border-color: #35403c;
  color: #77837d;
  background: #202825;
}

.filter-tabs { gap: 5px; }

.conversation-pane .filter-tab {
  min-height: 31px;
  padding: 5px 11px;
  color: #89958f;
}

.conversation-pane .filter-tab:hover,
.conversation-pane .filter-tab.active {
  color: #f1cd88;
  background: rgba(217, 168, 79, .11);
}

.conversation-list {
  padding: 4px 10px 14px;
  scrollbar-color: #3b4641 transparent;
}

.conversation-item {
  min-height: 76px;
  padding: 11px 9px;
  border: 1px solid transparent;
}

.conversation-item:hover {
  border-color: #2f3935;
  background: #202825;
}

.conversation-item.active {
  border-color: #3b463f;
  background: #27302d;
  box-shadow: inset 0 0 0 1px rgba(217, 168, 79, .04);
}

.conversation-item.active::before {
  left: -11px;
  width: 3px;
  height: 40px;
  border-radius: 0;
  background: var(--gold);
}

.conversation-title strong { color: #f0f4f2; }
.conversation-preview { color: #929e98; }
.conversation-time { color: #727e78; }
.managed-badge { color: #e1b762; }

.unread-count {
  color: #18201d;
  background: var(--gold);
}

.conversation-pane .avatar {
  border: 1px solid rgba(255, 255, 255, .06);
  color: #d4e3de;
  background: #2b4541;
}

.conversation-pane .avatar.tone-2 { color: #f1d8ad; background: #4e3925; }
.conversation-pane .avatar.tone-3 { color: #bfe0ca; background: #294735; }
.conversation-pane .avatar.tone-4 { color: #ddd1ef; background: #413751; }

.conversation-pane .empty-state { color: #849089; }

.conversation-pane .sync-footer {
  border-top-color: var(--ink-line);
  background: #151b19;
}

.conversation-pane .sync-indicator { color: #7f8a85; }
.conversation-pane .sync-indicator.live > span { background: #43a995; box-shadow: 0 0 0 3px rgba(67, 169, 149, .1); }

.chat-pane {
  background: #edf0ed;
}

.chat-header {
  min-height: 82px;
  padding: 14px 22px;
  border-bottom-color: #d4dad5;
  background: rgba(252, 253, 251, .96);
  box-shadow: 0 5px 18px rgba(24, 31, 28, .04);
}

.contact-avatar {
  width: 44px;
  height: 44px;
  border: 1px solid #ced8d2;
  border-radius: 7px;
}

.contact-heading h2 {
  color: #141a18;
  font-size: 16px;
}

.presence { color: #087063; }

.chat-header .icon-button {
  border-color: #d7ddd8;
  background: #f8faf7;
}

.chat-header .icon-button:hover {
  border-color: #bf9448;
  color: #745619;
  background: var(--gold-soft);
}

.conversation-status {
  min-height: 38px;
  background: rgba(237, 240, 237, .94);
}

.conversation-status > span:first-child::before,
.conversation-status > span:first-child::after {
  display: inline-block;
  width: 32px;
  height: 1px;
  margin: 0 8px 3px;
  background: #d1d7d2;
  content: "";
}

.message-list {
  gap: 16px;
  padding-top: 20px;
  scrollbar-color: #c0c8c2 transparent;
}

.message-row { gap: 5px; }

.message-bubble {
  padding: 11px 13px;
  border-color: #d7ddd8;
  border-radius: 7px 7px 7px 2px;
  background: #fcfdfb;
  box-shadow: 0 4px 14px rgba(20, 27, 24, .05);
}

.message-row.mine .message-bubble {
  border-color: #26322e;
  border-radius: 7px 7px 2px 7px;
  color: #f1f5f3;
  background: #1b2522;
  box-shadow: 0 7px 18px rgba(17, 23, 21, .12);
}

.message-row.mine .message-foot { color: #7d8883; }
.ai-origin { color: #a47625; }

.composer {
  margin-right: clamp(18px, 4vw, 52px);
  margin-bottom: 20px;
  margin-left: clamp(18px, 4vw, 52px);
  border-color: #c7cec8;
  border-radius: 7px;
  background: #fcfdfb;
  box-shadow: 0 14px 34px rgba(17, 23, 21, .12);
}

.composer:focus-within {
  border-color: #8f7545;
  box-shadow: 0 0 0 3px rgba(217, 168, 79, .09), 0 14px 34px rgba(17, 23, 21, .11);
}

.ai-quick-button {
  border: 1px solid #e1c58f;
  color: #73551d;
  background: var(--gold-soft);
}

.ai-quick-button:hover { background: #f2e2c2; }

.send-button {
  border-radius: 6px;
  color: #181f1c;
  background: var(--gold);
}

.send-button:hover { background: #e7ba68; }

.workspace-empty {
  color: #4e5954;
  background: #edf0ed;
}

.workspace-empty > span {
  width: 56px;
  height: 56px;
  border-color: #d2d9d3;
  color: #876727;
  background: #f9faf7;
  box-shadow: 0 10px 24px rgba(17, 23, 21, .07);
}

.workspace-empty button {
  color: #181f1c;
  background: var(--gold);
}

.ai-pane {
  border-left-color: var(--ink-line);
  color: #eef3f0;
  background: #141a18;
}

.ai-header {
  min-height: 82px;
  justify-content: flex-start;
  padding: 15px 16px;
  border-bottom-color: var(--ink-line);
  background: #111715;
}

.ai-brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(217, 168, 79, .42);
  border-radius: 7px;
  color: #edc675;
  background: rgba(217, 168, 79, .08);
}

.ai-brand-mark svg { width: 17px; height: 17px; }
.ai-header .eyebrow { color: #b99a60; }
.ai-header h2 { color: #f4f7f5; }

.managed-switch {
  margin-left: auto;
  color: #a6b0ab;
}

.switch-track { background: #3b4641; }
.managed-switch input:checked + .switch-track { background: var(--gold); }
.managed-switch input:checked + .switch-track::after { background: #19201e; }

.ai-tabs {
  min-height: 45px;
  padding: 0 18px;
  border-bottom-color: var(--ink-line);
  background: #171e1b;
}

.ai-tab { color: #7f8a85; }
.ai-tab.active { color: #f0f4f2; }
.ai-tab.active::after { background: var(--gold); }

.ai-content {
  padding: 18px;
  scrollbar-color: #3a4540 transparent;
}

.ai-pane .section-heading h3 { color: #f1f5f3; }
.ai-pane .section-heading p,
.ai-pane .freshness { color: #78847e; }

.ai-pane .icon-button {
  border-color: #34403b;
  color: #aab4af;
  background: #1d2522;
}

.ai-pane .icon-button:hover {
  border-color: #a5864d;
  color: #efc87e;
  background: #252e2b;
}

.generation-state {
  border-color: rgba(217, 168, 79, .28);
  color: #efc87e;
  background: rgba(217, 168, 79, .08);
}

.generation-state strong { color: #efc87e; }
.generation-state span:last-child { color: #97a29c; }
.spinner { border-color: #4e4838; border-top-color: var(--gold); }

.reply-suggestions { gap: 10px; }

.reply-card {
  gap: 10px;
  padding: 13px;
  border-color: #303a36;
  border-radius: 7px;
  background: #1b2320;
}

.reply-card:hover {
  border-color: #927947;
  background: #202824;
}

.reply-label { color: #b5beb9; }
.reply-card p { color: #edf2ef; }
.reply-reason { color: #77837d; }

.risk-badge {
  color: #9ad4c8;
  background: rgba(67, 169, 149, .12);
}

.risk-badge.medium {
  color: #efc87e;
  background: rgba(217, 168, 79, .1);
}

.apply-reply {
  border-color: #8e7444;
  color: #efc87e;
  background: transparent;
}

.apply-reply:hover {
  color: #191f1d;
  background: var(--gold);
}

.risk-strip {
  border-top-color: #303a36;
  color: #78c5b5;
}

.risk-strip span { color: #7d8983; }
.context-section { border-bottom-color: #303a36; }
.summary-text, .boundary-list span { color: #aeb8b3; }
.fact-list dt { color: #78847e; }
.fact-list dd { color: #e9eeeb; }
.boundary-list svg { color: #d6aa55; }

.settings-dialog {
  border-color: #333d39;
  background: #f9faf7;
  box-shadow: 0 28px 70px rgba(8, 12, 10, .35);
}

.settings-dialog::backdrop { background: rgba(8, 12, 10, .68); }

.settings-dialog header {
  border-bottom-color: #303a36;
  color: #f0f4f2;
  background: #171e1b;
}

.settings-dialog header .eyebrow { color: #c2a265; }
.settings-dialog header .icon-button { border-color: #38433e; color: #aeb8b3; background: #202825; }
.settings-dialog footer { border-top-color: #d6dcd7; background: #f2f4f1; }

.settings-content input,
.settings-content select,
.settings-content textarea {
  border-color: #cbd2cc;
  background: #fff;
}

.settings-content input:focus,
.settings-content select:focus,
.settings-content textarea:focus {
  border-color: #977b47;
  box-shadow: 0 0 0 3px rgba(217, 168, 79, .09);
}

.primary-action {
  border-color: var(--gold);
  color: #171d1b;
  background: var(--gold);
}

.secondary-action { border-color: #cbd2cc; background: #fff; }

.toast {
  border-color: #9d834f;
  color: #eac578;
  background: #171e1b;
}

@media (max-width: 1220px) {
  :root { --nav-width: 72px; --list-width: 260px; --ai-width: 300px; }

  .workspace-shell {
    grid-template-columns: var(--nav-width) var(--list-width) minmax(330px, 1fr) var(--ai-width);
  }

  body[data-user-role="contact_user"] .workspace-shell {
    grid-template-columns: var(--nav-width) var(--list-width) minmax(330px, 1fr);
  }
}

@media (max-width: 980px) {
  .workspace-shell,
  body[data-user-role="contact_user"] .workspace-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-shell { background: var(--ink); }

  .conversation-pane,
  .chat-pane,
  .ai-pane {
    min-height: 0;
  }

  .mobile-nav {
    border-top-color: #303a36;
    background: #111715;
  }

  .mobile-nav button { color: #77837d; }
  .mobile-nav button.active { color: #efc87e; }
  .chat-pane + .ai-pane { border-left: 0; }
}

@media (max-width: 520px) {
  .conversation-pane .pane-header,
  .ai-header,
  .chat-header { min-height: 68px; }

  .conversation-pane .pane-header { padding: 12px 14px; }
  .conversation-pane .pane-header h1 { font-size: 18px; }
  .ai-brand-mark { width: 34px; height: 34px; }
  .chat-header { padding: 10px; }

  .conversation-status > span:first-child::before,
  .conversation-status > span:first-child::after { width: 18px; }

  .message-list { padding-top: 14px; }
  .composer { margin: 0 8px 10px; }
}
