/* ==========================================================================
   大锤邮件 · Apple Liquid Glass (macOS × visionOS) Design System
   Strict Token Compliance:
   - Light Ambient: #DBEAFE + #EDE9FE + #FCE7F3 on #EEF4FC
   - Dark Ambient:  #1E3A8A/35% + #581C87/30% on #090D18
   - Glass Panel:   Light rgba(255,255,255,.72) / Slot rgba(255,255,255,.46)
                    Dark  rgba(26,31,46,.68) / Border rgba(255,255,255,.16)
                    blur(22px) saturate(1.6) + specular top inset highlight
   - Max 2 glass backdrop-filter layers stacked
   - Radii: Window 26px | Cards 18px | Inputs 14px | Pills/Segments 9999px
   - Motion: 180ms–260ms smooth ease-out
   ========================================================================== */

:root {
  color-scheme: light;
  --bg-base: #EEF4FC;
  --glow-1: #DBEAFE;
  --glow-2: #EDE9FE;
  --glow-3: #FCE7F3;

  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-slot: rgba(255, 255, 255, 0.46);
  --glass-card: rgba(255, 255, 255, 0.56);
  --glass-card-hover: rgba(255, 255, 255, 0.78);
  --glass-card-active: rgba(255, 255, 255, 0.90);
  --glass-input-bg: rgba(255, 255, 255, 0.66);
  --glass-modal-bg: rgba(255, 255, 255, 0.90);

  --glass-border: rgba(255, 255, 255, 0.80);
  --glass-inner-border: rgba(29, 29, 31, 0.08);
  --glass-specular: rgba(255, 255, 255, 0.96);
  --glass-shadow: 0 24px 60px rgba(31, 56, 100, 0.12), 0 4px 16px rgba(31, 56, 100, 0.06);
  --card-shadow: 0 2px 10px rgba(31, 56, 100, 0.045);

  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --accent: #007AFF;
  --accent-soft: rgba(0, 122, 255, 0.13);
  --accent-hover: #0066D6;
  --online: #34C759;
  --online-soft: rgba(52, 199, 89, 0.16);
  --warn: #FF9500;
  --warn-soft: rgba(255, 149, 0, 0.16);
  --danger: #FF3B30;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --star-color: #FF9F0A;

  --scrim-bg: rgba(15, 23, 42, 0.28);
  --code-bg: rgba(29, 29, 31, 0.055);
  --divider: rgba(29, 29, 31, 0.08);
  --scrollbar-thumb: rgba(29, 29, 31, 0.16);

  --radius-window: 26px;
  --radius-card: 18px;
  --radius-input: 14px;
  --radius-pill: 9999px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 180ms;
  --dur-base: 220ms;
  --dur-slow: 260ms;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #090D18;
  --glow-1: rgba(30, 58, 138, 0.35);
  --glow-2: rgba(88, 28, 135, 0.30);
  --glow-3: rgba(30, 58, 138, 0.22);

  --glass-bg: rgba(26, 31, 46, 0.68);
  --glass-slot: rgba(16, 20, 32, 0.50);
  --glass-card: rgba(30, 36, 54, 0.54);
  --glass-card-hover: rgba(38, 46, 68, 0.74);
  --glass-card-active: rgba(45, 55, 82, 0.88);
  --glass-input-bg: rgba(14, 18, 30, 0.64);
  --glass-modal-bg: rgba(26, 31, 46, 0.90);

  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-inner-border: rgba(255, 255, 255, 0.10);
  --glass-specular: rgba(255, 255, 255, 0.22);
  --glass-shadow: 0 28px 72px rgba(0, 0, 0, 0.52), 0 4px 18px rgba(0, 0, 0, 0.32);
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);

  --text-primary: #F5F5F7;
  --text-secondary: #A1A1AA;
  --accent: #0A84FF;
  --accent-soft: rgba(10, 132, 255, 0.20);
  --accent-hover: #3399FF;
  --online: #34C759;
  --online-soft: rgba(52, 199, 89, 0.20);
  --warn: #FF9F0A;
  --warn-soft: rgba(255, 159, 10, 0.20);
  --danger: #FF453A;
  --danger-soft: rgba(255, 69, 58, 0.18);
  --star-color: #FFD60A;

  --scrim-bg: rgba(4, 7, 15, 0.56);
  --code-bg: rgba(9, 13, 24, 0.62);
  --divider: rgba(255, 255, 255, 0.10);
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-base) var(--ease-out);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

/* Ambient Multi-Point Radial Glow Canvas */
.ambient-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(62% 58% at 12% 14%, var(--glow-1) 0%, transparent 72%),
    radial-gradient(56% 52% at 88% 18%, var(--glow-2) 0%, transparent 70%),
    radial-gradient(58% 55% at 52% 92%, var(--glow-3) 0%, transparent 72%);
  transition: background-color var(--dur-slow) var(--ease-out);
}

/* ==========================================================================
   Auth Gate Screen (Layer 1 Liquid Glass Card, radius 26px)
   ========================================================================== */
.auth-gate {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100dvh;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.auth-gate-card {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-window);
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--glass-shadow);
  padding: 26px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-hero h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.auth-hero p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.auth-primary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.local-dev-box {
  padding: 14px 16px;
  border-radius: var(--radius-card);
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.local-dev-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.local-dev-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.local-custom-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.local-custom-form .glass-input {
  flex: 1;
}

/* ==========================================================================
   Main App Window Frame (Layer 1 Liquid Glass, radius 26px)
   ========================================================================== */
.app-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  padding: 18px;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app-shell {
  width: 100%;
  max-width: 1520px;
  height: 100%;
  border-radius: var(--radius-window);
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--glass-shadow);
  display: grid;
  grid-template-columns: 276px 368px minmax(0, 1fr);
  overflow: hidden;
  transition:
    background-color var(--dur-slow) var(--ease-out),
    border-color var(--dur-slow) var(--ease-out),
    box-shadow var(--dur-slow) var(--ease-out);
}

.sidebar-scroll::-webkit-scrollbar,
.mail-list-scroll::-webkit-scrollbar,
.detail-scroll::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar-scroll::-webkit-scrollbar-thumb,
.mail-list-scroll::-webkit-scrollbar-thumb,
.detail-scroll::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 9999px;
}

/* ==========================================================================
   Column 1: Left Sidebar
   ========================================================================== */
.sidebar {
  background: var(--glass-slot);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  flex-shrink: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent), #5AC8FA);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-mark.mascot-mark {
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
  padding: 2px;
  overflow: hidden;
}

.brand-mark.mascot-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  min-width: 0;
  flex: 1;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-secondary);
}

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

.status-dot.needs_auth {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.status-dot.syncing {
  background: var(--accent);
  animation: pulseDot 1.2s ease-in-out infinite;
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  box-shadow: inset 0 1px 0 var(--glass-specular);
  min-width: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--accent), #AF52DE);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.user-name {
  font-size: 12.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.founder-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.user-handle {
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtle-logout {
  background: var(--divider);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.subtle-logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.nav-section-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  padding: 0 8px;
}

.nav-section-header .nav-section-title {
  padding: 0;
}

.nav-list, .account-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.nav-item:hover {
  background: var(--glass-card);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #FFFFFF;
}

.nav-badge.subtle {
  background: var(--divider);
  color: var(--text-secondary);
}

.nav-badge.empty {
  display: none;
}

.account-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  transition: background-color var(--dur-fast) var(--ease-out);
  cursor: pointer;
}

.account-item:hover {
  background: var(--glass-card);
}

.account-item.active {
  background: var(--glass-card-active);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
}

.account-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}

.account-avatar .status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg-base);
}

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

.account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email {
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.account-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.auth-tag-btn {
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.auth-tag-btn:hover {
  background: var(--warn);
  color: #FFFFFF;
}

.account-edit-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0.72;
  transition: opacity var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.account-item:hover .account-edit-btn,
.account-item.active .account-edit-btn {
  opacity: 1;
}

.account-edit-btn:hover {
  background: var(--divider);
  color: var(--text-primary);
}

.sidebar-empty-hint {
  padding: 12px;
  border-radius: 14px;
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.sidebar-footer {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================================
   Buttons, Pills & Segmented Controls (9999px)
   ========================================================================== */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

.pill-btn:active {
  transform: scale(0.97);
}

.pill-btn.small {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.pill-btn.full-width {
  width: 100%;
}

.pill-btn.primary {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(0, 122, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.30);
}

.pill-btn.primary:hover {
  background: var(--accent-hover);
}

.pill-btn.ghost {
  background: var(--glass-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-inner-border);
  box-shadow: inset 0 1px 0 var(--glass-specular);
}

.pill-btn.ghost:hover {
  background: var(--glass-card-hover);
}

.pill-btn.danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill-btn.danger-ghost:hover {
  opacity: 0.88;
}

.mini-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.mini-pill-btn:hover {
  background: var(--accent);
  color: #FFFFFF;
}

.icon-pill-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-card);
  color: var(--text-primary);
  border: 1px solid var(--glass-inner-border);
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.icon-pill-btn.mobile-close-drawer {
  display: none;
}

.icon-pill-btn:hover {
  background: var(--glass-card-hover);
}

.icon-pill-btn:active {
  transform: scale(0.95);
}

.icon-pill-btn.primary-icon-btn {
  background: var(--accent);
  color: #FFFFFF;
  border-color: transparent;
}

.icon-pill-btn.danger-hover:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.icon-pill-btn.starred {
  color: var(--star-color);
}

.icon-pill-btn.spinning .sync-icon {
  animation: spin 0.85s linear infinite;
}

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

.segmented-control,
.theme-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  gap: 2px;
}

.seg-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  background: var(--glass-card-active);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 1px 0 var(--glass-specular);
}

/* ==========================================================================
   Column 2: Mail List Pane
   ========================================================================== */
.list-pane {
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.list-header {
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.list-title-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.list-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-meta {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-secondary);
  pointer-events: none;
}

.glass-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-input);
  background: var(--glass-input-bg);
  border: 1px solid var(--glass-inner-border);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.glass-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.85;
}

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

.search-input {
  padding-left: 36px;
}

.glass-select {
  cursor: pointer;
  padding-right: 28px;
}

[data-theme="dark"] .glass-select option {
  background-color: #1A1F2E;
  color: #F5F5F7;
}

.glass-textarea {
  height: auto;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.6;
}

.mail-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mail-card {
  position: relative;
  padding: 13px 14px;
  border-radius: var(--radius-card);
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  transition:
    background-color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.mail-card:hover {
  background: var(--glass-card-hover);
  transform: translateY(-1px);
}

.mail-card.active {
  background: var(--glass-card-active);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 8px 22px rgba(0, 122, 255, 0.12), inset 0 1px 0 var(--glass-specular);
}

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

.mail-sender-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

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

.mail-card.unread .mail-sender,
.mail-card.unread .mail-card-subject {
  font-weight: 700;
}

.mail-card-time {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.mail-card-subject {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mail-card-snippet {
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mail-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
  min-width: 0;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 23px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  color: var(--text-secondary);
  min-width: 0;
}

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

.chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-card-flags {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.flag-star {
  color: var(--star-color);
  display: inline-flex;
}

.list-empty-state {
  margin: auto;
  text-align: center;
  padding: 28px 16px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.list-empty-state h4 {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
}

.list-empty-state p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Setup Checklist inside Empty Pane */
.setup-card-list {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 14px;
  text-align: left;
}

.setup-box-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
  min-width: 0;
}

.setup-box-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.setup-box-meta {
  min-width: 0;
  flex: 1;
}

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

.setup-box-email {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Column 3: Reading / Detail Pane
   ========================================================================== */
.detail-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.detail-empty {
  margin: auto;
  text-align: center;
  padding: 28px 24px;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-orb {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--glass-card);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.detail-empty h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.detail-empty p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.detail-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.detail-toolbar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.detail-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.mobile-back-btn {
  display: none;
}

.detail-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 28px;
}

.reading-card {
  background: var(--glass-card);
  border: 1px solid var(--glass-inner-border);
  border-radius: var(--radius-card);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--card-shadow);
  padding: 24px 26px;
  min-width: 0;
}

.mail-subject {
  margin: 0 0 18px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.mail-meta-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 16px;
  border-radius: 15px;
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  margin-bottom: 18px;
}

.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #5AC8FA);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sender-info {
  flex: 1;
  min-width: 0;
}

.sender-top-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sender-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.mail-time {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sender-address {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.recipient-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  flex-wrap: wrap;
}

.meta-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.meta-value {
  color: var(--text-primary);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 100%;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.attachment-pill:hover {
  background: var(--glass-card-active);
  border-color: var(--accent);
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.attachment-size {
  font-size: 11.5px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.mail-body-host {
  min-height: 120px;
  padding-top: 4px;
  overflow-x: auto;
}

/* ==========================================================================
   Modals (Layer 2 Glass over clean non-blurred Scrim)
   ========================================================================== */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--scrim-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fadeIn var(--dur-fast) var(--ease-out);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  width: 100%;
  max-width: 600px;
  max-height: min(90dvh, 780px);
  border-radius: var(--radius-window);
  background: var(--glass-modal-bg);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--glass-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop var(--dur-base) var(--ease-out);
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.modal-body {
  padding: 18px 22px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid transparent;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.color-dot:hover {
  transform: scale(1.1);
}

.color-dot.active {
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px var(--swatch);
}

.server-section {
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}

.port-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-input);
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.test-result-box {
  padding: 11px 14px;
  border-radius: var(--radius-input);
  font-size: 13px;
  line-height: 1.5;
}

.test-result-box.success {
  background: var(--online-soft);
  color: var(--online);
}

.test-result-box.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.info-card {
  padding: 14px 16px;
  border-radius: var(--radius-card);
  background: var(--glass-slot);
  border: 1px solid var(--glass-inner-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.info-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.token-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-copy-row .info-code {
  flex: 1;
  min-width: 0;
}

.code-block-wrap {
  border-radius: var(--radius-card);
  background: var(--code-bg);
  border: 1px solid var(--glass-inner-border);
  overflow: hidden;
}

.code-block-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.code-block {
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
}

.modal-footer-left,
.modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: var(--glass-modal-bg);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-specular), var(--glass-shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn var(--dur-base) var(--ease-out);
}

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--online); }
.toast.error .toast-dot { background: var(--danger); }

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

.mobile-topbar { display: none; }
.drawer-scrim { display: none; }

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

/* ==========================================================================
   Tablet Responsive (<= 1120px)
   ========================================================================== */
@media (max-width: 1120px) {
  .app-frame {
    padding: 12px;
  }

  .app-shell {
    grid-template-columns: 248px 320px minmax(0, 1fr);
  }
}

/* ==========================================================================
   Mobile Responsive (<= 900px, verified at 390px)
   ========================================================================== */
@media (max-width: 900px) {
  .app-frame {
    padding: 8px;
  }

  .auth-gate {
    padding: 12px;
  }

  .auth-gate-card {
    padding: 20px 18px;
  }

  .app-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--divider);
    background: var(--glass-slot);
    flex-shrink: 0;
    min-width: 0;
  }

  .mobile-topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
  }

  .mobile-title-wrap {
    min-width: 0;
    flex: 1;
  }

  .mobile-title {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-subtitle {
    display: block;
    font-size: 11.5px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .sidebar {
    position: fixed;
    top: 8px;
    bottom: 8px;
    left: 8px;
    width: min(304px, calc(100vw - 44px));
    z-index: 50;
    border-radius: var(--radius-window);
    background: var(--glass-modal-bg);
    backdrop-filter: blur(22px) saturate(1.6);
    -webkit-backdrop-filter: blur(22px) saturate(1.6);
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 1px 0 var(--glass-specular), var(--glass-shadow);
    transform: translateX(calc(-100% - 20px));
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--dur-base) var(--ease-out), visibility var(--dur-base) var(--ease-out);
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .icon-pill-btn.mobile-close-drawer {
    display: inline-flex;
  }

  .drawer-scrim.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: var(--scrim-bg);
  }

  .list-pane {
    flex: 1;
    border-right: none;
    min-height: 0;
  }

  .list-header {
    padding: 12px 12px 10px;
    gap: 9px;
  }

  .list-title-row {
    display: none;
  }

  .mail-list-scroll {
    padding: 10px 10px 16px;
  }

  .detail-pane {
    display: none;
    flex: 1;
    min-height: 0;
  }

  .app-shell.mobile-reading .list-pane {
    display: none;
  }

  .app-shell.mobile-reading .detail-pane {
    display: flex;
  }

  .mobile-back-btn {
    display: inline-flex;
    height: 32px;
    padding: 0 11px;
    font-size: 12.5px;
  }

  .detail-toolbar {
    padding: 10px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .detail-scroll {
    padding: 12px 10px 20px;
  }

  .reading-card {
    padding: 16px 14px;
  }

  .mail-subject {
    font-size: 17.5px;
    margin-bottom: 14px;
  }

  .mail-meta-card {
    padding: 12px;
    gap: 10px;
  }

  .sender-avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    font-size: 14px;
  }

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

  .modal-scrim {
    padding: 10px;
  }

  .modal-header {
    padding: 16px 16px 12px;
  }

  .modal-body {
    padding: 14px 16px 16px;
  }

  .toast-container {
    right: 12px;
    left: 12px;
    bottom: 12px;
    align-items: center;
  }
}

@media (max-width: 420px) {
  .seg-btn {
    font-size: 12px;
    padding: 0 6px;
  }

  .pill-btn.small {
    padding: 0 11px;
    font-size: 12.5px;
  }

  .detail-toolbar-left .account-chip {
    max-width: 150px;
  }

  .local-custom-form {
    flex-direction: column;
    align-items: stretch;
  }
}
