/* ==========================================================================
   FLOW BATCH STUDIO MAIL — EDITORIAL PRODUCTION DESK DESIGN SYSTEM
   Visual direction: industrial editorial / print room.
   Ink, bone, oxide orange, hard rules, restrained radii, monospace accents.
   ========================================================================== */

:root,
html[data-theme="dark"] {
  --bg: #11110f;
  --bg-gradient: radial-gradient(circle at 20% 0%, rgba(226, 102, 67, 0.055), transparent 28%), linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  --surface: #171714;
  --surface2: #1d1c18;
  --surface3: #24221d;
  --sidebar-bg: #141411;
  --line: #39362f;
  --line-soft: #282621;
  --text: #f1eee6;
  --text-muted: #aaa59a;
  --text-dim: #736e65;
  --accent: #e26643;
  --accent-hover: #ee7957;
  --accent-soft: rgba(226, 102, 67, 0.14);
  --accent2: #c6a76b;
  --green: #77a887;
  --green-soft: rgba(119, 168, 135, 0.15);
  --danger: #d85a52;
  --danger-soft: rgba(216, 90, 82, 0.15);
  --amber: #f5c96a;
  --paper: #ece8df;
  --paper-ink: #171613;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f2eee6;
  --bg-gradient: linear-gradient(rgba(33, 31, 26, 0.025) 1px, transparent 1px);
  --surface: #fffdf8;
  --surface2: #f9f6f0;
  --surface3: #ebe6dc;
  --sidebar-bg: #e8e2d6;
  --line: #d2cbc0;
  --line-soft: #e1dbd0;
  --text: #211f1a;
  --text-muted: #645e54;
  --text-dim: #948d82;
  --accent: #b84f35;
  --accent-hover: #c85b3f;
  --accent-soft: rgba(184, 79, 53, 0.12);
  --accent2: #9c7b48;
  --green: #357956;
  --green-soft: rgba(53, 121, 86, 0.12);
  --danger: #b4443b;
  --danger-soft: rgba(180, 68, 59, 0.12);
  --amber: #9a6a08;
  --paper: #f2eee6;
  --paper-ink: #211f1a;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

[hidden],
template,
.hidden {
  display: none !important;
}

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

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-size: auto, 100% 38px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

kbd,
.shortcut-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  min-width: 18px;
  height: 18px;
  border-radius: 3px;
  background: var(--surface3);
  border: 1px solid var(--line);
  color: var(--text-muted);
  line-height: 1;
}

/* ==========================================================================
   FLOW BATCH SVG MASK ICONS
   ========================================================================== */

.fb-ic {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: none;
  background-color: currentColor;
  -webkit-mask: var(--fb-ic) center / contain no-repeat;
  mask: var(--fb-ic) center / contain no-repeat;
  vertical-align: middle;
}
.fb-ic-sm { width: 14px; height: 14px; }
.fb-ic-lg { width: 20px; height: 20px; }
.fb-ic-xl { width: 32px; height: 32px; }

.fb-ic-inbox { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-6l-2 3h-4l-2-3H2'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E"); }
.fb-ic-star { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8-6.2-3.2-6.2 3.2L7 14.2 2 9.3l6.9-1z'/%3E%3C/svg%3E"); }
.fb-ic-send { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m22 2-7 20-4-9-9-4z'/%3E%3Cpath d='M22 2 11 13'/%3E%3C/svg%3E"); }
.fb-ic-pencil { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z'/%3E%3C/svg%3E"); }
.fb-ic-folder { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9l-.8-1.2A2 2 0 0 0 7.9 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z'/%3E%3C/svg%3E"); }
.fb-ic-shield { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
.fb-ic-trash { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'/%3E%3C/svg%3E"); }
.fb-ic-settings { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E"); }
.fb-ic-plus { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M12 5v14'/%3E%3C/svg%3E"); }
.fb-ic-search { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E"); }
.fb-ic-refresh { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-3-6.7L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E"); }
.fb-ic-menu { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16M4 12h16M4 18h16'/%3E%3C/svg%3E"); }
.fb-ic-logout { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9'/%3E%3C/svg%3E"); }
.fb-ic-zap { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2 3 14h9l-1 8 10-12h-9z'/%3E%3C/svg%3E"); }
.fb-ic-sun { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4'/%3E%3C/svg%3E"); }
.fb-ic-moon { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z'/%3E%3C/svg%3E"); }
.fb-ic-mail { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='m22 7-10 6L2 7'/%3E%3C/svg%3E"); }
.fb-ic-file { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6M8 13h8M8 17h6'/%3E%3C/svg%3E"); }
.fb-ic-paperclip { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l7.88-7.88'/%3E%3C/svg%3E"); }
.fb-ic-check { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
.fb-ic-x { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
.fb-ic-download { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3'/%3E%3C/svg%3E"); }
.fb-ic-undo { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-15-6.7L3 13'/%3E%3C/svg%3E"); }
.fb-ic-link { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7'/%3E%3C/svg%3E"); }
.fb-ic-user { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1'/%3E%3C/svg%3E"); }
.fb-ic-eye { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
.fb-ic-eyeoff { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 4.2A10 10 0 0 1 12 4c6.5 0 10 8 10 8a17 17 0 0 1-2.2 3.2M6.6 6.6A17 17 0 0 0 2 12s3.5 8 10 8a9.7 9.7 0 0 0 5.4-1.6M2 2l20 20M14.1 14.1a3 3 0 1 1-4.2-4.2'/%3E%3C/svg%3E"); }
.fb-ic-keyboard { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='4' width='20' height='16' rx='2'/%3E%3Cpath d='M6 8h.01M10 8h.01M14 8h.01M18 8h.01M6 12h.01M10 12h.01M14 12h.01M18 12h.01M7 16h10'/%3E%3C/svg%3E"); }
.fb-ic-archive { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='20' height='5' x='2' y='3' rx='1'/%3E%3Cpath d='M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4'/%3E%3C/svg%3E"); }
.fb-ic-alert { --fb-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */

.login-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-size: auto, 100% 38px;
}

.login-page[hidden],
#login[hidden] {
  display: none !important;
}

.login-card {
  width: min(440px, 94vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
  position: relative;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.login-logo {
  height: 38px;
  width: auto;
  max-width: 100%;
  display: block;
}

.login-card .logo {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-card label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 6px;
}

.password-input-wrap input {
  margin-top: 0 !important;
  padding-right: 42px !important;
}

.password-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.password-toggle-btn:hover {
  color: var(--text);
  background: var(--surface3) !important;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 20px;
  padding: 11px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}

.login-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

#loginError {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--danger);
  min-height: 18px;
  line-height: 1.4;
  word-break: break-word;
}

#loginError:not(:empty) {
  padding: 9px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(216, 90, 82, 0.35);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   APP SHELL LAYOUT (Sidebar + Main)
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: 200px 1fr;
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  overflow: hidden;
}

.app[hidden],
#app[hidden] {
  display: none !important;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100vh;
  max-height: 100vh;
  position: relative;
  overflow-y: auto;
  z-index: 50;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-logo {
  height: 24px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-text b {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: block;
  line-height: 1.15;
}

.brand-text small {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.compose {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, box-shadow 0.15s;
}

.compose:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px var(--accent-soft);
}

.compose .shortcut-pill {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.compose .fb-ic {
  flex: 0 0 16px !important;
  width: 16px !important;
  height: 16px !important;
  background-color: #fff;
}

/* Sidebar Navigation Groups */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-group-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 3px 8px;
  user-select: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

.nav:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}

.nav.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.nav .fb-ic {
  flex: 0 0 16px !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0;
}

.nav .nav-text,
.nav > span:not(.fb-ic) {
  flex: 0 1 auto;
  white-space: nowrap;
}

.nav-badge:not(:empty) {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-left: auto;
}

/* Sidebar Foot Dock */
.side-bottom {
  margin-top: auto;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green-soft);
}

.profile-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.profile-email {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 135px;
}

.profile-status {
  font-size: 9.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}

.side-action-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

.side-action-btn .fb-ic {
  flex: 0 0 16px !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0;
}

.side-action-btn .action-text,
.side-action-btn > span:not(.fb-ic) {
  flex: 0 1 auto;
  white-space: nowrap;
}

.side-action-btn .shortcut-pill {
  margin-left: auto;
}

/* ==========================================================================
   TOP BAR & CHROME
   ========================================================================== */

main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.top {
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  z-index: 40;
  flex-shrink: 0;
}

.mobile-menu {
  display: none;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  color: var(--text);
}

.search {
  height: 36px;
  width: min(440px, 45vw);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px 0 12px;
  color: var(--text-muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--text);
}

.search input {
  border: 0;
  outline: 0;
  background: transparent;
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.search input::placeholder {
  color: var(--text-dim);
}

.search-hint {
  pointer-events: none;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.mail-address-pill {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

.app-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.app-switcher:hover {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.top-right button,
.theme-toggle-btn {
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.top-right button:hover,
.theme-toggle-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

@keyframes fb-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinning {
  animation: fb-spin 0.8s linear infinite;
}

/* ==========================================================================
   MAIL SHELL & TOOLBAR
   ========================================================================== */

.mail-content-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.toolbar {
  padding: 14px 28px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toolbar-heading h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.toolbar-heading p {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.empty-trash-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(216, 90, 82, 0.4);
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s;
}

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

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions button {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.toolbar-actions button:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.toolbar-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sync-banner {
  padding: 10px 24px;
  margin: 0 24px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sync-banner.info {
  background: var(--surface2);
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.sync-banner.success {
  background: var(--green-soft);
  border: 1px solid rgba(119, 168, 135, 0.4);
  color: var(--green);
}

.sync-banner.error {
  background: var(--danger-soft);
  border: 1px solid rgba(216, 90, 82, 0.4);
  color: var(--danger);
}

/* ==========================================================================
   MAIL LAYOUT (List + Reader)
   ========================================================================== */

.mail-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1;
  min-height: 0;
  margin: 0 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  user-select: none;
}

.message:hover {
  background: var(--surface2);
}

.message.selected {
  background: var(--surface2);
}

.message.selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.message.unread {
  background: rgba(226, 102, 67, 0.035);
}

.message.unread .sender,
.message.unread .subject {
  font-weight: 700;
  color: var(--text);
}

.message-check {
  margin-top: 3px;
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.msg-main {
  flex: 1;
  min-width: 0;
}

.msg-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.sender {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.subject {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.star {
  background: none;
  border: 0;
  padding: 0;
  font-size: 16px;
  color: var(--text-dim);
  cursor: pointer;
  margin-top: 2px;
  transition: color 0.12s;
}

.star:hover {
  color: var(--amber);
}

.star.on {
  color: var(--amber);
}

/* Reader Pane */
.reader {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.empty-reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
}

.empty-reader h2 {
  margin: 16px 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.empty-reader p {
  margin: 0;
  font-size: 13px;
}

.shortcut-tip {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.empty-sync-btn {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 16px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
}

.empty-sync-btn:hover {
  background: var(--surface3);
  border-color: var(--accent);
}

.reader-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.reader-head h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.sender-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sender-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sender-info strong {
  font-size: 13.5px;
  color: var(--text);
}

.sender-info time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-actions button {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.reader-actions button:hover {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.reader-actions button.star-btn {
  font-size: 15px;
  padding: 0 8px;
}

.reader-actions button.star-btn.on {
  color: var(--amber);
}

.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  line-height: 1.6;
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.reader-footer {
  padding: 10px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Attachments */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.attachment:hover {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.attachment small {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}

.pdf-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.pdf-attachment a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
}

.pdf-edit-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.pdf-edit-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ==========================================================================
   MODAL LAYER SYSTEM & SCRIM
   ========================================================================== */

.modal-layer[hidden],
.modal[hidden] {
  display: none !important;
}

.modal-layer,
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fb-dialog-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
}

.fb-settings-center,
.fb-dialog-center {
  position: relative;
  z-index: 1001;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.fb-dialog-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.fb-dialog-close:hover {
  background: var(--surface3);
  color: var(--text);
}

/* Buttons */
.fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.fb-btn-primary {
  background: var(--accent);
  color: #fff;
}
.fb-btn-primary:hover {
  background: var(--accent-hover);
}

.fb-btn-outline {
  background: var(--surface2);
  border-color: var(--line);
  color: var(--text);
}
.fb-btn-outline:hover {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.fb-btn-destructive {
  background: var(--danger);
  color: #fff;
}
.fb-btn-destructive:hover {
  background: #c63930;
}

/* ==========================================================================
   SETTINGS MODAL DIALOG (Flow Batch Studio Design)
   ========================================================================== */

.fb-settings-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 980px;
  height: min(720px, 88vh);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.fb-settings-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  flex-shrink: 0;
}

.fb-settings-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
}

.fb-settings-title {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.fb-settings-body {
  display: grid;
  grid-template-columns: 230px 1fr;
  flex: 1;
  min-height: 0;
}

.fb-settings-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 10px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  overflow-y: auto;
}

.fb-settings-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fb-settings-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 10px;
}

.fb-settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.fb-settings-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.fb-settings-item.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
}

.fb-settings-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.fb-settings-content {
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--surface);
}

.fb-settings-panel[hidden] {
  display: none !important;
}

.route-section-heading h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.route-section-heading p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.route-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.route-info {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-info span {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.route-info strong {
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
}

.route-info small {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 4px;
}

.settings-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}

/* Callout and Diagnostic Cards */
.settings-callout-card,
.route-diag-card {
  padding: 18px 20px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.diag-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.sync-now-btn {
  height: 32px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.sync-now-btn:hover {
  background: var(--accent-hover);
}

.diag-output-box {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
  background: var(--surface);
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  word-break: break-word;
}

.settings-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Sender identities */
.route-identities {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.route-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.route-identity strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.route-identity span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.route-identity-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.route-identity-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
}

.route-identity-protected {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.route-identity-delete {
  height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(216, 90, 82, 0.4);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s;
}

.route-identity-delete:hover {
  background: var(--danger);
  color: #fff;
}

.route-add-card {
  border-top: 1px dashed var(--line);
  padding-top: 20px;
}

.route-add-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.route-add-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 12.5px;
}

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

.route-add-form label span {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.route-add-form input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.route-add-form input:focus {
  border-color: var(--accent);
}

.add-sender-submit-btn {
  align-self: flex-start;
  height: 35px;
  padding: 0 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s;
}

.add-sender-submit-btn:hover {
  background: var(--accent-hover);
}

.route-settings-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* Preferences & Shortcuts Grids */
.settings-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.settings-option-card {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.settings-option-card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.settings-option-card p {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.theme-choice-buttons,
.density-choice-buttons {
  display: flex;
  gap: 8px;
}

.theme-choice-btn,
.density-choice-btn {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}

.theme-choice-btn:hover,
.density-choice-btn:hover {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.density-choice-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.shortcuts-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.shortcuts-group h4 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text);
}

.shortcut-row span {
  color: var(--text-muted);
}

.account-logout-btn {
  height: 32px;
  padding: 0 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(216, 90, 82, 0.4);
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  transition: background 0.15s;
}

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

/* ==========================================================================
   COMPOSE MODAL
   ========================================================================== */

.compose-card {
  width: min(840px, 94vw);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1002;
}

.compose-card header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
}

.compose-card header b {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.compose-card header small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.compose-card header button[data-close] {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.compose-card header button[data-close]:hover {
  background: var(--surface3);
  color: var(--text);
}

.compose-card form {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compose-label {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.to-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cc-toggle-btn {
  background: none;
  border: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  cursor: pointer;
  text-transform: none;
  font-weight: 600;
}

.cc-toggle-btn:hover {
  text-decoration: underline;
}

.compose-card input,
.compose-card select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 11px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.compose-card input:focus,
.compose-card select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
}

.editor-tools button {
  height: 26px;
  min-width: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.12s;
}

.editor-tools button:hover {
  background: var(--surface3);
}

.editor {
  min-height: 200px;
  max-height: 340px;
  overflow-y: auto;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--text);
  outline: none;
  font-size: 13.5px;
  line-height: 1.6;
}

.editor:focus {
  border-color: var(--accent);
}

.editor:empty::before {
  content: attr(placeholder);
  color: var(--text-dim);
}

.attach {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px dashed var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}

.attach:hover {
  border-color: var(--accent);
  color: var(--text);
}

.compose-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  margin-top: 6px;
}

.compose-footer .secondary {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}

.compose-footer .secondary:hover {
  background: var(--surface3);
}

#sendStatus {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.compose-footer .send {
  margin-left: auto;
  height: 34px;
  padding: 0 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s;
}

.compose-footer .send:hover {
  background: var(--accent-hover);
}

/* ==========================================================================
   SHORTCUTS DIALOG & CONFIRMATION DIALOG
   ========================================================================== */

.fb-dialog-card {
  width: min(680px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fb-dialog-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fb-dialog-title {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.fb-dialog-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.shortcuts-dialog-body {
  max-height: 60vh;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.shortcuts-card {
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.shortcuts-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}

.shortcut-item:last-child {
  border-bottom: 0;
}

.shortcut-item span {
  color: var(--text-muted);
}

.fb-dialog-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface2);
  display: flex;
  justify-content: flex-end;
}

/* Confirmation Dialog */
.fb-confirm-card {
  width: min(460px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fb-confirm-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.fb-confirm-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.fb-confirm-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.fb-confirm-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.fb-confirm-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   PDF EDITOR MODAL
   ========================================================================== */

.pdf-editor-modal[hidden] {
  display: none !important;
}

.pdf-editor-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1010;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pdf-editor-card {
  width: min(1100px, 98vw);
  height: 94vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-editor-top {
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
}

.pdf-editor-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.pdf-editor-top h2 {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.pdf-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-editor-actions button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.pdf-editor-actions button:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--text-dim);
}

.pdf-editor-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#pdfDownload {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#pdfDownload:hover:not(:disabled) {
  background: var(--accent-hover);
}

#pdfAttach {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}
#pdfAttach:hover:not(:disabled) {
  background: var(--accent-soft);
}

.pdf-editor-toolbar {
  padding: 8px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pdf-editor-toolbar button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
}

.pdf-editor-toolbar button:hover {
  background: var(--surface3);
  color: var(--text);
}

.pdf-editor-toolbar button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pdf-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.pdf-size input {
  width: 52px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.pdf-editor-status {
  padding: 6px 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.pdf-pages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.pdf-page {
  position: relative;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.pdf-base {
  display: block;
}

.pdf-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.pdf-page.tool-select .pdf-overlay { cursor: default; }
.pdf-page.tool-text .pdf-overlay { cursor: text; }
.pdf-page.tool-draw .pdf-overlay { cursor: crosshair; }
.pdf-page.tool-highlight .pdf-overlay { cursor: crosshair; }
.pdf-page.tool-whiteout .pdf-overlay { cursor: crosshair; }

.pdf-text-item {
  position: absolute;
  pointer-events: none;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1;
  white-space: pre;
}

/* ==========================================================================
   DENSITY PREFERENCES
   ========================================================================== */

.compact-density .message {
  padding: 8px 12px;
  gap: 10px;
}

.compact-density .avatar {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.compact-density .subject,
.compact-density .sender {
  font-size: 12.5px;
}

/* ==========================================================================
   MOBILE & RESPONSIVE BEHAVIOR
   ========================================================================== */

.mail-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 45;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mail-mobile-backdrop.open {
  display: block;
  opacity: 1;
}

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

  .sidebar {
    position: fixed;
    left: -220px;
    top: 0;
    bottom: 0;
    width: 210px;
    z-index: 60;
    transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-menu {
    display: grid;
  }

  .top {
    padding: 0 16px;
  }

  #mailAddress {
    display: none;
  }

  .toolbar {
    padding: 14px 16px 10px;
  }

  .mail-layout {
    grid-template-columns: 1fr;
    margin: 0 12px 16px;
    height: calc(100vh - 140px);
  }

  .reader {
    display: none;
  }

  .mail-layout.reader-open .list {
    display: none;
  }

  .mail-layout.reader-open .reader {
    display: flex;
  }

  .fb-settings-body {
    grid-template-columns: 1fr;
  }

  .fb-settings-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}
