/* ==========================================================================
   TELEGRAM WEB K/A OFFICIAL DESIGN SYSTEM · YUYI PROFESSIONAL WEBMAIL
   100% Vector SVG Icons, Zero Emojis, Asymmetrical Geometry & Fluid Canvas
   ========================================================================== */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* 1. Brand Identity */
  --tg-primary: #3390ec;
  --tg-primary-hover: #2881d8;
  --tg-primary-active: #2071c2;
  --tg-primary-light: rgba(51, 144, 236, 0.1);
  --tg-accent-green: #4dcd5e;
  --tg-accent-red: #e53935;
  --tg-accent-gold: #f59e0b;
  --tg-accent-purple: #8774e1;

  /* 2. Surfaces & Acrylic Glass */
  --tg-surface-workspace: #ffffff;
  --tg-surface-sidebar: #ffffff;
  --tg-surface-glass: rgba(255, 255, 255, 0.88);
  --tg-surface-hover: rgba(0, 0, 0, 0.04);
  --tg-surface-active: rgba(51, 144, 236, 0.08);
  --tg-backdrop-blur: blur(18px) saturate(180%);

  /* 3. Canvas Gradient & Chat Wallpaper */
  --tg-chat-bg-gradient: 
    radial-gradient(circle at 18% 22%, #d4ebd0 0%, transparent 55%),
    radial-gradient(circle at 82% 28%, #b8dcf5 0%, transparent 55%),
    radial-gradient(circle at 50% 80%, #d8e6f3 0%, transparent 60%),
    linear-gradient(135deg, #c7dfeb 0%, #e1eed9 100%);
  --tg-doodle-opacity: 0.07;

  /* 4. Reading Cards */
  --tg-card-bg: #ffffff;
  --tg-card-shadow: 0 2px 12px rgba(16, 35, 47, 0.08);

  /* 5. Typography */
  --tg-text-primary: #0f1419;
  --tg-text-secondary: #707579;
  --tg-text-muted: #a2acb4;
  --tg-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --tg-font-mono: "SFMono-Regular", Consolas, monospace;

  /* 6. Curvature & Geometry */
  --tg-border-hairline: rgba(0, 0, 0, 0.08);
  --tg-radius-workspace: 24px;
  --tg-radius-card: 16px;
  --tg-radius-pill: 9999px;

  /* 7. Elevation */
  --tg-shadow-workspace: 0 24px 60px rgba(15, 34, 58, 0.14), 0 0 1px rgba(15, 34, 58, 0.12);
  --tg-shadow-menu: 0 8px 28px rgba(15, 25, 35, 0.16), 0 0 1px rgba(15, 25, 35, 0.1);
  --tg-shadow-composer: 0 12px 36px rgba(15, 34, 58, 0.22);
}

/* Dark Mode (Telegram Night Blue Palette) */
[data-theme="dark"] {
  --tg-primary: #52a1ec;
  --tg-primary-hover: #64adec;
  --tg-primary-light: rgba(82, 161, 236, 0.15);

  --tg-surface-workspace: #17212b;
  --tg-surface-sidebar: #17212b;
  --tg-surface-glass: rgba(23, 33, 43, 0.88);
  --tg-surface-hover: rgba(255, 255, 255, 0.05);
  --tg-surface-active: rgba(82, 161, 236, 0.14);

  --tg-chat-bg-gradient: 
    radial-gradient(circle at 20% 20%, #16293d 0%, transparent 55%),
    radial-gradient(circle at 80% 80%, #101d2c 0%, transparent 60%),
    linear-gradient(135deg, #0e1621 0%, #152232 100%);
  --tg-doodle-opacity: 0.045;

  --tg-card-bg: #1f2c38;
  --tg-card-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);

  --tg-text-primary: #f5f5f5;
  --tg-text-secondary: #8a9aa9;
  --tg-text-muted: #5d6e7e;
  --tg-border-hairline: rgba(255, 255, 255, 0.08);
  --tg-shadow-workspace: 0 24px 60px rgba(0, 0, 0, 0.6);
  --tg-shadow-menu: 0 12px 32px rgba(0, 0, 0, 0.55);
  --tg-shadow-composer: 0 16px 48px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--tg-chat-bg-gradient);
  color: var(--tg-text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* Ambient Wallpaper Doodle Overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300"><g fill="none" stroke="%233e80ad" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20 L45 10 L35 45 L25 32 L15 36 Z"/><circle cx="110" cy="25" r="14"/><path d="M200 15 Q225 8 238 30 T205 48 Z"/><path d="M40 140 L65 120 L85 140 L72 165 Z"/><circle cx="150" cy="130" r="18"/><path d="M245 115 L275 145 L245 175 L215 145 Z"/><path d="M60 240 Q85 200 110 240 T60 240 Z"/><circle cx="180" cy="245" r="12"/><path d="M250 230 L285 230 L268 270 Z"/></g></svg>');
  background-repeat: repeat;
  background-size: 300px 300px;
  opacity: var(--tg-doodle-opacity);
  pointer-events: none;
  z-index: 0;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: transparent; outline: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--tg-primary);
  outline-offset: 2px;
}

/* Universal SVG Icon Sizing */
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Top Master Switcher Bar */
.tg-spec-topbar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  background: var(--tg-surface-glass);
  backdrop-filter: var(--tg-backdrop-blur);
  -webkit-backdrop-filter: var(--tg-backdrop-blur);
  border-bottom: 1px solid var(--tg-border-hairline);
}
.tg-logo-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.tg-plane-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--tg-primary);
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 2px 8px rgba(51, 144, 236, 0.35);
}
.tg-plane-logo svg { width: 18px; height: 18px; }
.tg-spec-badge {
  font-size: 11px;
  font-family: var(--tg-font-mono);
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--tg-primary-light);
  color: var(--tg-primary);
  font-weight: 600;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.spec-btn-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--tg-radius-pill);
  border: 1px solid var(--tg-border-hairline);
  background: var(--tg-surface-workspace);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s ease;
}
.spec-btn-pill:hover { background: var(--tg-surface-hover); }

/* Main Container Shell */
.app-viewport-canvas {
  position: relative;
  z-index: 10;
  height: calc(100% - 52px);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tg-workspace-shell {
  width: 100%;
  max-width: 1440px;
  height: 100%;
  display: flex;
  gap: 16px;
  position: relative;
}

/* ==========================================================================
   LEFT SIDEBAR (390px Optimized Width)
   ========================================================================== */
.tg-sidebar {
  width: 390px;
  flex: 0 0 390px;
  background: var(--tg-surface-sidebar);
  border-radius: var(--tg-radius-workspace);
  box-shadow: var(--tg-shadow-workspace);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Top Search & Compose Bar */
.tg-sidebar-header {
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.tg-search-capsule {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--tg-radius-pill);
  background: rgba(0, 0, 0, 0.04);
  height: 40px;
  padding: 0 14px;
  color: var(--tg-text-muted);
  transition: all 0.2s ease;
}
[data-theme="dark"] .tg-search-capsule { background: rgba(255, 255, 255, 0.06); }
.tg-search-capsule:focus-within {
  background: var(--tg-surface-workspace);
  box-shadow: inset 0 0 0 2px var(--tg-primary);
}
.tg-search-capsule input {
  border: 0;
  background: transparent;
  width: 100%;
  outline: none;
  font-size: 13.5px;
  color: var(--tg-text-primary);
}

/* Telegram Compose Main Pill Button */
.tg-compose-main-btn {
  height: 42px;
  border-radius: var(--tg-radius-pill);
  background: linear-gradient(135deg, #3390ec 0%, #2071c2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(51, 144, 236, 0.35);
  transition: all 0.15s ease;
}
.tg-compose-main-btn:hover {
  background: linear-gradient(135deg, #2881d8 0%, #1a5ea3 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(51, 144, 236, 0.45);
}

/* Fully Visible Horizontal Folder Tabs (Zero Truncation Guarantee) */
.tg-folders-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  height: 44px;
  border-bottom: 1px solid var(--tg-border-hairline);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}
.tg-folder-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 6px;
  height: 100%;
  color: var(--tg-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s ease;
  flex: 1 1 0;
}
.tg-folder-tab:hover { color: var(--tg-text-primary); }
.tg-folder-tab.active {
  color: var(--tg-primary);
  font-weight: 600;
}
.tg-folder-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 6px;
  right: 6px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--tg-primary);
}
.tg-tab-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.folder-pill-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--tg-radius-pill);
  background: rgba(0, 0, 0, 0.08);
  color: var(--tg-text-secondary);
}
[data-theme="dark"] .folder-pill-badge { background: rgba(255, 255, 255, 0.12); }
.tg-folder-tab.active .folder-pill-badge {
  background: var(--tg-primary);
  color: white;
}

/* Batch Operations Header (Gmail Toolbar) */
.tg-batch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--tg-border-hairline);
  background: var(--tg-surface-glass);
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  flex-shrink: 0;
}
.tg-batch-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tg-checkbox-wrap {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.tg-checkbox-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--tg-primary);
  cursor: pointer;
}
.tg-batch-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tg-batch-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tg-text-secondary);
  transition: all 0.15s ease;
}
.tg-batch-btn:hover {
  background: var(--tg-surface-hover);
  color: var(--tg-text-primary);
}

/* Mail List Stream */
.tg-chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}
.tg-mail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 2px;
  position: relative;
}
.tg-mail-row:hover { background: var(--tg-surface-hover); }
.tg-mail-row.selected {
  background: var(--tg-surface-active);
  border: 1px solid rgba(51, 144, 236, 0.25);
}
.tg-mail-row.unread {
  background: rgba(51, 144, 236, 0.04);
}
.tg-mail-row.unread .tg-mail-sender {
  font-weight: 700;
  color: var(--tg-text-primary);
}
.tg-mail-row.unread .tg-mail-subject {
  font-weight: 600;
  color: var(--tg-text-primary);
}

/* Star Vector SVG Button */
.tg-star-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--tg-text-muted);
  transition: color 0.15s ease;
  flex-shrink: 0;
}
.tg-star-btn:hover { color: var(--tg-accent-gold); }
.tg-star-btn.starred { color: var(--tg-accent-gold); }
.tg-star-svg {
  width: 16px;
  height: 16px;
}
.tg-star-btn.starred .tg-star-svg polygon {
  fill: var(--tg-accent-gold);
}

/* Row Avatar */
.tg-mail-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #64b8f4, #238bee);
}
.tg-mail-avatar.tone-durov { background: linear-gradient(135deg, #242424, #121212); }
.tg-mail-avatar.tone-news { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.tg-mail-avatar.tone-team { background: linear-gradient(135deg, #a798ee, #7863ce); }
.tg-mail-avatar.tone-emerald { background: linear-gradient(135deg, #34d399, #059669); }
.tg-mail-avatar.tone-coral { background: linear-gradient(135deg, #fb7185, #e11d48); }

/* Row Content */
.tg-mail-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tg-mail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tg-mail-sender {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--tg-text-primary);
}
.tg-mail-date {
  font-size: 11.5px;
  color: var(--tg-text-muted);
  white-space: nowrap;
  margin-left: 6px;
}
.tg-mail-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--tg-text-secondary);
}
.tg-mail-subject {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

/* Row Hover Quick Actions (Gmail Feature) */
.tg-row-hover-actions {
  display: none;
  align-items: center;
  gap: 2px;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--tg-surface-workspace);
  padding: 2px 4px;
  border-radius: var(--tg-radius-pill);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--tg-border-hairline);
  z-index: 5;
}
.tg-mail-row:hover .tg-row-hover-actions {
  display: flex;
}
.tg-hover-act-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tg-text-secondary);
  transition: all 0.12s ease;
}
.tg-hover-act-btn:hover {
  background: var(--tg-surface-hover);
  color: var(--tg-primary);
}
.tg-hover-act-btn.act-delete:hover {
  color: var(--tg-accent-red);
}

/* ==========================================================================
   RIGHT READING PANE (Gmail Standard + Telegram Frosted Glass)
   ========================================================================== */
.tg-conversation {
  flex: 1;
  min-width: 0;
  border-radius: var(--tg-radius-workspace);
  background: transparent;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Top Header Toolbar */
.tg-reading-topbar {
  height: 56px;
  background: var(--tg-surface-glass);
  backdrop-filter: var(--tg-backdrop-blur);
  -webkit-backdrop-filter: var(--tg-backdrop-blur);
  border-radius: var(--tg-radius-workspace) var(--tg-radius-workspace) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--tg-border-hairline);
  z-index: 20;
}
.tg-reading-actions-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-reading-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-action-btn-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tg-text-secondary);
  transition: all 0.15s ease;
}
.tg-action-btn-circle:hover {
  background: var(--tg-surface-hover);
  color: var(--tg-text-primary);
}
.tg-action-btn-circle.danger:hover {
  color: var(--tg-accent-red);
}

/* Reading Body Viewport */
.tg-reading-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty State Canvas */
.tg-empty-reading-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--tg-text-secondary);
}
.tg-empty-icon-box {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--tg-surface-glass);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.tg-empty-icon-box svg {
  width: 36px;
  height: 36px;
  color: var(--tg-primary);
}

/* AI Copilot Frosted Card (Collapsible) */
.tg-ai-summary-card {
  background: var(--tg-surface-glass);
  backdrop-filter: var(--tg-backdrop-blur);
  border-radius: var(--tg-radius-card);
  border: 1px solid rgba(135, 116, 225, 0.3);
  box-shadow: 0 4px 20px rgba(135, 116, 225, 0.1);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.tg-ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tg-ai-badge-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--tg-accent-purple);
}
.tg-ai-badge-title svg {
  width: 18px;
  height: 18px;
}
.tg-ai-summary-text {
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: rgba(135, 116, 225, 0.05);
  border-radius: 12px;
  padding: 12px 14px;
}

/* Main Email Article Card */
.tg-mail-article {
  background: var(--tg-card-bg);
  border-radius: var(--tg-radius-card);
  box-shadow: var(--tg-card-shadow);
  border: 1px solid var(--tg-border-hairline);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Subject Bar */
.tg-article-subject-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--tg-border-hairline);
  padding-bottom: 14px;
}
.tg-article-subject {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--tg-text-primary);
}

/* Sender & Recipient Metadata Card */
.tg-article-sender-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.tg-sender-meta {
  flex: 1;
  min-width: 0;
}
.tg-sender-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--tg-text-primary);
}
.tg-sender-email {
  font-size: 13px;
  font-weight: 400;
  color: var(--tg-text-secondary);
}
.tg-sender-recipient-line {
  font-size: 12.5px;
  color: var(--tg-text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-security-pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--tg-radius-pill);
  background: rgba(77, 205, 94, 0.12);
  color: var(--tg-accent-green);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Email HTML Content Container */
.tg-mail-content-viewport {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--tg-text-primary);
  overflow-x: auto;
  word-break: break-word;
}
.tg-mail-content-viewport img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.tg-mail-content-viewport a {
  color: var(--tg-primary);
  text-decoration: none;
}
.tg-mail-content-viewport a:hover {
  text-decoration: underline;
}

/* Attachments Cards Grid */
.tg-attachments-container {
  border-top: 1px solid var(--tg-border-hairline);
  padding-top: 16px;
  margin-top: 10px;
}
.tg-attachments-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tg-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.tg-attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--tg-surface-hover);
  border: 1px solid var(--tg-border-hairline);
  transition: all 0.15s ease;
}
.tg-attachment-card:hover {
  background: var(--tg-surface-active);
  border-color: var(--tg-primary);
}
.tg-attachment-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--tg-surface-workspace);
  display: grid;
  place-items: center;
  color: var(--tg-primary);
  flex-shrink: 0;
}
.tg-attachment-info {
  flex: 1;
  min-width: 0;
}
.tg-attachment-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--tg-text-primary);
}
.tg-attachment-size {
  font-size: 11.5px;
  color: var(--tg-text-muted);
}
.tg-attachment-dl-btn {
  padding: 4px 10px;
  border-radius: var(--tg-radius-pill);
  background: var(--tg-primary-light);
  color: var(--tg-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Bottom Quick Actions (Reply / Forward Trigger Card) */
.tg-quick-reply-trigger {
  border: 1px dashed var(--tg-border-hairline);
  border-radius: var(--tg-radius-card);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  background: var(--tg-surface-workspace);
  transition: all 0.15s ease;
}
.tg-quick-reply-trigger:hover {
  border-color: var(--tg-primary);
  background: var(--tg-surface-active);
}

/* ==========================================================================
   GMAIL-GRADE DOCKED COMPOSER (3 States: Minimized, Docked, Fullscreen)
   ========================================================================== */
.tg-docked-composer {
  position: fixed;
  right: 28px;
  bottom: 0;
  width: 580px;
  height: 520px;
  background: var(--tg-surface-workspace);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--tg-shadow-composer);
  border: 1px solid var(--tg-border-hairline);
  border-bottom: 0;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: width 0.2s ease, height 0.2s ease, transform 0.2s ease;
}
.tg-docked-composer.active {
  display: flex;
}

/* State 1: Minimized Tab */
.tg-docked-composer.minimized {
  height: 44px;
  width: 260px;
  border-radius: 12px 12px 0 0;
}
.tg-docked-composer.minimized .tg-composer-body,
.tg-docked-composer.minimized .tg-composer-footer {
  display: none;
}

/* State 2: Fullscreen Centered */
.tg-docked-composer.fullscreen {
  right: 50%;
  bottom: 50%;
  transform: translate(50%, 50%);
  width: min(92vw, 860px);
  height: min(88vh, 680px);
  border-radius: var(--tg-radius-card);
  border-bottom: 1px solid var(--tg-border-hairline);
}

/* Composer Header */
.tg-composer-header {
  height: 44px;
  background: var(--tg-surface-glass);
  backdrop-filter: var(--tg-backdrop-blur);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--tg-border-hairline);
  cursor: pointer;
  flex-shrink: 0;
}
.tg-composer-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tg-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tg-composer-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tg-composer-btn-mini {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--tg-text-secondary);
  transition: all 0.12s ease;
}
.tg-composer-btn-mini:hover {
  background: var(--tg-surface-hover);
  color: var(--tg-text-primary);
}

/* Composer Body & Fields */
.tg-composer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.tg-composer-field-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--tg-border-hairline);
  padding: 6px 14px;
  gap: 8px;
}
.tg-composer-field-label {
  font-size: 13px;
  color: var(--tg-text-muted);
  width: 50px;
  flex-shrink: 0;
}
.tg-composer-input-field {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--tg-text-primary);
}
.tg-composer-extra-btn {
  font-size: 12px;
  color: var(--tg-text-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}
.tg-composer-extra-btn:hover {
  background: var(--tg-surface-hover);
  color: var(--tg-primary);
}

/* Rich Format Toolbar */
.tg-rich-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--tg-border-hairline);
  background: var(--tg-surface-hover);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.tg-format-btn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--tg-text-secondary);
  transition: all 0.12s ease;
}
.tg-format-btn:hover {
  background: var(--tg-surface-workspace);
  color: var(--tg-primary);
}
.tg-format-btn.active {
  background: var(--tg-primary-light);
  color: var(--tg-primary);
}

/* Attached Files Chips Bar */
.tg-composer-attachments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--tg-border-hairline);
}
.tg-composer-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tg-surface-workspace);
  border: 1px solid var(--tg-border-hairline);
  border-radius: var(--tg-radius-pill);
  padding: 3px 10px;
  font-size: 12px;
  color: var(--tg-text-primary);
}
.tg-composer-att-remove {
  cursor: pointer;
  color: var(--tg-text-muted);
  font-size: 13px;
}
.tg-composer-att-remove:hover { color: var(--tg-accent-red); }

/* Editable Content Box */
.tg-composer-editor {
  flex: 1;
  padding: 14px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--tg-text-primary);
  overflow-y: auto;
  min-height: 180px;
}
.tg-composer-editor[contenteditable]:empty::before {
  content: attr(placeholder);
  color: var(--tg-text-muted);
  pointer-events: none;
}

/* Composer Footer */
.tg-composer-footer {
  height: 52px;
  padding: 0 14px;
  border-top: 1px solid var(--tg-border-hairline);
  background: var(--tg-surface-workspace);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.tg-composer-send-btn {
  height: 36px;
  padding: 0 20px;
  border-radius: var(--tg-radius-pill);
  background: var(--tg-primary);
  color: white;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(51, 144, 236, 0.3);
}
.tg-composer-send-btn:hover {
  background: var(--tg-primary-hover);
  transform: translateY(-1px);
}
.tg-composer-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--tg-text-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .tg-workspace-shell { flex-direction: column; }
  .tg-sidebar { width: 100%; flex: 0 0 45%; }
  .tg-docked-composer { width: 100%; right: 0; }
}
