/* EmailChat — WhatsApp-inspired chat over SMTP/IMAP */
:root {
  --ec-bg: #0b141a;
  --ec-bg-panel: #111b21;
  --ec-bg-elevated: #202c33;
  --ec-bg-hover: #2a3942;
  --ec-bg-input: #2a3942;
  --ec-bg-chat: #0d1a21;
  --ec-bubble-in: #1f2c34;
  --ec-bubble-out: #005c4b;
  --ec-bubble-out-meta: #a8c9c1;
  --ec-fg: #e9edef;
  --ec-fg-muted: #aebac1;
  --ec-fg-subtle: #8696a0;
  --ec-accent: #00a884;
  --ec-accent-strong: #008069;
  --ec-danger: #ea4335;
  --ec-ok: #00a884;
  --ec-border: rgba(134, 150, 160, 0.22);
  --ec-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --ec-radius-xs: 4px;
  --ec-radius-sm: 8px;
  --ec-radius-md: 12px;
  --ec-radius-lg: 16px;
  --ec-radius-xl: 24px;
  --ec-font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --ec-sidebar-w: min(380px, 100%);
  --ec-motion: 180ms cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  font-family: var(--ec-font);
  background: var(--ec-bg);
  color: var(--ec-fg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button:not(:disabled),
[role="button"]:not(:disabled) {
  cursor: pointer;
}

/* ── App shell ── */
.ec-app {
  display: grid;
  grid-template-columns: var(--ec-sidebar-w) 1fr;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--ec-bg);
}

/* ── Sidebar ── */
.ec-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ec-bg-panel);
  border-right: 1px solid var(--ec-border);
  z-index: 2;
}

.ec-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  background: var(--ec-bg-elevated);
  min-height: 60px;
}

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

button.ec-brand-sync {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  border-radius: 12px;
  transition: background var(--ec-motion);
}
button.ec-brand-sync:hover:not(:disabled) {
  background: rgba(255,255,255,0.04);
}
button.ec-brand-sync:disabled {
  opacity: 0.85;
  cursor: wait;
}
button.ec-brand-sync.is-syncing .ec-brand-mark,
.ec-brand-mark.ec-spin-soft {
  animation: ec-rotate 0.9s linear infinite;
}

.ec-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ec-accent);
  color: #042f28;
  flex-shrink: 0;
}

.ec-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ec-brand-text strong {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.ec-status-pill {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ec-fg-muted);
  width: fit-content;
}

.ec-status-pill.is-online { color: var(--ec-ok); }
.ec-status-pill.is-demo { color: #f0c14b; }
.ec-status-pill.is-offline { color: var(--ec-fg-subtle); }

.ec-sidebar-actions {
  display: flex;
  gap: 4px;
}

.ec-icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ec-fg-muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: background var(--ec-motion), color var(--ec-motion);
  position: relative;
}

.ec-icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ec-fg);
}

.ec-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ec-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 12px 10px;
  padding: 0 12px;
  height: 40px;
  border-radius: var(--ec-radius-md);
  background: var(--ec-bg-input);
  color: var(--ec-fg-muted);
}

.ec-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ec-fg);
  min-width: 0;
}

.ec-search input::placeholder {
  color: var(--ec-fg-subtle);
}

.ec-conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
  touch-action: pan-y;
}

.ec-pull-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--ec-fg-muted);
  font-size: 0.78rem;
  transition: height 80ms ease, opacity 80ms ease;
  pointer-events: none;
}
.ec-pull-indicator.is-visible {
  height: var(--pull, 48px);
  opacity: 1;
}
.ec-pull-indicator.is-ready {
  color: var(--ec-accent);
  font-weight: 600;
}
.ec-pull-indicator.is-syncing {
  height: 40px;
  opacity: 1;
  color: var(--ec-accent);
}
.ec-pull-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,168,132,0.25);
  border-top-color: var(--ec-accent);
  border-radius: 50%;
  animation: ec-rotate 0.7s linear infinite;
}

.ec-conv-item {
  width: 100%;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--ec-border);
  transition: background var(--ec-motion);
}

.ec-conv-item:hover {
  background: var(--ec-bg-hover);
}

.ec-conv-item.is-active {
  background: var(--ec-bg-elevated);
}

.ec-avatar {
  --hue: 160;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: #fff;
  background: hsl(var(--hue) 32% 40%);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  position: relative;
}

.ec-avatar.has-photo {
  background: transparent;
  padding: 0;
}

.ec-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.ec-avatar.sm {
  width: 40px;
  height: 40px;
  font-size: 0.8rem;
}

.ec-conv-body {
  flex: 1;
  min-width: 0;
}

.ec-conv-top,
.ec-conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ec-conv-name {
  font-weight: 600;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-conv-time {
  font-size: 0.72rem;
  color: var(--ec-fg-subtle);
  flex-shrink: 0;
}

.ec-conv-preview {
  font-size: 0.84rem;
  color: var(--ec-fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.ec-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ec-accent);
  color: #042f28;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ec-empty-list {
  padding: 40px 24px;
  text-align: center;
  color: var(--ec-fg-muted);
  display: grid;
  gap: 16px;
  justify-items: center;
}

/* ── Main pane ── */
.ec-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background-color: var(--ec-bg-chat);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(0, 168, 132, 0.06), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(0, 168, 132, 0.04), transparent 35%);
  position: relative;
}

.ec-empty-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.ec-empty-card {
  max-width: 420px;
  text-align: center;
  padding: 36px 28px;
  border-radius: var(--ec-radius-xl);
  background: var(--ec-bg-panel);
  border: 1px solid var(--ec-border);
  box-shadow: var(--ec-shadow);
}

.ec-empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 168, 132, 0.12);
  color: var(--ec-accent);
}

.ec-empty-card h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.ec-empty-card p {
  margin: 0 0 24px;
  color: var(--ec-fg-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.ec-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.ec-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-height: 60px;
  flex-shrink: 0;
  background: var(--ec-bg-elevated);
  border-bottom: 1px solid var(--ec-border);
  z-index: 1;
}

.ec-back {
  display: none;
}

.ec-chat-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ec-chat-meta strong {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ec-chat-meta span {
  font-size: 0.78rem;
  color: var(--ec-fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Messages — min-height:0 is required so flex child can scroll */
.ec-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 6% 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  touch-action: pan-y;
}

.ec-day-sep {
  display: flex;
  justify-content: center;
  margin: 10px 0 6px;
}

.ec-day-sep span {
  background: #182229;
  color: var(--ec-fg-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ec-bubble-row {
  display: flex;
  margin: 2px 0;
}

.ec-bubble-row.in { justify-content: flex-start; }
.ec-bubble-row.out { justify-content: flex-end; }

.ec-bubble {
  max-width: min(72%, 520px);
  padding: 6px 8px 4px;
  border-radius: var(--ec-radius-md);
  position: relative;
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.28);
  animation: ec-pop 160ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ec-bubble-row.in .ec-bubble {
  background: var(--ec-bubble-in);
  border-top-left-radius: 4px;
  color: var(--ec-fg);
}

.ec-bubble-row.out .ec-bubble {
  background: var(--ec-bubble-out);
  border-top-right-radius: 4px;
  color: #e7fffa;
}

.ec-bubble.is-failed {
  outline: 1px solid rgba(234, 67, 53, 0.5);
}

.ec-img-wrap {
  display: block;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
  max-width: 100%;
}

.ec-img-wrap img {
  display: block;
  max-width: min(280px, 70vw);
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
}

.ec-bubble-text {
  margin: 2px 4px 0;
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
}

.ec-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  padding: 0 2px 2px;
}

.ec-bubble-meta time {
  font-size: 0.68rem;
  color: var(--ec-fg-subtle);
}

.ec-bubble-row.out .ec-bubble-meta time {
  color: var(--ec-bubble-out-meta);
}

.ec-ticks {
  color: var(--ec-bubble-out-meta);
  display: inline-flex;
  line-height: 1;
}

.ec-tick-fail {
  color: #ff8a80;
  font-weight: 700;
}

.ec-bubble-error {
  font-size: 0.72rem;
  color: #ffcdd2;
  padding: 2px 4px 4px;
}

/* Composer */
.ec-pending-images {
  display: flex;
  gap: 8px;
  padding: 8px 16px 0;
  overflow-x: auto;
  background: transparent;
  flex-shrink: 0;
}

.ec-pending-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--ec-radius-sm);
  overflow: hidden;
  border: 1px solid var(--ec-border);
  flex-shrink: 0;
}

.ec-pending-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ec-pending-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.ec-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: var(--ec-bg-panel);
  border-top: 1px solid var(--ec-border);
  flex-shrink: 0;
}

.ec-attach {
  flex-shrink: 0;
}

.ec-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.ec-composer-field {
  flex: 1;
  min-width: 0;
  background: var(--ec-bg-input);
  border-radius: var(--ec-radius-xl);
  padding: 10px 16px;
}

.ec-composer-field textarea {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  color: var(--ec-fg);
}

.ec-composer-field textarea::placeholder {
  color: var(--ec-fg-subtle);
}

.ec-send {
  appearance: none;
  border: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ec-accent);
  color: #042f28;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform var(--ec-motion), background var(--ec-motion), opacity var(--ec-motion);
}

.ec-send:hover:not(:disabled) {
  background: #06c295;
}

.ec-send:active:not(:disabled) {
  transform: scale(0.96);
}

.ec-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Buttons */
.ec-btn {
  appearance: none;
  border: 0;
  border-radius: var(--ec-radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 44px;
  transition: background var(--ec-motion), transform var(--ec-motion), opacity var(--ec-motion);
}

.ec-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.ec-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ec-btn-primary {
  background: var(--ec-accent);
  color: #042f28;
}

.ec-btn-primary:hover:not(:disabled) {
  background: #06c295;
}

.ec-btn-ghost {
  background: transparent;
  color: var(--ec-fg-muted);
  border: 1px solid var(--ec-border);
}

.ec-btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ec-fg);
}

/* Settings */
.ec-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  animation: ec-fade 160ms ease both;
}

.ec-settings {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--ec-bg-panel);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ec-shadow);
  animation: ec-slide-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ec-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 12px 20px;
  min-height: 60px;
  background: var(--ec-bg-elevated);
  border-bottom: 1px solid var(--ec-border);
}

.ec-settings-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.ec-settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ec-settings-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--ec-border);
  background: var(--ec-bg-elevated);
}

.ec-hint {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ec-fg-muted);
}

.ec-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8em;
  background: var(--ec-bg-input);
  padding: 1px 6px;
  border-radius: 4px;
}

.ec-field-note {
  margin: -6px 0 0;
  font-size: 0.78rem;
  color: var(--ec-fg-subtle);
  line-height: 1.4;
}

.ec-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ec-chip {
  appearance: none;
  border: 1px solid var(--ec-border);
  background: var(--ec-bg-elevated);
  color: var(--ec-fg);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  min-height: 36px;
}

.ec-chip:hover {
  border-color: var(--ec-accent);
  color: var(--ec-accent);
}

.ec-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ec-field span {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ec-fg-muted);
}

.ec-field input {
  height: 44px;
  border-radius: var(--ec-radius-sm);
  border: 1px solid var(--ec-border);
  background: var(--ec-bg-input);
  padding: 0 12px;
  outline: none;
  transition: border-color var(--ec-motion);
}

.ec-field input:focus {
  border-color: var(--ec-accent);
}

.ec-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ec-advanced {
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius-md);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
}

.ec-advanced summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ec-fg-muted);
  padding: 4px 0 8px;
}

.ec-advanced[open] summary {
  margin-bottom: 8px;
}

.ec-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ec-fg-muted);
  margin-top: 10px;
}

.ec-alert {
  padding: 12px 14px;
  border-radius: var(--ec-radius-sm);
  font-size: 0.86rem;
  line-height: 1.4;
}

.ec-alert-error {
  background: rgba(234, 67, 53, 0.12);
  color: #ffb4ab;
  border: 1px solid rgba(234, 67, 53, 0.3);
}

.ec-alert-ok {
  background: rgba(0, 168, 132, 0.12);
  color: #7ddec8;
  border: 1px solid rgba(0, 168, 132, 0.3);
}

/* Modal */
.ec-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, calc(100% - 32px));
  background: var(--ec-bg-panel);
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius-lg);
  padding: 22px;
  z-index: 50;
  box-shadow: var(--ec-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: ec-modal-in 200ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ec-modal h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.ec-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* Lightbox */
.ec-lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}

.ec-lightbox img {
  max-width: min(960px, 100%);
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

/* Motion */
@keyframes ec-pop {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes ec-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ec-slide-in {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes ec-modal-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ec-spin {
  animation: ec-rotate 0.8s linear infinite;
}

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

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

/* Mobile */
@media (max-width: 820px) {
  .ec-app {
    grid-template-columns: 1fr;
  }

  .ec-sidebar {
    display: flex;
  }

  .ec-main {
    display: none;
  }

  .ec-app.ec-chat-open .ec-sidebar {
    display: none;
  }

  .ec-app.ec-chat-open .ec-main {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .ec-back {
    display: grid;
  }

  .ec-messages {
    padding: 12px 10px;
  }

  .ec-bubble {
    max-width: 88%;
  }

  .ec-grid-2 {
    grid-template-columns: 1fr;
  }
}


/* ── Auth (login / register) ───────────────────────────────────────── */
.auth-page {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(0, 168, 132, 0.18), transparent 55%),
    var(--ec-bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--ec-bg-panel);
  border: 1px solid var(--ec-border);
  border-radius: var(--ec-radius-lg);
  box-shadow: var(--ec-shadow);
  padding: 28px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-brand p {
  margin: 0;
  color: var(--ec-fg-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 32ch;
}

.auth-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--ec-accent), var(--ec-accent-strong));
  color: #04140f;
  margin-bottom: 4px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-remember {
  margin-top: 2px;
}

.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
  min-height: 44px;
}

.auth-switch {
  margin: 4px 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ec-fg-muted);
}

.auth-switch a {
  color: var(--ec-accent);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-loading {
  align-items: center;
  text-align: center;
  color: var(--ec-fg-muted);
}

.ec-spin-block {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--ec-border);
  border-top-color: var(--ec-accent);
  border-radius: 50%;
  animation: ec-spin 0.7s linear infinite;
  margin: 0 auto 8px;
}

.ec-user-email {
  display: block;
  font-size: 0.72rem;
  color: var(--ec-fg-subtle);
  font-weight: 400;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.ec-icon-btn {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ec-field-note {
  margin: -6px 0 0;
  font-size: 0.78rem;
  color: var(--ec-fg-subtle);
  line-height: 1.4;
}


/* ── Groups + sender label ─────────────────────────────────────────── */
.ec-avatar.is-group {
  background: linear-gradient(145deg, #1a6b5a, #0d3d34);
  color: #b6f0df;
}

.ec-group-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ec-accent);
  background: rgba(0, 168, 132, 0.12);
  border-radius: 999px;
  vertical-align: middle;
}

.ec-conv-item.is-group .ec-conv-name {
  font-weight: 600;
}

.ec-bubble-from {
  font-size: 0.62rem;
  line-height: 1.2;
  color: var(--ec-fg-subtle);
  margin: 0 0 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
  letter-spacing: 0.01em;
}

.ec-bubble-row.out .ec-bubble-from {
  display: none;
}

.ec-modal-wide {
  width: min(460px, 100%);
  max-height: min(90dvh, 720px);
  overflow-y: auto;
}


/* ── File attachments, delete, export ──────────────────────────────── */
.ec-file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  color: inherit;
  text-decoration: none;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.06);
  transition: background .15s ease;
}
.ec-file-chip:hover {
  background: rgba(0,0,0,0.28);
}
.ec-bubble-row.out .ec-file-chip {
  background: rgba(0,0,0,0.12);
}
.ec-file-badge {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 168, 132, 0.2);
  color: #7ddec8;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
}
.ec-file-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.ec-file-meta strong {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ec-file-meta small {
  font-size: 0.68rem;
  opacity: 0.7;
}
.ec-pending-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 12px;
  background: var(--ec-surface-2, #1e2a30);
  max-width: 200px;
  position: relative;
}
.ec-pending-file-name {
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}
.ec-icon-btn.ec-danger:hover {
  color: #ff6b6b;
  background: rgba(255, 80, 80, 0.12);
}
.ec-btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
}
.ec-btn-danger:hover {
  background: #e74c3c;
}
.ec-btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}
.ec-settings-export {
  padding: 0 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 8px;
  padding-top: 14px;
}

.ec-settings-sub {
  margin: 12px 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ec-fg-muted, #9bb0b8);
  text-transform: uppercase;
}

.ec-alert-detail {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.4;
  max-height: 12rem;
  overflow-y: auto;
}

.ec-invite-meta {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  list-style: none;
  font-size: 0.85rem;
  line-height: 1.45;
}
.ec-invite-meta li + li { margin-top: 4px; }

.ec-vcard {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 4px 0 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.06);
  max-width: 100%;
  position: relative;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}
.ec-vcard:hover {
  border-color: rgba(0, 168, 132, 0.45);
  background: rgba(0, 168, 132, 0.08);
}
.ec-vcard-photo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: #2a3a40;
}
.ec-vcard-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #7ddec8;
}
.ec-vcard-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  font-size: 0.85rem;
}
.ec-vcard-body strong { font-size: 0.95rem; }
.ec-vcard-org { opacity: 0.7; font-size: 0.78rem; }
.ec-vcard-chat {
  margin-top: 6px;
  align-self: flex-start;
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
}
.ec-vcard-dl {
  position: absolute;
  top: 8px;
  right: 10px;
  opacity: 0.6;
  text-decoration: none;
  color: inherit;
  font-size: 0.9rem;
}
.ec-vcard-photo-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 8px;
}
.ec-file-input-visible {
  display: block;
  width: 100%;
  font-size: 0.85rem;
  margin-top: 4px;
}
.ec-status-pill.is-offline { opacity: 0.75; }

.ec-vcard-action {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--ec-accent);
  opacity: 0.9;
}
