/* ═══════════════════════════════════════════════════════════════════════════
   COMPOSE — Toolbar v4
   Google Docs philosophy: horizontal row of controls.
   Dropdowns for style/font, icon buttons for formatting, dividers between groups.
   Desktop/tablet: row below topbar. Mobile: fixed bottom.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Shared styles — applied to both #toolbar-row and #toolbar-mobile */
.toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  padding: 0 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  gap: 0;
  width: 100%;
}
.toolbar-inner::-webkit-scrollbar { display: none; }

/* ── Desktop / tablet: centre the toolbar group ──────────────────────── */
/* #toolbar-row centres its .toolbar-inner child.
   .toolbar-inner shrinks to the width of its buttons so it can centre
   correctly rather than spanning the full row width. */
@media (min-width: 768px) {
  #toolbar-row {
    justify-content: center;
  }
  #toolbar-row .toolbar-inner {
    width: auto;          /* shrink to content — buttons determine the width */
    flex: 0 0 auto;       /* don't grow or shrink beyond content */
    overflow-x: visible;  /* no scroll needed — all buttons fit */
  }
}

/* Scroll fade */
.toolbar-scroll-wrap {
  position: relative;
  flex: 1 1 0;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}

/* ── Toolbar button ──────────────────────────────────────────────────── */
.tb-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-sec);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
  cursor: pointer;
  /* No border at rest */
  border: none;
  background: transparent;
}

.tb-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.tb-btn:hover  { background: var(--fill-hover); color: var(--text); }
.tb-btn:active { background: var(--fill-active); }

/* Active/on state */
.tb-btn.is-active {
  background: var(--fill-selected);
  color: var(--accent);
}

/* Wide variant for labelled items */
.tb-btn--wide {
  width: auto;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  gap: 4px;
  color: var(--text-sec);
  font-family: var(--font-ui);
}

/* ── Styled dropdown select (Google Docs style) ──────────────────────── */
.tb-select {
  height: 28px;
  padding: 0 6px;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Arrow via background image */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235F6368' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  padding-right: 22px;
  flex-shrink: 0;
}

.tb-select:hover  { background-color: var(--fill-hover); border-color: var(--border); }
.tb-select:focus  { background-color: var(--fill-hover); border-color: var(--border-focus); }
.tb-select option { background: var(--bg-card); color: var(--text); }

/* Specific widths */
.tb-select--style { min-width: 112px; max-width: 140px; }
.tb-select--font  { min-width: 100px; max-width: 130px; }
.tb-select--size  { width: 42px; padding-right: 16px; text-align: right; }

/* ── Divider between toolbar groups ─────────────────────────────────── */
.tb-divider {
  flex: 0 0 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  align-self: center;
  flex-shrink: 0;
}

/* ── Context groups ──────────────────────────────────────────────────── */
.tb-group { display: contents; }
.tb-group[hidden] { display: none; }

.tb-context-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 8px;
  align-self: center;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Right-side sticky: sidebar toggle ───────────────────────────────── */
.tb-end {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-left: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Tooltips via data-tip (JS-powered rich tooltips) ────────────────── */
[data-tip] { position: relative; }

/* Arrow caret */
[data-tip]::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: var(--tip-arrow-x, 50%);
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  z-index: var(--z-tip);
}
[data-tip]:hover::after  { opacity: 1; }
[data-tip]:active::after { opacity: 0; }

/* Rich tooltip bubble injected by JS */
.tb-tooltip {
  position: fixed;
  background: var(--text);
  color: var(--bg-card);
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-ui);
  padding: 5px 10px;
  border-radius: var(--r-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  z-index: var(--z-tip);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tb-tooltip.is-visible { opacity: 1; }

/* Divider between label and shortcut group */
.tb-tooltip-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Each key token — solid light pill, clearly legible on dark tooltip surface */
.tb-tooltip kbd {
  display: inline-block;
  background: rgba(255,255,255,0.20);
  border: 1px solid rgba(255,255,255,0.35);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0;
  color: rgba(255,255,255,0.95);
}

/* ── Mobile-specific toolbar (bottom) ───────────────────────────────── */
#toolbar-mobile .toolbar-inner {
  justify-content: flex-start;
}

/* ── Style buttons (P / H1 / H2 / H3) — now all SVG icons ───────────── */
.tb-btn--style {
  width: 36px;
  padding: 0;
  font-family: var(--font-ui);
}
.tb-style-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.tb-btn--style svg { width: 18px; height: 18px; }

