/* ==========================================================================
   HIRAISHINMAIL — MULTI-THEME ENGINE (FLAT CSS — NO NESTING)
   Bug-free version: all selectors are flat, no CSS nesting.
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-normal: 0.15s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  background: #f6f8fc;
  color: #1f1f1f;
}

/* ==========================================================================
   THEME VARIABLES (data-theme on body)
   ========================================================================== */

/* iCloud */
body[data-theme="icloud"] {
  --bg-header: rgba(246,246,248,0.92);
  --bg-sidebar: rgba(246,246,248,0.95);
  --bg-page: #f2f2f7;
  --bg-surface: #ffffff;
  --border-color: #e5e5ea;
  --hover-color: #e5e5ea;
  --active-color: #e3e3e8;
  --primary-accent: #007aff;
  --text-main: #000000;
  --text-sub: #3c3c43;
  --text-muted: #8e8e93;
  --header-height: 52px;
  --compose-radius: 9999px;
  --item-radius: 10px;
  --compose-bg: #007aff;
  --compose-color: #ffffff;
  background: var(--bg-page);
  color: var(--text-main);
}

/* Gmail */
body[data-theme="gmail"] {
  --bg-header: #f6f8fc;
  --bg-sidebar: #f6f8fc;
  --bg-page: #f6f8fc;
  --bg-surface: #ffffff;
  --border-color: #e1e5ea;
  --hover-color: #f1f3f4;
  --active-color: #d3e3fd;
  --primary-accent: #0b57d0;
  --text-main: #1f1f1f;
  --text-sub: #444746;
  --text-muted: #5e5e5e;
  --header-height: 64px;
  --compose-radius: 16px;
  --item-radius: 28px;
  --compose-bg: #c2e7ff;
  --compose-color: #001d35;
  font-family: 'Roboto', 'Google Sans', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
}

/* Outlook */
body[data-theme="outlook"] {
  --bg-header: #0078d4;
  --bg-sidebar: #f3f2f1;
  --bg-page: #faf9f8;
  --bg-surface: #ffffff;
  --border-color: #edebe9;
  --hover-color: #f3f2f1;
  --active-color: #c7e0f4;
  --primary-accent: #0078d4;
  --text-main: #201f1e;
  --text-sub: #323130;
  --text-muted: #605e5c;
  --header-height: 48px;
  --compose-radius: 4px;
  --item-radius: 4px;
  --compose-bg: #0078d4;
  --compose-color: #ffffff;
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
}

/* ==========================================================================
   THEME-SPECIFIC VISIBILITY TOGGLES (FLAT — NO NESTING)
   ========================================================================== */

/* Default hide everything theme-specific */
.outlook-rail,
.outlook-ribbon-bar,
.gmail-tabs-bar,
.gmail-toolbar-actions {
  display: none !important;
}

/* iCloud: 3-col, no gmail/outlook extras */
body[data-theme="icloud"] .outlook-rail { display: none !important; }
body[data-theme="icloud"] .outlook-ribbon-bar { display: none !important; }
body[data-theme="icloud"] .gmail-tabs-bar { display: none !important; }
body[data-theme="icloud"] .gmail-toolbar-actions { display: none !important; }
body[data-theme="icloud"] .reading-detail-panel { display: flex !important; }

/* Gmail: show gmail tabs+toolbar, hide outlook, hide detail panel */
body[data-theme="gmail"] .outlook-rail { display: none !important; }
body[data-theme="gmail"] .outlook-ribbon-bar { display: none !important; }
body[data-theme="gmail"] .gmail-tabs-bar { display: flex !important; }
body[data-theme="gmail"] .gmail-toolbar-actions { display: flex !important; }
body[data-theme="gmail"] .reading-detail-panel { display: none !important; }

/* Outlook: show outlook rail+ribbon, hide gmail */
body[data-theme="outlook"] .outlook-rail { display: flex !important; }
body[data-theme="outlook"] .outlook-ribbon-bar { display: flex !important; }
body[data-theme="outlook"] .gmail-tabs-bar { display: none !important; }
body[data-theme="outlook"] .gmail-toolbar-actions { display: none !important; }
body[data-theme="outlook"] .reading-detail-panel { display: flex !important; }

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
  height: var(--header-height, 64px);
  background: var(--bg-header, #f6f8fc);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 50;
  user-select: none;
  border-bottom: 1px solid var(--border-color, #e1e5ea);
}

/* Outlook header override: white text on blue */
body[data-theme="outlook"] .app-header {
  color: #ffffff;
  border-bottom: none;
}
body[data-theme="outlook"] .brand-title-text,
body[data-theme="outlook"] .icon-btn-header,
body[data-theme="outlook"] .speed-badge-text {
  color: #ffffff !important;
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.brand-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--primary-accent);
  color: #ffffff;
  flex-shrink: 0;
}

.brand-title-text {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

.speed-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
  padding: 0.08rem 0.4rem;
  border-radius: 9999px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Search Box */
.search-box-universal {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  height: 36px;
  width: 340px;
  max-width: 100%;
  flex-shrink: 1;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
}

body[data-theme="gmail"] .search-box-universal {
  background: #edf2fc;
  border-radius: 28px;
  height: 44px;
  width: 520px;
}

body[data-theme="outlook"] .search-box-universal {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  height: 32px;
}

.search-box-universal input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 0.88rem;
  color: var(--text-main);
  font-family: inherit;
}

body[data-theme="outlook"] .search-box-universal input {
  color: #ffffff;
}

body[data-theme="outlook"] .search-box-universal input::placeholder {
  color: rgba(255,255,255,0.7);
}

.header-right-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Theme Selector Pill */
.theme-selector-box {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 1.5px solid var(--primary-accent);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.theme-select-dropdown {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-accent);
  cursor: pointer;
  font-family: inherit;
}

/* API Reference Button */
.btn-api-reference {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #0f172a;
  color: #facc15;
  border: 1px solid #ca8a04;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-api-reference:hover {
  background: #1e293b;
  border-color: #facc15;
}

/* Address Pill */
.address-pill-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  flex-shrink: 0;
}

.icon-btn-header {
  color: var(--primary-accent);
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn-header:hover {
  background: rgba(0,0,0,0.06);
}

/* ==========================================================================
   OUTLOOK RIBBON & LEFT RAIL
   ========================================================================== */

.outlook-rail {
  background: #201f1e;
  color: #ffffff;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 1.25rem;
  width: 48px;
  flex-shrink: 0;
}

.rail-icon-btn {
  color: #a19f9d;
  font-size: 1.15rem;
  cursor: pointer;
  transition: color 0.15s;
}

.rail-icon-btn:hover,
.rail-icon-btn.active {
  color: #ffffff;
}

.outlook-ribbon-bar {
  height: 44px;
  background: #ffffff;
  border-bottom: 1px solid #edebe9;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  white-space: nowrap;
}

.ribbon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #323130;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  background: transparent;
}

.ribbon-btn:hover {
  background: #f3f2f1;
  border-color: #8a8886;
}

.ribbon-btn-primary {
  background: #0078d4;
  color: #ffffff;
}

.ribbon-btn-primary:hover {
  background: #106ebe;
}

/* ==========================================================================
   GMAIL TABS & TOOLBAR
   ========================================================================== */

.gmail-tabs-bar {
  height: 48px;
  border-bottom: 1px solid #e1e5ea;
  user-select: none;
  background: #ffffff;
  white-space: nowrap;
  align-items: center;
}

.gmail-tab-item {
  flex: 1;
  max-width: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  height: 100%;
  font-size: 0.85rem;
  font-weight: 500;
  color: #5e5e5e;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: var(--transition-normal);
}

.gmail-tab-item:hover {
  background: #f1f3f4;
}

.gmail-tab-item.active {
  color: #0b57d0;
  font-weight: 700;
  border-bottom-color: #0b57d0;
}

.gmail-toolbar-actions {
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.gmail-toolbar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5e5e5e;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
}

.gmail-toolbar-btn:hover {
  background: #f1f3f4;
  color: #1f1f1f;
}

/* ==========================================================================
   MAIN LAYOUT
   ========================================================================== */

.app-layout-workspace {
  display: flex;
  height: calc(100vh - var(--header-height, 64px));
  overflow: hidden;
}

/* Outlook: subtract ribbon */
body[data-theme="outlook"] .app-layout-workspace {
  height: calc(100vh - 48px - 44px);
}

/* SIDEBAR */
.sidebar-panel {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  user-select: none;
  background: var(--bg-sidebar, #f6f8fc);
  border-right: 1px solid var(--border-color, #e1e5ea);
  padding: 0.65rem 0.75rem;
  overflow-y: auto;
}

body[data-theme="gmail"] .sidebar-panel {
  border-right: none;
}

body[data-theme="outlook"] .sidebar-panel {
  width: 200px;
}

.compose-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--compose-bg);
  color: var(--compose-color);
  padding: 0.75rem 1.25rem;
  border-radius: var(--compose-radius);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  margin-bottom: 0.85rem;
  width: fit-content;
  transition: var(--transition-normal);
  font-family: inherit;
}

body[data-theme="gmail"] .compose-action-btn {
  box-shadow: 0 1px 3px rgba(60,64,67,0.3);
  padding: 0.85rem 1.4rem;
}

.compose-action-btn:hover {
  filter: brightness(0.92);
}

.sidebar-menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.48rem 0.75rem;
  border-radius: var(--item-radius, 10px);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition-normal);
}

.sidebar-menu-item:hover {
  background: var(--hover-color);
}

.sidebar-menu-item.active {
  background: var(--active-color);
  color: var(--primary-accent);
  font-weight: 700;
}

body[data-theme="gmail"] .sidebar-menu-item.active {
  color: #041e49;
}

.sidebar-left-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.sidebar-left-content i {
  width: 18px;
  text-align: center;
}

.badge-count {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(0,0,0,0.06);
  padding: 0.08rem 0.45rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

/* ==========================================================================
   MAIL LIST PANEL
   ========================================================================== */

.mail-list-panel {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface, #ffffff);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

body[data-theme="gmail"] .mail-list-panel {
  border-radius: 16px;
  margin: 0 0.75rem 0.75rem 0;
  box-shadow: 0 1px 3px rgba(60,64,67,0.15);
  border: none;
}

.mail-list-topbar {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
  min-height: 44px;
}

.folder-title-text {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Hide folder title in Gmail (toolbar actions replace it) */
body[data-theme="gmail"] .folder-title-text {
  display: none;
}

.mail-cards-viewport {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Mail Card Item */
.mail-card-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  position: relative;
  transition: var(--transition-normal);
}

.mail-card-item:hover {
  background: var(--hover-color);
}

.mail-card-item.active {
  background: var(--active-color);
  border-left: 3px solid var(--primary-accent);
}

.card-sender-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
  white-space: nowrap;
}

.sender-name-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.mail-date-text {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.card-subject-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-snippet-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   READING DETAIL PANEL (Column 3)
   ========================================================================== */

.reading-detail-panel {
  flex: 1;
  min-width: 0;
  background: var(--bg-surface);
  flex-direction: column;
  overflow: hidden;
}

/* In Gmail this entire panel is hidden via visibility toggle above */
body[data-theme="icloud"] .reading-detail-panel,
body[data-theme="outlook"] .reading-detail-panel {
  display: flex;
}

body[data-theme="icloud"] .mail-list-panel,
body[data-theme="outlook"] .mail-list-panel {
  flex: 0 0 340px;
}

.detail-top-toolbar {
  height: 48px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
}

.toolbar-action-btn {
  color: var(--primary-accent);
  font-size: 1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-normal);
}

.toolbar-action-btn:hover {
  background: rgba(0,0,0,0.06);
}

.reading-body-scroll {
  padding: 2rem 2.5rem;
  overflow-y: auto;
  flex-grow: 1;
}

.detail-subject-header {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.5rem;
  word-break: break-word;
  line-height: 1.3;
}

.detail-sender-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.sender-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ==========================================================================
   FLOATING COMPOSE MODAL
   ========================================================================== */

.floating-compose-modal {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 560px;
  max-width: 90vw;
  height: 480px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.18);
  border: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95) translateY(20px);
  transition: var(--transition-normal);
}

.floating-compose-modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

body[data-theme="gmail"] .compose-header-bar {
  background: #404040;
  color: #ffffff;
}

.compose-header-bar {
  background: var(--bg-page, #f6f8fc);
  padding: 0.65rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: 0.9rem;
}

.compose-close-btn {
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

.compose-close-btn:hover {
  opacity: 1;
}

.compose-input-field {
  border-bottom: 1px solid var(--border-color);
  padding: 0.55rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.compose-input-field input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-main);
}

.compose-textarea-body {
  flex-grow: 1;
  padding: 1.15rem;
  border: none;
  outline: none;
  resize: none;
  font-size: 0.92rem;
  font-family: inherit;
  line-height: 1.6;
  color: var(--text-main);
}

.compose-footer-bar {
  padding: 0.65rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  background: var(--bg-page, #f6f8fc);
}

.btn-send-main {
  background: var(--primary-accent);
  color: #ffffff;
  padding: 0.45rem 1.25rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.86rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-send-main:hover {
  filter: brightness(0.9);
}

/* ==========================================================================
   API EXPLORER MODAL
   ========================================================================== */

.api-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11,19,41,0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.api-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.api-modal-card {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  overflow: hidden;
  border: 2px solid #ca8a04;
}

.api-modal-header {
  padding: 0.85rem 1.25rem;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #dc2626;
}

.api-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #facc15;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.api-modal-close-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.api-modal-close-btn:hover {
  color: #facc15;
}

.api-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex-grow: 1;
  background: #f8fafc;
}

.api-endpoints-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.api-tab-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
}

.api-tab-btn:hover {
  background: #f1f5f9;
}

.api-tab-btn.active {
  background: #ca8a04;
  color: #ffffff;
  border-color: #ca8a04;
}

.terminal-box {
  background: #070c1a;
  border: 1px solid #1e293b;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.terminal-top {
  background: #0f172a;
  padding: 0.5rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-code-body {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: #f8fafc;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

/* ==========================================================================
   MOBILE HAMBURGER MENU BUTTON
   ========================================================================== */

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-main);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: rgba(0,0,0,0.06);
}

body[data-theme="outlook"] .mobile-menu-btn {
  color: #ffffff;
}

/* Mobile sidebar overlay backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  z-index: 89;
}

.sidebar-backdrop.open {
  display: block;
}

/* ==========================================================================
   RESPONSIVE: TABLET (max-width: 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
  /* Hide detail pane on tablet */
  .reading-detail-panel {
    display: none !important;
  }

  /* Make mail list take full remaining space */
  body[data-theme="icloud"] .mail-list-panel,
  body[data-theme="outlook"] .mail-list-panel {
    flex: 1 !important;
  }

  /* Shrink sidebar */
  .sidebar-panel {
    width: 200px;
  }

  body[data-theme="outlook"] .sidebar-panel {
    width: 180px;
  }

  /* Shrink search */
  .search-box-universal {
    width: 220px;
  }

  body[data-theme="gmail"] .search-box-universal {
    width: 300px;
  }

  /* Hide address pill text, keep icon + copy */
  .address-pill-header #activeEmailDisplay {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================================================
   RESPONSIVE: MOBILE (max-width: 768px)
   ========================================================================== */

@media (max-width: 768px) {
  /* Show hamburger */
  .mobile-menu-btn {
    display: flex;
  }

  /* Compact header */
  .app-header {
    padding: 0 0.65rem;
    gap: 0.4rem;
  }

  .header-brand-group {
    gap: 0.4rem;
  }

  /* Hide non-essential header items */
  .search-box-universal {
    display: none !important;
  }

  .speed-badge {
    display: none;
  }

  .address-pill-header {
    display: none;
  }

  .btn-api-reference span {
    display: none;
  }

  /* Outlook ribbon: horizontal scroll */
  .outlook-ribbon-bar {
    overflow-x: auto;
    padding: 0 0.65rem;
    gap: 0.35rem;
  }

  .ribbon-btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }

  /* Outlook rail: hide on mobile */
  .outlook-rail {
    display: none !important;
  }

  /* Layout: full width single column */
  .app-layout-workspace {
    flex-direction: column;
  }

  body[data-theme="outlook"] .app-layout-workspace {
    height: calc(100vh - 48px - 44px);
  }

  /* Sidebar: offscreen drawer */
  .sidebar-panel {
    position: fixed;
    top: 0;
    left: -280px;
    width: 270px;
    height: 100vh;
    z-index: 90;
    background: var(--bg-sidebar, #f6f8fc);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    transition: left 0.25s ease;
    padding-top: calc(var(--header-height, 64px) + 0.75rem);
    overflow-y: auto;
  }

  .sidebar-panel.open {
    left: 0;
  }

  /* Mail list: full width */
  .mail-list-panel {
    flex: 1 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-right: none;
  }

  body[data-theme="icloud"] .mail-list-panel,
  body[data-theme="outlook"] .mail-list-panel {
    flex: 1 !important;
  }

  /* Detail pane: always hidden on mobile */
  .reading-detail-panel {
    display: none !important;
  }

  /* Gmail tabs: horizontal scroll */
  .gmail-tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .gmail-tab-item {
    padding: 0 0.85rem;
    font-size: 0.82rem;
    gap: 0.5rem;
    min-width: fit-content;
  }

  /* Bigger touch targets for mail cards */
  .mail-card-item {
    padding: 0.85rem 0.85rem;
  }

  /* Compose modal: full-width bottom sheet */
  .floating-compose-modal {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 75vh;
    border-radius: 16px 16px 0 0;
  }

  /* API modal: nearly full screen */
  .api-modal-card {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
  }

  .api-endpoints-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .api-tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .terminal-code-body {
    font-size: 0.7rem;
    padding: 0.75rem;
  }
}

/* ==========================================================================
   RESPONSIVE: SMALL PHONE (max-width: 420px)
   ========================================================================== */

@media (max-width: 420px) {
  .app-header {
    padding: 0 0.5rem;
  }

  .brand-title-text {
    font-size: 0.95rem;
  }

  .theme-selector-box {
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
  }

  .theme-select-dropdown {
    font-size: 0.72rem;
  }

  .btn-api-reference {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
  }

  .sidebar-panel {
    width: 250px;
  }

  .floating-compose-modal {
    height: 85vh;
  }

  .compose-input-field {
    padding: 0.5rem 0.85rem;
  }
}
