.canvas-text-overlay {
  position: absolute;
  z-index: 13;
  touch-action: none;
  cursor: crosshair;
}

.canvas-text-empty-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 8px 12px;
  border: 1px solid rgb(0 175 233 / 28%);
  border-radius: 8px;
  color: #344054;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 24px rgb(33 43 67 / 8%);
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.canvas-text-overlay.has-layers .canvas-text-empty-hint {
  display: none;
}

.canvas-text-layer {
  position: absolute;
  box-sizing: border-box;
  min-height: 24px;
  padding: 2px;
  border: 1px solid transparent;
  transform-origin: 50% 50%;
  cursor: move;
}

.canvas-text-layer.is-selected {
  border: 1px solid #00afe9;
  box-shadow: none;
}

.canvas-text-glyph {
  width: 100%;
  min-height: 1em;
  overflow: visible;
  color: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: none;
  pointer-events: none;
}

.canvas-text-layer.is-selected .canvas-text-glyph {
  outline: 0;
  cursor: text;
  user-select: text;
  pointer-events: auto;
}


.canvas-text-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 2px solid #00afe9;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgb(37 78 101 / 12%);
}

.canvas-text-handle[data-text-handle="left"] {
  left: 0;
  top: 50%;
  cursor: ew-resize;
  transform: translate(-50%, -50%);
}

.canvas-text-handle[data-text-handle="right"] {
  right: 0;
  top: 50%;
  cursor: ew-resize;
  transform: translate(50%, -50%);
}

.canvas-text-handle[data-text-handle="rotate"] {
  left: 50%;
  top: -24px;
  cursor: grab;
  transform: translate(-50%, -50%);
}

.canvas-text-handle[data-text-handle="rotate"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  width: 1px;
  height: 16px;
  background: #00afe9;
  transform: translateX(-50%);
}

.workbench-side.is-text-editing > :not(.canvas-text-inspector) {
  display: none !important;
}

.canvas-text-inspector {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgb(33 43 67 / 8%);
}

.canvas-text-inspector-head {
  flex: 0 0 auto;
  padding: 16px;
  border-bottom: 1px solid #e8edf5;
}

.canvas-text-inspector-head h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  font-weight: 700;
  line-height: 26px;
}

.canvas-text-inspector-head p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

.canvas-text-inspector-body {
  min-height: 0;
  display: grid;
  gap: 16px;
  overflow-y: auto;
  padding: 16px;
}

.canvas-text-layer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-text-layer-tab,
.canvas-text-add-layer {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  color: #344054;
  background: #ffffff;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
}

.canvas-text-layer-tab.is-active {
  border-color: #00afe9;
  color: #00afe9;
  background: #e7f8fe;
}

.canvas-text-field,
.canvas-text-section {
  display: grid;
  gap: 8px;
}

.canvas-text-field > label,
.canvas-text-section-title {
  color: #344054;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
}

.canvas-text-input,
.canvas-text-select,
.canvas-text-number,
.canvas-text-content {
  width: 100%;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  color: #344054;
  background: #ffffff;
  font-size: 14px;
  font-weight: 400;
}

.canvas-text-input,
.canvas-text-select,
.canvas-text-number {
  height: 40px;
  padding: 0 12px;
  text-align: center;
}

.canvas-text-content {
  min-height: 96px;
  resize: vertical;
  padding: 12px;
  line-height: 22px;
  text-align: left;
}

.canvas-text-input:focus,
.canvas-text-select:focus,
.canvas-text-number:focus,
.canvas-text-content:focus {
  border-color: #00afe9;
  outline: 0;
  box-shadow: 0 0 0 2px rgb(0 175 233 / 14%);
}

.canvas-text-font-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.canvas-text-font-upload-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgb(0 175 233 / 36%);
  border-radius: 8px;
  color: #00afe9;
  background: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  cursor: pointer;
}

.canvas-text-font-notice {
  margin: 0;
  color: #98a2b3;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

.canvas-text-grid-2,
.canvas-text-grid-3 {
  display: grid;
  gap: 8px;
}

.canvas-text-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.canvas-text-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.canvas-text-toggle-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.canvas-text-toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #00afe9;
}

.canvas-text-color {
  width: 100%;
  height: 40px;
  padding: 4px 8px;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  background: #ffffff;
}

.canvas-text-inspector-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 16px;
  border-top: 1px solid #e8edf5;
  background: #ffffff;
}

.canvas-text-action {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e8edf5;
  border-radius: 8px;
  color: #344054;
  background: #ffffff;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.canvas-text-action.is-danger {
  border-color: rgb(205 20 15 / 24%);
  color: #cd140f;
  background: #fff2f0;
}

.canvas-text-action.is-primary {
  grid-column: 1 / -1;
  height: 44px;
  border-color: transparent;
  color: #ffffff;
  background: linear-gradient(90deg, #00afe9 0%, #5cc8f4 100%);
  box-shadow: 0 4px 12px rgb(0 175 233 / 18%);
  font-weight: 600;
}

.canvas-text-action:hover,
.canvas-text-font-upload-button:hover,
.canvas-text-layer-tab:hover,
.canvas-text-add-layer:hover {
  filter: brightness(.98);
}

.canvas-text-action:active,
.canvas-text-font-upload-button:active,
.canvas-text-layer-tab:active,
.canvas-text-add-layer:active {
  transform: translateY(1px);
}

.canvas-text-action:focus-visible,
.canvas-text-font-upload-button:focus-visible,
.canvas-text-layer-tab:focus-visible,
.canvas-text-add-layer:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px rgb(0 175 233 / 18%);
}

.canvas-text-action:disabled,
.canvas-text-input:disabled,
.canvas-text-select:disabled,
.canvas-text-number:disabled,
.canvas-text-content:disabled {
  color: #98a2b3;
  border-color: #e8edf5;
  background: #f2f4f7;
  box-shadow: none;
  cursor: not-allowed;
  opacity: .8;
}

.canvas-text-presentation {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: visible;
  border-radius: inherit;
  pointer-events: none;
}

.canvas-image-frame.is-cropping .canvas-text-presentation {
  visibility: hidden;
}

.canvas-text-presentation-layer {
  position: absolute;
  box-sizing: border-box;
  min-height: 1em;
  transform-origin: 50% 50%;
  cursor: url("../icon-canvas-text-move.svg") 8 8, move;
  pointer-events: auto;
}

.canvas-text-presentation-layer.is-selected {
  outline: 1px solid #00afe9;
  outline-offset: 0;
}

.canvas-text-presentation-glyph {
  width: max-content;
  min-height: 1em;
  overflow: visible;
  white-space: pre;
  overflow-wrap: normal;
  pointer-events: none;
  user-select: none;
  pointer-events: none;
}


@media (max-width: 900px) {
  .canvas-text-inspector {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 90;
    max-height: min(72vh, 640px);
  }

  .workbench-side.is-text-editing {
    pointer-events: none;
  }

  .workbench-side.is-text-editing .canvas-text-inspector {
    pointer-events: auto;
  }

  .canvas-text-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
