.text-editor-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  color: #fff;
}
.text-editor-layer[hidden], .text-editor-format[hidden], .text-editor-toolbar[hidden] { display: none !important; }
.text-editor-selection {
  position: absolute;
  padding: 5px;
  border: 1.5px solid #0a84ff;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  outline: none;
}
.text-editor-selection:active { cursor: grabbing; }
.text-editor-content {
  box-sizing: content-box;
  white-space: normal;
  overflow-wrap: normal;
  min-width: 0;
  outline: none;
  border: 0;
  text-shadow: none;
  paint-order: stroke fill;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  caret-color: #0a84ff;
}
.text-editor-selection.editing .text-editor-content{white-space:pre-wrap;overflow-wrap:anywhere;hyphens:auto;cursor:text;user-select:text;-webkit-user-select:text;touch-action:manipulation}
.text-editor-layer.editing-layer{position:fixed;inset:0;z-index:18}
.text-editor-layer.editing-layer .text-editor-selection{box-sizing:border-box;padding:10.5px;border-radius:12px;background:var(--popup-surface,#3032388c);backdrop-filter:var(--popup-filter,blur(8px) saturate(1.15));-webkit-backdrop-filter:var(--popup-filter,blur(8px) saturate(1.15));box-shadow:0 6px 26px #0007;cursor:text;touch-action:pan-y}
.text-editor-layer.editing-layer .text-editor-content{box-sizing:border-box;hyphens:none;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;touch-action:pan-y;-webkit-touch-callout:default}
.text-editor-layer.editing-layer .text-editor-handle{display:none}
.text-editor-line{white-space:pre;line-height:inherit}
.text-editor-line.justified{text-align:justify;text-align-last:justify;white-space:normal}
.text-editor-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #0a84ff;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow:0 0 0 1px #0a84ff;
  cursor: ew-resize;
  touch-action: none;
}
.text-editor-handle:before{content:'';position:absolute;inset:-10px;border-radius:50%}
.text-editor-handle.left{left:-8px;top:calc(50% - 7px)}
.text-editor-handle.right{right:-8px;top:calc(50% - 7px)}
.text-editor-toolbar {
  --toolbar-button-size: calc(var(--round-button-size, 48px) - 8px);
  height: var(--round-button-size, 48px);
  position: fixed;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px;
  border-radius: 40px;
  background: var(--popup-surface,#3032388c);
  backdrop-filter: var(--popup-filter,blur(8px) saturate(1.15));
  -webkit-backdrop-filter: var(--popup-filter,blur(8px) saturate(1.15));
  box-shadow: 0 4px 20px #0005;
  pointer-events: auto;
  z-index: 16;
}
.text-editor-toolbar .text-editor-tool {
  --control-icon-size: calc((var(--toolbar-button-size) - 12px)*.8);
  display: grid;
  place-items: center;
  width: var(--toolbar-button-size);
  height: var(--toolbar-button-size);
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #353538;
  touch-action: manipulation;
}
.text-editor-toolbar .text-editor-tool:disabled { opacity: .35; }
.text-editor-toolbar .text-editor-tool svg { display: block; width: calc((100% - 12px)*.8); height: calc((100% - 12px)*.8); }
.text-editor-format {
  position: fixed;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  color-scheme: dark;
  box-shadow: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior: contain;
  touch-action: pan-x;
  pointer-events: auto;
  z-index: 15;
  font: 18px -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
.text-editor-format::-webkit-scrollbar { display: none; }
.text-editor-format .text-editor-styles { display: flex; flex: 0 0 auto; gap: var(--format-round-gap, 14px); align-items: center; }
.text-editor-format .text-editor-styles button {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  flex: 0 0 var(--format-round-size);
  width: var(--format-round-size);
  height: var(--format-round-size);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #242424b8;
  color: #fff;
  font-size: calc((var(--format-round-size) - 20px)*.8);
  line-height: 1;
  touch-action: manipulation;
}
.text-editor-format .text-editor-styles button.active { color: #0a84ff; background: #424247; }
.text-editor-format [data-text-style="bold"] { font-weight: 800; }
.text-editor-format [data-text-style="italic"] { font-style: italic; }
.text-editor-format [data-text-style="underline"] { text-decoration: underline; }
.text-editor-format [data-text-style="strike"] { text-decoration: line-through; }
.text-editor-format .text-editor-size-row {
  display: grid;
  flex: 0 0 140px;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  height: var(--format-round-size);
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #242424b8;
}
.text-editor-format .text-editor-size-row button {
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 25px;
}
.text-editor-format .text-editor-size {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  font-size: 18px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.text-editor-size::-webkit-inner-spin-button,
.text-editor-size::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.text-editor-format .text-editor-font {
  display: block;
  flex: 0 0 190px;
  width: 190px;
  min-width: 0;
  min-height: 0;
  height: var(--format-round-size);
  margin: 0;
  padding: 5px 44px 5px 16px;
  border: 0;
  border-radius: 999px;
  background: #242424b8;
  color: #fff;
  font-size: 18px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 18px 18px;
  background-position: right 16px center;
}
.text-editor-format [data-text-action="alignment"] svg { width: calc((var(--format-round-size) - 20px)*.8) !important; height: calc((var(--format-round-size) - 20px)*.8) !important; display: block; }
.text-editor-format .text-editor-styles .text-editor-color {
  padding: 4px;
  background: conic-gradient(#ff375f,#ff9f0a,#ffd60a,#30d158,#64d2ff,#0a84ff,#bf5af2,#ff375f);
}
.text-editor-color span { position:relative;display:block;width:100%;height:100%;border:2px solid #f6f6f7;border-radius:50%;overflow:hidden;background:repeating-conic-gradient(#aaa 0 25%,#333 0 50%) 0/10px 10px; }
.text-editor-color span:after{content:'';position:absolute;inset:0;background:var(--text-color,#fff);opacity:var(--text-opacity,1)}
.text-editor-format :is(.text-editor-styles button,.text-editor-size-row button,.text-editor-size-row input,.text-editor-font):focus-visible { outline-offset: -3px; }

.text-editor-toolbar .text-editor-aa { font-size: calc(var(--toolbar-button-size)*.48); font-weight: 600; line-height: 1; }
.text-editor-toolbar .text-editor-aa.active { color: #0a84ff; background: #424247; }
.text-editor-toolbar .text-editor-tool[hidden] { display: none !important; }

/* Floating text tools stay below sheets (19/25) and all popup surfaces.
   Temporarily hide the controls without losing the selected object's format view. */
body.effects-open .text-editor-toolbar,body.effects-open .text-editor-format,
body:has(dialog[open]) .text-editor-toolbar,body:has(dialog[open]) .text-editor-format{visibility:hidden;pointer-events:none}

/* Standalone project-name input must stay above the project sheet (z-index 35). */
.text-editor-layer.editing-layer.text-editor-input{z-index:50}
