:root {
  --ink: #172033;
  --muted: #697386;
  --surface: #ffffff;
  --line: #e4e9f2;
  --brand: #4457d9;
  --brand-dark: #27336f;
  --brand-soft: #eef0ff;
  --danger: #c43f4c;
  --shadow: 0 18px 50px rgba(27, 36, 74, 0.09);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #e8edf7;
  --muted: #9da9ba;
  --surface: #172235;
  --line: #344258;
  --brand: #8391ff;
  --brand-dark: #b7c0ff;
  --brand-soft: #293552;
  --danger: #ff7e8b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

html {
  font-size: 15px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(100, 116, 255, 0.13), transparent 28rem),
    #f6f7fb;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

.app-body {
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); }

.app-navbar {
  min-height: 72px;
  background: linear-gradient(115deg, #1e2854, #3747a9);
  box-shadow: 0 10px 35px rgba(30, 40, 84, 0.18);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-right: 2rem;
  font-weight: 750;
}

.brand-mark span,
.auth-logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #28347a;
  background: #fff;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .04em;
}

.brand-mark img { width: 38px; height: 38px; border-radius: 12px; object-fit: cover; }
.auth-logo { object-fit: cover; }

.navbar .nav-link { color: rgba(255, 255, 255, .72); }
.navbar .nav-link:hover { color: #fff; }
.account-dropdown { margin-left: auto; }
.account-menu-button { display: flex; max-width: 270px; align-items: center; gap: .65rem; padding: .35rem .55rem .35rem .35rem; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; color: #fff; background: rgba(255,255,255,.08); cursor: pointer; }
.account-menu-button:hover, .account-menu-button[aria-expanded="true"] { background: rgba(255,255,255,.16); }
.account-menu-button strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-button.dropdown-toggle::after { margin-left: .1rem; }
.account-avatar { position: relative; display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border: 2px solid rgba(255,255,255,.72); border-radius: 50%; color: #27336f; background: #fff; font-size: .82rem; font-weight: 850; }
.account-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.account-status-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border: 2px solid #3444a3; border-radius: 50%; background: #42bd7b; }
.status-busy, .status-do-not-disturb { background: #ef5365 !important; }
.status-away { background: #f0b742 !important; }
.status-offline { background: #9aa4b4 !important; }
.status-available { background: #42bd7b !important; }
.account-dropdown-menu { width: 230px; padding: .45rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 50px rgba(15,22,51,.24); }
.account-dropdown-summary { display: flex; padding: .55rem .65rem .7rem; flex-direction: column; }
.account-dropdown-summary strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.account-dropdown-summary small { color: var(--muted); }
.account-dropdown-menu .dropdown-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .65rem; border: 0; border-radius: 9px; color: var(--ink); background: transparent; }
.account-dropdown-menu .dropdown-item:hover, .account-dropdown-menu .dropdown-item:focus { color: var(--brand); background: var(--brand-soft); }
.account-dropdown-menu .dropdown-item > span { display: grid; width: 24px; place-items: center; }
.account-dropdown-menu form { margin: 0; }
.account-dropdown-menu .account-signout { width: 100%; color: var(--danger); }

.page-shell {
  flex: 1;
  min-height: calc(100vh - 144px);
  padding-top: 2.5rem;
  padding-bottom: 3rem;
}

.footer {
  padding: .8rem 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  color: #b9c7dc;
  background: linear-gradient(115deg, #1e2854, #3747a9);
  box-shadow: 0 -10px 35px rgba(30, 40, 84, .12);
  font-size: 1rem;
}

.footer-content { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.footer-branding { display: flex; align-items: center; gap: .75rem; }
.footer-divider { color: #d5deea; }
.app-footer a { color: #55dfd0; font-weight: 750; text-decoration: none; }
.app-footer a:hover { color: #8ef3e8; text-decoration: underline; }
.theme-switcher button { padding: .4rem .75rem; border: 1px solid #b9c7dc; color: #fff; background: transparent; }
.theme-switcher button:first-child { border-radius: 6px 0 0 6px; }
.theme-switcher button:last-child { margin-left: -1px; border-radius: 0 6px 6px 0; }
.theme-switcher button:hover { background: #26364e; }
.theme-switcher button.active { border-color: #55dfd0; color: #102036; background: #55dfd0; }

:root[data-theme="dark"] body {
  background: radial-gradient(circle at 90% 5%, rgba(100, 116, 255, .1), transparent 28rem), #0d1522;
}
:root[data-theme="dark"] .app-navbar { background: linear-gradient(115deg, #101a2c, #24335f); }
:root[data-theme="dark"] .footer { background: linear-gradient(115deg, #101a2c, #24335f); }
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select,
:root[data-theme="dark"] .form-panel,
:root[data-theme="dark"] .auth-card,
:root[data-theme="dark"] .table-panel,
:root[data-theme="dark"] .message-panel,
:root[data-theme="dark"] .mail-panel,
:root[data-theme="dark"] .calendar-panel,
:root[data-theme="dark"] .conversation-list-panel,
:root[data-theme="dark"] .people-panel,
:root[data-theme="dark"] .chat-shell,
:root[data-theme="dark"] .messaging-workspace,
:root[data-theme="dark"] .messaging-sidebar .messaging-section-title,
:root[data-theme="dark"] .messaging-sidebar .people-search,
:root[data-theme="dark"] .messaging-sidebar .person-row,
:root[data-theme="dark"] .messaging-sidebar .conversation-row,
:root[data-theme="dark"] .mail-workspace .mail-row,
:root[data-theme="dark"] .mail-list-controls,
:root[data-theme="dark"] .compose-rich-body { color: var(--ink); background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] .messaging-sidebar,
:root[data-theme="dark"] .mail-sidebar,
:root[data-theme="dark"] .mail-pagination,
:root[data-theme="dark"] .mail-list-header,
:root[data-theme="dark"] .mail-editor-toolbar { color: var(--ink); background: #121d2e; border-color: var(--line); }
:root[data-theme="dark"] .btn-soft { color: #dbe3f0; background: #1c293d; border-color: #40506a; }
:root[data-theme="dark"] .btn-soft:hover { color: #fff; background: #293956; border-color: #60729a; }
:root[data-theme="dark"] .mail-workspace .mail-row.mail-read,
:root[data-theme="dark"] .mail-workspace .mail-row:hover,
:root[data-theme="dark"] .conversation-row:hover { color: var(--ink); background: #202d43; }
:root[data-theme="dark"] .chat-messages { background: #101a29; }
:root[data-theme="dark"] .chat-bubble { color: var(--ink); background: #1b283b; border-color: var(--line); }
:root[data-theme="dark"] .mine .chat-bubble { background: #29375a; border-color: #465580; }
:root[data-theme="dark"] .chat-welcome-panel { background: radial-gradient(circle at 50% 35%, #263452, #172235 55%); }
:root[data-theme="dark"] .alert-success { color: #bdebd6; background: #17382c; border-color: #285c48; }
:root[data-theme="dark"] .alert-danger { color: #ffc0c7; background: #472129; border-color: #71323d; }
:root[data-theme="dark"] .text-danger { color: #ff929d !important; }
:root[data-theme="dark"] .text-muted { color: var(--muted) !important; }
:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .dropdown-menu { color: var(--ink); background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(180%); }

@media (max-width: 575px) {
  .footer-content { align-items: flex-start; flex-direction: column; }
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 230px;
  padding: 3.25rem;
  margin-bottom: 2rem;
  overflow: hidden;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(125deg, #222e67, #4b5ee5);
  box-shadow: var(--shadow);
}

.hero-panel h1,
.page-heading h1,
.auth-card h1 {
  margin: .35rem 0 .5rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 780;
  letter-spacing: -.04em;
}

.hero-panel p,
.page-heading p,
.auth-card p {
  margin: 0;
  color: inherit;
  opacity: .72;
  font-size: 1.05rem;
}

.hero-orb {
  display: grid;
  place-items: center;
  width: 122px;
  height: 122px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 38px;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, .09);
  font-size: 2rem;
  font-weight: 850;
  transform: rotate(6deg);
}

.hero-orb img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

.eyebrow {
  color: #7787ff;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.hero-panel .eyebrow { color: #cdd3ff; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

@media (max-width: 991px) {
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.app-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 125px;
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(27, 36, 74, .05);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

a.app-card:hover {
  color: var(--ink);
  border-color: #cbd1ff;
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border-radius: 17px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 1.25rem;
  font-weight: 850;
}

.card-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .25rem;
}

.card-copy strong { font-size: 1.08rem; }
.card-copy small { color: var(--muted); }
.card-arrow { color: var(--brand); font-size: 1.4rem; }
.app-card-muted { opacity: .7; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin: .75rem 0 2rem;
}

.page-heading h1 { font-size: clamp(1.9rem, 3vw, 2.55rem); }
.page-heading p { color: var(--muted); }

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 200px);
}

.auth-card,
.form-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 440px);
  padding: 2.4rem;
}

.auth-card h1 { font-size: 2.2rem; }
.auth-card p { color: var(--muted); margin-bottom: 2rem; }
.auth-logo { margin-bottom: 1.5rem; color: #fff; background: var(--brand); }

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-panel {
  width: min(100%, 720px);
  padding: 2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-label {
  margin-bottom: .4rem;
  color: #3c465b;
  font-size: .88rem;
  font-weight: 700;
}

.form-control,
.form-select {
  min-height: 48px;
  border-color: #d9dfeb;
  border-radius: 11px;
}

.form-control:focus,
.form-select:focus {
  border-color: #8f9bff;
  box-shadow: 0 0 0 .22rem rgba(68, 87, 217, .12);
}

.form-actions,
.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
}

.form-hint { margin: -.25rem 0 0; color: var(--muted); font-size: .82rem; }

.btn {
  border-radius: 10px;
  font-weight: 650;
}

.btn-primary {
  border-color: var(--brand);
  background: var(--brand);
}

.btn-primary:hover { border-color: #3547c3; background: #3547c3; }
.btn-soft { border: 1px solid #dfe3ed; color: #414b60; background: #fff; }
.btn-soft:hover { border-color: #cbd1ff; color: var(--brand); background: var(--brand-soft); }

.table-panel { overflow: hidden; }
.user-table { margin: 0; }
.user-table th {
  padding: 1rem 1.25rem;
  border-bottom-color: var(--line);
  color: var(--muted);
  background: #fafbfe;
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.user-table td { padding: 1rem 1.25rem; border-bottom-color: #edf0f5; }
.user-table tr:last-child td { border-bottom: 0; }

.user-cell { display: flex; align-items: center; gap: .75rem; }
.user-cell > span:last-child { display: flex; flex-direction: column; }
.user-cell small { color: var(--muted); }
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  height: 40px;
  border-radius: 13px;
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 800;
}

.role-pill,
.status-pill {
  display: inline-block;
  padding: .33rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 750;
}
.role-pill { color: #4f5ca5; background: #f0f2ff; }
.status-success { color: #237454; background: #e9f8f1; }
.status-warning { color: #9b6813; background: #fff4dc; }
.status-danger { color: #a5303c; background: #ffeaec; }
.action-row { justify-content: flex-end; }
.action-row form { margin: 0; }
.empty-table { padding: 3rem; color: var(--muted); text-align: center; }

.settings-test {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fafbfe;
}
.firebase-credential-input {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .78rem;
}

.import-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 900px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  border: 1px solid #cfd5ff;
  border-radius: 18px;
  background: var(--brand-soft);
}
.import-panel p { margin: .25rem 0 0; color: var(--muted); }
.import-form { display: flex; align-items: center; gap: .75rem; }
.import-form .form-control { min-width: 280px; background: #fff; }

.mail-panel,
.message-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mail-list { display: flex; flex-direction: column; }
.mail-row {
  display: grid;
  grid-template-columns: 8px minmax(150px, .7fr) minmax(260px, 1.5fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #edf0f5;
  color: var(--ink);
  text-decoration: none;
}
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { color: var(--ink); background: #f8f9ff; }
.mail-status { width: 7px; height: 7px; border-radius: 50%; background: #d8dce6; }
.mail-unread { font-weight: 750; }
.mail-unread .mail-status { background: var(--brand); }
.mail-from, .mail-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row time { color: var(--muted); font-size: .8rem; }

.message-panel { padding: 2rem; }
.message-title { overflow-wrap: anywhere; }
.message-meta {
  display: grid;
  grid-template-columns: 55px 1fr;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.message-meta dt { color: var(--muted); }
.message-meta dd { overflow-wrap: anywhere; }
.message-body {
  margin: 0;
  padding-top: 2rem;
  color: var(--ink);
  background: transparent;
  font: inherit;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.calendar-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.calendar-list { display: flex; flex-direction: column; }
.calendar-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1.25rem;
  padding: 1.35rem;
  border-bottom: 1px solid #edf0f5;
}
.calendar-row:last-child { border-bottom: 0; }
.calendar-date {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  width: 64px;
  height: 68px;
  border-radius: 16px;
  color: var(--brand);
  background: var(--brand-soft);
}
.calendar-date span {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.calendar-date strong { font-size: 1.55rem; line-height: 1.15; }
.calendar-copy h2 { margin: 0 0 .35rem; font-size: 1.08rem; }
.calendar-copy p { margin: 0 0 .35rem; color: var(--muted); }
.calendar-copy .calendar-location { color: #48546d; font-weight: 650; }
.calendar-copy .calendar-description {
  display: -webkit-box;
  overflow: hidden;
  margin-top: .65rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.calendar-copy small { color: #8a93a5; }

.empty-state {
  max-width: 520px;
  padding: 5rem 1rem;
  margin: auto;
  text-align: center;
}
.empty-code { color: #c8cee0; font-size: 5rem; font-weight: 850; }
.empty-state p { color: var(--muted); }

@media (max-width: 767px) {
  .page-shell { padding-top: 1.5rem; }
  .hero-panel { min-height: 200px; padding: 2rem; }
  .hero-orb { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-card, .form-panel { padding: 1.5rem; }
  .navbar-collapse { padding: 1rem 0; }
  .navbar-collapse .d-flex { align-items: flex-start !important; flex-direction: column; }
  .account-dropdown { width: 100%; margin-top: .65rem; margin-left: 0; }
  .account-menu-button { width: 100%; max-width: none; justify-content: flex-start; }
  .account-menu-button.dropdown-toggle::after { margin-left: auto; }
  .account-dropdown-menu { width: 100%; }
  .profile-panel { grid-template-columns: 1fr; }
  .profile-summary { border-right: 0; border-bottom: 1px solid var(--line); }
  .profile-form { padding: 1.5rem; }
  .mail-row { grid-template-columns: 8px 1fr auto; }
  .mail-subject { grid-column: 2 / -1; }
  .import-panel, .import-form { align-items: stretch; flex-direction: column; }
  .import-form .form-control { min-width: 0; }
}

/* Encrypted messaging */
.messaging-home { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 1.25rem; }
.messaging-workspace { display: grid; grid-template-columns: 350px minmax(0, 1fr); min-height: 650px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.messaging-heading { margin-top: 0; }
.messaging-sidebar { display: flex; min-width: 0; max-height: calc(100vh - 245px); min-height: 650px; overflow: hidden; border-right: 1px solid var(--line); background: #fafbfe; flex-direction: column; }
.sidebar-people { display: flex; max-height: 45%; border-bottom: 1px solid var(--line); flex-direction: column; }
.sidebar-people.has-search { min-height: 220px; }
.sidebar-user-list, .sidebar-conversation-list { min-height: 0; overflow-y: auto; }
.sidebar-conversations { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.sidebar-empty { padding: 1.5rem 1rem; color: var(--muted); font-size: .82rem; text-align: center; }
.messaging-sidebar .messaging-section-title { min-height: 54px; padding: .8rem 1rem; background: #fff; }
.messaging-sidebar .people-search { padding: .75rem; background: #fff; }
.messaging-sidebar .people-search .btn { padding-right: .75rem; padding-left: .75rem; }
.messaging-sidebar .person-row { padding: .65rem .75rem; background: #fff; }
.messaging-sidebar .person-row .avatar { flex: 0 0 36px; height: 36px; border-radius: 11px; }
.messaging-sidebar .conversation-row { grid-template-columns: 42px minmax(0, 1fr) auto; padding: .75rem; background: #fff; }
.messaging-sidebar .conversation-row.active { background: #e7eaff; box-shadow: inset 3px 0 var(--brand); }
.messaging-sidebar .conversation-avatar { width: 42px; height: 42px; border-radius: 13px; }
.messaging-sidebar > .encryption-note { margin-top: auto; padding: .75rem; font-size: .78rem; }
.conversation-list-panel, .people-panel, .chat-shell { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.messaging-section-title { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.messaging-section-title span { color: var(--muted); font-size: .78rem; }
.conversation-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: .85rem; padding: 1rem 1.2rem; border-bottom: 1px solid #edf0f5; color: var(--ink); text-decoration: none; }
.conversation-row:last-child { border-bottom: 0; }
.conversation-row:hover { color: var(--ink); background: #f8f9ff; }
.conversation-avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.conversation-copy, .person-row > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.conversation-name { display: flex; min-width: 0; align-items: center; gap: .4rem; }
.conversation-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-unread-count { display: inline-grid; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; flex: 0 0 auto; place-items: center; border-radius: 999px; color: #fff; background: var(--brand); font-size: .68rem; font-weight: 800; line-height: 1; }
.conversation-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.conversation-row time { color: #8b93a3; font-size: .72rem; }
.people-search { display: flex; gap: .55rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.person-row { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-bottom: 1px solid #edf0f5; }
.person-row > span:nth-child(2) { flex: 1; }
.person-row small { color: var(--muted); }
.person-row form { margin: 0; }
.messaging-empty { padding: 3rem 1rem; color: var(--muted); text-align: center; }
.encryption-note { display: flex; align-items: flex-start; gap: .8rem; padding: 1rem; color: #34417b; background: var(--brand-soft); }
.encryption-note > span { padding-top: .1rem; color: var(--brand); }
.encryption-note div { display: flex; flex-direction: column; }
.encryption-note small { color: #65709a; }
.member-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 310px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.member-picker label { display: flex; align-items: center; gap: .65rem; padding: .8rem; border-bottom: 1px solid #edf0f5; cursor: pointer; }
.member-picker label:nth-child(odd) { border-right: 1px solid #edf0f5; }
.member-picker input { width: 18px; height: 18px; accent-color: var(--brand); }
.member-picker span { display: flex; flex-direction: column; }
.member-picker small { color: var(--muted); }
.messaging-workspace .chat-shell { border: 0; border-radius: 0; box-shadow: none; }
.chat-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.messaging-workspace.conversation-workspace { height: calc(100vh - 160px); min-height: 560px; }
.conversation-workspace .messaging-sidebar { min-height: 0; max-height: none; }
.conversation-workspace .chat-shell { min-height: 0; max-height: none; }
.chat-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.chat-header h1 { margin: 0; font-size: 1.2rem; }
.chat-header small { color: var(--muted); }
.conversation-title-button { display: flex; min-width: 0; padding: .2rem; border: 0; border-radius: 9px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; flex-direction: column; }
.conversation-title-button:hover, .conversation-title-button:focus-visible { background: var(--surface-soft); outline: none; }
.conversation-title-button h1 { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-details-panel { width: min(92vw, 560px) !important; color: var(--ink); background: var(--surface); }
.conversation-details-panel .offcanvas-header { align-items: flex-start; border-bottom: 1px solid var(--line); }
.conversation-details-panel .offcanvas-header h2 { margin: .15rem 0 0; font-size: 1.25rem; }
.conversation-details-body { display: flex; padding: 0; flex-direction: column; }
.direct-user-profile { display: flex; align-items: center; gap: .85rem; padding: 1.15rem; border-bottom: 1px solid var(--line); }
.direct-user-profile .detail-avatar { width: 54px; height: 54px; font-size: 1.15rem; }
.direct-user-profile > div { display: flex; min-width: 0; flex-direction: column; }
.direct-user-profile h3 { margin: 0; font-size: 1rem; }
.direct-user-profile span, .direct-user-profile a { color: var(--muted); font-size: .78rem; text-decoration: none; }
.direct-user-profile a:hover { color: var(--brand); }
.conversation-detail-section { padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.conversation-detail-section > h3, .detail-section-heading h3 { margin: 0; font-size: .9rem; }
.detail-section-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .7rem; }
.detail-section-heading > span { padding: .15rem .4rem; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: .68rem; font-weight: 800; }
.detail-member-list { display: grid; gap: .25rem; }
.detail-member-row { display: grid; align-items: center; padding: .45rem; border-radius: 11px; grid-template-columns: auto minmax(0,1fr) auto; gap: .65rem; }
.detail-member-row:hover { background: var(--surface-soft); }
.detail-avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-weight: 850; }
.detail-member-row > div { display: flex; min-width: 0; flex-direction: column; }
.detail-member-row strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.detail-member-row small { color: var(--muted); font-size: .68rem; }
.detail-member-row form { margin: 0; }
.detail-management { display: grid; gap: .7rem; }
.detail-management form:first-of-type { display: grid; align-items: end; grid-template-columns: minmax(0,1fr) auto; gap: .5rem; }
.detail-management label { display: grid; color: var(--muted); font-size: .7rem; gap: .25rem; }
.detail-management form:last-of-type { margin: 0; }
.shared-content-section { border-bottom: 0; }
.detail-content-tabs { display: grid; margin: 0 -.2rem .8rem; overflow-x: auto; grid-template-columns: repeat(4, minmax(92px,1fr)); gap: .25rem; }
.detail-content-tabs button { display: flex; min-height: 38px; align-items: center; justify-content: center; gap: .3rem; padding: .4rem; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: .72rem; font-weight: 750; cursor: pointer; }
.detail-content-tabs button.active { color: var(--brand); background: var(--brand-soft); }
.detail-content-tabs span { font-size: .63rem; }
.detail-content-panel[hidden] { display: none; }
.detail-empty { margin: 1.5rem 0; color: var(--muted); font-size: .78rem; text-align: center; }
.detail-media-grid { display: grid; overflow: hidden; border-radius: 12px; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 3px; }
.detail-media-grid .chat-image-button img { height: 125px; }
.detail-media-grid figure { min-width: 0; margin: 0; overflow: hidden; background: #090d1a; }
.detail-media-grid video { display: block; width: 100%; height: 125px; object-fit: cover; }
.detail-media-grid figcaption { display: flex; padding: .35rem; color: #fff; font-size: .62rem; flex-direction: column; }
.detail-media-grid figcaption strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-media-grid figcaption a { color: #bcc5ff; }
.detail-media-grid .detail-audio-item { display: grid; padding: .55rem; background: var(--surface-soft); grid-column: 1 / -1; gap: .3rem; }
.detail-audio-item audio { width: 100%; height: 38px; }
.detail-audio-item figcaption { padding: .15rem; color: var(--ink); flex-direction: row; justify-content: space-between; }
.detail-audio-item figcaption a { color: var(--brand); }
.detail-file-row, .detail-location-row, .detail-event-row { display: grid; align-items: center; gap: .65rem; padding: .6rem .45rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; grid-template-columns: auto minmax(0,1fr); }
.detail-file-row:hover, .detail-location-row:hover, .detail-event-row:hover { color: var(--brand); background: var(--surface-soft); }
.detail-file-row > span, .detail-location-row > span, .detail-event-row > span { display: flex; width: 38px; height: 38px; align-items: center; justify-content: center; border-radius: 10px; color: var(--brand); background: var(--brand-soft); flex-direction: column; font-weight: 800; }
.detail-event-row > span { font-size: .58rem; text-transform: uppercase; }
.detail-event-row > span b { font-size: .92rem; line-height: 1; }
.detail-file-row > div, .detail-location-row > div, .detail-event-row > div { display: flex; min-width: 0; flex-direction: column; }
.detail-file-row strong, .detail-location-row strong, .detail-event-row strong { overflow: hidden; font-size: .77rem; text-overflow: ellipsis; white-space: nowrap; }
.detail-file-row small, .detail-location-row small, .detail-event-row small { overflow: hidden; color: var(--muted); font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-welcome-panel { display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, var(--brand-soft), #fff 55%); }
.chat-welcome { max-width: 420px; padding: 2rem; color: var(--muted); text-align: center; }
.chat-welcome h2 { margin: 1rem 0 .35rem; color: var(--ink); }
.chat-welcome p { margin: 0; }
.chat-welcome-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: auto; border-radius: 24px; color: #fff; background: var(--brand); font-size: 1.6rem; font-weight: 850; box-shadow: 0 14px 28px rgba(68,87,217,.24); }
.chat-messages { overflow-y: auto; padding: 1.25rem; background: linear-gradient(rgba(248,249,253,.92), rgba(248,249,253,.92)), radial-gradient(circle at 20% 20%, #dfe3ff, transparent 18rem); }
.chat-message { display: flex; margin: .7rem 0; }
.chat-message.mine { justify-content: flex-end; }
.chat-bubble { max-width: min(72%, 680px); padding: .7rem .85rem .45rem; border: 1px solid #e1e5ee; border-radius: 5px 18px 18px; background: #fff; box-shadow: 0 3px 12px rgba(31,42,83,.06); }
.mine .chat-bubble { border-color: #d2d8ff; border-radius: 18px 5px 18px 18px; background: #e9ecff; }
.chat-bubble > strong { display: block; margin-bottom: .25rem; color: var(--brand); font-size: .78rem; }
.chat-bubble p { margin: 0; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-bubble time { display: block; margin-top: .3rem; color: #8b93a3; font-size: .65rem; text-align: right; }
.message-reply-preview { display: flex; max-width: 100%; padding: .45rem .6rem; margin-bottom: .45rem; overflow: hidden; border-left: 3px solid var(--brand); border-radius: 7px; color: #4f5970; background: rgba(68,87,217,.08); text-decoration: none; flex-direction: column; }
.message-reply-preview strong { color: var(--brand); font-size: .72rem; }
.message-reply-preview span { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.deleted-message { color: #8790a2; font-style: italic; }
.message-actions-inline { display: flex; align-items: center; flex-wrap: wrap; gap: .15rem; min-height: 28px; margin-top: .3rem; opacity: .72; }
.chat-bubble:hover .message-actions-inline, .message-actions-inline:focus-within { opacity: 1; }
.message-actions-inline form { margin: 0; }
.message-action, .message-edit summary { padding: 0; border: 0; color: #68738a; background: transparent; font-size: .7rem; font-weight: 700; cursor: pointer; }
.message-action:hover, .message-edit summary:hover { color: var(--brand); }
.delete-action:hover { color: var(--danger); }
.message-action-icon { display: grid; place-items: center; width: 27px; height: 27px; padding: 0; border: 0; border-radius: 8px; color: #68738a; background: transparent; cursor: pointer; list-style: none; }
.message-action-icon:hover, .message-action-icon:focus { color: var(--brand); background: rgba(68,87,217,.1); outline: none; }
.message-action-icon svg { width: 14px; height: 14px; fill: currentColor; }
.message-edit, .message-forward { position: relative; }
.message-edit summary { list-style: none; }
.message-edit summary::-webkit-details-marker, .message-forward summary::-webkit-details-marker { display: none; }
.message-edit[open] form { position: fixed; z-index: 1060; top: 50%; left: 50%; display: flex; width: min(92vw, 520px); padding: 1rem; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 22px 70px rgba(25,34,70,.25); transform: translate(-50%, -50%); flex-direction: column; gap: .7rem; }
.message-edit textarea { min-height: 110px; padding: .7rem; border: 1px solid var(--line); border-radius: 9px; resize: vertical; }
.message-edit-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }
.message-edit-actions button { padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; cursor: pointer; }
.message-edit-actions .cancel-message-edit { color: var(--ink); background: var(--surface); }
.message-edit-actions .cancel-message-edit:hover { background: var(--surface-soft); }
.message-edit-actions .save-message-edit { border-color: var(--brand); color: #fff; background: var(--brand); }
.message-forward[open] form { position: fixed; z-index: 1060; top: 50%; left: 50%; display: flex; width: min(92vw, 390px); padding: 1rem; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 22px 70px rgba(25,34,70,.25); transform: translate(-50%, -50%); flex-direction: column; gap: .7rem; }
.message-forward form label { font-weight: 750; }
.message-forward form select { min-height: 44px; padding: .5rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.message-forward form button { align-self: flex-end; padding: .45rem .8rem; border: 0; border-radius: 8px; color: #fff; background: var(--brand); font-weight: 700; }
.forwarded-label { display: flex; align-items: center; gap: .25rem; margin-bottom: .25rem; color: #788298; font-size: .68rem; font-weight: 700; }
.forwarded-label svg { width: 12px; height: 12px; fill: currentColor; }
.message-meta-line { display: flex; align-items: center; justify-content: flex-end; gap: .28rem; margin-top: .25rem; color: #8b93a3; font-size: .65rem; }
.message-meta-line time { display: inline; margin: 0; }
.message-status { min-width: 13px; color: #7f899d; font-size: .8rem; font-weight: 850; letter-spacing: -.28em; direction: ltr; }
.message-status.seen { color: #1689ed; }
.chat-attachment { display: flex; align-items: center; gap: .65rem; min-width: 230px; padding: .65rem; margin: .25rem 0; border: 1px solid rgba(68,87,217,.16); border-radius: 12px; color: var(--ink); background: rgba(255,255,255,.75); text-decoration: none; }
.chat-attachment > span:first-child { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--brand); background: var(--brand-soft); font-size: 1.25rem; }
.chat-attachment > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.chat-attachment strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attachment small { color: var(--muted); }
.message-image-gallery { display: grid; max-width: 520px; margin: .35rem 0; overflow: hidden; border: 1px solid rgba(68,87,217,.18); border-radius: 14px; background: rgba(255,255,255,.78); grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.message-image-gallery.single { grid-template-columns: minmax(0, 1fr); }
.chat-image-button { position: relative; min-width: 0; padding: 0; overflow: hidden; border: 0; color: #fff; background: rgba(19,27,54,.08); cursor: zoom-in; }
.chat-image-button img { display: block; width: 100%; height: 180px; object-fit: cover; transition: transform .18s ease; }
.message-image-gallery.single .chat-image-button img { height: auto; max-height: 380px; object-fit: contain; }
.message-video-gallery { display: grid; max-width: 560px; margin: .35rem 0; gap: .45rem; }
.message-video-gallery figure { margin: 0; overflow: hidden; border: 1px solid rgba(68,87,217,.18); border-radius: 14px; background: rgba(255,255,255,.8); }
.message-video-gallery video { display: block; width: 100%; max-height: 380px; background: #090d1a; }
.message-video-gallery figcaption { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem .7rem; font-size: .76rem; }
.message-video-gallery figcaption strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-video-gallery figcaption a { color: var(--brand); text-decoration: none; }
.chat-image-button:hover img, .chat-image-button:focus-visible img { transform: scale(1.025); }
.chat-image-button > span { position: absolute; right: 0; bottom: 0; left: 0; display: flex; min-width: 0; padding: 1.5rem .65rem .5rem; text-align: left; background: linear-gradient(transparent, rgba(8,13,30,.82)); flex-direction: column; }
.chat-image-button strong { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.chat-image-button small { color: rgba(255,255,255,.78); font-size: .66rem; }
.chat-composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: .7rem; padding: .8rem 1rem .55rem; border-top: 1px solid var(--line); background: #fff; }
.chat-composer textarea { min-height: 44px; max-height: 140px; resize: vertical; }
.composer-reply { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem .7rem; border-left: 3px solid var(--brand); border-radius: 8px; color: #56617a; background: var(--brand-soft); }
.composer-reply[hidden] { display: none; }
.composer-reply div { display: flex; min-width: 0; flex-direction: column; }
.composer-reply strong { color: var(--brand); font-size: .75rem; }
.composer-reply span { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.composer-reply button { border: 0; color: #68738a; background: transparent; font-size: 1.2rem; }
.composer-attachment-preview { display: flex; grid-column: 1 / -1; min-width: 0; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft, #f7f8fc); flex-direction: column; gap: .55rem; }
.composer-attachment-preview[hidden] { display: none; }
.composer-attachment-heading { display: flex; align-items: center; gap: .5rem; }
.composer-attachment-heading span { color: var(--muted); font-size: .75rem; }
.composer-attachment-heading button { margin-left: auto; padding: .2rem .45rem; border: 0; color: var(--brand); background: transparent; font-size: .75rem; cursor: pointer; }
.composer-attachment-list { display: flex; min-width: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: .15rem; gap: .5rem; scroll-snap-type: x proximity; }
.composer-attachment-item { display: grid; flex: 0 0 min(245px, 78vw); grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .55rem; min-width: 0; padding: .4rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, #fff); scroll-snap-align: start; }
.composer-attachment-item img, .composer-file-icon { width: 56px; height: 46px; border-radius: 8px; background: rgba(19,27,54,.08); }
.composer-attachment-item img { object-fit: cover; }
.composer-attachment-item.composer-audio-item { flex-basis: min(390px, 88vw); }
.composer-audio-item audio { width: 170px; height: 38px; }
.composer-file-icon { display: grid; place-items: center; color: var(--brand); font-size: 1.2rem; }
.composer-attachment-item > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.composer-attachment-item strong { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.composer-attachment-item small { color: var(--muted); font-size: .7rem; }
.composer-attachment-item > button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; color: #68738a; background: transparent; font-size: 1.1rem; cursor: pointer; }
.composer-attachment-item > button:hover { color: var(--danger); background: rgba(220,53,69,.09); }
.composer-add-menu { position: relative; }
.file-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--brand); background: var(--surface); font-size: 1.5rem; cursor: pointer; }
.file-button input { display: none; }
.composer-add-options { position: absolute; z-index: 30; bottom: calc(100% + .6rem); left: 0; display: grid; width: 180px; padding: .4rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 16px 45px rgba(28,36,73,.2); gap: .2rem; }
.composer-add-options[hidden] { display: none; }
.composer-add-options button { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border: 0; border-radius: 9px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.composer-add-options button:hover { color: var(--brand); background: var(--brand-soft); }
.composer-add-options button span { display: grid; width: 25px; height: 25px; place-items: center; color: var(--brand); font-weight: 800; }
.composer-voice-recorder { position: relative; }
.voice-record-button { display: flex; width: 44px; height: 44px; align-items: center; justify-content: center; gap: .3rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--brand); background: var(--surface); font-size: .72rem; font-weight: 800; cursor: pointer; transition: width .16s ease, color .16s ease, background .16s ease; }
.voice-record-button svg { width: 20px; height: 20px; fill: currentColor; }
.voice-record-button span { display: none; }
.voice-record-button:hover { background: var(--brand-soft); }
.voice-record-button.recording { width: 72px; border-color: #d7394f; border-radius: 999px; color: #fff; background: #d7394f; animation: voice-recording-pulse 1.4s ease-in-out infinite; }
.voice-record-button.recording span { display: inline; }
.voice-recorder-status { position: absolute; z-index: 25; right: 0; bottom: calc(100% + .6rem); width: max-content; max-width: min(280px, 80vw); padding: .45rem .65rem; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); box-shadow: 0 10px 28px rgba(25,34,70,.18); font-size: .7rem; }
.voice-recorder-status[hidden] { display: none; }
.composer-emoji-picker { position: relative; }
.emoji-picker-button { display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--brand); background: var(--surface); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.emoji-picker-button:hover, .emoji-picker-button[aria-expanded="true"] { background: var(--brand-soft); }
.emoji-picker-menu { position: absolute; z-index: 30; right: 0; bottom: calc(100% + .6rem); display: grid; width: min(248px, calc(100vw - 1.5rem)); max-height: 260px; padding: .55rem; overflow-y: auto; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 16px 45px rgba(28,36,73,.2); gap: .25rem; scrollbar-width: thin; }
.emoji-picker-menu[hidden] { display: none; }
.emoji-picker-menu button { display: grid; width: 34px; height: 34px; padding: 0; place-items: center; border: 0; border-radius: 8px; background: transparent; font-size: 1.18rem; line-height: 1; cursor: pointer; }
.emoji-picker-menu button:hover, .emoji-picker-menu button:focus-visible { outline: 0; background: var(--brand-soft); }
@keyframes voice-recording-pulse { 50% { box-shadow: 0 0 0 5px rgba(215,57,79,.16); } }
.message-audio-list { display: grid; min-width: min(420px, 65vw); margin: .35rem 0; gap: .4rem; }
.message-audio-list figure { display: grid; margin: 0; padding: .65rem; border: 1px solid rgba(68,87,217,.16); border-radius: 13px; background: rgba(255,255,255,.76); gap: .45rem; }
.message-audio-list figure > div { display: grid; align-items: center; grid-template-columns: auto minmax(0,1fr); column-gap: .55rem; }
.message-audio-list figure > div strong, .message-audio-list figure > div small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-audio-list figure > div small { color: var(--muted); font-size: .66rem; }
.message-audio-list audio { width: 100%; height: 38px; }
.message-audio-list figure > a { justify-self: end; color: var(--brand); font-size: .68rem; text-decoration: none; }
.voice-wave { grid-row: 1 / 3; color: var(--brand); font-size: .8rem; font-weight: 900; letter-spacing: .08em; }
.chat-event-card { display: grid; min-width: min(440px, 70vw); margin: .25rem 0; padding: .8rem; border: 1px solid rgba(68,87,217,.2); border-radius: 14px; background: rgba(255,255,255,.78); grid-template-columns: 54px minmax(0,1fr); gap: .8rem; }
.chat-event-date { display: flex; height: 58px; align-items: center; justify-content: center; border-radius: 12px; color: #fff; background: var(--brand); flex-direction: column; line-height: 1; }
.chat-event-date strong { font-size: 1.3rem; }
.chat-event-date span { margin-top: .25rem; font-size: .68rem; text-transform: uppercase; }
.chat-event-content { min-width: 0; }
.chat-card-type { display: block; color: var(--brand); font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.chat-event-content h3 { margin: .12rem 0 .2rem; font-size: 1rem; }
.chat-event-content time, .chat-event-content > p { display: block; margin: .18rem 0; color: var(--muted); font-size: .76rem; }
.chat-event-location { font-weight: 700; }
.event-response-list { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.event-response { padding: .22rem .42rem; border-radius: 999px; color: #657089; background: #eef1f7; font-size: .65rem; }
.event-response.approved { color: #14724a; background: #dff6eb; }
.event-response.rejected { color: #a33845; background: #fde8eb; }
.event-response-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.chat-location-card { min-width: min(440px, 70vw); margin: .25rem 0; overflow: hidden; border: 1px solid rgba(68,87,217,.2); border-radius: 14px; background: rgba(255,255,255,.8); }
.chat-location-card iframe { display: block; width: 100%; height: 190px; border: 0; }
.chat-location-card > div { display: grid; padding: .65rem .75rem; gap: .15rem; }
.chat-location-card small { color: var(--muted); }
.chat-location-card a { margin-top: .2rem; color: var(--brand); font-size: .75rem; text-decoration: none; }
.share-dialog { width: min(92vw, 620px); max-width: none; padding: 0; border: 0; border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 26px 80px rgba(20,27,55,.35); }
.share-dialog::backdrop { background: rgba(8,13,30,.58); backdrop-filter: blur(3px); }
.share-dialog-form { display: grid; padding: 1.15rem; gap: .8rem; }
.share-dialog-form header, .share-dialog-form footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.share-dialog-form header h2 { margin: .1rem 0 0; font-size: 1.25rem; }
.share-dialog-form header > button { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-soft); font-size: 1.3rem; }
.share-dialog-form label { display: grid; color: var(--ink); font-size: .78rem; font-weight: 700; gap: .3rem; }
.share-dialog-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.share-dialog-form footer { justify-content: flex-end; padding-top: .25rem; }
.share-dialog-form .dialog-checkbox { display: flex; align-items: center; flex-direction: row; gap: .5rem; }
.contact-share-dialog { width: min(600px, calc(100vw - 24px)); }
.contact-share-list { max-height: 50vh; overflow-y: auto; }
.contact-share-choice { padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.contact-share-choice[hidden] { display: none; }
.share-dialog-form .contact-share-select { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.contact-share-choice:has(input:checked) { outline: 2px solid var(--bs-primary); outline-offset: -2px; }
.contact-detail-row { display: flex; align-items: flex-start; gap: 8px; }
.contact-detail-row > .form-control, .contact-detail-content { flex: 1; min-width: 0; }
.contact-detail-content > label { display: block; width: 100%; margin-bottom: 8px; }
.contact-detail-button { flex: 0 0 40px; width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; line-height: 1; }
.location-picker-map { height: 320px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.current-location-button { justify-self: start; }
.location-help { margin: -.35rem 0 0; color: var(--muted); font-size: .74rem; }
.composer-limit { grid-column: 2; color: var(--muted); }
.reader-notice { padding: 1rem; border-top: 1px solid var(--line); color: var(--muted); background: #fafbfc; text-align: center; }
.image-lightbox { width: min(96vw, 1400px); height: min(94vh, 960px); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 0; border-radius: 16px; color: #f7f8ff; background: #090d1a; box-shadow: 0 28px 90px rgba(0,0,0,.55); }
.image-lightbox::backdrop { background: rgba(3,6,15,.88); backdrop-filter: blur(5px); }
.lightbox-toolbar { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem .85rem; border-bottom: 1px solid rgba(255,255,255,.12); background: #101628; }
.lightbox-toolbar > div:first-child { display: flex; min-width: 0; flex-direction: column; }
.lightbox-toolbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-toolbar small { color: #aeb8d2; }
.lightbox-actions { display: flex; align-items: center; gap: .35rem; }
.lightbox-actions button, .lightbox-actions a { display: grid; min-width: 36px; height: 36px; padding: 0 .6rem; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; color: #f7f8ff; background: rgba(255,255,255,.07); text-decoration: none; cursor: pointer; }
.lightbox-actions button:hover, .lightbox-actions a:hover { background: rgba(255,255,255,.15); }
.lightbox-actions span { min-width: 48px; color: #c6cde0; font-size: .75rem; text-align: center; }
.lightbox-stage { position: relative; display: grid; height: calc(100% - 58px); min-height: 0; grid-template-columns: 54px minmax(0, 1fr) 54px; align-items: center; }
.lightbox-viewport { display: grid; width: 100%; height: 100%; overflow: auto; place-items: center; }
.lightbox-viewport img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; transition: transform .12s ease; }
.lightbox-nav { z-index: 1; display: grid; width: 44px; height: 58px; margin: auto; padding: 0; place-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 12px; color: #fff; background: rgba(255,255,255,.08); font-size: 2rem; cursor: pointer; }
.lightbox-nav:hover { background: rgba(255,255,255,.18); }
.lightbox-nav:disabled { opacity: .3; cursor: default; }
.chat-empty { display: grid; place-items: center; min-height: 300px; color: var(--muted); }
.chat-empty strong { color: var(--ink); font-size: 1.1rem; }
.member-management { display: flex; flex-direction: column; gap: .75rem; }
.compact-form { gap: .65rem; }
.manage-member-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.manage-member-row > div { display: flex; flex: 1; min-width: 120px; flex-direction: column; }
.manage-member-row small { color: var(--muted); }
.manage-member-row form { margin: 0; }
.admin-settings-grid { display: grid; grid-template-columns: minmax(350px, .8fr) minmax(420px, 1.2fr); gap: 1.25rem; align-items: start; }
.admin-settings-grid .form-panel { width: auto; }
.setting-toggle { display: flex; align-items: flex-start; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.setting-toggle input { width: 20px; height: 20px; margin-top: .15rem; accent-color: var(--brand); }
.setting-toggle span { display: flex; flex-direction: column; }
.setting-toggle small { color: var(--muted); }
.password-input-wrap { position: relative; }
.password-input-wrap .form-control { padding-right: 3rem; }
.password-visibility-button { position: absolute; top: 50%; right: .45rem; display: grid; width: 36px; height: 36px; padding: 0; place-items: center; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; transform: translateY(-50%); }
.password-visibility-button:hover, .password-visibility-button:focus-visible { color: var(--brand); background: var(--brand-soft); }
.password-visibility-button svg { width: 20px; height: 20px; fill: currentColor; }
.password-visibility-button .eye-closed { display: none; }
.password-visibility-button.is-visible .eye-open { display: none; }
.password-visibility-button.is-visible .eye-closed { display: block; }
.profile-panel { display: grid; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); grid-template-columns: minmax(260px, .65fr) minmax(0, 1.35fr); }
.profile-summary { display: flex; align-items: center; padding: 2rem; border-right: 1px solid var(--line); background: linear-gradient(150deg, var(--brand-soft), var(--surface)); text-align: center; flex-direction: column; gap: 1rem; }
.profile-avatar-large { display: grid; width: 132px; height: 132px; overflow: hidden; place-items: center; border: 5px solid var(--surface); border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--brand), #7b8aff); box-shadow: 0 14px 36px rgba(49,65,160,.2); font-size: 2.6rem; font-weight: 850; }
.profile-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.profile-summary h2 { margin: 0 0 .2rem; font-size: 1.35rem; }
.profile-summary p, .profile-summary small { display: block; margin: 0; color: var(--muted); }
.profile-status-preview { padding: .4rem .7rem; border-radius: 999px; color: #14724a; background: #dff6eb; font-size: .74rem; font-weight: 800; }
.profile-status-preview.status-busy, .profile-status-preview.status-do-not-disturb { color: #a33845; background: #fde8eb !important; }
.profile-status-preview.status-away { color: #8a6400; background: #fff1c7 !important; }
.profile-status-preview.status-offline { color: #5f6878; background: #e9edf3 !important; }
.profile-form { display: grid; padding: 2rem; gap: 1.15rem; }
.profile-form > div { min-width: 0; }
.profile-remove-image { display: flex; align-items: center; margin-top: .65rem; color: var(--muted); font-size: .8rem; gap: .45rem; cursor: pointer; }
.profile-remove-image input { accent-color: var(--brand); }
.profile-bio-label { display: flex; align-items: center; justify-content: space-between; }
.profile-bio-label small { color: var(--muted); }
.access-panel { max-height: 700px; overflow-y: auto; }

@media (max-width: 900px) {
  .messaging-home, .admin-settings-grid { grid-template-columns: 1fr; }
  .messaging-workspace { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .messaging-workspace { display: flex; overflow: visible; border: 0; border-radius: 0; box-shadow: none; flex-direction: column; }
  .messaging-sidebar { width: 100%; max-height: 500px; min-height: 420px; border: 1px solid var(--line); border-radius: 18px; }
  .conversation-workspace .messaging-sidebar { display: none; }
  .messaging-workspace.conversation-workspace { height: calc(100dvh - 110px); min-height: 520px; }
  .chat-shell { grid-template-rows: auto minmax(0, 1fr) auto; margin: -1rem; border-radius: 0; }
  .chat-header { grid-template-columns: minmax(0, 1fr) auto; }
  .chat-bubble { max-width: 88%; }
  .chat-image-button img { height: 140px; }
  .composer-attachment-preview { padding: .45rem; }
  .chat-composer { gap: .4rem; padding-right: .55rem; padding-left: .55rem; }
  .message-audio-list { min-width: min(300px, 78vw); }
  .chat-event-card, .chat-location-card { min-width: min(310px, 78vw); }
  .share-dialog-columns { grid-template-columns: 1fr; }
  .location-picker-map { height: 260px; }
  .image-lightbox { width: 100vw; height: 100vh; border-radius: 0; }
  .lightbox-toolbar { min-height: 104px; align-items: stretch; flex-direction: column; gap: .45rem; }
  .lightbox-actions { overflow-x: auto; }
  .lightbox-actions a { margin-left: auto; }
  .lightbox-stage { height: calc(100% - 104px); grid-template-columns: 42px minmax(0, 1fr) 42px; }
  .lightbox-nav { width: 36px; height: 52px; }
  .member-picker { grid-template-columns: 1fr; }
  .member-picker label:nth-child(odd) { border-right: 0; }
}

/* Contacts */
.contacts-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.contacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}
.contacts-toolbar .form-control { max-width: 360px; }
.contacts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.contact-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: .85rem;
  padding: 1.15rem 1.25rem;
  border-right: 1px solid #edf0f5;
  border-bottom: 1px solid #edf0f5;
}
.contact-card-copy { min-width: 0; }
.contact-actions { display: flex; align-items: center; align-self: center; gap: .4rem; }
.contact-actions form { margin: 0; }
.contact-form-panel { max-width: 720px; }
.contact-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 1.1rem;
  font-weight: 800;
}
.contact-card h2 { margin: 0 0 .15rem; font-size: 1rem; }
.contact-card a { display: block; overflow: hidden; color: #536079; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.contact-card small { display: block; margin-top: .35rem; color: var(--muted); font-size: .72rem; }

/* Interactive calendar */
.calendar-app {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.calendar-navigation { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.calendar-navigation h2 { margin: 0 0 0 .5rem; font-size: 1.15rem; white-space: nowrap; }
.calendar-nav-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #48546a;
  background: #fff;
  font-size: 1.4rem;
}
.calendar-nav-button:hover { color: var(--brand); background: var(--brand-soft); }
.calendar-view-switch { display: flex; padding: .2rem; border: 1px solid var(--line); border-radius: 10px; background: #f7f8fb; }
.calendar-view-switch button { padding: .45rem .8rem; border: 0; border-radius: 7px; color: #687287; background: transparent; font-size: .8rem; font-weight: 700; }
.calendar-view-switch button.active { color: #fff; background: var(--brand); }
.calendar-grid { min-height: 560px; }
.calendar-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday { padding: .55rem; border-right: 1px solid #edf0f5; border-bottom: 1px solid var(--line); color: var(--muted); background: #fafbfc; font-size: .72rem; font-weight: 800; text-align: center; text-transform: uppercase; }
.calendar-day-cell { min-width: 0; min-height: 105px; padding: .35rem; border-right: 1px solid #edf0f5; border-bottom: 1px solid #edf0f5; }
.calendar-day-cell:nth-child(7n) { border-right: 0; }
.calendar-day-cell.outside-month { background: #fafbfc; }
.calendar-day-cell.outside-month .calendar-day-number { color: #afb6c5; }
.calendar-day-number {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  margin: 0 0 .2rem auto;
  border: 0;
  border-radius: 50%;
  color: #515b70;
  background: transparent;
  font-size: .78rem;
}
.calendar-day-cell.today .calendar-day-number, .calendar-week-column.today .calendar-week-date strong { color: #fff; background: var(--brand); }
.calendar-event { margin: .25rem 0; border-left: 3px solid var(--brand); border-radius: 5px; background: #eef0ff; }
.calendar-event summary { display: flex; align-items: baseline; gap: .4rem; padding: .45rem .55rem; color: #303a61; cursor: pointer; font-size: .76rem; list-style: none; }
.calendar-event summary::-webkit-details-marker { display: none; }
.calendar-event summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event-time { flex: 0 0 auto; color: #697596; font-size: .67rem; }
.calendar-event-details { display: flex; flex-direction: column; gap: .35rem; padding: 0 .6rem .6rem; color: #556079; font-size: .75rem; overflow-wrap: anywhere; }
.calendar-event-details p { max-height: 100px; overflow: auto; margin: 0; }
.calendar-event.compact summary { display: block; overflow: hidden; padding: .3rem .4rem; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event.compact .calendar-event-time { margin-right: .3rem; }
.calendar-more { padding: .15rem .35rem; border: 0; color: var(--brand); background: transparent; font-size: .7rem; font-weight: 700; }
.calendar-week { display: grid; grid-template-columns: repeat(7, minmax(125px, 1fr)); overflow-x: auto; }
.calendar-week-column { min-height: 560px; padding: .45rem; border-right: 1px solid #edf0f5; }
.calendar-week-column:last-child { border-right: 0; }
.calendar-week-date { display: flex; align-items: center; flex-direction: column; width: 100%; padding: .5rem; border: 0; border-bottom: 1px solid #edf0f5; color: var(--muted); background: transparent; }
.calendar-week-date strong { display: grid; place-items: center; width: 30px; height: 30px; margin-top: .2rem; border-radius: 50%; color: var(--ink); font-size: 1rem; }
.calendar-no-events { margin-top: 1rem; color: #a0a7b5; font-size: .72rem; text-align: center; }
.calendar-day-view { padding: 1rem; }
.calendar-day-view .calendar-event { max-width: 820px; margin: .65rem auto; }
.calendar-day-view .calendar-event summary { padding: .8rem 1rem; font-size: .9rem; }
.calendar-day-empty { display: grid; place-items: center; min-height: 500px; color: var(--muted); }

@media (max-width: 767px) {
  .contacts-grid { grid-template-columns: 1fr; }
  .contact-card { grid-template-columns: 42px minmax(0, 1fr); }
  .contact-avatar { width: 42px; height: 42px; }
  .contact-actions { grid-column: 2; justify-content: flex-start; }
  .contacts-toolbar, .calendar-toolbar { align-items: stretch; flex-direction: column; }
  .contacts-toolbar .form-control { max-width: none; }
  .calendar-navigation { flex-wrap: wrap; }
  .calendar-navigation h2 { width: 100%; margin: .4rem 0 0; }
  .calendar-view-switch button { flex: 1; }
  .calendar-day-cell { min-height: 82px; }
  .calendar-event.compact .calendar-event-time { display: none; }
  .calendar-event.compact summary { font-size: .65rem; }
}

/* Mail workspace */
.mail-workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}
.mail-sidebar { padding: 1.25rem .8rem; border-right: 1px solid var(--line); background: #f8f9fc; }
.compose-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: .9rem 1rem;
  margin: 0 .35rem 1.2rem;
  border-radius: 16px;
  color: #fff;
  background: var(--brand);
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(68, 87, 217, .2);
}
.compose-button:hover { color: #fff; background: #3547c3; }
.compose-button span { font-size: 1.5rem; font-weight: 400; line-height: 1; }
.folder-nav { display: flex; flex-direction: column; gap: .2rem; }
.folder-link {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: .55rem;
  padding: .65rem .8rem;
  border-radius: 10px;
  color: #49536a;
  text-decoration: none;
}
.folder-link:hover { color: var(--brand); background: #eef0ff; }
.folder-link.active { color: #24358f; background: #dfe4ff; font-weight: 750; }
.folder-link strong { font-size: .75rem; }
.folder-icon { color: #727c92; text-align: center; }
.mail-content { min-width: 0; background: #fff; }
.mail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 110px;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.mail-toolbar h1 { margin: .1rem 0; font-size: 1.55rem; }
.mail-toolbar p { margin: 0; color: var(--muted); font-size: .85rem; }
.mail-icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #4b556b;
  font-size: 1.25rem;
  text-decoration: none;
}
.mail-icon-button:hover { color: var(--brand); background: var(--brand-soft); }
.mail-date-heading {
  padding: .62rem 1.1rem;
  border-bottom: 1px solid #e8ebf2;
  color: #717b91;
  background: #f6f7fa;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.mail-workspace .mail-row {
  display: grid;
  grid-template-columns: 34px 34px 34px minmax(0, 1fr);
  gap: 0;
  padding: 0 .75rem;
  background: #fff;
}
.mail-summary-button {
  align-self: center;
  padding: .38rem .58rem;
  border: 1px solid #cbd1ff;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}
.mail-summary-button:hover:not(:disabled) { color: #fff; background: var(--brand); border-color: var(--brand); }
.mail-summary-button:disabled { cursor: not-allowed; opacity: .5; }
.mail-summary-modal .modal-header { align-items: flex-start; }
.mail-summary-modal .modal-title { margin-top: .15rem; font-size: 1.2rem; }
.mail-summary-loading { display: flex; align-items: center; gap: .7rem; min-height: 120px; color: var(--muted); justify-content: center; }
.mail-summary-result + .mail-summary-result { padding-top: 1.25rem; margin-top: 1.25rem; border-top: 2px solid var(--line); }
.mail-summary-result h3 { margin: 0 0 .35rem; font-size: 1rem; }
.mail-summary-result small { display: block; padding-bottom: .7rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.mail-summary-result > div { line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 52px;
  padding: .55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.mail-select-all, .mail-message-select { display: flex; align-items: center; gap: .5rem; color: #626d82; font-size: .78rem; }
.mail-message-select { justify-content: center; margin: 0; }
.mail-select-all input, .mail-message-select input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.mail-sort-form { display: flex; align-items: center; gap: .5rem; margin: 0; color: var(--muted); font-size: .78rem; }
.mail-sort-form .form-select { width: auto; min-width: 140px; padding-top: .35rem; padding-bottom: .35rem; font-size: .78rem; }
.mail-bulk-form { display: flex; align-items: center; gap: .45rem; margin: 0 auto 0 1rem; }
.mail-bulk-form .form-select { width: auto; min-width: 165px; padding-top: .35rem; padding-bottom: .35rem; font-size: .78rem; }
.mail-bulk-form select:disabled, .mail-bulk-form button:disabled { cursor: not-allowed; opacity: .5; }
.mail-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fafbfc;
  font-size: .78rem;
}
.mail-pagination > div { display: flex; gap: .4rem; }
.mail-pagination .disabled { pointer-events: none; opacity: .45; }
.mail-workspace .mail-row.mail-read { background: #f5f6f9; font-weight: 400; }
.mail-workspace .mail-row:hover { position: relative; z-index: 1; background: #eef1ff; box-shadow: 0 1px 5px rgba(34, 44, 79, .13); }
.mail-quick-form { display: flex; align-items: center; margin: 0; }
.mail-flag { border: 0; color: #a1a8b6; background: transparent; font-size: 1.15rem; cursor: pointer; }
.mail-flag:hover { color: #667085; }
.mail-flag.star { color: #e7ab19; }
.mail-flag.important { color: #e2a324; }
.mail-row-link {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(250px, 1.5fr) minmax(135px, auto);
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: .82rem .5rem;
  color: var(--ink);
  text-decoration: none;
}
.mail-row-link:hover { color: var(--ink); }
.mail-copy { display: flex; align-items: center; min-width: 0; gap: .55rem; }
.mail-tags { display: flex; flex: 0 0 auto; gap: .25rem; }
.mail-tags span, .message-tags button {
  padding: .15rem .45rem;
  border: 0;
  border-radius: 6px;
  color: #4e5b81;
  background: #e6e9f5;
  font-size: .68rem;
  font-weight: 700;
}
.mail-row-link time { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.mail-empty { padding: 5rem 1rem; color: var(--muted); text-align: center; }
.message-actions, .message-tags { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-bottom: .8rem; }
.message-actions form, .message-tags form { margin: 0; }
.tag-add-form { display: flex; gap: .4rem; margin-left: auto !important; }
.tag-add-form .form-control { width: 180px; }
.message-tags button:hover { color: #9a2938; background: #ffe8eb; }
.compose-panel { width: 100%; max-width: none; }
.compose-body { min-height: 420px; resize: vertical; }
.rich-mail-editor.rich-editor-ready .compose-body-source { display: none; }
.mail-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .55rem;
  border: 1px solid #cfd5e1;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f7f8fb;
}
.mail-editor-toolbar .form-select { width: 115px; }
.mail-editor-toolbar button {
  min-width: 34px;
  height: 32px;
  padding: .25rem .5rem;
  border: 0;
  border-radius: 5px;
  color: #4f596b;
  background: transparent;
}
.mail-editor-toolbar button:hover, .mail-editor-toolbar button:focus { color: var(--brand); background: #e8ebf8; }
.mail-editor-separator { width: 1px; height: 24px; margin: 0 .2rem; background: #d7dce6; }
.mail-editor-color { position: relative; display: grid; place-items: center; width: 34px; height: 32px; cursor: pointer; font-weight: 700; }
.mail-editor-color input { position: absolute; inset: auto 5px 2px; width: 24px; height: 4px; padding: 0; border: 0; opacity: .85; }
.compose-rich-body {
  min-height: 420px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  border: 1px solid #cfd5e1;
  border-radius: 0 0 8px 8px;
  outline: none;
  background: #fff;
  white-space: pre-wrap;
  line-height: 1.55;
}
.compose-rich-body:focus { border-color: #8793e8; box-shadow: 0 0 0 .2rem rgba(68, 87, 217, .12); }
.llm-panel { width: 100%; max-width: 1000px; }
.llm-status { padding: .45rem .8rem; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.llm-status.ready { color: #237454; background: #e9f8f1; }
.llm-status.unavailable { color: #9b6813; background: #fff4dc; }
.llm-model-info { display: flex; flex-direction: column; gap: .2rem; padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.llm-model-info small, .llm-form .form-actions small { color: var(--muted); }
.llm-answer { padding: 1.25rem; margin-bottom: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: var(--brand-soft); }
.llm-answer > strong { display: block; margin-bottom: .55rem; color: var(--brand); }
.llm-answer > div { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.llm-form textarea { min-height: 180px; resize: vertical; }
:root[data-theme="dark"] .llm-status.ready { color: #a9e4ca; background: #17382c; }
:root[data-theme="dark"] .llm-status.unavailable { color: #f0ca83; background: #41351c; }

.ai-integration-panel { max-width: 820px; }
.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.integration-panel { min-width: 0; }
.integration-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.integration-heading h2 { margin: .15rem 0 0; }
.integration-step { display: flex; flex-direction: column; gap: .35rem; padding: 1rem; margin-bottom: 1.25rem; border: 1px solid var(--line); border-radius: 12px; background: var(--brand-soft); }
.integration-step small { color: var(--muted); }
.integration-code-row { display: flex; gap: .55rem; margin-top: .35rem; }
.integration-code { min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
@media (max-width: 900px) { .integration-grid { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .integration-code-row { flex-direction: column; } }
.ai-provider-options { display: grid; gap: .75rem; padding: 0; border: 0; }
.ai-provider-options legend { margin-bottom: .25rem; font-size: .9rem; font-weight: 800; }
.ai-provider-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.ai-provider-option input { width: 18px; height: 18px; accent-color: var(--brand); }
.ai-provider-option span:nth-child(2) { display: flex; flex-direction: column; gap: .2rem; }
.ai-provider-option small { color: var(--muted); }
.ai-provider-option.disabled { cursor: not-allowed; opacity: .55; }
.licence-panel { max-width: 900px; }
.licence-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.licence-heading > div { display: flex; flex-direction: column; gap: .3rem; }
.licence-heading small, .licence-registration-box small { color: var(--muted); }
.licence-registration-box { padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--brand-soft); }
.licence-url-row { display: flex; gap: .6rem; margin-bottom: .45rem; }
.licence-url-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .76rem; }
@media (max-width: 767px) { .licence-url-row { flex-direction: column; } }

@media (max-width: 767px) {
  .mail-workspace { grid-template-columns: 1fr; }
  .mail-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .folder-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mail-workspace .mail-row { grid-template-columns: 28px 28px 28px minmax(0, 1fr); }
  .mail-list-controls { align-items: stretch; flex-wrap: wrap; }
  .mail-bulk-form { order: 3; width: 100%; margin: 0; }
  .mail-summary-button { order: 2; }
  .mail-bulk-form .form-select { min-width: 0; flex: 1; }
  .mail-pagination { align-items: stretch; flex-direction: column; }
  .mail-row-link { grid-template-columns: 1fr auto; gap: .35rem; }
  .mail-copy { grid-column: 1 / -1; grid-row: 2; }
  .tag-add-form { width: 100%; margin-left: 0 !important; }
  .tag-add-form .form-control { width: auto; flex: 1; }
}
