/* ==========================================================================
   VinhLab Mail — Clean, Intuitive Modern Mail & OTP Interface
   Supports Crisp Light Mode (Default) & Refined Dark Mode ([data-theme="dark"])
   ========================================================================== */

:root {
  --bg-app: #f1f5f9;
  --bg-sidebar: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-active: #eff6ff;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #3b82f6;

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-text: #1e40af;

  --otp-bg: #ecfdf5;
  --otp-border: #6ee7b7;
  --otp-accent: #059669;
  --otp-accent-hover: #047857;
  --otp-text: #065f46;

  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #b45309;

  --danger-bg: #fef2f2;
  --danger-text: #dc2626;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.16);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

html[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-sidebar: #0f172a;
  --bg-surface: #131c2e;
  --bg-subtle: #1e293b;
  --bg-hover: #1e293b;
  --bg-active: rgba(59, 130, 246, 0.16);

  --border-light: #1e293b;
  --border-medium: #334155;
  --border-focus: #60a5fa;

  --text-main: #f8fafc;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --primary-text: #93c5fd;

  --otp-bg: rgba(16, 185, 129, 0.12);
  --otp-border: rgba(16, 185, 129, 0.38);
  --otp-accent: #10b981;
  --otp-accent-hover: #059669;
  --otp-text: #34d399;

  --amber-bg: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(245, 158, 11, 0.35);
  --amber-text: #fbbf24;

  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-text: #f87171;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-main);
  background: var(--bg-app);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 999px;
}

/* ==========================================================================
   MAIN LAYOUT (2 CLEAR ZONES: LEFT SIDEBAR + RIGHT STAGE)
   ========================================================================== */

.app-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ==================== LEFT SIDEBAR ==================== */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-brand {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.brand-domain {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.brand-actions {
  display: flex;
  gap: 4px;
}

.icon-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.icon-action-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

/* Create Email Box in Sidebar */
.create-box {
  margin: 0 12px 12px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-random-hero {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-random-hero:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-random-icon {
  font-size: 20px;
}

.btn-random-text {
  display: flex;
  flex-direction: column;
}
.btn-random-text strong {
  font-size: 13.5px;
  font-weight: 700;
}
.btn-random-text span {
  font-size: 11px;
  opacity: 0.88;
}

.create-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
}
.create-divider::before,
.create-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-light);
}
.create-divider span {
  padding: 0 8px;
}

.custom-create-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-email-field {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.custom-email-field:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-surface);
}
.custom-email-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 7px 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}
.custom-email-domain {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 7px 8px 7px 4px;
  user-select: none;
}

.custom-note-row {
  display: flex;
  gap: 6px;
}
.custom-note-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
}
.custom-note-row input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
}

.btn-create-submit {
  padding: 0 13px;
  background: var(--primary-soft);
  color: var(--primary-text);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-create-submit:hover {
  background: var(--primary);
  color: #fff;
}

.service-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.service-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.14s ease;
}
.service-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-active);
}

/* Sidebar Navigation & Saved Mailboxes */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
}

.nav-all-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  margin-bottom: 12px;
}
.nav-all-btn:hover {
  border-color: var(--border-medium);
}
.nav-all-btn.active {
  background: var(--bg-active);
  border-color: var(--primary);
}

.nav-all-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nav-all-icon {
  font-size: 18px;
}
.nav-all-title {
  font-size: 13px;
  font-weight: 700;
}
.nav-all-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.pill-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-body);
}
.nav-all-btn.active .pill-count {
  background: var(--primary);
  color: #fff;
}

.sidebar-section-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding: 0 4px;
}

.sidebar-search-wrap {
  margin-bottom: 8px;
}
.sidebar-search-wrap input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
}
.sidebar-search-wrap input:focus {
  border-color: var(--border-focus);
}

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

.mailbox-row {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.14s ease;
  position: relative;
}
.mailbox-row:hover {
  background: var(--bg-surface);
  border-color: var(--border-light);
  box-shadow: var(--shadow-xs);
}
.mailbox-row.active {
  background: var(--bg-active);
  border-color: var(--primary);
}

.mailbox-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mailbox-row-addr {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-row-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 3px;
}

.mailbox-row-note {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-otp-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--otp-bg);
  color: var(--otp-text);
  border: 1px solid var(--otp-border);
  padding: 1px 6px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.mailbox-otp-pill:hover {
  background: var(--otp-accent);
  color: #fff;
}

.mailbox-unread-dot {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Hover Quick Actions on Mailbox Row (Giu cho binh thuong cuc ky sach se!) */
.mailbox-hover-actions {
  display: none;
  align-items: center;
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 1px 3px;
  box-shadow: var(--shadow-xs);
}
.mailbox-row:hover .mailbox-hover-actions {
  display: inline-flex;
}
.mailbox-row:hover .mailbox-unread-dot {
  display: none;
}

.mini-act-btn {
  border: none;
  background: transparent;
  padding: 2px 5px;
  font-size: 11.5px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
}
.mini-act-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* ==================== RIGHT MAIN STAGE ==================== */
.main-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-app);
}

/* Stage Header (Hero Active Mailbox) */
.stage-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.hero-kicker {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 2px;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-address {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.hero-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.hero-desc code {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 600;
}

.btn-copy-email {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-soft);
  color: var(--primary-text);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-copy-email:hover {
  background: var(--primary);
  color: #fff;
}

.hero-note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 12.5px;
}
.hero-note-display {
  color: var(--text-muted);
}
.btn-link-edit {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link-edit:hover {
  text-decoration: underline;
}

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

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-tool:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}
.btn-tool.active {
  border-color: var(--otp-border);
  color: var(--otp-text);
  background: var(--otp-bg);
}

.btn-tool-test {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-text);
  font-weight: 700;
}
.btn-tool-test:hover {
  filter: brightness(0.97);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.btn-tool.active .status-dot {
  background: var(--otp-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ==================== OTP SPOTLIGHT BANNER ==================== */
.otp-spotlight {
  margin: 12px 16px 0;
  padding: 12px 18px;
  background: var(--otp-bg);
  border: 1px solid var(--otp-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.otp-spotlight-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.otp-spotlight-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--otp-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.otp-spotlight-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--otp-text);
}

.otp-spotlight-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.otp-spotlight-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.otp-spotlight-digits {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--otp-text);
  background: var(--bg-surface);
  padding: 4px 14px;
  border-radius: 8px;
  border: 1px dashed var(--otp-border);
}

.btn-copy-otp-hero {
  padding: 9px 16px;
  border-radius: 9px;
  border: none;
  background: var(--otp-accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.24);
  transition: all 0.15s ease;
}
.btn-copy-otp-hero:hover {
  background: var(--otp-accent-hover);
  transform: translateY(-1px);
}

/* ==================== INBOX MASTER-DETAIL SPLIT ==================== */
.inbox-split {
  flex: 1;
  min-height: 0;
  margin: 12px 16px 16px;
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 14px;
}

.inbox-list-pane,
.inbox-reader-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.inbox-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inbox-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 9px;
}

.inbox-tab {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.14s ease;
}
.inbox-tab.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-xs);
}

.inbox-search {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
}
.inbox-search:focus {
  background: var(--bg-surface);
  border-color: var(--border-focus);
}

.email-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Email Item Card */
.mail-card {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}
.mail-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-hover);
}
.mail-card.active {
  background: var(--bg-active);
  border-color: var(--primary);
}
.mail-card.unread .mail-subject {
  font-weight: 800;
}

.sender-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
  background: #475569;
}

.mail-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mail-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mail-sender-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-time {
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.mail-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  line-height: 1.38;
}

.mail-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.mail-recipient-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 2px 7px;
  border-radius: 5px;
}

.btn-inline-otp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--otp-border);
  background: var(--otp-bg);
  color: var(--otp-text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}
.btn-inline-otp:hover {
  background: var(--otp-accent);
  color: #ffffff;
}
.btn-inline-otp .copy-hint {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
}

/* ==================== READER PANE ==================== */
.reader-placeholder {
  margin: auto;
  max-width: 440px;
  padding: 32px;
  text-align: center;
}

.placeholder-illustration {
  font-size: 46px;
  margin-bottom: 12px;
}

.reader-placeholder h3 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.reader-placeholder p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 22px;
}

.steps-mini-guide {
  text-align: left;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-mini {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-body);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.reader-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.reader-top {
  padding: 18px 22px 0;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.reader-title-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.reader-subject {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
}

.btn-delete-mail {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-delete-mail:hover {
  filter: brightness(0.95);
}

.reader-people-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.reader-people-meta {
  flex: 1;
  min-width: 0;
}

.reader-from {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-to-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.reader-to-chip {
  border: none;
  background: var(--primary-soft);
  color: var(--primary-text);
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.reader-to-chip:hover {
  text-decoration: underline;
}

.reader-timestamp {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.reader-otp-box {
  background: var(--otp-bg);
  border: 1px solid var(--otp-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reader-otp-caption {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--otp-text);
}

.reader-otp-number {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--otp-text);
}

.reader-mode-switch {
  display: flex;
  gap: 18px;
}

.view-tab {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 8px 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.reader-frame-container {
  flex: 1;
  min-height: 0;
  background: #ffffff;
}

.reader-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.reader-raw-box {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 20px;
  background: var(--bg-surface);
  color: var(--text-body);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==================== MODALS & TOAST ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-dialog {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-dialog.modal-wide {
  max-width: 640px;
}

.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 {
  font-size: 16px;
  font-weight: 800;
}

.modal-close-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 80vh;
  overflow-y: auto;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-body);
}
.field-group input,
.field-group select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-medium);
  background: var(--bg-subtle);
  color: var(--text-main);
  outline: none;
}
.field-group input:focus,
.field-group select:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.btn-secondary {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-body);
  font-weight: 600;
  cursor: pointer;
}

.btn-primary-solid {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.guide-card {
  padding: 14px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
}
.guide-card h4 {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--primary);
}
.guide-card ol {
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-body);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.guide-note {
  font-size: 12px;
  color: var(--text-muted);
}
.code-snippet {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
}

.empty-state-small {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeUp 0.18s ease-out;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 1080px) {
  .app-layout {
    grid-template-columns: 270px 1fr;
  }
  .inbox-split {
    grid-template-columns: 330px 1fr;
  }
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    max-height: 440px;
  }
  .inbox-split {
    grid-template-columns: 1fr;
    height: auto;
  }
  .inbox-list-pane {
    max-height: 420px;
  }
  .inbox-reader-pane {
    min-height: 500px;
  }
}
