/* =========================================================
   LilMail — hand-written design system
   No build step. Pure CSS custom properties + modern layout.
   ========================================================= */

/* ---------------------------------------------------------
   Design tokens
--------------------------------------------------------- */
:root {
  /* ---- LilMail brand palette ----
     PRIMARY  Coral  #F2674E  → logo, primary buttons, key actions
     ACCENT   Teal   #14B8A6  → links, new-mail, highlights, unread dots
     TEXT     Ink    #1F2A37 / Slate #6B7280
     SURFACES Paper  #FBF7F4 (app bg) / warm white cards / Mist #EEE6E0 borders
  */

  /* Surfaces — warm "paper" tones */
  --c-bg:          #FBF7F4;   /* Paper — app background */
  --c-surface:     #FFFDFB;   /* clean warm white cards/panes */
  --c-surface-alt: #F6F0EA;   /* subtle warm tint for hovers/strips */
  --c-surface-hover:#F1EAE3;
  --c-border:      #EEE6E0;   /* Mist — dividers / input borders */
  --c-border-soft: #F4EEE8;   /* a touch lighter */

  /* Text */
  --c-text:        #1F2A37;   /* Ink */
  --c-text-2:      #6B7280;   /* Slate */
  --c-text-3:      #9AA1AB;   /* lighter slate */
  --c-text-inv:    #ffffff;

  /* Accent — Coral (primary brand) */
  --c-accent:      #F2674E;
  --c-accent-dark: #D94E37;
  --c-accent-soft: #FCE9E4;
  --c-accent-text: #9E3520;

  /* Link / highlight — Teal */
  --c-link:        #14B8A6;
  --c-link-dark:   #0E9384;
  --c-link-soft:   #DCF5F1;
  --c-link-text:   #0B6B60;
  --c-highlight:   #14B8A6;

  /* Semantic — warm-harmonised */
  --c-danger:      #E0533A;
  --c-danger-soft: #FCEAE5;
  --c-danger-text: #9C2B16;
  --c-success:     #15A38C;
  --c-success-soft:#DEF4F0;
  --c-success-text:#0B6B5C;
  --c-warn:        #E08A2B;
  --c-warn-soft:   #FBEFDD;
  --c-warn-text:   #8A4E0F;

  /* Avatar colours (cycle by initial) — warm, harmonised set */
  --av-a: #F2674E; --av-b: #E8833C; --av-c: #D9587A;
  --av-d: #E0A52B; --av-e: #14B8A6; --av-f: #4E94C4;
  --av-g: #D9543E; --av-h: #0E9384; --av-i: #E8763C;
  --av-j: #9DA84E;

  /* Layout */
  --topbar-h: 52px;
  --sidebar-w: 220px;
  --list-w: 320px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, monospace;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.07);

  /* Transitions */
  --t-fast: 120ms ease;
  --t-base: 180ms ease;
}

/* ---------------------------------------------------------
   Dark mode
--------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    /* Warm-charcoal surfaces that keep the coral/teal identity in the dark */
    --c-bg:          #16130F;
    --c-surface:     #211D18;
    --c-surface-alt: #2A251F;
    --c-surface-hover:#332D26;
    --c-border:      #3A332B;
    --c-border-soft: #2E2820;

    --c-text:        #F4EFE9;
    --c-text-2:      #B7AFA4;
    --c-text-3:      #847C71;

    --c-accent:      #F2785F;
    --c-accent-dark: #FF8E76;
    --c-accent-soft: #3A241D;
    --c-accent-text: #FBB6A4;

    --c-link:        #2DD4BF;
    --c-link-dark:   #5EEAD9;
    --c-link-soft:   #163A36;
    --c-link-text:   #7FE6D9;
    --c-highlight:   #2DD4BF;

    --c-danger:      #F08368;
    --c-danger-soft: #3A1C15;
    --c-danger-text: #F5B3A2;
    --c-success:     #34D3BC;
    --c-success-soft:#10302B;
    --c-success-text:#86E8D8;
    --c-warn:        #ECA85B;
    --c-warn-soft:   #33240F;
    --c-warn-text:   #F3CE96;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.55);
  }
}

/* ---------------------------------------------------------
   Reset + base
--------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
/* Teal link accent for body content + generic links */
.email-content a,
.email-body--text a,
a.link, .text-link { color: var(--c-link); text-decoration: none; }
.email-content a:hover,
.email-body--text a:hover,
a.link:hover, .text-link:hover { color: var(--c-link-dark); text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ---------------------------------------------------------
   Scrollbar
--------------------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-3); }

/* ---------------------------------------------------------
   Utilities
--------------------------------------------------------- */
[x-cloak] { display: none !important; }

.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------
   Loading bar (top-of-page HTMX indicator)
--------------------------------------------------------- */
#htmx-loading-bar {
  position: fixed; top: 0; left: 0; height: 2px;
  background: var(--c-accent);
  width: 0; z-index: 9999;
  transition: width 0.3s ease;
}

/* ---------------------------------------------------------
   TOP BAR
--------------------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  padding: 0 12px; gap: 8px;
  box-shadow: var(--shadow-sm);
}

.topbar__hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.topbar__hamburger:hover { background: var(--c-surface-alt); }
@media (max-width: 1023px) {
  .topbar__hamburger { display: flex; }
}

.topbar__logo {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; margin-right: 4px;
  text-decoration: none;
}
.topbar__logo-mark {
  width: 30px; height: 30px;
  background: var(--c-accent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar__logo-mark svg { color: white; width: 16px; height: 16px; }
.topbar__logo-name {
  font-size: 15px; font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.02em;
}
@media (max-width: 480px) { .topbar__logo-name { display: none; } }

.topbar__search {
  flex: 1; max-width: 480px; margin: 0 auto;
  position: relative;
}
.topbar__search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-3); pointer-events: none;
  width: 15px; height: 15px;
}
.topbar__search-input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  background: var(--c-surface-alt);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.topbar__search-input:focus {
  background: var(--c-surface);
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 15%, transparent);
}

.topbar__account {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto;
}
.topbar__username {
  font-size: 12px; color: var(--c-text-2);
  max-width: 140px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
@media (max-width: 640px) { .topbar__username { display: none; } }

.topbar__logout {
  font-size: 12px; font-weight: 500;
  color: var(--c-danger);
  padding: 5px 12px;
  border-radius: var(--r-full);
  transition: background var(--t-fast);
  white-space: nowrap;
}
.topbar__logout:hover { background: var(--c-danger-soft); }

.topbar__settings {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar__settings:hover { background: var(--c-surface-alt); color: var(--c-text); }

/* ---------------------------------------------------------
   MAIN LAYOUT WRAPPER
--------------------------------------------------------- */
.app-body {
  padding-top: var(--topbar-h);
}

.app-shell {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ---------------------------------------------------------
   LEFT SIDEBAR
--------------------------------------------------------- */
.sidebar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow: hidden;
}

/* Mobile: off-canvas */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease, box-shadow 200ms ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
}

.sidebar__compose {
  padding: 12px;
  flex-shrink: 0;
}

.btn-compose {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 9px 16px;
  background: var(--c-accent);
  color: white;
  font-size: 13px; font-weight: 600;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast), transform var(--t-fast);
  letter-spacing: 0.01em;
}
.btn-compose:hover { background: var(--c-accent-dark); transform: translateY(-1px); }
.btn-compose:active { transform: translateY(0); }
.btn-compose svg { width: 14px; height: 14px; flex-shrink: 0; }

.sidebar__nav {
  flex: 1; overflow-y: auto;
  padding: 4px 8px 16px;
  display: flex; flex-direction: column; gap: 1px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
  cursor: pointer;
}
.nav-item:hover { background: var(--c-surface-alt); color: var(--c-text); }
.nav-item.is-active {
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-item.is-active svg { opacity: 1; }
.nav-item__label { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-item__badge {
  font-size: 11px; font-weight: 700;
  background: var(--c-highlight);
  color: white;
  border-radius: var(--r-full);
  padding: 1px 6px;
  min-width: 20px; text-align: center;
  line-height: 16px;
}
.nav-item__badge--muted {
  background: var(--c-border);
  color: var(--c-text-2);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; top: var(--topbar-h);
  z-index: 40; background: rgba(0,0,0,.35);
}
@media (max-width: 1023px) {
  .sidebar-backdrop { display: block; }
}

/* ---------------------------------------------------------
   EMAIL LIST COLUMN
--------------------------------------------------------- */
.list-col {
  flex-shrink: 0;
  display: flex; flex-direction: column;
  width: var(--list-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow: hidden;
}
/* On mobile: takes full width when viewer is hidden */
@media (max-width: 1023px) {
  .list-col { width: 100%; }
  .list-col.viewer-open { display: none; }
}

.list-toolbar {
  display: flex; align-items: center;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--c-border-soft);
  flex-shrink: 0; gap: 8px;
}
.list-toolbar__title {
  font-size: 13px; font-weight: 600;
  color: var(--c-text); flex: 1;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* Spinner */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: flex; align-items: center; }
.htmx-indicator-inner {
  width: 14px; height: 14px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.list-scroll {
  flex: 1; overflow-y: auto;
}

/* ---------------------------------------------------------
   EMAIL ROW
--------------------------------------------------------- */
.email-row {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px 11px 18px;
  border-bottom: 1px solid var(--c-border-soft);
  cursor: pointer;
  transition: background var(--t-fast);
  text-decoration: none;
  color: inherit;
}
.email-row:hover { background: var(--c-surface-alt); }
.email-row.is-selected { background: var(--c-accent-soft); }

.email-row__unread-dot {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--c-highlight);
  flex-shrink: 0;
}

.avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; user-select: none;
  letter-spacing: 0.02em;
  margin-top: 1px;
}
.avatar--sm {
  width: 26px; height: 26px;
  font-size: 10px;
}

.email-row__body { flex: 1; min-width: 0; }

.email-row__top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; margin-bottom: 2px;
}
.email-row__from {
  font-size: 13px; font-weight: 500; color: var(--c-text);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  flex: 1;
}
.email-row.is-unread .email-row__from { font-weight: 700; }

.email-row__meta {
  display: flex; align-items: center; gap: 5px; flex-shrink: 0;
}
.email-row__count {
  font-size: 11px; font-weight: 700;
  background: var(--c-border);
  color: var(--c-text-2);
  border-radius: var(--r-full);
  padding: 1px 5px;
  min-width: 18px; text-align: center;
}
.email-row__date {
  font-size: 11px; color: var(--c-text-3); white-space: nowrap;
}
.email-row.is-unread .email-row__date { color: var(--c-link-text); font-weight: 600; }

.email-row__subject {
  font-size: 12px; color: var(--c-text-2);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.email-row.is-unread .email-row__subject { font-weight: 600; color: var(--c-text); }

.email-row__preview {
  font-size: 12px; color: var(--c-text-3);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.email-row__attach {
  flex-shrink: 0; margin-top: 2px;
  color: var(--c-text-3);
}
.email-row__attach svg { width: 13px; height: 13px; }
.email-row:hover .email-row__attach { color: var(--c-text-2); }

.email-row__chevron {
  flex-shrink: 0; margin-top: 3px; color: var(--c-text-3);
  transition: transform var(--t-fast);
}
.email-row__chevron svg { width: 12px; height: 12px; }
.email-row__chevron.is-open { transform: rotate(180deg); }

/* Thread expanded messages */
.thread-messages {
  background: var(--c-surface-alt);
  border-top: 1px solid var(--c-border-soft);
}
.thread-msg {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 14px 9px 44px;
  border-bottom: 1px solid var(--c-border-soft);
  cursor: pointer;
  transition: background var(--t-fast);
}
.thread-msg:last-child { border-bottom: none; }
.thread-msg:hover { background: var(--c-surface); }

.thread-msg__body { flex: 1; min-width: 0; }
.thread-msg__top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px;
}
.thread-msg__from {
  font-size: 12px; font-weight: 500; color: var(--c-text);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.thread-msg__date { font-size: 11px; color: var(--c-text-3); flex-shrink: 0; }
.thread-msg__preview {
  font-size: 11px; color: var(--c-text-3);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 260px; gap: 8px; text-align: center; padding: 24px;
  color: var(--c-text-3);
}
.empty-state svg { width: 44px; height: 44px; opacity: 0.35; }
.empty-state__title { font-size: 13px; font-weight: 500; color: var(--c-text-2); }
.empty-state__sub { font-size: 12px; color: var(--c-text-3); }

/* ---------------------------------------------------------
   EMAIL VIEWER (reading pane)
--------------------------------------------------------- */
.viewer-col {
  flex: 1; display: flex; flex-direction: column;
  background: var(--c-surface);
  overflow: hidden; min-width: 0;
}
@media (max-width: 1023px) {
  .viewer-col { display: none; }
}

.viewer-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 10px;
  color: var(--c-text-3); user-select: none;
}
.viewer-placeholder svg { width: 56px; height: 56px; opacity: 0.25; }
.viewer-placeholder p { font-size: 13px; color: var(--c-text-3); }

/* Mobile viewer overlay */
.viewer-mobile {
  display: none;
  position: fixed; inset: 0; top: var(--topbar-h);
  background: var(--c-surface);
  z-index: 40; flex-direction: column;
}
@media (max-width: 1023px) {
  .viewer-mobile.is-open { display: flex; }
}
.viewer-mobile__bar {
  display: flex; align-items: center;
  height: 44px; padding: 0 12px;
  border-bottom: 1px solid var(--c-border); gap: 8px; flex-shrink: 0;
}
.viewer-mobile__back {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast);
}
.viewer-mobile__back:hover { background: var(--c-surface-alt); }
.viewer-mobile__back svg { width: 18px; height: 18px; }
.viewer-mobile__label { font-size: 13px; font-weight: 500; color: var(--c-text-2); }

/* Email viewer content */
/* min-height (not height) lets the whole reading pane scroll as one document
   so the HTML-mail iframe can grow to its natural content height. */
.email-view { min-height: 100%; display: flex; flex-direction: column; background: var(--c-surface); }

.email-view__header {
  border-bottom: 1px solid var(--c-border);
  padding: 16px 20px 12px;
  flex-shrink: 0;
  /* Keep the subject + action toolbar in view while scrolling a long message. */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--c-surface);
}

.email-view__subject {
  font-size: 17px; font-weight: 700;
  color: var(--c-text);
  line-height: 1.3; margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.email-view__close-btn {
  display: none; flex-shrink: 0;
  padding: 6px;
  border-radius: var(--r-full);
  color: var(--c-text-2);
  transition: background var(--t-fast);
  margin-right: -4px;
}
.email-view__close-btn:hover { background: var(--c-surface-alt); }
.email-view__close-btn svg { width: 18px; height: 18px; }
@media (max-width: 1023px) { .email-view__close-btn { display: flex; } }

.email-view__subject-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}

.email-view__sender-row {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px;
}
.email-view__sender-info { flex: 1; min-width: 0; }
.email-view__sender-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-bottom: 2px;
}
.email-view__from {
  font-size: 13px; font-weight: 600; color: var(--c-text);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.email-view__from-addr {
  font-size: 11px; color: var(--c-text-3); margin-left: 4px;
}
.email-view__date {
  font-size: 11px; color: var(--c-text-3); white-space: nowrap;
}
.email-view__to {
  font-size: 12px; color: var(--c-text-2);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.email-view__to em { color: var(--c-text); font-style: normal; }

/* Action bar */
.action-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.btn-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn-action:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
  border-color: var(--c-text-3);
}
.btn-action svg { width: 13px; height: 13px; }

.btn-action--danger { color: var(--c-danger); }
.btn-action--danger:hover { background: var(--c-danger-soft); border-color: var(--c-danger); }

/* More dropdown */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; left: 0; top: calc(100% + 4px);
  min-width: 160px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 20; overflow: hidden;
}
.dropdown__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  font-size: 12px; color: var(--c-text-2);
  text-align: left;
  transition: background var(--t-fast);
}
.dropdown__item:hover { background: var(--c-surface-alt); color: var(--c-text); }
.dropdown__item--danger { color: var(--c-danger); }
.dropdown__item--danger:hover { background: var(--c-danger-soft); }
.dropdown__item svg { width: 13px; height: 13px; }

/* Calendar invite banner */
.cal-banner {
  padding: 12px 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--c-accent) 20%, transparent);
  background: var(--c-accent-soft);
  flex-shrink: 0;
}
.cal-banner__inner { display: flex; align-items: flex-start; gap: 10px; }
.cal-banner__icon {
  flex-shrink: 0; width: 34px; height: 34px;
  background: color-mix(in srgb, var(--c-accent) 15%, transparent);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}
.cal-banner__icon svg { width: 17px; height: 17px; color: var(--c-accent); }
.cal-banner__content { flex: 1; }
.cal-banner__title { font-size: 13px; font-weight: 600; color: var(--c-accent-text); margin-bottom: 2px; }
.cal-banner__sub { font-size: 11px; color: var(--c-accent-text); opacity: 0.75; margin-bottom: 8px; }
.cal-banner__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-banner__dl {
  flex-shrink: 0; align-self: flex-start;
}

/* RSVP buttons */
.btn-rsvp {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: var(--r-sm);
  transition: filter var(--t-fast);
}
.btn-rsvp:hover { filter: brightness(0.92); }
.btn-rsvp--accept { background: var(--c-success); color: white; }
.btn-rsvp--tentative { background: var(--c-warn); color: white; }
.btn-rsvp--decline {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text-2);
}
.btn-rsvp svg { width: 12px; height: 12px; }
.btn-rsvp-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 500;
  border: 1px solid color-mix(in srgb, var(--c-accent) 35%, transparent);
  border-radius: var(--r-sm);
  color: var(--c-accent-text);
  transition: background var(--t-fast);
}
.btn-rsvp-link:hover { background: color-mix(in srgb, var(--c-accent) 10%, transparent); }
.btn-rsvp-link svg { width: 12px; height: 12px; }

/* Attachments strip */
.attach-strip {
  padding: 10px 20px;
  border-bottom: 1px solid var(--c-border-soft);
  background: var(--c-surface-alt);
  display: flex; flex-wrap: wrap; gap: 6px;
  flex-shrink: 0;
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 500;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast), border-color var(--t-fast);
  text-decoration: none; max-width: 200px;
}
.attach-chip:hover { background: var(--c-surface-alt); border-color: var(--c-text-3); color: var(--c-text); }
.attach-chip svg { width: 12px; height: 12px; flex-shrink: 0; }
.attach-chip__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attach-chip__size { color: var(--c-text-3); flex-shrink: 0; }

/* Email body — flows naturally; the reading pane (#email-viewer-pane) scrolls. */
.email-body { padding: 0; }
/* The HTML-mail iframe auto-sizes to its content height via JS; min-height
   avoids a 0px flash before the load handler runs. */
.email-iframe {
  display: block;
  width: 100%;
  min-height: 220px;
  border: none;
  background: #ffffff;
}
@media (prefers-color-scheme: dark) {
  .email-iframe { background: var(--c-surface); }
}
.email-body--text {
  padding: 20px 24px;
  font-size: 14px; color: var(--c-text);
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.65;
}

/* Remote-image privacy banner (Gmail-style) */
.remote-img-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 20px 0;
  padding: 9px 14px;
  background: var(--c-warn-soft);
  border: 1px solid var(--c-warn);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--c-warn-text);
}
.remote-img-banner svg { width: 16px; height: 16px; flex-shrink: 0; }
.remote-img-banner__text { flex: 1; min-width: 0; }
.remote-img-banner__btn {
  flex-shrink: 0;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--r-sm);
  background: var(--c-warn);
  color: #fff;
  transition: filter var(--t-fast);
}
.remote-img-banner__btn:hover { filter: brightness(0.94); }
.email-content img { max-width: 100%; height: auto; }
.email-content blockquote {
  border-left: 3px solid var(--c-border);
  padding-left: 14px; margin: 12px 0;
  color: var(--c-text-2); font-style: italic;
}

/* ---------------------------------------------------------
   COMPOSE MODAL
--------------------------------------------------------- */
.compose-wrap {
  position: fixed; z-index: 50;
}
/* Desktop: bottom-right docked */
@media (min-width: 1024px) {
  .compose-wrap { bottom: 0; right: 16px; width: 380px; }
}
/* Mobile: full screen */
@media (max-width: 1023px) {
  .compose-wrap.compose-fullscreen { inset: 0; top: var(--topbar-h); }
  .compose-wrap.compose-minimized { bottom: 0; right: 16px; width: 100%; max-width: 380px; }
}

.compose-card {
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--c-border); border-bottom: none;
  overflow: hidden;
}
@media (min-width: 1024px) {
  .compose-card:not(.compose-minimized) { height: auto; }
}
@media (max-width: 1023px) {
  .compose-card:not(.compose-minimized) { height: 100%; }
}

.compose-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--c-text);
  cursor: pointer; user-select: none; flex-shrink: 0;
}
.compose-header__title {
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.9);
}
.compose-header__actions { display: flex; align-items: center; gap: 2px; }
.compose-header__btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.6);
  transition: background var(--t-fast), color var(--t-fast);
}
.compose-header__btn:hover { background: rgba(255,255,255,.1); color: white; }
.compose-header__btn svg { width: 14px; height: 14px; }

.compose-field {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--c-border-soft);
  padding: 0 14px;
}
.compose-field__label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-3); width: 40px; flex-shrink: 0;
  padding: 10px 0;
}
.compose-field__input {
  flex: 1; padding: 10px 0;
  font-size: 13px; background: none;
  border: none; outline: none;
  color: var(--c-text);
}
.compose-field__input::placeholder { color: var(--c-text-3); }
.compose-field__input:disabled { opacity: 0.55; }

.compose-body {
  padding: 12px 14px;
  font-size: 13px; background: none;
  border: none; outline: none; resize: none;
  color: var(--c-text); width: 100%; flex: 1;
  min-height: 200px;
  line-height: 1.6;
}
@media (max-width: 1023px) {
  .compose-body { min-height: 0; }
}
.compose-body::placeholder { color: var(--c-text-3); }
.compose-body:disabled { opacity: 0.55; }

.compose-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--c-border-soft);
  flex-shrink: 0;
}
.btn-send {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px;
  font-size: 13px; font-weight: 600;
  background: var(--c-accent); color: white;
  border-radius: var(--r-full);
  transition: background var(--t-fast), opacity var(--t-fast);
}
.btn-send:hover { background: var(--c-accent-dark); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-send svg { width: 14px; height: 14px; }
.btn-discard {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  color: var(--c-text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-discard:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.btn-discard svg { width: 15px; height: 15px; }

/* Compose backdrop (mobile) */
.compose-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 49;
}
@media (min-width: 1024px) { .compose-backdrop { display: none; } }

/* ---------------------------------------------------------
   TOAST NOTIFICATIONS
--------------------------------------------------------- */
.toast-stack {
  position: fixed; bottom: 16px; right: 16px;
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 340px; width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.toast--success { border-left: 3px solid var(--c-success); }
.toast--error   { border-left: 3px solid var(--c-danger); }
.toast--info    { border-left: 3px solid var(--c-accent); }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast__icon svg { width: 16px; height: 16px; }
.toast--success .toast__icon { color: var(--c-success); }
.toast--error   .toast__icon { color: var(--c-danger); }
.toast--info    .toast__icon { color: var(--c-accent); }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-size: 13px; font-weight: 600; color: var(--c-text); }
.toast__message { font-size: 12px; color: var(--c-text-2); margin-top: 1px; }
.toast__close {
  flex-shrink: 0; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-3); border-radius: 4px;
  transition: background var(--t-fast);
}
.toast__close:hover { background: var(--c-surface-alt); color: var(--c-text-2); }
.toast__close svg { width: 12px; height: 12px; }

/* ---------------------------------------------------------
   LOGIN PAGE
--------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px;
  background: var(--c-bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  display: flex; align-items: center; gap: 10px;
  justify-content: center; margin-bottom: 28px;
}
.login-logo-mark {
  width: 36px; height: 36px;
  background: var(--c-accent);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.login-logo-mark svg { width: 18px; height: 18px; color: white; }
.login-logo-name {
  font-size: 20px; font-weight: 700;
  color: var(--c-text); letter-spacing: -0.03em;
}
.login-tagline {
  font-size: 12px; color: var(--c-text-3);
  text-align: center; margin-top: -20px; margin-bottom: 20px;
}

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--c-text-2); margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.form-input {
  width: 100%; padding: 9px 12px;
  font-size: 13px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 15%, transparent);
}
.form-input::placeholder { color: var(--c-text-3); }

.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--c-text-2); cursor: pointer;
}
.form-check input { accent-color: var(--c-accent); width: 14px; height: 14px; cursor: pointer; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px;
  font-size: 13px; font-weight: 700;
  background: var(--c-accent); color: white;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), opacity var(--t-fast);
  letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--c-accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0; color: var(--c-text-3); font-size: 11px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--c-border);
}

.btn-secondary {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 9px;
  font-size: 13px; font-weight: 500;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-secondary:hover { background: var(--c-surface-alt); border-color: var(--c-text-3); }

.form-hint {
  font-size: 11px; color: var(--c-text-3);
  text-align: center; margin-top: 14px;
}

.alert {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 12px; margin-bottom: 14px;
}
.alert--error { background: var(--c-danger-soft); color: var(--c-danger-text); border: 1px solid color-mix(in srgb, var(--c-danger) 20%, transparent); }
.alert--success { background: var(--c-success-soft); color: var(--c-success-text); border: 1px solid color-mix(in srgb, var(--c-success) 20%, transparent); }
.alert svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.spinner-ring {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------------------------------------------------------
   CALENDAR
--------------------------------------------------------- */
.cal-shell {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.cal-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface); flex-shrink: 0;
}
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav__btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-full);
  color: var(--c-text-2);
  transition: background var(--t-fast);
  text-decoration: none;
}
.cal-nav__btn:hover { background: var(--c-surface-alt); }
.cal-nav__btn svg { width: 18px; height: 18px; }
.cal-nav__title { font-size: 15px; font-weight: 700; color: var(--c-text); min-width: 160px; text-align: center; letter-spacing: -0.02em; }
.cal-actions { display: flex; gap: 6px; }
.cal-action-btn {
  font-size: 11px; font-weight: 600; padding: 5px 12px;
  border: 1px solid var(--c-border); border-radius: var(--r-full);
  color: var(--c-text-2); text-decoration: none;
  transition: background var(--t-fast);
}
.cal-action-btn:hover { background: var(--c-surface-alt); }

.cal-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center;
  border-bottom: 1px solid var(--c-border-soft);
  background: var(--c-surface); flex-shrink: 0;
}
.cal-header__day {
  padding: 7px 0;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--c-text-3);
}
.cal-header__day--weekend { color: color-mix(in srgb, var(--c-accent) 60%, var(--c-text-3)); }

.cal-grid {
  flex: 1; overflow-y: auto; background: var(--c-bg);
}
.cal-grid-inner {
  display: grid; grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, minmax(100px, 1fr));
  min-height: 100%;
  border-left: 1px solid var(--c-border-soft);
  border-top: 1px solid var(--c-border-soft);
}
.cal-cell {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border-soft);
  border-bottom: 1px solid var(--c-border-soft);
  padding: 6px 4px;
  display: flex; flex-direction: column;
}
.cal-cell--other-month { opacity: 0.38; }
.cal-cell__day-num {
  display: flex; align-items: center; margin-bottom: 2px;
}
.cal-cell__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  font-size: 11px; font-weight: 500;
  color: var(--c-text-2);
  border-radius: 50%;
}
.cal-cell__num--today {
  background: var(--c-accent); color: white; font-weight: 700;
}
.cal-event-chip {
  display: block;
  font-size: 10px; font-weight: 500;
  padding: 2px 5px; margin-bottom: 2px;
  border-radius: 4px;
  background: var(--c-accent-soft); color: var(--c-accent-text);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast);
  line-height: 1.4;
}
.cal-event-chip:hover { background: color-mix(in srgb, var(--c-accent) 25%, transparent); }

/* Week grid */
.week-grid { flex: 1; overflow-y: auto; }
.week-grid-inner {
  display: grid; grid-template-columns: repeat(7, 1fr);
  min-height: 600px; height: 100%;
  border-left: 1px solid var(--c-border-soft);
}
.week-col {
  border-right: 1px solid var(--c-border-soft);
  padding: 8px 4px;
  display: flex; flex-direction: column; gap: 3px;
  min-height: 600px;
}
.week-col--today { background: color-mix(in srgb, var(--c-accent) 4%, transparent); }
.week-col-header {
  padding: 8px 4px;
  border-bottom: 1px solid var(--c-border-soft);
  text-align: center; background: var(--c-surface); flex-shrink: 0;
}
.week-col-header__day { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-text-3); }
.week-col-header__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; font-size: 13px; font-weight: 600;
  color: var(--c-text-2); border-radius: 50%;
  margin-top: 2px;
}
.week-col-header__num--today { background: var(--c-accent); color: white; }
.week-event {
  display: block;
  font-size: 11px; padding: 4px 7px;
  border-radius: var(--r-sm);
  background: var(--c-accent-soft); color: var(--c-accent-text);
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast);
}
.week-event:hover { background: color-mix(in srgb, var(--c-accent) 22%, transparent); }
.week-event__title { font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.week-event__time { font-size: 10px; opacity: 0.75; }
.week-event__loc { font-size: 10px; opacity: 0.65; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Event detail panel */
.event-panel {
  width: 0; overflow: hidden;
  border-left: 1px solid var(--c-border);
  background: var(--c-surface); flex-shrink: 0;
  transition: width 200ms ease;
}
.event-panel:not(:empty) { width: 260px; }

.event-detail { height: 100%; display: flex; flex-direction: column; }
.event-detail__header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border-soft); flex-shrink: 0;
}
.event-detail__title { font-size: 14px; font-weight: 700; color: var(--c-text); line-height: 1.3; }
.event-detail__body { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.event-detail__row { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--c-text-2); }
.event-detail__row svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; color: var(--c-text-3); }
.event-detail__row-content { flex: 1; min-width: 0; }
.event-detail__date { font-weight: 600; color: var(--c-text); }
.event-detail__time { font-size: 11px; color: var(--c-text-3); }
.event-detail__desc {
  font-size: 11px; color: var(--c-text-2);
  border-top: 1px solid var(--c-border-soft); padding-top: 10px;
  white-space: pre-wrap;
}

/* Create event modal */
.modal-card {
  position: fixed; bottom: 16px; right: 16px; z-index: 50;
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border-soft);
  background: var(--c-surface-alt); flex-shrink: 0;
}
.modal-card__title { font-size: 13px; font-weight: 700; color: var(--c-text); }
.modal-card__close {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-3); transition: background var(--t-fast);
}
.modal-card__close:hover { background: var(--c-border); }
.modal-card__close svg { width: 13px; height: 13px; }
.modal-card__body { padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.modal-card__footer { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--c-border-soft); flex-shrink: 0; }

.field-input {
  width: 100%; padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-text); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-accent) 12%, transparent);
}
.field-input::placeholder { color: var(--c-text-3); }

.field-label { font-size: 11px; font-weight: 600; color: var(--c-text-3); margin-bottom: 3px; display: block; }
.field-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--c-text-2); cursor: pointer; }
.field-check input { accent-color: var(--c-accent); }

.btn-sm-cancel {
  padding: 6px 14px; font-size: 12px; font-weight: 500;
  color: var(--c-text-2); border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.btn-sm-cancel:hover { background: var(--c-surface-alt); }
.btn-sm-primary {
  padding: 6px 14px; font-size: 12px; font-weight: 700;
  background: var(--c-accent); color: white;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.btn-sm-primary:hover { background: var(--c-accent-dark); }

/* ---------------------------------------------------------
   ERROR PAGE
--------------------------------------------------------- */
.error-page {
  min-height: 80vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.error-card { text-align: center; max-width: 480px; }
.error-icon { width: 80px; height: 80px; color: var(--c-text-3); margin: 0 auto 20px; opacity: 0.45; }
.error-icon svg { width: 100%; height: 100%; }
.error-code { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--c-text-3); margin-bottom: 6px; }
.error-title { font-size: 26px; font-weight: 800; color: var(--c-text); letter-spacing: -0.03em; margin-bottom: 8px; }
.error-message { font-size: 14px; color: var(--c-text-2); line-height: 1.5; margin-bottom: 24px; }
.error-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm); color: var(--c-text-2);
  background: var(--c-surface);
  transition: background var(--t-fast), border-color var(--t-fast);
  cursor: pointer; text-decoration: none;
}
.btn-ghost:hover { background: var(--c-surface-alt); border-color: var(--c-text-3); }
.btn-ghost svg { width: 13px; height: 13px; }

.error-details {
  margin-top: 24px; text-align: left;
}
.error-details summary {
  font-size: 12px; font-weight: 600; color: var(--c-text-2);
  cursor: pointer; user-select: none;
}
.error-details pre {
  margin-top: 10px; padding: 12px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--c-surface-alt); border: 1px solid var(--c-border);
  border-radius: var(--r-sm); overflow-x: auto;
  color: var(--c-text-2); white-space: pre; line-height: 1.5;
}

/* ---------------------------------------------------------
   GLOBAL BANNERS
--------------------------------------------------------- */
.global-banner {
  max-width: 800px; margin: 12px auto 0;
  padding: 0 16px;
}

/* ---------------------------------------------------------
   Alpine transition helpers (used in templates)
--------------------------------------------------------- */
.fade-enter { opacity: 0; }
.fade-enter-active { transition: opacity 150ms ease; }
.fade-leave-active { transition: opacity 100ms ease; }
.fade-leave-to { opacity: 0; }

.slide-up-enter { opacity: 0; transform: translateY(8px); }
.slide-up-enter-active { transition: opacity 200ms ease, transform 200ms ease; }
.slide-up-leave-active { transition: opacity 150ms ease, transform 150ms ease; }
.slide-up-leave-to { opacity: 0; transform: translateY(8px); }

/* ---------------------------------------------------------
   AUTOCOMPLETE DROPDOWN (compose To/CC/BCC)
--------------------------------------------------------- */
.ac-dropdown {
  position: absolute;
  top: calc(100% + 2px); left: 0; right: 0;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 200px; overflow-y: auto;
  list-style: none; margin: 0; padding: 4px 0;
}
.ac-item {
  display: flex; flex-direction: column;
  padding: 7px 12px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.ac-item:hover { background: var(--c-surface-hover); }
.ac-item__name { font-size: 13px; color: var(--c-text); font-weight: 500; }
.ac-item__email { font-size: 11px; color: var(--c-text-3); margin-top: 1px; }

/* ---------------------------------------------------------
   RICH TEXT TOOLBAR
--------------------------------------------------------- */
.rich-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 12px;
  border-bottom: 1px solid var(--c-border-soft);
  flex-shrink: 0; flex-wrap: wrap;
}
.rich-btn {
  padding: 3px 7px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
  min-width: 26px; text-align: center;
}
.rich-btn:hover { background: var(--c-surface-alt); color: var(--c-text); }
.rich-sep { color: var(--c-border); padding: 0 2px; }

/* Rich contenteditable area — same look as the plain textarea */
.compose-rich {
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.compose-rich:empty::before {
  content: attr(data-placeholder);
  color: var(--c-text-3);
  pointer-events: none;
}
.compose-rich:focus { outline: none; }

/* ---------------------------------------------------------
   ATTACHMENT CHIPS in compose
--------------------------------------------------------- */
.compose-attachments {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 14px 0;
  flex-shrink: 0;
}
.attach-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 11px; font-weight: 500;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  color: var(--c-text-2);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------
   DRAFT SAVE BUTTON in compose toolbar
--------------------------------------------------------- */
.btn-draft {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-draft:hover { background: var(--c-surface-alt); color: var(--c-text); }
.btn-draft:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-draft svg { flex-shrink: 0; }

/* ---------------------------------------------------------
   SETTINGS PAGE
--------------------------------------------------------- */
.settings-page {
  padding: 32px 16px;
  min-height: calc(100vh - var(--topbar-h));
}
.settings-container {
  max-width: 680px;
  margin: 0 auto;
}
.settings-title {
  font-size: 22px; font-weight: 700;
  color: var(--c-text);
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}
.settings-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 20px;
}
.settings-section__title {
  font-size: 15px; font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}
.settings-section__desc {
  font-size: 13px; color: var(--c-text-2);
  margin-bottom: 16px;
  line-height: 1.6;
}
.settings-empty {
  font-size: 13px; color: var(--c-text-3);
  font-style: italic;
  margin-bottom: 12px;
}
.settings-back {
  margin-top: 8px;
}

/* Push panel */
.push-panel__status {
  font-size: 13px; color: var(--c-text-2);
  margin-bottom: 12px;
  min-height: 20px;
}
.push-panel__unsupported {
  font-size: 13px; color: var(--c-text-3);
  margin-top: 8px;
}

/* Accounts table */
.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}
.accounts-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text-3);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.accounts-table__row td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: middle;
}
.accounts-table__row:last-child td { border-bottom: none; }
.accounts-table__actions { display: flex; gap: 6px; justify-content: flex-end; }

.account-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Add-account form */
.add-account-details { margin-top: 4px; }
.add-account-details > summary { margin-bottom: 16px; }
.add-account-form { padding: 16px; border: 1px solid var(--c-border); border-radius: var(--r-md); margin-top: 4px; }
.add-account-advanced { margin-top: 12px; font-size: 13px; }
.add-account-advanced > summary {
  color: var(--c-text-2); cursor: pointer; margin-bottom: 10px;
  font-size: 12px; font-weight: 500;
}
.form-row { margin-bottom: 12px; }
.form-label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--c-text-2); margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-accent) 15%, transparent);
}
.form-input--color { width: 48px; height: 32px; padding: 2px; cursor: pointer; }
.form-actions { margin-top: 16px; }

/* Small/danger button variants */
.btn--small { padding: 4px 10px; font-size: 12px; }
.btn--danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border: 1px solid transparent;
}
.btn--danger:hover { background: color-mix(in srgb, var(--c-danger) 22%, transparent); }

/* ---------------------------------------------------------
   Unified inbox — account badge + toolbar toggle
--------------------------------------------------------- */

/* Coloured label badge shown on each row in unified mode */
.acct-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--c-accent);
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Unified toggle link in the list toolbar */
.list-toolbar__unified {
  margin-left: auto;
  margin-right: 8px;
}
.unified-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.unified-toggle:hover {
  background: var(--c-accent-soft);
  border-color: var(--c-accent);
  color: var(--c-accent-text);
}
.unified-toggle--active {
  background: var(--c-accent);
  border-color: var(--c-accent-dark);
  color: #fff;
}
.unified-toggle--active:hover {
  background: var(--c-accent-dark);
  color: #fff;
}

/* Per-account error indicator dots in toolbar */
.list-toolbar__acct-errors {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
.acct-error-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
}

/* =========================================================
   UI/UX POLISH — 2026-06
   Improvements: logo sizing, focus rings, empty states,
   loading skeletons, hover states, topbar refinements,
   email row polish, viewer improvements, responsive tweaks,
   dark-mode contrast boosts, micro-animations.
   ========================================================= */

/* ---------------------------------------------------------
   Logo — topbar + login
--------------------------------------------------------- */
.topbar__logo { gap: 7px; }
.topbar__logo-img {
  height: 26px;
  width: 26px;
  display: block;
  flex-shrink: 0;
}
.topbar__logo-word {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--c-text);
}
@media (max-width: 480px) {
  .topbar__logo-img { height: 24px; width: 24px; }
  .topbar__logo-word { font-size: 15px; }
}

.login-logo { gap: 12px; }
.login-logo-img {
  height: 44px;
  width: 44px;
  display: block;
}
.login-logo-word {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--c-text);
}

/* Legacy class kept — hide old box-mark if present */
.topbar__logo-mark { display: none; }
.topbar__logo-name { display: none; }
.login-logo-mark  { display: none; }
.login-logo-name  { display: none; }

/* ---------------------------------------------------------
   Focus rings — keyboard-accessible, no outline:none traps
--------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}
/* Remove browser default only when :focus-visible is supported */
:focus:not(:focus-visible) { outline: none; }

/* Buttons that already have their own active-look */
.btn-compose:focus-visible,
.btn-send:focus-visible,
.btn-primary:focus-visible {
  outline-offset: 3px;
}

/* Nav items */
.nav-item:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: -2px;
}

/* ---------------------------------------------------------
   Topbar refinements
--------------------------------------------------------- */
.topbar {
  /* Subtle warm tint to match the logo paper palette */
  background: var(--c-surface);
  border-bottom-color: var(--c-border);
}

/* Search bar: slightly wider on large screens */
.topbar__search { max-width: 540px; }

/* Settings icon: slightly larger hit area */
.topbar__settings {
  width: 34px;
  height: 34px;
}

/* ---------------------------------------------------------
   Sidebar enhancements
--------------------------------------------------------- */
.sidebar {
  /* Thin accent line on active-folder side */
  border-right: 1px solid var(--c-border);
}

.nav-item {
  /* Tighter letter spacing for folder names */
  letter-spacing: -0.01em;
}

.nav-item.is-active {
  /* Slightly stronger left indicator */
  box-shadow: inset 3px 0 0 var(--c-accent);
}

/* Compose button — pill style, slight gradient lift */
.btn-compose {
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent-dark) 100%);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--c-accent) 35%, transparent);
}
.btn-compose:hover {
  background: linear-gradient(135deg, var(--c-accent-dark) 0%, var(--c-accent-text) 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--c-accent) 40%, transparent);
}

/* ---------------------------------------------------------
   Email list — improved row polish
--------------------------------------------------------- */

/* Selected email row: accent left bar */
.email-row.is-selected {
  background: var(--c-accent-soft);
  box-shadow: inset 3px 0 0 var(--c-accent);
}

/* Unread dot — teal "new mail" accent, slightly bigger */
.email-row__unread-dot {
  width: 6px;
  height: 6px;
  background: var(--c-highlight);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-highlight) 20%, transparent);
}

/* Row hover — smooth lift illusion */
.email-row { transition: background var(--t-fast), box-shadow var(--t-fast); }
.email-row:hover { background: var(--c-surface-alt); }

/* Avatar — richer colors based on first letter, cycled */
.avatar { font-weight: 700; }

/* Subject line: slightly darker when unread */
.email-row.is-unread .email-row__subject {
  color: var(--c-text);
  font-weight: 600;
}

/* Preview fade: use a subtle gradient instead of hard ellipsis on wide screens */
@media (min-width: 1200px) {
  .email-row__preview {
    position: relative;
    overflow: hidden;
  }
}

/* ---------------------------------------------------------
   Empty states — richer, friendlier
--------------------------------------------------------- */
.empty-state {
  height: 320px;
  gap: 12px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--c-accent) 3%, transparent));
  border-radius: var(--r-md);
  margin: 12px;
}
.empty-state svg { width: 52px; height: 52px; opacity: 0.2; }
.empty-state__title { font-size: 14px; font-weight: 600; color: var(--c-text-2); }
.empty-state__sub { font-size: 13px; color: var(--c-text-3); max-width: 200px; line-height: 1.5; }

/* Viewer placeholder */
.viewer-placeholder {
  gap: 14px;
}
.viewer-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.15;
  color: var(--c-accent);
}
.viewer-placeholder p {
  font-size: 14px;
  color: var(--c-text-3);
  font-weight: 500;
}

/* ---------------------------------------------------------
   HTMX loading indicator — smoother animation
--------------------------------------------------------- */
#htmx-loading-bar {
  height: 2.5px;
  background: linear-gradient(90deg, var(--c-accent), var(--c-link));
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 2px 2px 0;
}

/* List spinner — use accent colour */
.htmx-indicator-inner {
  border-color: var(--c-border);
  border-top-color: var(--c-accent);
  width: 16px;
  height: 16px;
}

/* HTMX loading — dim the list while refreshing */
.htmx-request #email-list-inner {
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

/* ---------------------------------------------------------
   Skeleton loading rows (shown while HTMX loads)
   Usage: add class .skeleton to a placeholder div
--------------------------------------------------------- */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--c-surface-alt) 25%,
    var(--c-border-soft) 50%,
    var(--c-surface-alt) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------
   Email viewer — reading pane improvements
--------------------------------------------------------- */
.email-view__header {
  background: var(--c-surface);
  /* Slightly more generous padding */
  padding: 18px 24px 14px;
}

.email-view__subject {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

/* Sender avatar in viewer — slightly larger */
.email-view .avatar {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

/* Action bar buttons — slightly taller hit area */
.btn-action {
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  gap: 6px;
}
.btn-action:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Reply/Forward: accent-tinted hover */
.btn-action:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
  border-color: var(--c-border);
}

/* Email body: comfortable reading width on very wide screens */
.email-body--text {
  max-width: 72ch;
  padding: 24px 28px;
  font-size: 14px;
  line-height: 1.7;
}

/* Blockquote styling in HTML mail body */
.email-content blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 16px;
  margin: 14px 0;
  color: var(--c-text-2);
  font-style: normal;
  opacity: 0.8;
}

/* ---------------------------------------------------------
   Compose modal improvements
--------------------------------------------------------- */
.compose-header {
  /* Richer header using a warm ink → coral gradient instead of flat */
  background: linear-gradient(135deg, var(--c-text) 0%, var(--c-accent-dark) 140%);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* Compose field labels — slightly wider for alignment */
.compose-field__label { width: 46px; }

/* Compose body: minimum height on desktop */
@media (min-width: 1024px) {
  .compose-body { min-height: 240px; }
}

/* Drag-over state for compose file attachment */
.compose-card.drag-over {
  border: 2px dashed var(--c-accent);
  background: var(--c-accent-soft);
}

/* ---------------------------------------------------------
   Toast notifications — small position tweak for mobile
--------------------------------------------------------- */
@media (max-width: 640px) {
  .toast-stack {
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
  }
}

/* Toast enter animation */
.toast {
  animation: toastIn 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}

/* ---------------------------------------------------------
   Login page improvements
--------------------------------------------------------- */
.login-page {
  /* Warm gradient background */
  background: radial-gradient(
    ellipse at 50% 30%,
    color-mix(in srgb, var(--c-accent) 7%, var(--c-bg)),
    var(--c-bg) 70%
  );
}

.login-card {
  border-radius: var(--r-lg);
  box-shadow:
    var(--shadow-md),
    0 0 0 1px color-mix(in srgb, var(--c-accent) 8%, transparent);
}

.login-logo {
  /* Extra breathing room */
  margin-bottom: 32px;
}

/* ---------------------------------------------------------
   Settings page improvements
--------------------------------------------------------- */
.settings-section {
  border-radius: var(--r-lg);
  transition: box-shadow var(--t-base);
}
.settings-section:hover {
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------
   Dark mode contrast boosts
--------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  /* Slightly warmer topbar in dark */
  .topbar {
    background: #18181e;
    border-bottom-color: #2a2a35;
  }

  /* Compose header — warm charcoal → coral in dark mode */
  .compose-header {
    background: linear-gradient(135deg, #1A1510 0%, var(--c-accent-dark) 160%);
  }

  /* Login background */
  .login-page {
    background: radial-gradient(
      ellipse at 50% 30%,
      color-mix(in srgb, var(--c-accent) 10%, #0f0f11),
      #0f0f11 70%
    );
  }

  /* Email rows — unread dot slightly brighter */
  .email-row__unread-dot {
    background: var(--c-highlight);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-highlight) 25%, transparent);
  }

  /* Empty state gradient in dark */
  .empty-state {
    background: linear-gradient(
      180deg,
      transparent,
      color-mix(in srgb, var(--c-accent) 5%, transparent)
    );
  }

  /* Active nav item — brighter in dark */
  .nav-item.is-active {
    background: color-mix(in srgb, var(--c-accent) 18%, transparent);
    color: var(--c-accent-text);
  }

  /* Card hover in dark settings */
  .settings-section:hover {
    box-shadow: 0 0 0 1px var(--c-accent-soft);
  }
}

/* ---------------------------------------------------------
   Responsive improvements
--------------------------------------------------------- */

/* Compact list view on medium screens */
@media (min-width: 768px) and (max-width: 1200px) {
  :root { --list-w: 280px; }
}

/* Larger sidebar on wide screens */
@media (min-width: 1400px) {
  :root { --sidebar-w: 240px; }
}

/* Email row: tighter padding on small screens */
@media (max-width: 480px) {
  .email-row { padding: 10px 12px 10px 16px; gap: 8px; }
  .avatar { width: 30px; height: 30px; font-size: 11px; }
}

/* Viewer col hidden on tablet — full list view */
@media (max-width: 1023px) {
  .list-col { width: 100%; max-width: 100%; }
}

/* ---------------------------------------------------------
   Micro-interactions: selection & active states
--------------------------------------------------------- */
.email-row:active { background: var(--c-accent-soft); }
.nav-item:active { opacity: 0.75; }
.btn-action:active { transform: scale(0.97); }

/* Thread expand animation */
.thread-messages {
  transition: opacity var(--t-base), transform var(--t-base);
}

/* ---------------------------------------------------------
   Accessibility: high-contrast mode support
--------------------------------------------------------- */
@media (forced-colors: active) {
  .btn-compose,
  .btn-send,
  .btn-primary { forced-color-adjust: none; }
  .email-row__unread-dot { forced-color-adjust: none; }
}

/* =========================================================
   THUNDERBIRD-CLASS DESKTOP MAIL — 3-pane layout, resizable
   reading pane (right/bottom/off), density, multi-select,
   bulk action bar, list controls, expanded reading toolbar.
   ========================================================= */

/* ---- Pane container: holds list + resizer + reading pane ---- */
.mail-panes {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-width: 0;
  /* live width set by the resizer; falls back to the token */
  --list-w-live: var(--list-w);
  --list-h: 45%;
}

/* RIGHT layout (default): list | resizer | viewer side-by-side */
.mail-panes.pane-right { flex-direction: row; }
.mail-panes.pane-right .list-col {
  width: var(--list-w-live);
}
.mail-panes.pane-right .viewer-col { flex: 1; min-width: 0; }

/* BOTTOM layout: list on top, viewer below */
.mail-panes.pane-bottom { flex-direction: column; }
.mail-panes.pane-bottom .list-col {
  width: 100%;
  flex: 1 1 auto;
  border-right: none;
  border-bottom: 1px solid var(--c-border);
}
.mail-panes.pane-bottom .viewer-col {
  width: 100%;
  height: var(--list-h);
  flex: 0 0 var(--list-h);
}
.mail-panes.pane-bottom .pane-resizer {
  width: 100%; height: 6px; cursor: row-resize;
}

/* OFF layout: list fills, viewer hidden on desktop */
.mail-panes.pane-off .list-col { width: 100%; }
@media (min-width: 1024px) {
  .mail-panes.pane-off .viewer-col,
  .mail-panes.pane-off .pane-resizer { display: none; }
}

/* Resizer handle */
.pane-resizer {
  flex-shrink: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
}
.pane-resizer::after {
  content: '';
  position: absolute; inset: 0;
  margin: auto;
  background: var(--c-border);
  transition: background var(--t-fast);
}
.mail-panes.pane-right .pane-resizer::after { width: 1px; height: 100%; }
.mail-panes.pane-bottom .pane-resizer::after { width: 100%; height: 1px; }
.pane-resizer:hover::after { background: var(--c-accent); }
@media (max-width: 1023px) {
  .pane-resizer { display: none; }
}

/* The desktop viewer column is hidden until a message is active */
@media (min-width: 1024px) {
  .viewer-col { display: none; }
  .viewer-col.viewer-active { display: flex; }
  /* When no message is open keep an empty reading pane visible in right layout
     so the placeholder ("Select a message") shows — Thunderbird-like. */
  .mail-panes.pane-right .viewer-col { display: flex; }
}

/* ---- List toolbar controls (density + layout) ---- */
.list-toolbar__controls {
  display: flex; align-items: center; gap: 2px;
  margin-left: 6px;
}
.list-ctrl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--c-text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.list-ctrl-btn:hover { background: var(--c-surface-alt); color: var(--c-text-2); }
.list-ctrl-btn.is-active { background: var(--c-accent-soft); color: var(--c-accent-text); }
.list-ctrl-btn svg { width: 15px; height: 15px; }

.layout-toggle { position: relative; }
.layout-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 168px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 25; overflow: hidden; padding: 4px;
}
.layout-menu__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  font-size: 12px; color: var(--c-text-2);
  border-radius: var(--r-sm);
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.layout-menu__item:hover { background: var(--c-surface-alt); color: var(--c-text); }
.layout-menu__item.is-active { background: var(--c-accent-soft); color: var(--c-accent-text); }
.layout-menu__item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; }

/* ---- Multi-select checkbox on rows ---- */
.email-row__check {
  flex-shrink: 0;
  width: 18px; height: 18px;
  margin-top: 9px;
  border: 1.5px solid var(--c-border);
  border-radius: 5px;
  background: var(--c-surface);
  display: flex; align-items: center; justify-content: center;
  color: transparent;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.email-row:hover .email-row__check,
.email-row.is-cursor .email-row__check { opacity: 1; }
.email-row__check svg { width: 12px; height: 12px; }
.email-row__check.is-checked {
  opacity: 1;
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* Keyboard cursor row */
.email-row.is-cursor {
  background: var(--c-surface-alt);
  box-shadow: inset 3px 0 0 var(--c-link);
}

/* ---- Bulk action bar ---- */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--c-accent-soft);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.bulk-bar__count { font-size: 12px; font-weight: 600; color: var(--c-accent-text); }
.bulk-bar__actions { display: flex; gap: 4px; }
.bulk-bar__btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.bulk-bar__btn:hover { background: var(--c-surface-alt); color: var(--c-text); border-color: var(--c-text-3); }
.bulk-bar__btn svg { width: 13px; height: 13px; }
.bulk-bar__btn--danger { color: var(--c-danger); }
.bulk-bar__btn--danger:hover { background: var(--c-danger-soft); border-color: var(--c-danger); }

/* ---- Density: compact (single-line rows, no avatar/preview) ---- */
body[data-density="compact"] .email-row {
  padding: 5px 12px 5px 18px;
  gap: 8px;
  align-items: center;
}
body[data-density="compact"] .email-row .avatar { display: none; }
body[data-density="compact"] .email-row__check { margin-top: 0; }
body[data-density="compact"] .email-row__top { margin-bottom: 0; }
body[data-density="compact"] .email-row__subject {
  font-size: 12px; margin-bottom: 0;
}
body[data-density="compact"] .email-row__preview { display: none; }
body[data-density="compact"] .email-row__unread-dot { top: 50%; }

/* ---- Reading-pane action toolbar (expanded) ---- */
.reading-toolbar {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  padding: 6px 10px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-alt);
  flex-shrink: 0;
}
.rt-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 9px;
  font-size: 12px; font-weight: 500;
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  background: transparent;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.rt-btn:hover { background: var(--c-surface); color: var(--c-text); }
.rt-btn svg { width: 15px; height: 15px; }
/* Reply is the primary action — render it as a filled coral button so it reads
   as the obvious next step (Gmail-class prominence). */
.rt-btn--primary {
  background: var(--c-accent);
  color: #fff;
  font-weight: 600;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
}
.rt-btn--primary:hover { background: var(--c-accent-dark); color: #fff; }
.rt-btn--primary svg { width: 16px; height: 16px; }
.rt-btn--danger:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.rt-btn.is-on { color: var(--c-warn); }
.rt-sep { width: 1px; height: 18px; background: var(--c-border); margin: 0 4px; flex-shrink: 0; }
.rt-btn__label { }
@media (max-width: 1300px) {
  /* Keep the Reply label even when secondary labels collapse, so the primary
     action stays legible. */
  .rt-btn:not(.rt-btn--primary) .rt-btn__label { display: none; }
  .rt-btn:not(.rt-btn--primary) { padding: 6px; }
}

/* Star/flag toggle on rows */
.email-row__star {
  flex-shrink: 0; margin-top: 8px;
  color: var(--c-text-3);
  opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast);
}
.email-row:hover .email-row__star { opacity: 0.7; }
.email-row__star.is-on { opacity: 1; color: var(--c-warn); }
.email-row__star svg { width: 14px; height: 14px; }

/* Loading skeleton rows shown during HTMX list swaps */
.list-skeleton { padding: 8px 14px; }
.list-skeleton__row { height: 46px; margin-bottom: 6px; border-radius: var(--r-sm); }

/* Make the placeholder reading pane look intentional in right layout */
.mail-panes.pane-right .viewer-col:not(.viewer-active) { background: var(--c-bg); }

/* ---- Folder-tree section header + tree ---- */
.nav-section {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 8px 10px 4px;
  margin-top: 6px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--c-text-3);
  text-align: left;
}
.nav-section__chevron {
  width: 12px; height: 12px; flex-shrink: 0;
  transition: transform var(--t-fast);
}
.nav-section__chevron.is-open { transform: rotate(90deg); }
.nav-section__label {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  text-transform: none; letter-spacing: 0; font-weight: 600;
  color: var(--c-text-2); font-size: 11px;
}
.nav-tree { display: flex; flex-direction: column; gap: 1px; }
.nav-tree .nav-item { padding-left: 22px; }

.nav-item--footer {
  margin-top: auto;
}
.sidebar__nav { display: flex; flex-direction: column; }
