/* ==========================================================================
   ZOK MAIL v3: AIRY FROSTED GLASS DESIGN SYSTEM & DETACHED 3-PANEL SHELL
   Tokens: pearl (Frosted Airy Light default) & glass (Smoky Dark Glass)
   ========================================================================== */

:root,
html[data-theme="pearl"],
html[data-theme="paper"],
html[data-theme="alabaster"],
html[data-theme="alabaster-studio"],
html[data-theme="light"] {
  color-scheme: light;

  --bg-canvas: #EDF0F5;
  --bg-canvas-gradient: linear-gradient(145deg, #F2F4F8 0%, #E7EBF2 100%);
  --bg-panel: rgba(255, 255, 255, 0.88);
  --bg-surface: #FFFFFF;
  --bg-track: #F3F4F7;
  --bg-card-active: #F5F6F9;
  --bg-pill: #FFFFFF;

  --border-panel: rgba(15, 23, 42, 0.07);
  --border-subtle: rgba(15, 23, 42, 0.06);
  --border-strong: rgba(15, 23, 42, 0.13);
  --specular-rim: inset 0 1px 0 rgba(255, 255, 255, 0.92);

  --shadow-panel: 0 10px 32px -8px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-pill: 0 1px 3px rgba(15, 23, 42, 0.07), 0 0 0 1px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 18px 44px -10px rgba(15, 23, 42, 0.13), 0 2px 6px rgba(15, 23, 42, 0.05);

  --text-primary: #111318;
  --text-secondary: #464C58;
  --text-muted: #5B6372;

  --btn-primary-bg: #14161B;
  --btn-primary-hover: #242832;
  --btn-primary-fg: #FFFFFF;

  --accent-emerald: #2EB88A;
  --accent-emerald-tint: rgba(46, 184, 138, 0.13);
  --accent-coral: #F97316;
  --accent-coral-tint: rgba(249, 115, 22, 0.12);
  --accent-blue: #3B82F6;
  --accent-blue-tint: rgba(59, 130, 246, 0.12);
  --focus-ring: rgba(59, 130, 246, 0.35);

  --status-ok: #0F6E50;
  --status-ok-tint: rgba(46, 184, 138, 0.13);
  --status-warn: #9A3412;
  --status-warn-tint: rgba(249, 115, 22, 0.12);
  --status-danger: #B91C1C;
  --status-danger-tint: rgba(220, 38, 38, 0.10);

  --scrim-bg: rgba(15, 23, 42, 0.28);

  /* Backward-compatible component token aliases */
  --bg-shell: var(--bg-canvas);
  --bg-workspace: var(--bg-surface);
  --bg-subtle: var(--bg-track);
  --bg-elevated: var(--bg-surface);
  --bg-hover: rgba(15, 23, 42, 0.042);
  --border-frame: var(--border-panel);
  --border-hairline: var(--border-subtle);
  --accent: var(--btn-primary-bg);
  --accent-hover: var(--btn-primary-hover);
  --accent-ink: #1D4ED8;
  --accent-tint: rgba(59, 130, 246, 0.12);

  --font-ui: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Inter", "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", "JetBrains Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;

  --radius-panel: 20px;
  --radius-card: 16px;
  --radius-track: 12px;
  --radius-pill: 10px;
  --radius-frame: 20px;
  --radius-composer: 14px;
  --radius-control: 10px;
  --radius-tag: 8px;
}

html[data-theme="glass"],
html[data-theme="graphite"],
html[data-theme="obsidian"],
html[data-theme="nordic"],
html[data-theme="dark"] {
  color-scheme: dark;

  --bg-canvas: #0C0E13;
  --bg-canvas-gradient: linear-gradient(145deg, #11141C 0%, #090B10 100%);
  --bg-panel: rgba(22, 25, 34, 0.82);
  --bg-surface: rgba(32, 36, 48, 0.90);
  --bg-track: rgba(255, 255, 255, 0.045);
  --bg-card-active: rgba(255, 255, 255, 0.058);
  --bg-pill: rgba(255, 255, 255, 0.05);

  --border-panel: rgba(255, 255, 255, 0.085);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.16);
  --specular-rim: inset 0 1px 0 rgba(255, 255, 255, 0.08);

  --shadow-panel: 0 16px 40px -10px rgba(0, 0, 0, 0.55);
  --shadow-pill: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-float: 0 22px 52px -12px rgba(0, 0, 0, 0.65);

  --text-primary: #F3F5F8;
  --text-secondary: #C2C7D2;
  --text-muted: #9BA3B4;

  --btn-primary-bg: #F3F5F8;
  --btn-primary-hover: #FFFFFF;
  --btn-primary-fg: #111318;

  --accent-emerald: #34D399;
  --accent-emerald-tint: rgba(52, 211, 153, 0.16);
  --accent-coral: #FB923C;
  --accent-coral-tint: rgba(251, 146, 60, 0.16);
  --accent-blue: #60A5FA;
  --accent-blue-tint: rgba(96, 165, 250, 0.16);
  --focus-ring: rgba(96, 165, 250, 0.40);

  --status-ok: #6EE7B7;
  --status-ok-tint: rgba(52, 211, 153, 0.16);
  --status-warn: #FDBA74;
  --status-warn-tint: rgba(251, 146, 60, 0.16);
  --status-danger: #FCA5A5;
  --status-danger-tint: rgba(248, 113, 113, 0.16);

  --scrim-bg: rgba(5, 7, 11, 0.62);

  /* Backward-compatible component token aliases */
  --bg-shell: var(--bg-canvas);
  --bg-workspace: var(--bg-surface);
  --bg-subtle: var(--bg-track);
  --bg-elevated: rgba(38, 43, 58, 0.94);
  --bg-hover: rgba(255, 255, 255, 0.055);
  --border-frame: var(--border-panel);
  --border-hairline: var(--border-subtle);
  --accent: var(--btn-primary-bg);
  --accent-hover: var(--btn-primary-hover);
  --accent-ink: #93C5FD;
  --accent-tint: rgba(96, 165, 250, 0.16);
}

/* ==========================================================================
   BASE RESET, SCROLLBARS & TAURI DESKTOP DRAG STRIPS
   ========================================================================== */

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-gradient);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.44;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

#zok-root {
  width: 100%;
  height: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0;
  font-weight: 400;
}

strong,
b {
  font-weight: 600;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

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

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

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

.tabular {
  font-variant-numeric: tabular-nums;
}

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

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

[data-tauri-drag-region] {
  -webkit-app-region: drag;
}

[data-tauri-drag-region] button,
[data-tauri-drag-region] a,
[data-tauri-drag-region] input,
[data-tauri-drag-region] select,
[data-tauri-drag-region] textarea,
[data-tauri-drag-region] label,
[data-tauri-drag-region] [role="button"],
[data-tauri-drag-region] [role="tab"] {
  -webkit-app-region: no-drag;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

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

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

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

@keyframes zok-spin {
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: zok-spin 0.85s linear infinite;
}

/* ==========================================================================
   BOOT SCREEN
   ========================================================================== */

.zok-boot-screen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.zok-boot-mark {
  display: grid;
  place-items: center;
}

.zok-boot-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   DETACHED 20PX FROSTED GLASS SHELL & PANELS (DESIGN.md Section 5.1)
   ========================================================================== */

.zok-glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--border-panel);
  box-shadow: var(--shadow-panel), var(--specular-rim);
  border-radius: var(--radius-panel);
}

.zok-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 10px;
  gap: 10px;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-gradient);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  position: relative;
}

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

.mobile-only {
  display: none !important;
}

/* Stage wrapper (transparent flex row when used around list + reader + agent dock) */
.zok-inset-stage,
.zok-main-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  display: flex;
  align-items: stretch;
  gap: 10px;
  overflow: hidden;
}

/* Detached Frosted Glass Panels */
.zok-sidebar,
.zok-list-pane,
.zok-reader-pane,
.zok-agent-dock {
  background: var(--bg-panel);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--border-panel);
  box-shadow: var(--shadow-panel), var(--specular-rim);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

/* ==========================================================================
   MINIMALIST SIDEBAR (216PX GLASS PANEL, DESIGN.md Section 5.3)
   ========================================================================== */

.zok-sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 10px 10px;
  gap: 10px;
  user-select: none;
  transition: width 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 0 2px;
}

.brand-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.018em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-cmdk-trigger {
  height: 28px;
  min-width: 28px;
  padding: 0 7px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-pill);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: border-color 140ms ease, color 140ms ease;
}

.btn-cmdk-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Compact Account Switcher Pill (DESIGN.md Section 5.3) */
.account-switcher-pill,
.sidebar-account-pill,
.account-pill-btn {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pill), var(--specular-rim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.account-switcher-pill:hover,
.sidebar-account-pill:hover,
.account-pill-btn:hover {
  border-color: var(--border-strong);
}

.account-pill-left {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.account-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-pill-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.provider-dots-stack,
.account-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

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

/* Sidebar Navigation Rows */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section.push-bottom {
  margin-top: auto;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 6px;
  flex-shrink: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 8px 3px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-row-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-row-wrap .account-sync-mini {
  opacity: 0;
  transition: opacity 140ms ease;
}

.nav-row-wrap:hover .account-sync-mini,
.nav-row-wrap .account-sync-mini.syncing {
  opacity: 1;
}

.nav-item {
  width: 100%;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), color 140ms ease, box-shadow 140ms ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
}

.nav-item.muted-action,
.sidebar-more-toggle {
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.nav-item.muted-action:hover,
.sidebar-more-toggle:hover {
  color: var(--text-primary);
}

.sidebar-more-group,
.sidebar-more-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

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

.nav-item-icon {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.nav-item.active .nav-item-icon,
.nav-item:hover .nav-item-icon {
  color: var(--text-primary);
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 5px;
}

.nav-ready-dot,
.agent-ready-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  flex-shrink: 0;
}

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

.nav-count {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.nav-item.active .nav-count {
  color: var(--text-secondary);
}

.inline-label-creator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  margin: 2px 0 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
}

.inline-label-creator input[type="color"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.inline-label-creator input[type="text"] {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--text-primary);
}

/* v4 Sidebar Pinned Smart Views & Live Agent Makeover Demo Pill */
.smart-view-item {
  width: 100%;
  min-height: 32px;
  padding: 5px 9px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), color 140ms ease, box-shadow 140ms ease;
}

.smart-view-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.smart-view-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
}

.smart-view-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-blue);
  flex-shrink: 0;
  margin: 0 4px;
}

.sidebar-demo-pill,
#btn-run-crazy-demo {
  width: 100%;
  min-height: 33px;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pill), var(--specular-rim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.sidebar-demo-pill:hover,
#btn-run-crazy-demo:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-active);
}

.sidebar-demo-pill svg,
#btn-run-crazy-demo svg {
  color: var(--status-ok);
  flex-shrink: 0;
}

.zok-shell.sidebar-collapsed .sidebar-demo-pill span:not(:first-child),
.zok-shell.sidebar-collapsed #btn-run-crazy-demo span:not(.nav-item-icon) {
  display: none;
}

/* Sidebar 44px Compact Footer */
.sidebar-footer {
  min-height: 44px;
  padding: 6px 0 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  padding: 4px;
  border-radius: 10px;
  text-align: left;
  transition: background-color 140ms ease;
}

.user-chip .zok-avatar.sm {
  width: 22px;
  height: 22px;
  font-size: 9.5px;
}

.user-chip:hover {
  background: var(--bg-hover);
}

.user-chip-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.24;
}

.user-chip-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sync-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  flex-shrink: 0;
}

.sync-status-dot.reconnecting {
  background: var(--accent-coral);
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.sidebar-footer-actions .icon-btn.icon-btn-sm {
  width: 24px;
  height: 24px;
}

/* Collapsed Desktop Rail */
.zok-shell.sidebar-collapsed .zok-sidebar {
  width: 64px;
  padding: 12px 8px 10px;
}

.zok-shell.sidebar-collapsed .brand-name,
.zok-shell.sidebar-collapsed .btn-cmdk-trigger,
.zok-shell.sidebar-collapsed .account-pill-label,
.zok-shell.sidebar-collapsed .account-pill-right,
.zok-shell.sidebar-collapsed .sidebar-section-header,
.zok-shell.sidebar-collapsed .nav-item-label,
.zok-shell.sidebar-collapsed .nav-count,
.zok-shell.sidebar-collapsed .account-sync-mini,
.zok-shell.sidebar-collapsed .inline-label-creator,
.zok-shell.sidebar-collapsed .user-chip-info,
.zok-shell.sidebar-collapsed .sidebar-footer-actions {
  display: none;
}

.zok-shell.sidebar-collapsed .brand-row,
.zok-shell.sidebar-collapsed .account-switcher-pill,
.zok-shell.sidebar-collapsed .sidebar-account-pill,
.zok-shell.sidebar-collapsed .nav-item,
.zok-shell.sidebar-collapsed .sidebar-footer,
.zok-shell.sidebar-collapsed .user-chip {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* Zen / Full-View Layout Modes */
.zok-shell.layout-zen:not(.zen-reading) .zok-list-pane {
  flex: 1;
  width: auto;
}

.zok-shell.layout-zen:not(.zen-reading) .zok-reader-pane {
  display: none;
}

.zok-shell.layout-zen.zen-reading .zok-list-pane {
  display: none;
}

/* ==========================================================================
   EXACT REFERENCE MAIL LIST PANEL (364PX, DESIGN.md Section 5.2)
   ========================================================================== */

.zok-list-pane {
  width: 364px;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.list-header {
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

/* Row 1: [ Write Email ] Pill + [ Search ] Square Pill */
.list-top-actions,
.list-action-row,
.mail-list-topbar,
.compose-cta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-pane-top-row {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.write-email-pill,
.btn-compose-main {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border-radius: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pill), var(--specular-rim);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  transition: border-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), color 140ms ease, transform 140ms ease;
}

.write-email-pill:hover,
.btn-compose-main:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.write-email-pill svg,
.btn-compose-main svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.write-email-pill:hover svg,
.btn-compose-main:hover svg {
  color: var(--text-primary);
}

.write-email-pill .compose-left,
.btn-compose-main .compose-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.search-icon-pill {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pill), var(--specular-rim);
  color: var(--text-secondary);
  display: inline-grid;
  place-items: center;
  transition: border-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), color 140ms ease, background-color 140ms ease;
}

.search-icon-pill:hover,
.search-icon-pill.active,
.search-icon-pill[aria-expanded="true"] {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Expandable Search Bar & Filter Chips */
.list-search-drawer,
.mail-search-drawer,
.list-search-wrap {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.list-header .list-search-drawer,
.list-header .mail-search-drawer,
.list-header .list-search-wrap {
  padding: 0;
}

.search-box-wrap {
  height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-pill);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-box-wrap:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-icon {
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

.search-box-wrap input::placeholder {
  color: var(--text-muted);
}

.search-chips-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Row 2: Recessed Segmented Pill Bar [ All Mails | Unread | Archive ] */
.segmented-track {
  margin: 0 14px 10px;
  padding: 3px;
  border-radius: var(--radius-track);
  background: var(--bg-track);
  border: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  flex-shrink: 0;
}

.list-header .segmented-track {
  margin: 0;
}

.segmented-track.cols-2 {
  margin: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented-track.cols-4 {
  margin: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented-track.cols-5 {
  margin: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented-track.cols-5::-webkit-scrollbar {
  display: none;
}

.segmented-track.inline {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.segmented-pill {
  height: 31px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), color 140ms ease, box-shadow 140ms ease;
}

.segmented-pill:hover {
  color: var(--text-primary);
}

.segmented-pill.active,
.segmented-pill[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-pill);
}

/* Optional subtle category chip strip */
.split-tabs-bar,
.category-chip-strip {
  padding: 0 14px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  overflow-x: auto;
}

.split-tab {
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.split-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.split-tab.active {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  box-shadow: var(--shadow-pill);
}

.split-tab-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

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

.list-header .list-title-row {
  padding: 0;
}

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

.list-folder-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-folder-count {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.list-header-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* ==========================================================================
   4-ROW FLOATING EMAIL CARDS (ZERO HORIZONTAL BORDERS, DESIGN.md Section 5.2)
   ========================================================================== */

.thread-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 12px;
}

.thread-row {
  margin: 2px 10px;
  padding: 12px 12px;
  border-radius: var(--radius-card);
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  position: relative;
  cursor: pointer;
  transition: background-color 140ms cubic-bezier(0.2, 0.8, 0.2, 1), border-color 140ms ease;
}

html[data-density="compact"] .thread-row {
  padding: 9px 11px;
  margin: 1px 8px;
}

.thread-row:hover {
  background: var(--bg-card-active);
}

.thread-row.selected {
  background: var(--bg-card-active);
  border-color: var(--border-subtle);
}

.thread-row.active {
  background: var(--bg-card-active);
  border-color: var(--border-subtle);
}

/* Left Avatar + 6px Emerald Unread Dot Centered Directly Underneath */
.thread-avatar-stack {
  width: 30px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 1px;
}

.unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  margin-top: 7px;
  flex-shrink: 0;
}

/* Right 4-Line Card Body */
.thread-card-body,
.thread-body-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.thread-card-line1,
.thread-line-1,
.thread-top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.thread-sender-wrap,
.thread-meta-left {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.thread-sender {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-row.unread .thread-sender {
  color: var(--text-primary);
  font-weight: 600;
}

.thread-sep {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.thread-time {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.thread-more-btn {
  width: 24px;
  height: 22px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background-color 140ms ease, color 140ms ease;
}

.thread-more-btn:hover,
.thread-more-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.thread-subject {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.36;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-snippet {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.38;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-card-line4,
.thread-line-4,
.thread-card-footer,
.thread-bottom-row {
  margin-top: 5px;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-micro-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.micro-pill {
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-pill);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.micro-pill svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.micro-pill.coral svg,
.micro-pill.attachment svg,
.micro-pill.event svg {
  color: var(--accent-coral);
}

.micro-pill.emerald svg,
.micro-pill.messages svg,
.micro-pill.thread svg {
  color: var(--accent-emerald);
}

.micro-pill.blue svg,
.micro-pill.chart svg {
  color: var(--accent-blue);
}

.thread-star-btn {
  width: 24px;
  height: 22px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: auto;
  transition: color 140ms ease, transform 140ms ease;
}

.thread-star-btn:hover {
  color: var(--accent-coral);
}

.thread-star-btn.starred,
.thread-star-btn[aria-pressed="true"] {
  color: var(--accent-coral);
}

.thread-star-btn.starred svg polygon,
.thread-star-btn[aria-pressed="true"] svg polygon {
  fill: currentColor;
}

/* Bulk Action Bar */
.bulk-action-bar {
  margin: 0 10px 10px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.bulk-count-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.bulk-btns {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Reader Pane Container */
.zok-reader-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   RESPONSIVE TABLET & FULL-BLEED 390X844 MOBILE LAYOUT (ZERO OVERFLOW)
   ========================================================================== */

@media (max-width: 1480px) {
  .zok-shell.agent-dock-open .zok-list-pane {
    width: 332px;
  }
}

@media (max-width: 1180px) {
  .zok-list-pane {
    width: 328px;
  }

  .zok-sidebar {
    width: 220px;
  }
}

@media (max-width: 860px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .zok-shell {
    padding: 0;
    gap: 0;
    width: 100vw;
    max-width: 100vw;
  }

  .zok-inset-stage,
  .zok-main-stage {
    gap: 0;
    width: 100%;
    max-width: 100vw;
  }

  .zok-sidebar {
    position: fixed;
    top: 8px;
    bottom: 8px;
    left: 8px;
    width: 268px;
    max-width: calc(100vw - 24px);
    border-radius: var(--radius-panel);
    z-index: 90;
    transform: translateX(calc(-100% - 20px));
    transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-float);
  }

  .zok-shell.mobile-nav-open .zok-sidebar {
    transform: translateX(0);
  }

  .zok-shell.mobile-nav-open .mobile-drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--scrim-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 80;
  }

  .zok-list-pane,
  .zok-reader-pane {
    width: 100%;
    max-width: 100vw;
    flex: 1;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .zok-shell:not(.mobile-thread-open) .zok-reader-pane {
    display: none;
  }

  .zok-shell.mobile-thread-open .zok-list-pane {
    display: none;
  }

  .zok-agent-dock,
  #zok-agent-dock {
    position: fixed;
    inset: 0;
    width: 100% !important;
    max-width: none !important;
    border-radius: 0;
    border: none;
    z-index: 95;
  }
}

@media print {
  .zok-sidebar,
  .zok-list-pane,
  .zok-agent-dock,
  .reader-toolbar,
  .quick-reply-shell,
  #zok-composer-root,
  #zok-toast-root {
    display: none !important;
  }

  html,
  body,
  .zok-shell,
  .zok-inset-stage,
  .zok-reader-pane,
  .reader-scroll {
    height: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
    color: #000000 !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}
