/* ============================================================
   TEXT FORMAT — FAB "T" above paint, vertical tools panel
   FAB stacks: paint-fab (bottom 108) → tf-fab (bottom 184)
   ============================================================ */

.tf-fab {
  position: fixed;
  bottom: 108px;                     /* над dict-fab */
  right: max(20px, calc(50% - 481px));
  z-index: 49;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #2c2d31 0%, #1a1b1e 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 6px 18px rgba(60, 64, 67, 0.28),
    0 2px 6px rgba(60, 64, 67, 0.16);
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.18s, opacity 0.2s, background 0.2s;
}
.tf-fab:hover {
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 12px 28px rgba(60, 64, 67, 0.36),
    0 4px 8px rgba(60, 64, 67, 0.20);
}
.tf-fab:active { transform: translateY(-1px); }

body.tf-on .tf-fab {
  background: linear-gradient(180deg, #1a73e8 0%, #1557b0 100%);
  border-color: #1557b0;
}

.dict-open .tf-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}

.tf-fab-label {
  position: absolute;
  right: 72px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.tf-fab:hover .tf-fab-label { opacity: 1; }
body.tf-on .tf-fab:hover .tf-fab-label { opacity: 0; }

/* ---- Tools panel ---- */
.tf-tools {
  position: fixed;
  bottom: 108px;                     /* same level as tf-fab */
  right: calc(max(20px, calc(50% - 481px)) + 60px + 10px);  /* left of FAB */
  z-index: 49;
  height: 44px;                      /* single horizontal strip */
  background: #f1f3f4;               /* серая подложка контрастирует с белым листом */
  border: 1px solid #d4d6d9;
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  box-shadow:
    0 4px 14px rgba(60, 64, 67, 0.22),
    0 1px 4px rgba(60, 64, 67, 0.12);
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.18s, transform 0.18s;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  white-space: nowrap;
}
body.tf-on .tf-tools {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.tf-row,
.tf-row.tf-grid {
  display: contents;                 /* «растворяем» исторические row-обёртки */
}

/* Тонкие визуальные разделители между группами (вместо row-переносов) */
.tf-sep {
  width: 1px;
  height: 22px;
  background: var(--rule);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Font select — компактнее */
.tf-font {
  width: 110px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 4px 22px 4px 8px;
  font-family: inherit;
  font-size: 12px;
  background: var(--paper);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%235f6368' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  height: 28px;
}
.tf-font:focus { border-color: #1a73e8; }

/* Size stepper */
.tf-size {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--paper);
  height: 28px;
  flex-shrink: 0;
}
.tf-size input {
  width: 32px;
  height: 26px;
  border: none;
  outline: none;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  -moz-appearance: textfield;
}
.tf-size input::-webkit-outer-spin-button,
.tf-size input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tf-size .tf-size-btns {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--rule);
  height: 100%;
}
.tf-size .tf-size-btns button {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 22px;
  height: 14px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
}
.tf-size .tf-size-btns button:first-child {
  border-bottom: 1px solid var(--rule);
}
.tf-size .tf-size-btns button:hover {
  background: #f1f3f4;
  color: var(--ink);
}
.tf-size .tf-size-btns svg {
  width: 8px;
  height: 8px;
}

/* Generic tool button */
.tf-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  transition: background 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.tf-btn:hover { background: #e1e5e8; }
.tf-btn.is-active {
  background: #e8f0fe;
  border-color: #1a73e8;
  color: #1a73e8;
}
.tf-btn svg {
  width: 16px;
  height: 16px;
}

/* Bold/Italic/Underline letters */
.tf-btn .tf-letter { font-family: Georgia, serif; }
.tf-btn .tf-letter.b { font-weight: 700; }
.tf-btn .tf-letter.i { font-style: italic; font-weight: 500; }
.tf-btn .tf-letter.u { text-decoration: underline; font-weight: 500; }
.tf-btn .tf-letter.s { text-decoration: line-through; font-weight: 500; }

/* Color swatch indicator on the icon button: A with underline of current color */
.tf-color-trigger {
  position: relative;
}
.tf-color-trigger .tf-color-bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 5px;
  height: 3px;
  border-radius: 1px;
  background: var(--ink);
}

/* Color popover */
.tf-popover {
  position: absolute;
  bottom: 38px;
  right: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 6px 18px rgba(60, 64, 67, 0.20);
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
}
.tf-popover.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.tf-popover-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.tf-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: #fff;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.tf-swatch:hover { transform: scale(1.1); }
.tf-swatch.is-none {
  background:
    linear-gradient(45deg, transparent 47%, #d93025 47%, #d93025 53%, transparent 53%),
    var(--paper);
}

/* Grouped color block (text color + highlight, both with their own popovers) */
.tf-color-group {
  position: relative;
  display: inline-flex;
}
