/* Auth Screen */
#auth-view {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 20% 20%, #eaf1ff 0%, #f5f6f7 55%, #eef2f8 100%);
  padding: 24px;
}

.auth-stack {
  width: 100%;
  max-width: 400px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-announcement {
  width: 100%;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d6e4ff;
  border-left: 3.5px solid var(--brand);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.auth-announcement-icon {
  color: var(--brand);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
}
.auth-announcement-body {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.auth-card {
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-logo {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, #3370ff 0%, #5b8cff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(51, 112, 255, 0.28);
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}
.auth-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-hover);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.auth-tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.auth-error {
  margin-bottom: 14px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12px;
}

/* Main App Four-Part Feishu Shell */
#app-shell {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
}

/* Left Navigation Rail */
.nav-rail {
  width: var(--rail-w);
  height: 100%;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  flex-shrink: 0;
  z-index: 20;
}

.rail-avatar-btn {
  margin-bottom: 20px;
  border-radius: 50%;
  padding: 2px;
  transition: transform 0.15s;
}
.rail-avatar-btn:hover {
  transform: scale(1.05);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex: 1;
}

.rail-item {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.rail-item:hover {
  background: rgba(31, 35, 41, 0.06);
  color: var(--text-primary);
}
.rail-item.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.rail-item svg {
  width: 21px;
  height: 21px;
}

.rail-unread {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

.rail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ws-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #bbbfca;
  transition: background 0.2s;
}
.ws-indicator.connected { background: var(--success); }
.ws-indicator.reconnecting { background: var(--warning); }
.ws-indicator.disconnected { background: var(--danger); }

/* Workspace Views */
.workspace-view {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
}

/* Conversation Sidebar */
.conv-sidebar {
  width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.conv-sidebar-top {
  height: var(--header-h);
  padding: 12px 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.search-box:focus-within {
  background: #fff;
  border-color: var(--brand);
}
.search-box input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
}
.search-box svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conv-filter-tabs {
  display: flex;
  padding: 0 12px 8px;
  gap: 4px;
  border-bottom: 1px solid var(--border-light);
}
.conv-filter-tab {
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}
.conv-filter-tab:hover {
  background: var(--bg-hover);
}
.conv-filter-tab.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  overflow: hidden;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.conv-item:hover {
  background: var(--bg-hover);
}
.conv-item.active {
  background: var(--brand-soft);
}
.conv-item.pinned {
  background: #fafbfc;
}
.conv-item.pinned.active {
  background: var(--brand-soft);
}

.conv-tail-btn {
  width: 24px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.45;
  transition: opacity 0.14s, background 0.14s, color 0.14s;
}
.conv-item:hover .conv-tail-btn,
.conv-item.actions-open .conv-tail-btn,
.conv-tail-btn:hover {
  opacity: 1;
  color: var(--text-primary);
}
.conv-tail-btn:hover {
  background: rgba(31, 35, 41, 0.08);
}

.conv-row-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  padding-left: 22px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #ffffff 18px, #ffffff 100%);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  z-index: 3;
  animation: convActIn 0.14s ease-out;
}
.conv-item:hover .conv-row-actions {
  background: linear-gradient(90deg, rgba(242, 243, 245, 0) 0%, #f2f3f5 18px, #f2f3f5 100%);
}
.conv-item.active .conv-row-actions {
  background: linear-gradient(90deg, rgba(235, 241, 255, 0) 0%, #ebf1ff 18px, #ebf1ff 100%);
}
.conv-item.pinned:not(.active) .conv-row-actions {
  background: linear-gradient(90deg, rgba(250, 251, 252, 0) 0%, #fafbfc 18px, #fafbfc 100%);
}
.conv-act-btn {
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.12s;
}
.conv-act-btn:hover {
  filter: brightness(0.93);
}
.conv-act-btn.pin {
  background: var(--brand);
}
.conv-act-btn.del {
  background: var(--danger);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
@keyframes convActIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.conv-item-body {
  flex: 1;
  min-width: 0;
}
.conv-item-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.conv-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.conv-item-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.conv-item-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.conv-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-unread-pill {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* Contacts View */
.contacts-layout {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--bg-surface);
}
.contacts-groups-col {
  width: 250px;
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  overflow-y: auto;
  flex-shrink: 0;
}
.contacts-col-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 10px 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.contact-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 13px;
}
.contact-group-item:hover { background: var(--bg-hover); }
.contact-group-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}
.contact-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.contacts-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.contacts-header {
  height: var(--header-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.contacts-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  align-content: start;
}
.contact-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.contact-card:hover {
  border-color: #c2d4ff;
  box-shadow: var(--shadow-sm);
}

/* Modal & Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 41, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-card.wide { max-width: 620px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
}
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.checkbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.checkbox-item:hover {
  background: var(--bg-hover);
}
.checkbox-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Profile & Security Settings Modal */
.pf-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f4f7ff 0%, #f8f9fc 100%);
  border: 1px solid #e4ecfc;
}
.pf-avatar-trigger {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: transform 0.15s;
}
.pf-avatar-trigger:hover {
  transform: scale(1.03);
}
.pf-avatar-cam {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #dce1eb;
  box-shadow: 0 2px 6px rgba(31, 35, 41, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  pointer-events: none;
}
.pf-hero-meta {
  flex: 1;
  min-width: 0;
}
.pf-hero-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pf-hero-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-break: break-word;
}
.pf-hero-handle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pf-hero-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.pf-hero-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.pf-section {
  background: #f9fafc;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.pf-section:last-child {
  margin-bottom: 0;
}
.pf-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.pf-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.pf-section .form-group:last-of-type {
  margin-bottom: 12px;
}
.pf-section-actions {
  display: flex;
  justify-content: flex-end;
}

.pf-swatch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.pf-swatch {
  cursor: pointer;
  display: inline-flex;
}
.pf-swatch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.pf-swatch-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.14s, box-shadow 0.14s;
}
.pf-swatch-dot svg {
  width: 13px;
  height: 13px;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.14s, transform 0.14s;
}
.pf-swatch:hover .pf-swatch-dot {
  transform: scale(1.08);
}
.pf-swatch input:checked + .pf-swatch-dot {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--brand);
}
.pf-swatch input:checked + .pf-swatch-dot svg {
  opacity: 1;
  transform: scale(1);
}

.pf-notify-list .drawer-setting-row {
  padding: 10px 0;
}
.pf-notify-list .drawer-setting-row:first-child {
  padding-top: 2px;
}
.pf-notify-list .drawer-setting-row:last-child {
  padding-bottom: 2px;
  border-bottom: none;
}
.pf-notify-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.pf-footer-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pf-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.pf-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.pf-status-badge.connected {
  background: #e8ffea;
  color: #009a29;
}
.pf-status-badge.reconnecting {
  background: var(--warning-bg);
  color: #d46b08;
}
.pf-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
