/* ============================================================================
 * Riven Mail — brand styles (Riven Enterprise design language)
 * Tokens: Process Magenta #EC008C, ink #162126, surfaces #F2F6F7.
 * ========================================================================== */
:root {
  --magenta: #EC008C;
  --magenta-dark: #C40074;
  --tint: #FDE0F0;
  --tint-2: #FBB1DD;
  --ink: #162126;
  --muted: #546064;
  --surface: #F2F6F7;
  --card: #FFFFFF;
  --line: #D3D8DA;
  --radius-ctl: 8px;
  --radius-card: 16px;
  --shadow-sm: 0 1px 2px rgba(22, 33, 38, .06);
  --shadow-md: 0 4px 16px rgba(22, 33, 38, .10);
  --shadow-lg: 0 12px 40px rgba(22, 33, 38, .16);
  --font-ui: "Satoshi", "Inter", "Segoe UI", -apple-system, sans-serif;
  --font-display: "Boska", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

/* ============================ Buttons ==================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--magenta);
  color: #fff;
  border: none;
  border-radius: var(--radius-ctl);
  padding: 10px 18px;
  font: 600 14px var(--font-ui);
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--magenta-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary svg { width: 16px; height: 16px; }
.btn-block { width: 100%; justify-content: center; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  color: var(--muted);
  padding: 7px 14px;
  font: 500 13px var(--font-ui);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--magenta); color: var(--magenta); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-ctl);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--tint); color: var(--magenta); }
.icon-btn.danger:hover { background: #fdeaea; color: #c0392b; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active { color: var(--magenta); background: var(--tint); }

/* ============================ Login ====================================== */
.login-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 80% -10%, var(--tint) 0%, transparent 60%),
    var(--surface);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: 40px 36px 24px;
  text-align: center;
}
.login-mark { width: 52px; height: 52px; object-fit: contain; }
.login-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  margin: 14px 0 4px;
  letter-spacing: .2px;
}
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }

.field { position: relative; margin-bottom: 14px; text-align: left; }
.field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.field input {
  width: 100%;
  padding: 11px 12px 11px 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  font: 400 14px var(--font-ui);
  color: var(--ink);
  background: var(--card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px var(--tint);
}
.login-error {
  background: #fdeaea;
  color: #a02c2c;
  border: 1px solid #f3c2c2;
  border-radius: var(--radius-ctl);
  font-size: 13px;
  padding: 9px 12px;
  margin-bottom: 14px;
  text-align: left;
}
.login-footer { margin-top: 26px; color: var(--muted); font-size: 12px; }

.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ App shell ================================== */
.app-view { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 58px;
  flex-shrink: 0;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.topbar-mark { width: 28px; height: 28px; object-fit: contain; }
.topbar-wordmark { font-family: var(--font-display); font-size: 20px; }
.topbar-wordmark b { color: var(--magenta); font-weight: 600; }

.topbar-search {
  flex: 1;
  max-width: 560px;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search svg {
  position: absolute; left: 12px;
  width: 16px; height: 16px; color: var(--muted);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  padding: 9px 12px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: 400 14px var(--font-ui);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.topbar-search input:focus {
  background: var(--card);
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px var(--tint);
}
.topbar-account { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.account-email { font-size: 13px; color: var(--muted); }

.main { display: flex; flex: 1; min-height: 0; }

/* ============================ Sidebar ==================================== */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.compose-btn { justify-content: center; margin-bottom: 18px; }
.folder-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-ctl);
  background: transparent;
  color: var(--ink);
  font: 500 14px var(--font-ui);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .12s;
}
.folder-item svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.folder-item:hover { background: var(--surface); }
.folder-item.active { background: var(--tint); color: var(--magenta-dark); }
.folder-item.active svg { color: var(--magenta); }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-badge {
  background: var(--magenta);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--line); }
.kbd-hint { font-size: 12px; color: var(--muted); }

/* ============================ Message list =============================== */
.list-pane {
  width: 360px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.list-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 18px 10px;
}
.list-title { font-family: var(--font-display); font-size: 22px; margin: 0; font-weight: 500; }
.list-count { font-size: 12px; color: var(--muted); }
.message-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }

.msg-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .12s, background .12s;
}
.msg-item:hover { border-color: var(--line); }
.msg-item.selected { background: var(--tint); border-color: var(--tint-2); }
.msg-row1 { display: flex; align-items: center; gap: 8px; }
.msg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--magenta);
  flex-shrink: 0;
}
.msg-dot.hidden-dot { visibility: hidden; }
.msg-sender { font-size: 14px; color: var(--ink); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item.unread .msg-sender { font-weight: 700; }
.msg-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.msg-subject {
  font-size: 13px;
  margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.msg-item.unread .msg-subject { font-weight: 600; }
.msg-star { width: 14px; height: 14px; color: var(--magenta); flex-shrink: 0; }
.msg-clip { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.msg-preview {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.list-more { padding: 10px; text-align: center; }

/* ============================ Reading pane =============================== */
.reading-pane {
  flex: 1;
  min-width: 0;
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.reading-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 12px;
}
.reading-empty-mark { width: 56px; height: 56px; opacity: .25; }

.reading-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.reading-actions { display: flex; align-items: center; gap: 2px; }
.reading-subject {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  margin: 18px 24px 6px;
  line-height: 1.25;
}
.reading-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px 14px;
  border-bottom: 1px solid var(--line);
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.reading-addresses { flex: 1; min-width: 0; font-size: 13px; }
.reading-from { font-weight: 600; }
.reading-to, .reading-cc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reading-date { font-size: 12px; color: var(--muted); flex-shrink: 0; }

.reading-attachments {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
}
.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  transition: border-color .15s, color .15s;
}
.attachment-chip:hover { border-color: var(--magenta); color: var(--magenta); }
.attachment-chip svg { width: 14px; height: 14px; }
.attachment-size { color: var(--muted); font-size: 12px; }

.reading-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 300px;
  background: #fff;
}

.reading-loading { padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.skel {
  background: linear-gradient(90deg, var(--surface) 25%, #e8eef0 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
.skel-line { height: 18px; }
.w60 { width: 60%; }
.w40 { width: 40%; }
.skel-block { height: 240px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.list-skeleton { padding: 12px; }
.list-skeleton .skel { height: 74px; margin-bottom: 8px; border-radius: 12px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 14px;
}
.empty-state svg { width: 40px; height: 40px; opacity: .3; margin-bottom: 8px; }

/* ============================ Move menu ================================== */
.move-wrap { position: relative; }
.move-menu {
  position: absolute;
  top: 38px;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 6px;
  z-index: 50;
}
.move-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: var(--radius-ctl);
  font: 500 13px var(--font-ui);
  color: var(--ink);
  cursor: pointer;
}
.move-menu button:hover { background: var(--tint); color: var(--magenta-dark); }

/* ============================ Modals ===================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 38, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.compose-card, .shortcuts-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.shortcuts-card { max-width: 420px; padding-bottom: 18px; }
.compose-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.compose-head h3 { font-family: var(--font-display); font-size: 20px; margin: 0; font-weight: 500; }
.compose-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.compose-body input, .compose-body textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  padding: 10px 12px;
  font: 400 14px var(--font-ui);
  color: var(--ink);
  outline: none;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.compose-body input:focus, .compose-body textarea:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px var(--tint);
}
.compose-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.shortcuts-table { width: 100%; border-collapse: collapse; padding: 0 20px; }
.shortcuts-table td { padding: 8px 20px; font-size: 13px; border-bottom: 1px solid var(--surface); }
.shortcuts-table td:first-child { width: 40%; color: var(--muted); }

/* ============================ Toasts ===================================== */
.toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}
.toast.error { background: #a02c2c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-only { display: none; }

/* ============================ Responsive ================================= */
@media (max-width: 1100px) {
  .sidebar { width: 200px; }
  .list-pane { width: 300px; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .list-pane { width: 100%; border-right: none; }
  .reading-pane {
    position: fixed;
    inset: 58px 0 0 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform .2s ease;
  }
  .app-view.show-detail .reading-pane { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar-brand { min-width: 0; }
  .topbar-wordmark { display: none; }
  .account-email { display: none; }
}

/* ------------------------------ SSO ----------------------------------- */
.sso-btn {
  display: flex;
  text-decoration: none;
  margin-bottom: 4px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 12px;
  color: var(--muted, #546064);
  font-size: 12.5px;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line, #D3D8DA);
}
.sso-splash-card { text-align: center; }
.sso-spinner {
  margin: 18px auto 4px;
  width: 22px;
  height: 22px;
  display: block;
}

/* ============================ Multi-Tenant Branding & Bar ================= */
.topbar-brand { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.topbar-riven-home {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; padding: 4px;
  box-shadow: var(--shadow-sm);
}
.topbar-mark { width: 24px; height: 24px; object-fit: contain; }
.topbar-brand-titles { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-wordmark { font-family: var(--font-display); font-size: 19px; color: var(--ink); }
.topbar-wordmark b { color: var(--magenta); font-weight: 600; }
.topbar-tenant-badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--magenta-dark);
}
.tenant-switcher-bar {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px 10px;
}
.switcher-group { display: inline-flex; align-items: center; gap: 6px; }
.switcher-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--muted); text-transform: uppercase;
}
.switcher-divider { width: 1px; height: 18px; background: var(--line); }
.switcher-select {
  border: 1px solid transparent; border-radius: 6px;
  background: var(--card); color: var(--ink);
  font: 600 12.5px var(--font-ui); padding: 4px 8px;
  cursor: pointer; outline: none;
  box-shadow: 0 1px 2px rgba(22,33,38,0.05);
}
.switcher-select:hover, .switcher-select:focus {
  border-color: var(--magenta);
}
.mailbox-select { min-width: 220px; }

/* ======================== Superhuman/Gmail parity ======================== */
.palette-trigger { font-size: 12px; padding: 5px 10px; font-weight: 700; }
.inbox-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--card); overflow-x: auto; }
.inbox-tab { border: none; background: transparent; padding: 9px 10px 8px; font: 600 12px var(--font-ui); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.inbox-tab.active { color: var(--magenta-dark); border-bottom-color: var(--magenta); }
.inbox-tab .tab-cnt { font-size: 10.5px; background: var(--surface); border-radius: 999px; padding: 1px 6px; color: var(--muted); }
.inbox-tab.active .tab-cnt { background: var(--tint); color: var(--magenta-dark); }
.filter-row { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.select-all { display: inline-flex; align-items: center; cursor: pointer; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 10px; font: 600 11.5px var(--font-ui); color: var(--muted); cursor: pointer; }
.filter-chip.active { background: var(--tint); border-color: var(--magenta); color: var(--magenta-dark); }
.bulk-bar { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--tint); border-bottom: 1px solid var(--tint-2); font-size: 12px; font-weight: 600; flex-wrap: wrap; }
.bulk-bar .btn-ghost { padding: 4px 9px; font-size: 11.5px; background: var(--card); }
.bulk-bar .danger:hover { border-color: #c0392b; color: #c0392b; }

.msg-item { position: relative; display: flex; gap: 9px; align-items: flex-start; }
.msg-chk { margin-top: 3px; accent-color: var(--magenta); cursor: pointer; flex-shrink: 0; }
.msg-main { flex: 1; min-width: 0; }
.msg-hover { position: absolute; right: 10px; top: 8px; display: none; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: var(--shadow-sm); }
.msg-item:hover .msg-hover { display: inline-flex; }
.msg-item:hover .msg-time { visibility: hidden; }
.msg-hover button { width: 26px; height: 26px; border: none; background: transparent; border-radius: 6px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.msg-hover button:hover { background: var(--tint); color: var(--magenta-dark); }
.msg-hover svg { width: 14px; height: 14px; }
body.compact .msg-item { padding: 7px 11px; margin-bottom: 3px; border-radius: 8px; }
body.compact .msg-preview { display: none; }

.ai-card { margin: 12px 24px 0; border: 1px solid var(--tint-2); background: linear-gradient(180deg, var(--tint) 0%, #fff 90%); border-radius: 12px; padding: 10px 14px; }
.ai-card-head { display: flex; align-items: center; gap: 8px; }
.ai-badge { background: var(--magenta); color: #fff; font: 700 10.5px var(--font-ui); letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; }
.ai-meta { font-size: 12px; color: var(--muted); flex: 1; }
.ai-run { padding: 4px 10px; font-size: 12px; background: #fff; }
.ai-body { margin-top: 8px; font-size: 13px; line-height: 1.45; }
.ai-body .ai-tldr { font-weight: 600; color: var(--ink); }
.ai-body ul { margin: 5px 0 0; padding-left: 18px; color: var(--muted); }
.ai-replies { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ai-reply-chip { border: 1px solid var(--magenta); background: #fff; color: var(--magenta-dark); border-radius: 999px; padding: 4px 11px; font: 600 12px var(--font-ui); cursor: pointer; }
.ai-reply-chip:hover { background: var(--magenta); color: #fff; }

.compose-card.maximized { max-width: 92vw; width: 92vw; height: 88vh; max-height: 88vh; }
.compose-from { font-size: 12px; color: var(--muted); padding: 2px 4px; }
.ai-toolbar, .fmt-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-toolbar .btn-ghost { padding: 4px 9px; font-size: 12px; }
.fmt-toolbar button, .attach-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 4px 9px; font: 500 12px var(--font-ui); cursor: pointer; color: var(--ink); }
.fmt-toolbar button:hover, .attach-btn:hover { border-color: var(--magenta); color: var(--magenta-dark); }
.compose-editor { min-height: 180px; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-ctl); padding: 10px 12px; font: 400 14px/1.5 var(--font-ui); outline: none; background: #fff; }
.compose-editor:focus { border-color: var(--magenta); box-shadow: 0 0 0 3px var(--tint); }
.compose-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.compose-attachments { display: flex; gap: 6px; flex-wrap: wrap; }
.att-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.att-pill button { border: none; background: none; cursor: pointer; color: var(--muted); font-weight: 700; }
.compose-signature { border-top: 1px dashed var(--line); padding-top: 8px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.compose-signature img { width: 22px; height: 22px; object-fit: contain; }

.palette-backdrop { align-items: flex-start; padding-top: 10vh; }
.palette-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; overflow: hidden; }
#palette-input { width: 100%; border: none; border-bottom: 1px solid var(--line); padding: 14px 16px; font: 500 15px var(--font-ui); outline: none; }
.palette-results { max-height: 340px; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; justify-content: space-between; width: 100%; border: none; background: transparent; padding: 9px 12px; border-radius: 8px; font: 500 13px var(--font-ui); color: var(--ink); cursor: pointer; text-align: left; }
.palette-item:hover, .palette-item.active { background: var(--tint); color: var(--magenta-dark); }
.palette-item small { color: var(--muted); font-size: 11.5px; }

.undo-bar { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 18px; display: flex; align-items: center; gap: 14px; font-size: 13px; box-shadow: var(--shadow-md); z-index: 210; }
.undo-bar button { border: none; background: var(--magenta); color: #fff; font: 700 12px var(--font-ui); border-radius: 999px; padding: 4px 12px; cursor: pointer; }

/* ======================== Wave 7 Depth: Threading, Waffle, Help, Settings ======================== */
.msg-thread-badge {
  background: var(--tint);
  color: var(--magenta-dark);
  font: 700 10.5px var(--font-ui);
  border-radius: 999px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.msg-unsub-tag {
  border: 1px solid var(--line);
  color: var(--muted);
  font: 600 10px var(--font-ui);
  border-radius: 4px;
  padding: 0 5px;
  flex-shrink: 0;
}

.waffle-wrap { position: relative; }
.waffle-menu {
  position: absolute;
  top: 42px;
  right: 0;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  z-index: 150;
}
.waffle-head {
  font: 700 11px var(--font-ui);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 0 4px;
}
.waffle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.waffle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--ink);
  font: 600 11.5px var(--font-ui);
  text-align: center;
  transition: background .12s, border-color .12s;
}
.waffle-item:hover, .waffle-item.active {
  background: var(--tint);
  border-color: var(--tint-2);
  color: var(--magenta-dark);
}
.waffle-ico { font-size: 20px; line-height: 1; }

.unsub-banner {
  margin: 10px 24px 0;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}
.unsub-btn { padding: 3px 10px; font-size: 11.5px; text-decoration: none; background: var(--card); }

.thread-stack {
  margin: 10px 24px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thread-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.thread-card.current {
  border-color: var(--magenta);
  background: var(--card);
}
.thread-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
}
.thread-card-head:hover { background: var(--tint); }
.thread-sender { font-weight: 700; color: var(--ink); }
.thread-snippet { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-date { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.thread-card-body {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
}

.reading-bottom-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}
.ai-bottom-trigger {
  border-color: var(--magenta);
  color: var(--magenta-dark);
  background: var(--tint);
  font-weight: 600;
}

.drawer-backdrop { justify-content: flex-end; padding: 0; }
.drawer-card {
  background: var(--card);
  width: 100%;
  max-width: 520px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.drawer-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 400 13.5px var(--font-ui);
  outline: none;
}
.drawer-search:focus { border-color: var(--magenta); box-shadow: 0 0 0 3px var(--tint); }
.help-links-row { display: flex; gap: 6px; flex-wrap: wrap; }
.help-links-row .btn-ghost { font-size: 12px; padding: 5px 10px; text-decoration: none; }
.help-articles { display: flex; flex-direction: column; gap: 10px; }
.help-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.help-card h4 { margin: 0 0 6px; font-size: 14px; color: var(--ink); }
.help-card p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

.settings-card { max-width: 680px; }
.settings-tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.settings-body { min-height: 320px; }
.stab-pane { display: flex; flex-direction: column; gap: 14px; }
.settings-group { display: flex; flex-direction: column; gap: 6px; }
.settings-label { font: 700 12px var(--font-ui); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.settings-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
}
.settings-hint { font-size: 12px; color: var(--muted); }
.settings-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.quota-bar-wrap { width: 100%; height: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.quota-bar-fill { height: 100%; background: var(--magenta); transition: width .3s ease; }
