/* ── BJ Assistant — BrettlJausn Brand Tokens ── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --alpine-forest: #1F4D3A;
  --forest-mid: #2F6B4F;
  --herbal-lime: #8DC63F;
  --soft-sand: #F2EFE7;
  --alpine-white: #F7F9F8;
  --accent-sage: #A8C7B5;
  --near-black: #2B2B2B;
  --pale-sage: #E6ECE8;

  --primary: var(--alpine-forest);
  --accent: var(--herbal-lime);
  --bg: var(--soft-sand);
  --card-bg: #ffffff;
  --text: var(--alpine-forest);
  --text-light: var(--forest-mid);
  --border: var(--pale-sage);
  --success: var(--herbal-lime);
  --danger: #c0392b;
  --warning: #e67e22;

  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(31,77,58,.06), 0 1px 2px rgba(31,77,58,.04);
  --shadow-md: 0 4px 6px rgba(31,77,58,.07), 0 2px 4px rgba(31,77,58,.04);

  --sidebar-width: 260px;
  --sidebar-width-collapsed: 64px;

  /* Height of the fixed top-right bar (clock + page actions). */
  --top-bar-h: 2.375rem;
}

body.sidebar-collapsed,
html.sidebar-collapsed-preload body { --sidebar-width: var(--sidebar-width-collapsed); }

/* .sidebar-icon is only shown in the collapsed view */
.sidebar-icon { display: none; }

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

body {
  font-family: var(--font-body);
  font-weight: 300;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 300;
  color: var(--alpine-forest);
}

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--alpine-forest);
  color: var(--alpine-white);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width .2s ease, padding .2s ease;
  overflow: hidden;
}

.sidebar-toggle {
  position: absolute;
  top: .75rem;
  right: .5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(168,199,181,.25);
  border-radius: 6px;
  color: var(--alpine-white);
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  transition: background .15s, transform .2s ease;
  z-index: 2;
}

.sidebar-toggle:hover { background: rgba(255,255,255,.18); }

body.sidebar-collapsed .sidebar-toggle,
html.sidebar-collapsed-preload body .sidebar-toggle {
  right: 50%;
  transform: translateX(50%);
}

body.sidebar-collapsed .sidebar,
html.sidebar-collapsed-preload body .sidebar { padding: 1.5rem .5rem; }

body.sidebar-collapsed .sidebar-logo,
body.sidebar-collapsed .sidebar-user,
body.sidebar-collapsed .sidebar-label,
html.sidebar-collapsed-preload body .sidebar-logo,
html.sidebar-collapsed-preload body .sidebar-user,
html.sidebar-collapsed-preload body .sidebar-label {
  display: none;
}

body.sidebar-collapsed .sidebar-icon,
html.sidebar-collapsed-preload body .sidebar-icon { display: inline; }

body.sidebar-collapsed .sidebar-nav,
html.sidebar-collapsed-preload body .sidebar-nav {
  margin-top: 3rem;
}

body.sidebar-collapsed .sidebar-nav a,
html.sidebar-collapsed-preload body .sidebar-nav a {
  justify-content: center;
  padding: .65rem .25rem;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  position: relative;
}

.sidebar-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(168,199,181,.3);
  margin-bottom: 1.5rem;
}

.sidebar-logo img {
  display: block;
  height: 72px;
  width: auto;
  max-width: 100%;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(168,199,181,.4) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(168,199,181,.4);
  border-radius: 3px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  color: var(--accent-sage);
  text-decoration: none;
  border-radius: var(--radius);
  margin-bottom: .25rem;
  font-weight: 400;
  transition: all .15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(168,199,181,.15);
  color: var(--alpine-white);
}

.sidebar-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.25rem;
  padding: 0 .4rem;
  border-radius: 999px;
  background: var(--herbal-lime);
  color: var(--alpine-forest);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
}

body.sidebar-collapsed .sidebar-badge,
html.sidebar-collapsed-preload body .sidebar-badge {
  position: absolute;
  top: .25rem;
  right: .25rem;
  margin-left: 0;
  min-width: 1rem;
  height: 1rem;
  padding: 0 .25rem;
  font-size: .6rem;
}

.sidebar-user {
  flex-shrink: 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(168,199,181,.3);
  font-size: .875rem;
  color: var(--accent-sage);
  overflow-wrap: break-word;
  word-break: break-all;
}

.sidebar-user .name {
  color: var(--alpine-white);
  font-weight: 500;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.25rem 2rem 2rem;
  max-width: 1200px;
  transition: margin-left .2s ease, max-width .2s ease;
}

body.sidebar-collapsed .main-content { max-width: none; }

/* ── Top Bar (brand element) ── */
.top-bar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 4px;
  background: var(--alpine-forest);
  z-index: 99;
  transition: left .2s ease;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--soft-sand);
}

.login-card {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
  border-top: 4px solid var(--alpine-forest);
}

.login-card h1 {
  font-size: 1.75rem;
  margin-bottom: .25rem;
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--accent-sage);
  margin-bottom: 2rem;
  font-size: .9375rem;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1.25rem;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 1rem;
}

.page-header h1 {
  font-size: 1.5rem;
  margin-bottom: .125rem;
  line-height: 1.2;
}

.page-header p {
  color: var(--accent-sage);
  font-size: .875rem;
  margin: 0;
}

/* Fixed top-right slot for primary page actions (sits left of the top clock) */
.page-actions {
  position: fixed;
  top: .75rem;
  right: 15rem;
  z-index: 200;
  display: flex;
  align-items: stretch;
  gap: .5rem;
}

/* Buttons in the top-right slot match the clock's height for a
   cohesive top-bar look (same padding, font-size and box-sizing). */
.page-actions .btn {
  height: var(--top-bar-h);
  padding: 0 .875rem;
  font-size: .8125rem;
  box-sizing: border-box;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 400;
  margin-bottom: .375rem;
  color: var(--alpine-forest);
}

.form-control {
  width: 100%;
  padding: .625rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9375rem;
  font-weight: 300;
  color: var(--alpine-forest);
  background: #fff;
  transition: border-color .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--herbal-lime);
  box-shadow: 0 0 0 3px rgba(141,198,63,.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231F4D3A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .9375rem;
  font-weight: 400;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--alpine-forest);
  color: #ffffff !important;
}
.btn-primary:hover { background: var(--forest-mid); }

.btn-accent {
  background: var(--herbal-lime);
  color: #ffffff !important;
}
.btn-accent:hover { opacity: .9; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: .9; }

.btn-success {
  background: var(--herbal-lime);
  color: var(--alpine-forest);
  font-weight: 500;
}

.btn-sm {
  padding: .375rem .75rem;
  font-size: .8125rem;
}

.btn-block { width: 100%; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--alpine-forest);
}
.btn-outline:hover { background: var(--pale-sage); }

/* ── Toggle Switch ── */
.toggle {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--pale-sage);
  border-radius: 26px;
  transition: .3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .3s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--herbal-lime); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

.toggle-label {
  font-weight: 400;
  color: var(--alpine-forest);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--font-body);
  font-size: .8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--alpine-forest);
  background: var(--soft-sand);
}

tr:hover { background: rgba(242,239,231,.5); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge-high { background: #fef2f2; color: var(--danger); }
.badge-medium { background: #fffbeb; color: var(--warning); }
.badge-low { background: rgba(141,198,63,.15); color: var(--forest-mid); }
.badge-active { background: rgba(141,198,63,.15); color: var(--forest-mid); }
.badge-inactive { background: #fef2f2; color: var(--danger); }
.badge-admin, .badge-client_admin { background: rgba(168,199,181,.2); color: var(--alpine-forest); }
.badge-user { background: var(--pale-sage); color: var(--accent-sage); }
.badge-system_admin { background: rgba(141,198,63,.2); color: var(--alpine-forest); }

/* ── Alerts ── */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9375rem;
}

.alert-success {
  background: rgba(141,198,63,.1);
  color: var(--forest-mid);
  border: 1px solid rgba(141,198,63,.3);
}

.alert-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid rgba(192,57,43,.2);
}

/* Dismissible banners (flight alerts, etc.) rendered by partials/alerts.ejs */
.alerts-stack {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.bj-alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  background: #fff8ed;
  border-left: 4px solid var(--warning, #f39c12);
  color: var(--alpine-forest);
}
.bj-alert-flight_status { background: #fef2f2; border-left-color: var(--danger); }
.bj-alert-body { flex: 1; min-width: 0; }
.bj-alert-title {
  font-weight: 600;
  margin-bottom: .125rem;
}
.bj-alert-msg { font-size: .9375rem; color: var(--forest-mid); line-height: 1.45; }
.bj-alert-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--forest-mid);
  cursor: pointer;
  padding: .125rem .375rem;
}
.bj-alert-dismiss:hover { color: var(--alpine-forest); }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.stat-card .label {
  font-size: .8125rem;
  color: var(--accent-sage);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-card .value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 300;
  margin-top: .25rem;
  color: var(--alpine-forest);
}

/* ── Connection Status ── */
.connection-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
}

.connection-status.connected {
  background: rgba(141,198,63,.1);
  color: var(--forest-mid);
}

.connection-status.disconnected {
  background: #fef2f2;
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.green { background: var(--herbal-lime); }
.status-dot.red { background: var(--danger); }

/* ── Grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 2.75rem 1rem 1rem; max-width: none; }
  .top-bar { left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* On mobile the clock shrinks to just the time, so move page-actions closer */
  .page-actions { top: .5rem; right: 7rem; }
}

/* ── Action group ── */
.actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.actions form { display: inline; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--accent-sage);
}

.empty-state p { margin-top: .5rem; }

/* ── Links ── */
a {
  color: var(--herbal-lime);
  text-decoration: underline;
}

a:hover {
  color: var(--forest-mid);
}

/* Sidebar + nav links override */
.sidebar a,
.sidebar-nav a,
.btn {
  text-decoration: none;
}

/* ── Inbox (two-pane) ── */
.inbox-main {
  max-width: none;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.inbox-list {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: .5rem;
}

.inbox-item[hidden] { display: none; }

.inbox-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  border-left: 4px solid var(--border);
  border-radius: 6px;
  padding: .75rem .875rem;
  margin-bottom: .375rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 300;
  color: var(--alpine-forest);
  transition: background .15s, border-color .15s;
}

.inbox-item:hover { background: var(--soft-sand); }
.inbox-item.active {
  background: rgba(141,198,63,.12);
  box-shadow: inset 0 0 0 1px rgba(141,198,63,.35);
}

.inbox-item.priority-high { border-left-color: var(--danger); }
.inbox-item.priority-medium { border-left-color: var(--warning); }
.inbox-item.priority-low { border-left-color: var(--herbal-lime); }

.inbox-item.is-finished { opacity: .55; }

.inbox-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .2rem;
}

.inbox-item-sender {
  font-weight: 500;
  font-size: .875rem;
  color: var(--alpine-forest);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.inbox-item-subject {
  font-size: .9375rem;
  color: var(--near-black);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: .25rem;
}

.inbox-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
  color: var(--forest-mid);
}

.inbox-tag {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}

.tag-pending { background: rgba(168,199,181,.25); color: var(--forest-mid); }
.tag-sent { background: rgba(141,198,63,.2); color: var(--forest-mid); }
.tag-skipped { background: var(--pale-sage); color: var(--accent-sage); }
.tag-cc { background: rgba(47,107,79,.15); color: var(--forest-mid); }
.tag-info { background: rgba(141,198,63,.18); color: var(--alpine-forest); }
.tag-meeting-invite { background: rgba(47,107,79,.2); color: var(--alpine-forest); font-weight: 600; }
.tag-read { background: rgba(47,107,79,.1); color: var(--forest-mid); }

/* ===== Archive ===== */
.archive-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  margin-top: 16px;
}
.archive-filters {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 16px;
}
.archive-filter-group + .archive-filter-group { margin-top: 20px; }
.archive-filter-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--forest-mid);
  margin-bottom: 8px;
  font-weight: 500;
}
.archive-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--alpine-forest);
  font-size: .9rem;
  text-transform: capitalize;
}
.archive-filter:hover { background: var(--soft-sand); }
.archive-filter.is-active {
  background: var(--alpine-forest);
  color: #ffffff;
}
.archive-filter.is-active .archive-filter-count { color: #ffffff; opacity: .8; }
.archive-filter-count {
  font-size: .75rem;
  color: var(--forest-mid);
  font-variant-numeric: tabular-nums;
}

.archive-list-meta {
  font-size: .85rem;
  color: var(--forest-mid);
  margin-bottom: 10px;
}
.archive-items {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
}
.archive-item {
  padding: 12px 16px;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--pale-sage);
}
.archive-item:last-child { border-bottom: none; }
.archive-item.priority-high { border-left-color: var(--danger); }
.archive-item.priority-medium { border-left-color: var(--warning); }
.archive-item.priority-low { border-left-color: var(--herbal-lime); }
.archive-item.is-read { opacity: .75; }
.archive-item.is-finished { opacity: .6; }
.archive-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.archive-item-sender { font-weight: 500; color: var(--alpine-forest); }
.archive-item-subject {
  margin-top: 2px;
  font-size: .95rem;
  color: var(--alpine-forest);
}
.archive-item-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: .8rem;
  color: var(--forest-mid);
}
.archive-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  text-decoration: none;
  font-size: .72rem;
  text-transform: lowercase;
  letter-spacing: .02em;
  font-weight: 500;
}
.archive-chip.chip-category {
  background: rgba(31,77,58,.12);
  color: var(--alpine-forest);
}
.archive-chip.chip-project {
  background: rgba(141,198,63,.2);
  color: var(--forest-mid);
}
.archive-item-recipients {
  margin-top: 2px;
  font-size: .8rem;
  color: var(--forest-mid);
}
.archive-item-more {
  background: rgba(47,107,79,.15);
  border-radius: 8px;
  padding: 1px 6px;
  font-size: .72rem;
}

/* Prompt shown when the archive contains emails processed before the AI
   tagging feature existed. The button kicks off a batched backfill that
   classifies them one page at a time. */
.archive-backfill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(141, 198, 63, .12);
  border: 1px dashed rgba(141, 198, 63, .5);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: .875rem;
  color: var(--alpine-forest);
}
.archive-backfill-text { flex: 1 1 260px; }
.archive-backfill-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.archive-backfill-status {
  font-size: .8125rem;
  color: var(--forest-mid);
  font-style: italic;
}

/* Archive search box. Matches subject, sender, recipient names and (for
   still-pending emails) the AI draft reply. Original message bodies aren't
   stored, so keyword hits come from what's persisted on the row. */
.archive-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.archive-search-input {
  flex: 1 1 280px;
  min-width: 0;
  padding: 10px 14px;
  font-size: .9375rem;
  font-family: inherit;
  color: var(--alpine-forest);
  background: var(--card-bg);
  border: 1px solid rgba(31, 77, 58, .2);
  border-radius: 8px;
}
.archive-search-input:focus {
  outline: none;
  border-color: var(--herbal-lime);
  box-shadow: 0 0 0 3px rgba(141, 198, 63, .2);
}
.archive-search-clear {
  font-size: .8125rem;
  color: var(--forest-mid);
  text-decoration: underline;
}
@media (max-width: 480px) {
  .archive-search-input { flex-basis: 100%; }
}

/* Tag heatmap / word cloud: five size tiers based on email count. Works for
   both categories and projects — chip background colours come from the
   chip-category / chip-project rules above. */
.archive-heatmap {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 16px;
}
.archive-heatmap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.archive-heatmap-row + .archive-heatmap-row { margin-top: 10px; }
.archive-heatmap-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--forest-mid);
  margin-right: 4px;
}
.heatmap-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  text-decoration: none;
  text-transform: lowercase;
  line-height: 1;
}
.heatmap-chip.is-active {
  outline: 2px solid var(--alpine-forest);
  outline-offset: 1px;
}
.heatmap-chip.heatmap-t1 { font-size: .78rem; opacity: .65; }
.heatmap-chip.heatmap-t2 { font-size: .9rem; opacity: .8; }
.heatmap-chip.heatmap-t3 { font-size: 1.05rem; opacity: .9; }
.heatmap-chip.heatmap-t4 { font-size: 1.2rem; opacity: 1; font-weight: 500; }
.heatmap-chip.heatmap-t5 { font-size: 1.4rem; opacity: 1; font-weight: 500; }
.heatmap-count {
  font-size: .7rem;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.archive-empty {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  color: var(--forest-mid);
}
.archive-truncated {
  margin-top: 12px;
  font-size: .8rem;
  color: var(--forest-mid);
  text-align: center;
}
@media (max-width: 768px) {
  .archive-layout { grid-template-columns: 1fr; }
  .archive-filters { position: static; }
}

/* Hero shown when the archive first loads (no category/activity picked).
   Large display word in the middle — the "pick a bucket" nudge. */
.archive-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  margin-top: 24px;
  background: var(--card-bg);
  border-radius: 12px;
  min-height: 340px;
}
.archive-hero-word {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: clamp(4rem, 14vw, 10rem);
  line-height: 1;
  color: var(--alpine-forest);
  letter-spacing: .01em;
  background: linear-gradient(135deg, var(--alpine-forest) 0%, var(--herbal-lime) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.archive-hero-sub {
  margin-top: 18px;
  color: var(--forest-mid);
  font-size: 1rem;
  max-width: 480px;
}
@media (max-width: 480px) {
  .archive-hero { padding: 56px 16px; min-height: 240px; }
}

/* Email detail dialog (Archive → click an email) */
.archive-item-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--pale-sage);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background .12s ease;
}
.archive-item-btn:hover,
.archive-item-btn:focus-visible {
  background: var(--soft-sand);
  outline: none;
}
.archive-items li:last-child .archive-item-btn { border-bottom: none; }

.archive-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 77, 58, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.archive-dialog-backdrop[hidden] { display: none; }
.archive-dialog {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(31, 77, 58, .25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.archive-dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--forest-mid);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background .12s ease;
}
.archive-dialog-close:hover { background: var(--soft-sand); }
.archive-dialog-body {
  padding: 28px 32px 32px;
  overflow-y: auto;
}
.archive-dialog-loading {
  padding: 40px 0;
  text-align: center;
  color: var(--forest-mid);
}
.archive-dialog-title {
  margin: 0 40px 14px 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300;
  font-size: 1.75rem;
  color: var(--alpine-forest);
  line-height: 1.2;
}
.archive-dialog-meta {
  display: grid;
  gap: 4px;
  font-size: .9rem;
  color: var(--alpine-forest);
  margin-bottom: 12px;
}
.archive-dialog-meta .archive-dialog-label {
  display: inline-block;
  min-width: 60px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--forest-mid);
  font-weight: 500;
}
.archive-dialog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.archive-dialog-divider {
  height: 1px;
  background: var(--pale-sage);
  margin: 16px 0;
}
.archive-dialog-body-text {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: .95rem;
  color: var(--alpine-forest);
  line-height: 1.55;
}
.archive-dialog-body-html {
  font-size: .95rem;
  color: var(--alpine-forest);
  line-height: 1.55;
  word-break: break-word;
}
.archive-dialog-body-html img { max-width: 100%; height: auto; }
.archive-dialog-body-html a { color: var(--forest-mid); }
.archive-dialog-body-html blockquote {
  margin: 10px 0;
  padding-left: 12px;
  border-left: 3px solid var(--pale-sage);
  color: var(--forest-mid);
}
.archive-dialog-unavailable {
  padding: 20px;
  background: var(--soft-sand);
  border-radius: 8px;
  color: var(--forest-mid);
  font-size: .9rem;
  text-align: center;
}
@media (max-width: 480px) {
  .archive-dialog { max-height: 95vh; }
  .archive-dialog-body { padding: 22px 20px 24px; }
  .archive-dialog-title { font-size: 1.4rem; }
}

/* Already-read-in-Outlook rows are shown but de-emphasized — the user has
   already engaged with the message, so it doesn't compete for attention with
   unread items. The is-finished rule above (opacity .55) takes precedence
   when both apply. */
.inbox-item.is-read:not(.is-finished) {
  opacity: .7;
}
.inbox-item.is-read:not(.is-finished) .inbox-item-sender,
.inbox-item.is-read:not(.is-finished) .inbox-item-subject {
  font-weight: 400;
}

/* Meeting-invite response block (Accept / Ask for other time / Decline) */
.inbox-invite {
  background: rgba(141,198,63,.08);
  border: 1px solid rgba(47,107,79,.18);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.inbox-invite[hidden] { display: none; }

.inbox-invite-summary {
  display: grid;
  gap: .375rem;
  margin-bottom: 1rem;
}

.inbox-invite-row {
  display: flex;
  gap: .75rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.inbox-invite-label {
  flex: 0 0 5rem;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--forest-mid);
  font-weight: 500;
}

.inbox-invite-value {
  color: var(--alpine-forest);
}

.inbox-invite-summary-loading {
  color: var(--forest-mid);
  font-style: italic;
}

.inbox-help-inline {
  color: var(--forest-mid);
  font-weight: 400;
  font-size: .8125rem;
}

/* Meeting response tags — declined and new-time get high-visibility colours
   so the user's eye catches them first in the Meeting Responses register. */
.tag-mresp-accepted  { background: rgba(141,198,63,.22); color: var(--alpine-forest); }
.tag-mresp-tentative { background: rgba(242,167,77,.22); color: #a6471f; }
.tag-mresp-declined  { background: rgba(192,57,43,.16); color: #a12d21; font-weight: 600; }
.tag-mresp-new-time  { background: rgba(230,126,34,.2); color: #8a4410; font-weight: 600; }
.tag-mresp-unknown   { background: var(--pale-sage); color: var(--forest-mid); }

/* Left-border cue on the list item itself for the noteworthy kinds — lets the
   user spot declines and new-time proposals without scanning the tag. */
.inbox-item.is-meeting-response.is-mresp-declined {
  border-left-color: var(--danger);
}
.inbox-item.is-meeting-response.is-mresp-new-time {
  border-left-color: var(--warning);
}

.inbox-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: .875rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.inbox-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .5rem .875rem;
  font: inherit;
  color: var(--forest-mid);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  font-size: .875rem;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}

.inbox-tab:hover { color: var(--alpine-forest); }

.inbox-tab.is-active {
  color: var(--alpine-forest);
  border-bottom-color: var(--herbal-lime);
  font-weight: 500;
}

.inbox-tab-count {
  background: var(--pale-sage);
  border-radius: 999px;
  padding: .0625rem .5rem;
  font-size: .6875rem;
  min-width: 1.5rem;
  text-align: center;
  font-weight: 500;
}

.inbox-tab.is-active .inbox-tab-count {
  background: var(--herbal-lime);
  color: var(--alpine-forest);
}

.inbox-empty-register {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--forest-mid);
  font-size: .875rem;
}

/* Collapsible card (uses native <details>/<summary>). Collapsed the card
   shrinks to just its header so the settings page stays compact. */
.rollup-card { padding: 0; }
.rollup-card > *:not(summary) { margin-left: 1.5rem; margin-right: 1.5rem; }
.rollup-card > *:not(summary):last-child { margin-bottom: 1.5rem; }

.rollup-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid transparent;
  user-select: none;
}

.rollup-summary::-webkit-details-marker { display: none; }

.rollup-summary h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--alpine-forest);
}

.rollup-chevron {
  font-size: 1.5rem;
  color: var(--forest-mid);
  transition: transform .15s;
  line-height: 1;
}

details[open] .rollup-chevron { transform: rotate(90deg); }
details[open] .rollup-summary { border-bottom-color: var(--border); margin-bottom: 1rem; }

.inbox-detail {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  min-height: 400px;
}

.inbox-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--accent-sage);
}

.inbox-view-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.inbox-view-head-main {
  min-width: 0;
  flex: 1 1 auto;
}

.inbox-view-head h2 {
  font-size: 1.5rem;
  margin-bottom: .25rem;
}

.inbox-view-meta {
  font-size: .875rem;
  color: var(--forest-mid);
}

.inbox-view-head-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .5rem;
  flex: 0 0 auto;
}

.inbox-head-actions {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.inbox-head-actions .btn { white-space: nowrap; }
.inbox-head-actions .btn[hidden] { display: none; }

.inbox-head-action-count {
  margin-left: .25rem;
  color: var(--forest-mid);
  font-size: .75rem;
}

.inbox-attach-icon {
  margin-right: .2rem;
  font-size: .9375rem;
  line-height: 1;
}

.inbox-status-row {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.inbox-intent {
  font-size: .8125rem;
  color: var(--accent-sage);
  text-transform: capitalize;
}

.inbox-field {
  margin-bottom: 1.25rem;
}

.inbox-field label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .375rem;
  color: var(--alpine-forest);
}

.inbox-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .375rem;
}

.inbox-field-header label { margin-bottom: 0; }

.inbox-save-status {
  font-size: .75rem;
  color: var(--forest-mid);
  font-style: italic;
  transition: opacity .2s;
  min-height: 1em;
}

.inbox-save-status-saving { color: var(--accent-sage); }
.inbox-save-status-saved { color: var(--herbal-lime); font-style: normal; }
.inbox-save-status-error { color: var(--danger); font-style: normal; }

.inbox-help {
  font-size: .8125rem;
  color: var(--forest-mid);
  margin-top: .375rem;
}

.inbox-change-row {
  display: flex;
  gap: .5rem;
}

.inbox-change-row .form-control { flex: 1; }

.inbox-gen-draft {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem;
  margin-bottom: .5rem;
  background: rgba(141, 198, 63, .08);
  border: 1px dashed rgba(141, 198, 63, .4);
  border-radius: .375rem;
}

.inbox-gen-draft[hidden] { display: none; }

.inbox-gen-draft .inbox-help { margin: 0; flex: 1 1 260px; }

.inbox-attachments-list {
  list-style: none;
  padding: 0;
  margin: .5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.inbox-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .375rem .625rem;
  background: var(--soft-sand);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .875rem;
}

.inbox-attachment-remove {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: .8125rem;
  padding: 0;
}

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

.inbox-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
  .inbox-layout { grid-template-columns: 1fr; }
  .inbox-list { max-height: 280px; }
  .inbox-view-head { flex-direction: column; }
  .inbox-view-head-side {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .inbox-head-actions { justify-content: flex-end; }
}

/* ── Inbox compose (new email) ── */
.compose-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 77, 58, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 900;
}

.compose-backdrop[hidden] { display: none; }

.compose-modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(31, 77, 58, .25);
  width: 100%;
  max-width: min(1200px, 96vw);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.compose-head h2 { font-size: 1.5rem; margin: 0; }

.compose-close {
  background: transparent;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--forest-mid);
  cursor: pointer;
  padding: 0 .25rem;
}

.compose-close:hover { color: var(--alpine-forest); }

.compose-body {
  padding: 1.25rem 1.5rem;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0 1.5rem;
}

.compose-col-left,
.compose-col-right {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compose-col-left {
  overflow-y: auto;
  padding-right: .25rem;
}

.compose-col-right {
  overflow: hidden;
}

.compose-field-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.compose-field-body textarea {
  flex: 1 1 auto;
  min-height: 220px;
  resize: none;
}

.compose-field { margin-bottom: 1rem; position: relative; }

.compose-field label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .375rem;
  color: var(--alpine-forest);
}

.compose-field-row {
  margin: -.25rem 0 .75rem;
}

.compose-toggle {
  background: transparent;
  border: none;
  color: var(--forest-mid);
  font: inherit;
  font-size: .8125rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.compose-toggle:hover { color: var(--alpine-forest); }

.compose-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-bottom: .25rem;
}

.compose-chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  background: rgba(141, 198, 63, .18);
  color: var(--alpine-forest);
  border-radius: 999px;
  padding: .2rem .625rem;
  font-size: .8125rem;
  max-width: 100%;
}

.compose-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 20rem;
}

.compose-chip button {
  background: transparent;
  border: none;
  color: var(--forest-mid);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.compose-chip button:hover { color: var(--danger); }

.compose-ac { position: relative; }

.compose-ac-dd {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 950;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}

.compose-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: .5rem .75rem;
  cursor: pointer;
  font: inherit;
  color: var(--alpine-forest);
}

.compose-ac-item:last-child { border-bottom: none; }
.compose-ac-item:hover { background: rgba(141, 198, 63, .12); }
.compose-ac-item strong { font-weight: 500; margin-right: .375rem; }
.compose-ac-email { color: var(--forest-mid); font-size: .75rem; }

.compose-ai-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .5rem;
}

.compose-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--soft-sand);
}

@media (max-width: 900px) {
  .compose-body {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow-y: auto;
    gap: 0;
  }
  .compose-col-left {
    overflow: visible;
    padding-right: 0;
  }
  .compose-col-right {
    overflow: visible;
  }
  .compose-field-body {
    flex: 0 0 auto;
  }
  .compose-field-body textarea {
    min-height: 200px;
  }
}

@media (max-width: 600px) {
  .compose-backdrop { padding: .5rem; }
  .compose-modal { max-height: calc(100vh - 1rem); }
  .compose-body { padding: 1rem; }
  .compose-head { padding: .75rem 1rem; }
  .compose-actions { padding: .75rem 1rem; }
}

/* ── Branded modal dialog (confirm / alert / prompt) ── */
.bj-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 77, 58, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity .18s ease;
  /* Safety net: if a modal's content is somehow taller than the viewport
     (e.g. the cap is overridden by a child's intrinsic size), let the
     backdrop itself scroll so nothing gets cut off at the top. */
  overflow-y: auto;
}

.bj-modal-backdrop.visible { opacity: 1; }

/* The [hidden] attribute must win over .bj-modal-backdrop's display:flex,
   otherwise a hidden modal still covers the viewport and swallows clicks.
   Also applies to any other element (buttons, inputs) whose display mode
   is set via a class — without !important the HTML `hidden` attribute
   loses to the class's declared display. */
[hidden] { display: none !important; }

.bj-modal {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(31,77,58,.28);
  width: 100%;
  max-width: 460px;
  padding: 2rem;
  border-top: 4px solid var(--alpine-forest);
  transform: translateY(12px) scale(.98);
  transition: transform .18s ease;
}

.bj-modal-backdrop.visible .bj-modal { transform: translateY(0) scale(1); }

.bj-modal h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 300;
  margin-bottom: .5rem;
  color: var(--alpine-forest);
}

.bj-modal p {
  color: var(--forest-mid);
  font-size: .9375rem;
  margin-bottom: 1.5rem;
  line-height: 1.55;
}

.bj-modal .form-control { margin-bottom: 1.5rem; }

.bj-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ── Inbox source-email pane ── */
.inbox-source {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--soft-sand);
}

.inbox-source-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .625rem 1rem;
  background: var(--pale-sage);
  font-size: .8125rem;
  color: var(--forest-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}

.inbox-source-toggle {
  background: none;
  border: none;
  color: var(--forest-mid);
  font-size: .8125rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 0;
}

.inbox-source-toggle:hover { color: var(--alpine-forest); }

.inbox-source-body {
  padding: 0;
  background: #fff;
  max-height: min(720px, 68vh);
  overflow-y: auto;
}

.inbox-source-body iframe {
  border: 0;
  width: 100%;
  min-height: min(640px, 60vh);
  display: block;
}

.inbox-source-body .inbox-source-text {
  padding: 1rem 1.25rem;
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: .9375rem;
  color: var(--near-black);
  line-height: 1.55;
}

.inbox-source.collapsed .inbox-source-body { display: none; }

.inbox-source-loading,
.inbox-source-error {
  padding: 1rem 1.25rem;
  font-size: .875rem;
  color: var(--forest-mid);
}

.inbox-source-error { color: var(--danger); }

/* Received attachments live inside a modal dialog (inbox-received-modal) —
   triggered by the "Attachments" button in the email-detail header. */
.inbox-received-modal-card {
  max-width: 520px;
  padding: 0;
  overflow: hidden;
}

.inbox-received-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.inbox-received-modal-head h3 {
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 300;
  margin: 0;
  color: var(--alpine-forest);
}

.inbox-received-attachments-list {
  list-style: none;
  margin: 0;
  padding: .75rem 1.25rem 1.25rem;
  max-height: 420px;
  overflow-y: auto;
}

.inbox-received-attachment {
  padding: .2rem 0;
  font-size: .9375rem;
}

.inbox-received-attachment-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--soft-sand);
  color: var(--alpine-forest);
  text-decoration: none;
  font-weight: 500;
  word-break: break-word;
  transition: background .15s, border-color .15s;
}

.inbox-received-attachment-link:hover {
  background: var(--pale-sage);
  border-color: rgba(141, 198, 63, .5);
  color: var(--alpine-forest);
}

.inbox-received-attachment-name { min-width: 0; }

.inbox-received-attachment-size {
  color: var(--forest-mid);
  font-size: .8125rem;
  flex: 0 0 auto;
}

/* ── Collapsible Proposed Reply ── */
.inbox-reply-collapse {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.inbox-reply-collapse[hidden] { display: none; }

.inbox-reply-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--pale-sage);
  font-size: .9375rem;
  font-weight: 500;
  color: var(--alpine-forest);
  user-select: none;
}

.inbox-reply-summary::-webkit-details-marker { display: none; }
.inbox-reply-summary::marker { content: ''; }

.inbox-reply-summary-label {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.inbox-reply-chevron {
  display: inline-block;
  font-size: .9375rem;
  color: var(--forest-mid);
  transition: transform .15s ease;
}

.inbox-reply-collapse[open] > .inbox-reply-summary .inbox-reply-chevron {
  transform: rotate(90deg);
}

.inbox-reply-collapse[open] > .inbox-reply-summary {
  border-bottom: 1px solid var(--border);
}

.inbox-reply-body {
  padding: 1rem 1rem 1.25rem;
}

.inbox-reply-body .inbox-field:last-child { margin-bottom: 0; }

/* ── Drag-and-drop attachments zone ── */
.inbox-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1.25rem 1rem;
  border: 2px dashed rgba(141, 198, 63, .45);
  border-radius: 10px;
  background: rgba(141, 198, 63, .06);
  color: var(--forest-mid);
  text-align: center;
  transition: background .15s, border-color .15s;
}

.inbox-dropzone.is-dragover {
  background: rgba(141, 198, 63, .18);
  border-color: var(--herbal-lime);
}

.inbox-dropzone-icon {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--alpine-forest);
}

.inbox-dropzone-text {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .9375rem;
  color: var(--alpine-forest);
}

.inbox-dropzone-text span {
  color: var(--forest-mid);
  font-size: .8125rem;
}

.inbox-dropzone-hint {
  font-size: .75rem;
  color: var(--forest-mid);
  margin: 0;
}

.inbox-dropzone .btn { pointer-events: auto; }

/* Drops inside the dropzone shouldn't trigger child hover states. */
.inbox-dropzone.is-dragover * { pointer-events: none; }

/* ── Rich text editor (bj-ui) ── */
.bj-rich {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.bj-rich-toolbar {
  display: flex;
  gap: .25rem;
  padding: .375rem;
  background: var(--soft-sand);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.bj-rich-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 32px;
  height: 28px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--alpine-forest);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all .15s;
}

.bj-rich-btn:hover {
  background: var(--pale-sage);
  border-color: var(--accent-sage);
}

.bj-rich-btn.active {
  background: var(--alpine-forest);
  border-color: var(--alpine-forest);
  color: var(--alpine-white);
}

.bj-rich-select {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 28px;
  padding: 0 .375rem;
  font-size: .8125rem;
  color: var(--alpine-forest);
  cursor: pointer;
  font-family: var(--font-body);
}

.bj-rich-select:hover {
  border-color: var(--accent-sage);
}

.bj-rich-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 .25rem;
  align-self: center;
}

/* ── Signature preview (settings + inbox) ── */
.signature-preview {
  background: var(--soft-sand);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: .9375rem;
  color: var(--alpine-forest);
  line-height: 1.55;
}

.signature-preview-template { background: var(--pale-sage); }

.signature-preview p { margin-bottom: .5rem; }
.signature-preview p:last-child { margin-bottom: 0; }
.signature-preview a { color: var(--forest-mid); }
.signature-preview ul, .signature-preview ol { padding-left: 1.5rem; }

.bj-rich-editor {
  min-height: 160px;
  max-height: 480px;
  overflow-y: auto;
  padding: .75rem 1rem;
  background: #fff;
  border: none !important;
  border-radius: 0 !important;
  outline: none;
  font-family: var(--font-body);
  font-size: .9375rem;
  color: var(--alpine-forest);
  line-height: 1.55;
}

.bj-rich-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(141,198,63,.3);
}

.bj-rich-editor p { margin-bottom: .5rem; }
.bj-rich-editor ul, .bj-rich-editor ol { padding-left: 1.5rem; margin-bottom: .5rem; }

/* ── Calendar (weekly view) ── */
.calendar-main {
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
}
/* The week grid is sized to its content and scrolls internally when it
   exceeds the remaining viewport height. On tall screens where the grid
   fits naturally we don't want the wrap card to stretch past the last
   row — the last row has no bottom border, so extra card space below it
   would read as an oversized final slot. `flex: 0 1 auto` keeps the
   wrap content-sized but still allows it to shrink and scroll when the
   grid is taller than the remaining viewport. */
.calendar-main .cal-matrix-wrap {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* Keep the day header row pinned while scrolling. */
.calendar-main .cal-mx-corner,
.calendar-main .cal-mx-day-head {
  position: sticky;
  top: 0;
  z-index: 3;
}

.cal-week-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.cal-week-title {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  flex-wrap: wrap;
}

.cal-week-label {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--alpine-forest);
}

.cal-week-range {
  color: var(--forest-mid);
  font-size: .9375rem;
}

.cal-week-nav { display: flex; gap: .375rem; }

.cal-focus-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cal-focus-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-end;
}

.cal-focus-row { display: flex; flex-direction: column; gap: .375rem; }

.cal-focus-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--forest-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cal-focus-select { min-width: 100px; }

.cal-days-grid {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}

.cal-day-pill {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.cal-day-pill input { position: absolute; opacity: 0; pointer-events: none; }

.cal-day-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--forest-mid);
  transition: all .12s;
}

.cal-day-pill input:checked + span {
  background: var(--alpine-forest);
  border-color: var(--alpine-forest);
  color: #ffffff;
}

.cal-focus-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-left: auto;
}

.cal-focus-status {
  font-size: .8125rem;
  color: var(--herbal-lime);
  font-weight: 500;
}

/* Shared event tag pills */
.cal-tag {
  display: inline-block;
  padding: .0625rem .375rem;
  border-radius: 10px;
  font-size: .6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cal-tag-high { background: var(--danger); color: #ffffff; }
.cal-tag-normal { background: var(--warning); color: #ffffff; }
.cal-tag-low { background: var(--herbal-lime); color: var(--alpine-forest); }
.cal-tag-online { background: var(--forest-mid); color: #ffffff; }
.cal-tag-focus { background: var(--alpine-forest); color: #ffffff; }

/* Weekly matrix view */
.cal-matrix-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cal-allday {
  display: grid;
  border-bottom: 1px solid var(--border);
  background: var(--soft-sand);
}

.cal-allday-label {
  padding: .375rem .5rem;
  font-size: .6875rem;
  color: var(--forest-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.cal-allday-cell {
  padding: .25rem .375rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .1875rem;
  min-height: 28px;
}

.cal-allday-cell:last-child { border-right: none; }
.cal-allday-cell.is-today { background: rgba(141, 198, 63, .1); }

.cal-allday-pill {
  background: var(--pale-sage);
  border-left: 3px solid var(--accent-sage);
  border-radius: 4px;
  padding: .1875rem .375rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--alpine-forest);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-allday-pill.is-other { opacity: .82; }
.cal-allday-pill.is-mine.importance-high { border-left-color: var(--danger); background: #fef3f1; }
.cal-allday-pill.is-mine.importance-normal { border-left-color: var(--warning); }
.cal-allday-pill.is-mine.importance-low { border-left-color: var(--herbal-lime); }

.cal-matrix {
  display: grid;
  position: relative;
  font-variant-numeric: tabular-nums;
}

/* Header row */
.cal-mx-corner {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--soft-sand);
}

.cal-mx-day-head {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--soft-sand);
  padding: .375rem .5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: .125rem;
  overflow: hidden;
}

.cal-mx-day-head:last-child { border-right: none; }

.cal-mx-day-head.is-today {
  background: rgba(141, 198, 63, .18);
}

.cal-mx-day-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--alpine-forest);
  line-height: 1;
}

.cal-mx-day-date {
  font-size: .6875rem;
  color: var(--forest-mid);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Time column — grid is 15-min rows internally but labels only appear on
   :00 (bold) and :30 (regular) so the UI reads as a 30-min grid. Top-half
   rows (:00 and :15) share the soft-sand hour shading. */
.cal-mx-time {
  grid-column: 1;
  border-right: 1px solid var(--border);
  padding: 0 .5rem;
  font-size: .6875rem;
  color: var(--forest-mid);
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  line-height: 1;
  padding-top: 2px;
}

.cal-mx-time.is-top-half {
  background: var(--soft-sand);
}

.cal-mx-time.is-hour {
  color: var(--alpine-forest);
  font-weight: 500;
}

/* Grid cells (background matrix). The hour is split into 4 × 15-min rows
   but we only draw boundaries at :15 (half-hour line, dashed) and :45 (hour
   line, solid) so the visible gridline density matches the old 30-min grid.
   Background shading groups :00+:15 as the soft-sand "top half" of the hour
   and :30+:45 as the white "bottom half". */
.cal-mx-cell {
  border-right: 1px solid var(--border);
}

.cal-mx-cell.is-top-half { background: rgba(242, 239, 231, .55); }
.cal-mx-cell.is-bottom-half { background: #ffffff; }
.cal-mx-cell.is-today.is-top-half { background: rgba(141, 198, 63, .14); }
.cal-mx-cell.is-today.is-bottom-half { background: rgba(141, 198, 63, .07); }
.cal-mx-cell.at-half-boundary { border-bottom: 1px dashed rgba(168, 199, 181, .5); }
.cal-mx-cell.at-hour-boundary { border-bottom: 1px solid var(--border); }
.cal-mx-cell.is-last-row { border-bottom: none; }
.cal-mx-cell { cursor: copy; transition: background .1s ease; }
.cal-mx-cell:hover { background: rgba(141, 198, 63, .12); }

/* Current-time indicator — horizontal green line across today's column. JS
   repositions it every minute so it tracks the current time without a full
   re-render. */
.cal-now-line {
  position: absolute;
  height: 2px;
  background: var(--herbal-lime);
  box-shadow: 0 0 0 1px rgba(141, 198, 63, .35);
  pointer-events: none;
  z-index: 2;
}
.cal-now-line::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--herbal-lime);
  box-shadow: 0 0 0 1px rgba(141, 198, 63, .35);
}

/* Events positioned on the matrix */
.cal-mx-event {
  margin: 1px 3px;
  padding: .25rem .375rem;
  border-radius: 4px;
  background: var(--soft-sand);
  border-left: 3px solid var(--accent-sage);
  font-size: .75rem;
  color: var(--alpine-forest);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: .0625rem;
  z-index: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  min-height: 0;
}

.cal-mx-event.is-other { opacity: .82; }
.cal-mx-event.is-mine.importance-high { border-left-color: var(--danger); background: #fef3f1; }
.cal-mx-event.is-mine.importance-normal { border-left-color: var(--warning); background: #fff8ed; }
.cal-mx-event.is-mine.importance-low { border-left-color: var(--herbal-lime); background: #f3f9e8; }

.cal-mx-event-time {
  font-size: .625rem;
  color: var(--forest-mid);
  line-height: 1.1;
}

.cal-mx-event-subject {
  font-weight: 500;
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cal-mx-event-loc {
  font-size: .625rem;
  color: var(--forest-mid);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-mx-event-tags {
  display: flex;
  gap: .1875rem;
  flex-wrap: wrap;
  margin-top: .125rem;
}

.cal-mx-focus {
  background: linear-gradient(135deg, rgba(141, 198, 63, .18), rgba(31, 77, 58, .08));
  border: 1px dashed var(--herbal-lime);
  border-left: 3px solid var(--herbal-lime);
}

.cal-mx-focus.cal-mx-lunch {
  background: linear-gradient(135deg, rgba(242, 167, 77, .18), rgba(47, 107, 79, .08));
  border-color: #f2a74d;
  border-left-color: #f2a74d;
}

.cal-mx-focus .cal-focus-block {
  margin-top: .25rem;
  align-self: flex-start;
  padding: .1875rem .5rem;
  font-size: .6875rem;
}

.cal-mx-event .cal-join-teams {
  margin-top: .25rem;
  align-self: flex-start;
  padding: .1875rem .5rem;
  font-size: .6875rem;
  text-decoration: none;
  color: #ffffff !important;
}

.cal-mx-event.is-laned .cal-join-teams { display: none; }

.cal-mx-task {
  background: linear-gradient(135deg, rgba(47, 107, 79, .18), rgba(141, 198, 63, .06));
  border: 1px dashed var(--forest-mid, #2F6B4F);
  border-left: 3px solid var(--forest-mid, #2F6B4F);
}

.cal-mx-task-actions {
  display: flex;
  gap: .25rem;
  margin-top: .25rem;
  flex-wrap: wrap;
}

.cal-mx-task .cal-task-confirm,
.cal-mx-task .cal-task-ignore {
  padding: .1875rem .5rem;
  font-size: .6875rem;
}

.cal-mx-event.is-draggable { cursor: grab; }
.cal-mx-event.is-draggable.is-dragging {
  cursor: grabbing;
  opacity: .78;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(31, 77, 58, .25);
  transition: none;
}
.cal-mx-event.is-saving { opacity: .5; pointer-events: none; }

/* Past meetings are read-only — dim them so it's clear the edit/cancel
   actions on the detail modal aren't available. */
.cal-mx-event.is-past {
  opacity: .55;
  cursor: default;
}
.cal-mx-event.is-past:hover { opacity: .65; }

/* Unconfirmed invites get a distinct dashed border so the user can spot
   meetings they still need to respond to at a glance. Clicking the event
   opens the modal with Accept / Ask for new time / Decline actions. */
.cal-mx-event.is-unconfirmed-invite {
  border: 1px dashed #a6741f;
  border-left: 3px solid #a6741f;
  background: #fff8ed;
  cursor: pointer;
}

.cal-tag-invite {
  background: #fff3db;
  color: #a6741f;
  border: 1px solid #f0c66d;
  font-weight: 500;
}

/* When multiple meetings share a slot we squeeze them into side-by-side
   lanes (see the renderer). Inside a laned event space is tight, so truncate
   long text with an ellipsis and drop the meta rows (location, tags) so the
   subject stays visible. The full details stay reachable via the modal. */
.cal-mx-event.is-laned {
  margin-left: 0;
  margin-right: 0;
  padding: .1875rem .25rem;
  gap: 0;
}
.cal-mx-event.is-laned .cal-mx-event-time,
.cal-mx-event.is-laned .cal-mx-event-loc,
.cal-mx-event.is-laned .cal-mx-event-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-mx-event.is-laned .cal-mx-event-tags {
  margin-top: 0;
  max-height: 1.25rem;
  overflow: hidden;
}

.cal-event-invite {
  border-top: 1px solid var(--pale-sage);
  padding-top: 1rem;
  margin-top: 1rem;
}
.cal-event-invite .form-group { margin-bottom: .75rem; }

.cal-tag-travel {
  background: #fff0e6;
  color: #a6471f;
  border: 1px solid #f2a74d;
  font-weight: 500;
}

/* ── Meeting detail modal ── */
.cal-event-modal {
  max-width: 540px;
  max-height: calc(100vh - 2rem);
  position: relative;
  padding-top: 2.25rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cal-event-close {
  position: absolute;
  top: .5rem;
  right: .75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--forest-mid);
  cursor: pointer;
  padding: .25rem .5rem;
  z-index: 2;
}
.cal-event-close:hover { color: var(--alpine-forest); }

/* Body + invite section scroll together so the title and action bar
   stay visible even on very short viewports. */
.cal-event-body {
  margin-bottom: 1.25rem;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.cal-event-modal .cal-event-invite {
  flex: 0 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.cal-event-modal > .bj-modal-actions {
  flex: 0 0 auto;
}

.cal-event-past-banner {
  background: #fff7e6;
  border: 1px solid #f2c06b;
  color: #7a4b00;
  border-radius: 6px;
  padding: .625rem .875rem;
  font-size: .875rem;
  margin-bottom: .75rem;
}

.cal-event-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9375rem;
  color: var(--alpine-forest);
  align-items: start;
}
.cal-event-row:last-child { border-bottom: none; }
.cal-event-label {
  color: var(--forest-mid);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding-top: .125rem;
}
.cal-event-muted { color: var(--forest-mid); font-size: .8125rem; }
.cal-event-desc {
  white-space: pre-wrap;
  line-height: 1.5;
  /* The parent .cal-event-body already scrolls, so let the description
     flow naturally — nested scrolling was confusing on tall content. */
}
.cal-event-people {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cal-event-people li {
  padding: .125rem 0;
  font-size: .875rem;
}
.cal-event-resp {
  display: inline-block;
  font-size: .6875rem;
  padding: .0625rem .375rem;
  border-radius: 3px;
  margin-left: .25rem;
  font-weight: 500;
}
.cal-event-resp-accepted { background: #e8f5ea; color: #2a7a3d; }
.cal-event-resp-tentativelyAccepted { background: #fff8ed; color: #a6741f; }
.cal-event-resp-declined { background: #fef3f1; color: #a62b1f; }
.cal-event-resp-notresponded { background: var(--pale-sage); color: var(--forest-mid); }
.cal-event-resp-organizer { background: rgba(141, 198, 63, .18); color: var(--alpine-forest); }

@media (max-width: 900px) {
  .cal-week-head { flex-direction: column; align-items: stretch; }
  .cal-week-nav { justify-content: flex-end; }
  .cal-matrix { font-size: .75rem; }
  .cal-mx-day-name { font-size: .875rem; }
  .cal-mx-event-subject { -webkit-line-clamp: 3; }
  .cal-event-row { grid-template-columns: 1fr; gap: .125rem; }
}

/* ── New-meeting modal ── */
.cal-new-modal {
  max-width: 560px;
  max-height: calc(100vh - 2rem);
  position: relative;
  padding-top: 2.25rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cal-new-modal > h3 { flex: 0 0 auto; }
.cal-new-form {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}
.cal-new-form > .bj-modal-actions {
  background: var(--card-bg);
  position: sticky;
  bottom: 0;
  padding-top: .75rem;
  margin-top: .5rem;
}
.cal-new-form .form-group { margin-bottom: 1rem; }
.cal-new-form .form-control { margin-bottom: 0; }
.cal-new-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.cal-new-toggle { display: flex; flex-direction: column; gap: .25rem; }
.cal-new-switch {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
}
.cal-new-switch input { width: 1rem; height: 1rem; }
.cal-new-switch-label { color: var(--alpine-forest); font-weight: 500; }
.cal-new-hint {
  font-size: .8125rem;
  color: var(--forest-mid);
}
.cal-new-tz {
  font-size: .75rem;
  color: var(--forest-mid);
  font-weight: 400;
  margin-left: .25rem;
}
.cal-new-tz-select {
  margin-top: .375rem;
  font-size: .8125rem;
  color: var(--forest-mid);
  padding: .375rem .5rem;
}
.cal-new-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-bottom: .375rem;
  min-height: 0;
}
.cal-new-chips:empty { display: none; }
.cal-new-chip {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .1875rem .5rem;
  border-radius: 999px;
  background: rgba(141, 198, 63, .18);
  border: 1px solid rgba(141, 198, 63, .4);
  color: var(--alpine-forest);
  font-size: .8125rem;
}
.cal-new-chip-email { color: var(--forest-mid); font-size: .75rem; }
.cal-new-chip-x {
  background: none;
  border: none;
  color: var(--forest-mid);
  cursor: pointer;
  padding: 0 0 0 .125rem;
  font-size: 1rem;
  line-height: 1;
}
.cal-new-chip-x:hover { color: var(--danger); }

.cal-new-ac { position: relative; }
.cal-new-ac-dd {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 10;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(31, 77, 58, .12);
  max-height: 220px;
  overflow-y: auto;
}
.cal-new-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .5rem .625rem;
  cursor: pointer;
  font-size: .875rem;
  color: var(--alpine-forest);
  border-bottom: 1px solid rgba(168, 199, 181, .25);
}
.cal-new-ac-item:last-child { border-bottom: none; }
.cal-new-ac-item:hover { background: rgba(141, 198, 63, .12); }
.cal-new-ac-item strong { font-weight: 500; margin-right: .375rem; }
.cal-new-ac-email { color: var(--forest-mid); font-size: .75rem; }
.cal-new-ac-item .cal-new-ac-email { margin-left: .375rem; }
.cal-new-ac-empty {
  padding: .5rem .625rem;
  color: var(--forest-mid);
  font-size: .8125rem;
  font-style: italic;
}
.cal-new-ac-badge {
  display: inline-block;
  font-size: .6875rem;
  font-weight: 500;
  padding: .0625rem .375rem;
  margin-left: .375rem;
  border-radius: 999px;
  vertical-align: middle;
}
.cal-new-ac-badge-free { background: rgba(141, 198, 63, .18); color: var(--alpine-forest); }
.cal-new-ac-badge-busy { background: rgba(190, 60, 60, .15); color: #a13333; }
.cal-new-ac-badge-tentative { background: rgba(225, 170, 60, .2); color: #8a5a15; }

@media (max-width: 560px) {
  .cal-new-row { grid-template-columns: 1fr; }
}

/* ── Dashboard heatmap ── */
.heatmap-card .card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.heatmap-tz {
  font-size: .75rem;
  color: var(--forest-mid);
  font-family: var(--font-body);
  letter-spacing: .02em;
}

.heatmap {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.heatmap-grid {
  display: grid;
  gap: 4px;
  align-items: stretch;
}

.heatmap-corner { min-width: 3rem; }

.heatmap-day-head {
  text-align: center;
  padding: .25rem 0 .375rem;
  border-bottom: 1px solid var(--border);
}

.heatmap-day-label {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--alpine-forest);
  font-weight: 400;
}

.heatmap-day-date {
  font-size: .7rem;
  color: var(--forest-mid);
  letter-spacing: .02em;
}

.heatmap-hour {
  font-size: .7rem;
  color: var(--forest-mid);
  padding-right: .5rem;
  text-align: right;
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.heatmap-cell {
  display: block;
  min-height: 22px;
  border-radius: 4px;
  background: var(--pale-sage);
  transition: transform .12s ease;
}

.heatmap-cell:hover { transform: scale(1.05); }

.heatmap-cell-0 { background: #EEF2EE; }
.heatmap-cell-1 { background: #D3E3D1; }
.heatmap-cell-2 { background: #8FBE7C; }
.heatmap-cell-3 { background: #4E8F55; }
.heatmap-cell-4 { background: var(--alpine-forest); }

/* Focus-dominated cells get a lime wash instead of green */
.heatmap-cell-focus.heatmap-cell-1 { background: #E8F3CE; }
.heatmap-cell-focus.heatmap-cell-2 { background: #C9E295; }
.heatmap-cell-focus.heatmap-cell-3 { background: var(--herbal-lime); }
.heatmap-cell-focus.heatmap-cell-4 {
  background: var(--herbal-lime);
  box-shadow: inset 0 0 0 2px var(--alpine-forest);
}

.heatmap-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .75rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}

.heatmap-summary-day {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .625rem;
  background: var(--alpine-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.heatmap-summary-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}

.heatmap-summary-title strong {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--alpine-forest);
  font-size: .95rem;
}

.heatmap-summary-sub {
  font-size: .7rem;
  color: var(--forest-mid);
}

.heatmap-summary-stats {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .125rem;
  margin: 0;
  padding: 0;
}

.heatmap-summary-stats li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .75rem;
}

.heatmap-stat-label { color: var(--forest-mid); }

.heatmap-stat-value {
  font-weight: 500;
  color: var(--alpine-forest);
  font-variant-numeric: tabular-nums;
}

.heatmap-stat-value-hot {
  color: var(--danger);
  font-weight: 500;
}

.heatmap-topics {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  min-height: 1.25rem;
}

.heatmap-topic {
  background: var(--pale-sage);
  color: var(--alpine-forest);
  border-radius: 10px;
  padding: .125rem .5rem;
  font-size: .7rem;
  line-height: 1.25;
}

.heatmap-topic em {
  color: var(--forest-mid);
  font-style: normal;
  margin-left: .125rem;
}

.heatmap-topic-empty {
  background: transparent;
  color: var(--forest-mid);
  padding-left: 0;
  font-style: italic;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .7rem;
  color: var(--forest-mid);
  flex-wrap: wrap;
}

.heatmap-legend .heatmap-cell {
  width: 14px;
  min-height: 14px;
  height: 14px;
}

.heatmap-legend-label { margin: 0 .25rem; }

.heatmap-legend-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 .5rem;
}

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

@media (max-width: 560px) {
  .heatmap-grid { gap: 3px; }
  .heatmap-hour { font-size: .6rem; padding-right: .25rem; }
  .heatmap-day-label { font-size: .85rem; }
  .heatmap-day-date { font-size: .65rem; }
  .heatmap-cell { min-height: 18px; }
  .heatmap-summary { grid-template-columns: 1fr; }
}

/* ── Top-right clock ── */
.top-clock {
  position: fixed;
  top: .75rem;
  right: 1.25rem;
  z-index: 200;
  height: var(--top-bar-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--alpine-forest);
  backdrop-filter: blur(4px);
}
.top-clock-date { font-size: .8125rem; color: var(--forest-mid); }
.top-clock-time {
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
@media (max-width: 768px) {
  .top-clock {
    top: .5rem;
    right: .5rem;
    padding: 0 .5rem;
  }
  .top-clock-date { display: none; }
  .top-clock-time { font-size: .875rem; }
}

/* ── Todos page ── */
.todo-tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.todo-tab {
  background: none;
  border: none;
  padding: .625rem 1rem;
  font-family: var(--font-body);
  font-size: .9375rem;
  color: var(--forest-mid);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  gap: .5rem;
  align-items: center;
}
.todo-tab .todo-tab-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 .375rem;
  font-size: .75rem;
  line-height: 1.25rem;
  text-align: center;
  border-radius: 999px;
  background: var(--pale-sage);
  color: var(--alpine-forest);
}
.todo-tab.active {
  color: var(--alpine-forest);
  border-bottom-color: var(--herbal-lime);
}
.todo-tab.active .todo-tab-count { background: var(--herbal-lime); color: #fff; }
.todo-tab .todo-tab-count.has-suggestions,
.todo-tab.active .todo-tab-count.has-suggestions { background: var(--warning); color: #fff; }
.todo-tab:hover { color: var(--alpine-forest); }

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .625rem;
}
.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .75rem;
  align-items: flex-start;
  padding: .875rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-sage);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.todo-item.priority-high { border-left-color: var(--danger); }
.todo-item.priority-medium { border-left-color: var(--warning); }
.todo-item.priority-low { border-left-color: var(--herbal-lime); }
.todo-item.is-overdue { background: #fef6f4; }
.todo-item.is-completed .todo-title { text-decoration: line-through; color: var(--forest-mid); }

.todo-check {
  margin-top: .25rem;
}
.todo-body { min-width: 0; }
.todo-title {
  font-weight: 500;
  color: var(--alpine-forest);
  word-break: break-word;
}
.todo-desc {
  color: var(--forest-mid);
  font-size: .875rem;
  margin-top: .25rem;
  word-break: break-word;
}
.todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
  font-size: .75rem;
  color: var(--forest-mid);
}
.todo-meta .meta-chip {
  padding: .125rem .5rem;
  background: var(--pale-sage);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.todo-meta .meta-chip.due-overdue { background: #fef2f2; color: var(--danger); }
.todo-meta .meta-chip.due-soon { background: #fffbeb; color: var(--warning); }
.todo-meta .meta-chip.src-email { background: rgba(168, 199, 181, .25); }
.todo-meta .meta-chip.src-meeting { background: rgba(141, 198, 63, .2); }

.todo-actions {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  align-items: flex-end;
}
.todo-actions .btn { padding: .375rem .625rem; font-size: .8125rem; }

.todo-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--forest-mid);
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.todo-add-modal { max-width: 520px; }
.todo-new-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1rem;
  align-items: end;
}
.todo-new-form .form-group { margin-bottom: 0; }
.todo-new-form .todo-new-title { grid-column: span 2; }
.todo-new-form .todo-new-submit { grid-column: span 2; margin-top: .25rem; }
.todo-add-modal .form-control { margin-bottom: 0; }
@media (max-width: 720px) {
  .todo-new-form { grid-template-columns: 1fr; }
  .todo-new-form .todo-new-title,
  .todo-new-form .todo-new-submit { grid-column: span 1; }
  .todo-item { grid-template-columns: auto 1fr; }
  .todo-item .todo-actions { grid-column: span 2; flex-direction: row; align-items: center; }
}

.todo-slot-picker {
  margin-top: .625rem;
  padding: .75rem;
  background: var(--pale-sage);
  border-radius: var(--radius);
}
.todo-slot-picker h4 { font-family: var(--font-body); font-size: .875rem; margin-bottom: .5rem; color: var(--alpine-forest); }
.todo-slot-list { display: flex; flex-direction: column; gap: .375rem; }
.todo-slot-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  padding: .5rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.todo-slot-option .slot-when { font-weight: 500; color: var(--alpine-forest); }
