/* ============================================================
   ZenvyHub Private Mail - Modern App Shell Design System
   ============================================================ */

:root {
  /* Light theme */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e6e9f2;
  --text: #161826;
  --text-secondary: #585f7a;
  --muted: #8489a3;
  --border: #dfe2ec;
  --border-subtle: #eceef5;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.1);
  --accent-glow: rgba(99, 102, 241, 0.18);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.1);
  --glass: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

[data-theme="dark"] {
  --bg: #0b0e17;
  --surface: #131724;
  --surface-2: #191e2e;
  --surface-3: #22283d;
  --text: #eef0f7;
  --text-secondary: #9ba3bd;
  --muted: #6c7393;
  --border: #252b40;
  --border-subtle: #1c2133;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-light: rgba(129, 140, 248, 0.14);
  --accent-glow: rgba(129, 140, 248, 0.2);
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-light: rgba(248, 113, 113, 0.14);
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --glass: rgba(19, 23, 36, 0.88);
  --glass-border: rgba(255, 255, 255, 0.07);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color var(--transition), color var(--transition);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 20%, var(--accent-glow) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 15%, rgba(139, 92, 246, 0.08) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

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

/* ----- Top App Bar ----- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--glass-border);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-shrink: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.logo-sub-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.auth-nav-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Status Indicator ----- */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 9999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-indicator[data-status="live"] {
  background: var(--success-light);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--success);
}

.status-indicator[data-status="connecting"],
.status-indicator[data-status="reconnecting"] {
  background: var(--warning-light);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warning);
}

.status-indicator[data-status="offline"] {
  background: var(--danger-light);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ----- Theme Toggle ----- */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: transparent;
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.08);
  border-color: transparent;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.78rem;
}

.btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary-sm:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.btn-block {
  width: 100%;
  padding: 11px 16px;
  font-size: 0.92rem;
}

.btn-generate {
  padding: 13px 20px;
  font-size: 0.96rem;
  border-radius: var(--radius-md);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
}

.btn-back:hover {
  border-color: var(--accent);
}

.btn-icon-xs {
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-xs:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ----- App Shell & 3-Column Inbox Workspace ----- */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
}

.mobile-pane-tabs {
  display: none;
}

.tablet-sidebar-toggle {
  display: none;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(2px);
  z-index: 30;
}

.drawer-backdrop.active {
  display: block;
}

.inbox-workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  height: calc(100dvh - var(--header-h, 61px));
  overflow: hidden;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  background: var(--surface);
  position: relative;
}

/* Column 1: Sidebar */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.sidebar-search-wrap {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.83rem;
  outline: none;
  transition: var(--transition);
}

.sidebar-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.sidebar-block {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-addresses-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: none;
}

.sidebar-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-block-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-block-actions {
  display: flex;
  gap: 6px;
}

.sidebar-count-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.category-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.835rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.category-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.category-item.active {
  background: var(--accent-light);
  border-color: rgba(129, 140, 248, 0.35);
  color: var(--text);
  font-weight: 600;
}

.category-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.category-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.category-item-count {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.address-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.address-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  cursor: pointer;
  transition: var(--transition);
}

.address-item:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.address-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}

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

.address-item-text {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.address-copy-mini {
  flex-shrink: 0;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.72rem;
  cursor: pointer;
  transition: var(--transition);
}

.address-copy-mini:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sidebar-empty-note {
  text-align: center;
  padding: 20px 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Right Area: Active Inbox Bar + Split Message Panes */
.mail-main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.active-inbox-bar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.active-inbox-empty-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.active-inbox-filled-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.active-address-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.active-address-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.active-address-text {
  font-family: var(--mono);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

.btn-copy-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-copy-sm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.active-address-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-select-sm {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.81rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.category-select-sm:focus {
  border-color: var(--accent);
}

.badge-permanent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

/* Split Message List + Reader */
.mail-split-panes {
  flex: 1;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

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

.panel-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.message-count-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--surface-2);
  padding: 2px 9px;
  border-radius: 9999px;
}

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

.inbox-empty-icon {
  margin-bottom: 14px;
  opacity: 0.45;
}

.inbox-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.inbox-empty-text {
  font-size: 0.84rem;
  max-width: 260px;
}

.message-list {
  display: flex;
  flex-direction: column;
}

.message-item {
  display: flex;
  flex-direction: column;
  padding: 14px 18px 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.message-item:hover {
  background: var(--surface-2);
}

.message-item.active {
  background: var(--accent-light);
  box-shadow: inset 3px 0 0 var(--accent);
}

.message-item.unread::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 20px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.message-item.unread .message-sender,
.message-item.unread .message-subject {
  font-weight: 700;
}

.message-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.message-sender {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-time {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

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

.message-preview {
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Column 3: Message Reader */
.message-detail-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow-y: auto;
}

.reader-placeholder {
  margin: auto;
  text-align: center;
  padding: 48px 24px;
  max-width: 340px;
  color: var(--muted);
}

.reader-placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.7;
}

.reader-placeholder-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.reader-placeholder-text {
  font-size: 0.84rem;
}

.message-detail-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.message-detail-header {
  display: none;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.message-detail-content {
  padding: 24px 28px;
}

.message-detail-subject {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 14px;
  line-height: 1.35;
}

.message-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.message-attachments {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.attachments-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.email-body-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.email-body-iframe {
  width: 100%;
  min-height: 420px;
  border: none;
  background: #ffffff;
  display: block;
}

.email-body-text {
  padding: 20px;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ----- View 2: Separate Create Email Page (#/create) ----- */
.create-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.create-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.create-page-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.create-page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}

.create-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 26px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.create-step-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--accent-light);
  color: var(--accent);
  margin-bottom: 10px;
}

.create-card-title {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.segmented-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
}

.segmented-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.segmented-btn.active {
  background: var(--accent);
  color: #ffffff;
}

.input-with-suffix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.input-with-suffix .form-input {
  border: none;
  border-radius: 0;
  background: transparent;
}

.domain-select-suffix {
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.84rem;
  padding: 0 12px;
  cursor: pointer;
  outline: none;
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.create-preview-box {
  margin-top: auto;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  background: var(--surface-2);
}

.create-preview-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.create-preview-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.inline-cat-box {
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.color-picker-input {
  width: 42px;
  height: 38px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.create-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  max-height: 210px;
  overflow-y: auto;
}

.create-cat-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.create-cat-option:hover {
  border-color: var(--accent);
  color: var(--text);
}

.create-cat-option.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

.permanent-info-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--success-light);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: var(--text);
  font-size: 0.8rem;
  margin-top: auto;
  margin-bottom: 16px;
}

.create-success-card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius-xl);
  padding: 24px 26px;
  box-shadow: var(--shadow-lg);
}

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

.success-status-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.email-address-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.email-address {
  flex: 1;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  word-break: break-all;
}

.btn-copy {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-copy:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.success-category-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.success-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ----- Forms, Modals, Login Gate, Toast ----- */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-error {
  padding: 9px 12px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.81rem;
  margin-bottom: 12px;
}

.login-gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.login-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  padding: 34px 30px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.login-gate-header {
  text-align: center;
  margin-bottom: 22px;
}

.login-gate-icon {
  font-size: 2.3rem;
  margin-bottom: 8px;
}

.login-gate-header h2 {
  font-size: 1.32rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-gate-header p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-lg {
  max-width: 680px;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.segmented-toggle-3 {
  grid-template-columns: repeat(3, 1fr);
}

.context-banner {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.81rem;
  line-height: 1.45;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.context-banner.context-auto {
  background: var(--accent-light);
  border-color: rgba(129, 140, 248, 0.4);
  color: var(--text);
}

.bulk-controls-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.bulk-presets-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.modal-category-section {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* ----- Auto-Detected OTP Code Banner & Quick-Copy Pill ----- */
.otp-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin-top: 7px;
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: var(--success-light);
  color: var(--success);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.otp-copy-chip:hover {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.otp-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  background: var(--success-light);
  border: 1px solid rgba(16, 185, 129, 0.42);
}

.otp-banner-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.otp-banner-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--success);
}

.otp-banner-code {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text);
}

.bulk-result-addr {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}

.modal-close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.saved-inboxes-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.saved-inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.saved-inbox-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Toast Container */
.toast-container {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 360px;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--accent); }

/* Legacy inline responsive block removed; unified 4-Tier Responsive System lives at the Outlook & Global Responsive section below. */

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}


/* === Dual-Mode Unified Category Inbox Additions === */
.unified-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.unified-context-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.unified-cat-dot {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.unified-context-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.unified-context-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.unified-context-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-back-unified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2, rgba(255, 255, 255, 0.05));
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-back-unified:hover {
  border-color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.14);
}

.category-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary, #6366f1);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 4px;
}

.address-unread-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.22);
  color: #a5b4fc;
  font-size: 0.7rem;
  font-weight: 700;
}

.message-badges-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.recipient-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text);
}

.detail-recipient-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}


/* ============================================================
   QiraunaMail - 2-Tab Mode Switcher & Outlook OTP Workspace
   ============================================================ */

.ol-workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100dvh - var(--header-h, 61px));
  overflow: hidden;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  position: relative;
}

.ol-sidebar-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100%;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.ol-sidebar-panel .sidebar-search-wrap {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.ol-main-area {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.15fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "inbox control"
    "inbox detail";
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.ol-inbox-panel {
  grid-area: inbox;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.ol-control-card {
  grid-area: control;
  margin: 16px 20px 0 20px;
  min-width: 0;
}

.ol-detail-panel {
  grid-area: detail;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px 20px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.ol-detail-header {
  display: none;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.ol-control-identity {
  min-width: 0;
  flex: 1;
}

.ol-accounts-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: none;
}

.ol-account-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ol-account-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.ol-account-item:hover { background: var(--surface-2); color: var(--text); }
.ol-account-item.active {
  background: var(--accent-light);
  border-color: rgba(129, 140, 248, 0.35);
  color: var(--text);
  font-weight: 600;
}

.ol-account-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ol-acc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ol-acc-dot.ok { background: #34d399; }
.ol-acc-dot.needs_reauth,
.ol-acc-dot.error { background: #f87171; }
.ol-acc-dot.rate_limited,
.ol-acc-dot.idle-warn { background: #fbbf24; }

.ol-account-email-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ol-mini-otp-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  flex-shrink: 0;
}

.ol-panel-header { display: flex; flex-direction: column; gap: 10px; }
.ol-panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ol-panel-title { font-size: 1.02rem; font-weight: 700; }
.ol-panel-actions { display: flex; align-items: center; gap: 8px; }

.ol-toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.ol-cards-list { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.ol-otp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ol-otp-card:hover { border-color: var(--accent); }
.ol-otp-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.ol-card-left { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ol-card-sender { font-weight: 700; font-size: 0.88rem; display: flex; align-items: center; gap: 6px; }
.ol-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.ol-card-account { font-size: 0.76rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-card-subject { font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

.ol-folder-badge {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  width: fit-content;
}
.ol-folder-badge.inbox { background: rgba(16, 185, 129, 0.14); color: #34d399; }
.ol-folder-badge.junkemail { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }

.ol-otp-pill-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.94rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
  cursor: pointer;
}
.ol-otp-pill-btn:hover { background: #10b981; color: #052e16; }
.ol-card-time { font-size: 0.72rem; color: var(--muted); }

.ol-control-card,
.ol-hero-card,
.ol-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.ol-control-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ol-control-email { font-size: 0.98rem; font-weight: 700; word-break: break-all; }
.ol-control-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ol-control-right { display: flex; align-items: center; gap: 8px; }

.ol-status-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
}
.ol-status-badge.needs_reauth,
.ol-status-badge.error { background: rgba(239, 68, 68, 0.14); color: #f87171; }
.ol-status-badge.rate_limited { background: rgba(245, 158, 11, 0.14); color: #fbbf24; }
.ol-idle-chip { font-size: 0.72rem; color: var(--muted); }

.ol-control-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.ol-btn-emerald { background: rgba(16, 185, 129, 0.14); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.4); }
.ol-btn-emerald.watching { background: #10b981; color: #052e16; box-shadow: 0 0 18px rgba(16, 185, 129, 0.45); }
.ol-btn-emerald-solid { background: #10b981; color: #042f2e; font-weight: 700; }
.ol-btn-warning { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }
.ol-btn-danger-ghost { background: transparent; color: #f87171; border: 1px solid rgba(248, 113, 113, 0.35); }

.ol-hero-card {
  border-color: rgba(52, 211, 153, 0.55);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(16, 185, 129, 0.08) 100%);
}
.ol-hero-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; color: #34d399; }
.ol-hero-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 8px; flex-wrap: wrap; }
.ol-hero-code { font-family: 'JetBrains Mono', monospace; font-size: 2.2rem; font-weight: 800; letter-spacing: 0.08em; color: #34d399; }
.ol-hero-meta { font-size: 0.78rem; color: var(--text-secondary); }

.ol-preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ol-preview-title { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.ol-preview-subject { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.ol-preview-addresses {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.ol-preview-body { font-size: 0.85rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.ol-empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-secondary);
  font-size: 0.86rem;
  margin: auto 0;
  max-width: 380px;
  align-self: center;
}
.ol-empty-icon { font-size: 2.2rem; margin-bottom: 10px; }

.ol-anti-lock-tip {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  font-size: 0.78rem;
  line-height: 1.45;
}

/* ============================================================
   4-Tier Adaptive Responsive System (QiraunaMail)
   Tier 1: >= 1200px  -> Full 3 Columns
   Tier 2: 820-1199px -> 2 Columns (Sidebar + Inbox ALWAYS visible) + Slide-Over Detail Drawer
   Tier 3: 640-819px  -> Inbox-First + Left Sidebar Drawer + Right Detail Drawer
   Tier 4: < 640px    -> Mobile Single-Pane Tabs + Compact Header
   ============================================================ */

.btn,
.btn-icon-xs,
.btn-secondary-sm,
.user-chip,
.sidebar-block-actions,
.sidebar-block-title {
  white-space: nowrap;
  flex-shrink: 0;
}

.mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.mode-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-tab-btn:hover { color: var(--text); }

.mode-tab-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.mode-tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: inherit;
  white-space: nowrap;
}

.nav-tab-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ol-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #34d399;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

.ol-status-indicator.has-warning {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
}

@media (max-width: 1320px) {
  .logo-sub-badge { display: none; }
}

/* Tier 2: Windowed / Split-Screen Laptop (820px - 1199px, incl. 960px half-screen) */
@media (max-width: 1199px) {
  .header-inner { padding: 0 14px; gap: 10px; }
  .header-right,
  .auth-nav-area,
  .nav-tab-controls { gap: 7px; }
  .mode-tabs { padding: 3px; gap: 4px; }
  .mode-tab-btn { padding: 5px 10px; font-size: 0.78rem; }
  .mode-tab-count,
  .hide-compact { display: none; }

  .user-chip {
    max-width: 116px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Temp Mail: Keep 240px Sidebar + Inbox visible; Detail becomes right Slide-Over Drawer */
  .inbox-workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .mail-split-panes {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .message-list-panel {
    border-right: none;
  }

  .message-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(540px, 94%);
    z-index: 35;
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 42px rgba(0, 0, 0, 0.5);
    transform: translateX(104%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
  }

  .mail-split-panes.detail-open .message-detail-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .message-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  /* Outlook OTP: Keep 240px Sidebar + Control Bar + Inbox visible; Detail becomes right Slide-Over Drawer */
  .ol-workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .ol-main-area {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "control"
      "inbox";
  }

  .ol-inbox-panel {
    border-right: none;
    padding: 14px 16px;
  }

  .ol-control-card {
    margin: 12px 16px 0 16px;
    padding: 12px 14px;
  }

  .ol-detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(540px, 94%);
    z-index: 35;
    padding: 14px 18px 20px;
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 42px rgba(0, 0, 0, 0.5);
    transform: translateX(104%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
  }

  .ol-workspace[data-ol-detail-open="true"] .ol-detail-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .ol-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}

@media (max-width: 1120px) {
  .docs-link-text { display: none; }
}

@media (max-width: 960px) {
  .user-chip { display: none; }
}

/* Tier 3: Tablet Portrait / Narrow Split (640px - 819px) -> Inbox-First + Left Sidebar Drawer */
@media (max-width: 819px) {
  .header-inner {
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .header-left { flex-shrink: 0; }
  .header-right { margin-left: auto; }
  .mode-tabs { order: 3; width: 100%; justify-content: center; }
  .mode-tab-btn { flex: 1; justify-content: center; }

  .status-indicator .status-text,
  .ol-status-indicator .status-text { display: none; }

  .tablet-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
  }

  .inbox-workspace,
  .ol-workspace {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .sidebar-panel,
  .ol-sidebar-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 45;
    box-shadow: 16px 0 42px rgba(0, 0, 0, 0.52);
    transform: translateX(-105%);
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .inbox-workspace[data-sidebar-open="true"] .sidebar-panel,
  .ol-workspace[data-ol-sidebar-open="true"] .ol-sidebar-panel {
    transform: translateX(0);
    pointer-events: auto;
  }

  .message-detail-panel,
  .ol-detail-panel {
    width: min(540px, 100%);
  }

  .create-grid {
    grid-template-columns: 1fr;
  }
}

/* Tier 4: Mobile (< 640px) -> Compact Single-Pane Tabs */
@media (max-width: 639px) {
  .hide-xs { display: none; }
  .tablet-sidebar-toggle { display: none !important; }
  .drawer-backdrop { display: none !important; }

  .mobile-pane-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  #ol-mobile-pane-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .mobile-pane-btn {
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-pane-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--text);
  }

  .inbox-workspace,
  .ol-workspace {
    display: block;
    height: auto;
    min-height: calc(100dvh - var(--header-h, 110px) - 52px);
    overflow: visible;
  }

  .sidebar-panel,
  .ol-sidebar-panel,
  .message-detail-panel,
  .ol-detail-panel {
    position: static;
    width: 100%;
    height: auto;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    box-shadow: none;
    border-right: none;
    border-left: none;
  }

  /* Temp Mail Mobile Pane Switcher */
  .inbox-workspace[data-mobile-active="sidebar"] .mail-main-area { display: none; }
  .inbox-workspace[data-mobile-active="messages"] .sidebar-panel { display: none; }
  .inbox-workspace[data-mobile-active="messages"] .mail-split-panes .message-detail-panel { display: none; }
  .inbox-workspace[data-mobile-active="messages"] .mail-split-panes.detail-open .message-list-panel { display: none; }
  .inbox-workspace[data-mobile-active="messages"] .mail-split-panes.detail-open .message-detail-panel { display: flex; }

  /* Outlook Mobile Pane Switcher */
  .ol-workspace .ol-sidebar-panel,
  .ol-workspace .ol-main-area,
  .ol-workspace .ol-inbox-panel,
  .ol-workspace .ol-control-card,
  .ol-workspace .ol-detail-panel {
    display: none;
    height: auto;
  }

  .ol-workspace[data-ol-mobile-pane="sidebar"] .ol-sidebar-panel {
    display: flex;
  }

  .ol-workspace[data-ol-mobile-pane="inbox"] .ol-main-area,
  .ol-workspace[data-ol-mobile-pane="inbox"] .ol-inbox-panel {
    display: flex;
  }

  .ol-workspace[data-ol-mobile-pane="inbox"][data-ol-has-account="true"] .ol-control-card {
    display: block;
    margin: 10px 12px 0;
  }

  .ol-workspace[data-ol-mobile-pane="detail"] .ol-main-area,
  .ol-workspace[data-ol-mobile-pane="detail"] .ol-detail-panel {
    display: flex;
  }
}

@media (min-width: 640px) and (max-width: 1199px) {
  #ol-account-empty-placeholder {
    display: none !important;
  }
}

/* ----- Protected API Docs & Permanent API Key Portal (/docs) ----- */
.docs-body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.docs-gate-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.docs-gate-footer {
  margin-top: 14px;
  text-align: center;
}

.docs-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.docs-nav {
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-nav-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 4px 10px 8px;
}

.docs-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: 8px;
  transition: var(--transition);
}

.docs-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.docs-content {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.docs-hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.docs-hero p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.docs-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  padding-top: 8px;
}

.docs-section > p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.docs-callout {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  border: 1px solid rgba(129, 140, 248, 0.35);
  font-size: 0.84rem;
  line-height: 1.5;
  margin-bottom: 14px;
}

.docs-callout-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}

.docs-card,
.docs-endpoint,
.docs-code-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
}

.docs-ep-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.docs-ep-head code {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
}

.docs-ep-note {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.docs-endpoint p {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.method {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.method.get { background: rgba(16, 185, 129, 0.16); color: #34d399; }
.method.post { background: rgba(99, 102, 241, 0.2); color: #818cf8; }

.docs-endpoint pre,
.docs-code-card pre {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.79rem;
  line-height: 1.55;
  margin: 0;
}

.docs-copy-btn {
  margin-top: 8px;
}

.docs-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  font-weight: 700;
}

.docs-lang-tabs {
  display: flex;
  gap: 6px;
}

.docs-lang-tabs .btn.active {
  background: var(--accent);
  color: #fff;
}

.docs-key-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.docs-key-form .form-input {
  flex: 1;
  min-width: 220px;
}

.docs-created-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.4);
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.docs-created-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 4px;
}

.docs-created-code {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.docs-keys-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docs-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  flex-wrap: wrap;
}

.docs-key-name {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.docs-key-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.docs-empty-keys {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.83rem;
}

.docs-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  background: var(--surface);
}

.docs-table th,
.docs-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.docs-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--surface-2);
}

@media (max-width: 900px) {
  .docs-container {
    grid-template-columns: 1fr;
  }
  .docs-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .docs-nav-title {
    width: 100%;
  }
}
