/* ============================================================
   PAINT — overlay drawing on the sheet
   FAB sits above the dictionary "Aa" button (right side)

   ⚠ ВРЕМЕННО СКРЫТО на вебе. Модуль остаётся подключенным,
   снять display:none — и всё вернётся.
   ============================================================ */

.paint-fab,
.paint-tools {
  display: none !important;
}

.paint-fab {
  position: fixed;
  bottom: 184px;                     /* выше text-format FAB (108) */
  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;
  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;
}
.paint-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);
}
.paint-fab:active { transform: translateY(-1px); }
.paint-fab svg { width: 26px; height: 26px; color: #fff; }

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

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

.paint-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;
}
.paint-fab:hover .paint-fab-label { opacity: 1; }
body.paint-on .paint-fab:hover .paint-fab-label { opacity: 0; }

/* ---- Tools panel ---- */
.paint-tools {
  position: fixed;
  bottom: 254px;                     /* выше paint-fab (184 + 60 + 10) */
  right: max(20px, calc(50% - 481px));
  z-index: 49;
  width: 60px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(60, 64, 67, 0.20);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.18s, transform 0.18s;
}
body.paint-on .paint-tools {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.paint-tool {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.paint-tool:hover { background: #f1f3f4; }
.paint-tool.is-active {
  background: #e8f0fe;
  border-color: #1a73e8;
}
.paint-tool:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.paint-tool:disabled:hover { background: transparent; }

.paint-tool svg { width: 20px; height: 20px; color: var(--ink); }

.paint-tool .size-dot {
  border-radius: 50%;
  background: var(--ink);
}
.paint-tool .size-dot.thin  { width: 6px;  height: 6px;  }
.paint-tool .size-dot.thick { width: 14px; height: 14px; }

.paint-tool .color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s;
}
.paint-tool.is-active .color-swatch {
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px #1a73e8;
}

.paint-divider {
  width: 28px;
  height: 1px;
  background: var(--rule);
  margin: 2px 0;
}

/* ---- Drawing surface inside sheet ---- */
.paint-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  touch-action: none;     /* important: prevents scroll on touch devices */
}
.paint-snapshot {
  /* Hidden snapshot image — used purely for persistence in innerHTML.
     Becomes visible only when canvas is gone (e.g. SSR view). */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  display: none;
}

body.paint-on .paint-canvas {
  pointer-events: auto;
  cursor:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><g fill='none' stroke='%231a1b1e' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path d='M2 22 L4 17 L17 4 L20 7 L7 20 Z' fill='%23ffd56b'/><path d='M14 7 L17 10' stroke='%231a1b1e'/><path d='M2 22 L4 17 L7 20 Z' fill='%231a1b1e'/><path d='M17 4 L19 2 L22 5 L20 7 Z' fill='%23ec5252'/></g></svg>") 1 22,
    crosshair;
}
body.paint-on.tool-eraser .paint-canvas {
  cursor:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><g><rect x='4' y='10' width='16' height='8' rx='1.5' fill='%23ffb1b1' stroke='%231a1b1e' stroke-width='1.3'/><rect x='4' y='10' width='5' height='8' fill='%23ec5252' stroke='%231a1b1e' stroke-width='1.3'/></g></svg>") 12 14,
    cell;
}

body.paint-on article.sheet,
body.paint-on article.sheet * {
  user-select: none;
  -webkit-user-select: none;
}
body.paint-on article.sheet[contenteditable="true"] {
  -webkit-user-modify: read-only;
}
