/* Shared desktop/mobile shell controls use the existing editor palette. */
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none;
  min-height: 36px; margin: 0; padding: 6px; box-sizing: border-box;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: #4a4447;
  font-size: 13px; font-weight: 600; line-height: 1.3; white-space: nowrap; cursor: pointer;
}
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-button:hover { background: #fff7fb; }
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-button.is-active { background: #fff7fb; border-color: #ead5df; color: #9f315b; }
:is(.td-editor-shell, .td-mobile-editor-shell) button:focus-visible { outline: 2px solid #c64b7f; outline-offset: -2px; }
:is(.td-editor-shell, .td-mobile-editor-shell) button:disabled { opacity: .45; cursor: default; }
.td-shell-button svg { width: 18px; height: 18px; flex: none; }
.td-shell-material-icon { fill: currentColor; }
.td-left-panel-header .td-shell-button svg { width: 20px; height: 20px; }
.td-context-toolbar, .td-shell-toolbar-controls, .td-shell-toolbar-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
.td-context-toolbar { width: 100%; max-width: 100%; overflow: hidden; height: 56px; box-sizing: border-box; padding: 4px 8px; border-bottom: 1px solid #e7e0e3; z-index: 91; }
.td-context-toolbar .td-shell-button { height: 36px; }
.td-shell-toolbar-scroll { position: relative; display: flex; align-items: center; gap: 2px; flex: 1 1 0; min-width: 0; height: 100%; overflow: hidden; }
.td-shell-toolbar-scroll-button { display: none; }
.td-shell-toolbar-scroll-button[hidden] { display: none !important; }
.td-shell-toolbar-controls { flex: 1 1 0; width: auto; height: 100%; min-width: 0; overflow-x: hidden; overflow-y: hidden; }
.td-shell-toolbar-actions { flex: none; margin-left: auto; }
.td-shell-toolbar-actions:not(:empty)::before, .td-shell-divider { content: ''; flex: 0 0 1px; width: 1px; height: 24px; background: #e7e0e3; margin: 0 4px; }
.td-context-toolbar, .td-shell-toolbar-controls { scrollbar-width: none; }
.td-context-toolbar::-webkit-scrollbar, .td-shell-toolbar-controls::-webkit-scrollbar { display: none; }
.td-shell-icon-only { width: 36px; }
.td-shell-icon-only.is-vertical svg { transform: rotate(90deg); }
.td-shell-font-controls { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.td-shell-edit-text { color: #6e6670; }
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-font-button { width: 210px; min-width: 210px; justify-content: space-between; background: #fff; border: 1px solid #ded7d4; font-size: 14px; }
.td-shell-font-icon { display: none; }
.td-shell-font-caret { display: inline-flex; }
.td-shell-font-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.td-shell-font-size { flex: none; }
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-stepper { display: flex; align-items: center; gap: 0; height: 36px; box-sizing: border-box; background: #fff; border: 1px solid #ded7d4; border-radius: 8px; padding: 1px; }
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-stepper > button { width: 28px; height: 32px; min-height: 0; flex: none; padding: 0; margin: 0; border: 0; border-radius: 6px; background: #f7f3f6; color: #8f2e56; font-size: 14px; }
:is(.td-editor-shell, .td-mobile-editor-shell) .td-shell-stepper > .td-shell-font-size-picker { width: 56px; min-width: 56px; flex: 0 0 56px; }
.td-shell-font-size-picker .td-value-combo-main { grid-template-columns: minmax(0, 1fr); }
.td-shell-font-size-picker .td-value-select-input { padding: 0 4px; text-align: center; }
.td-shell-font-size-picker .td-value-option-list { min-width: 104px; }
.td-value-option-list.is-portal-menu { right: auto; top: auto; }
.td-value-option-list.is-portal-menu .td-value-option { width: 100%; box-sizing: border-box; text-align: center; }
.td-shell-size-unit { font-size: 12px; color: #8a8286; padding-right: 4px; }
.td-shell-color-swatch { width: 22px; height: 22px; box-sizing: border-box; flex: none; border: 1px solid #ded7d4; border-radius: 50%; }
.td-shell-selection-count { white-space: nowrap; font-size: 13px; padding: 0 8px; }
.td-context-toolbar [data-tool-key="selectionCount"] { color: #9f315b; font-weight: 700; }
.td-shell-disabled-value { font-size: 13px; }
.td-left-panel { background: #fff; color: #241f20; font-size: 14px; }
.td-left-panel-body > section + section { margin-top: 12px; }
.td-text-writing-mode { display: grid; gap: 6px; }
.td-text-writing-mode-label { color: #655d62; font-size: 13px; font-weight: 700; }
.td-text-writing-mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 4px; border-radius: 10px; background: #f5f2f7; }
.td-text-writing-mode-tab { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: #665e6f; font: inherit; font-weight: 800; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.td-text-writing-mode-tab.is-active { background: #fff; color: #4f4264; box-shadow: 0 4px 14px rgba(54, 46, 68, .12); }
.td-text-writing-mode-tab svg { width: 18px; height: 18px; flex: none; }
.td-text-writing-mode-tab:focus-visible { outline: 2px solid #c64b7f; outline-offset: 2px; }
.td-left-panel-body, .td-layer-column, .td-layer-list { scrollbar-width: thin; scrollbar-color: #d5d5da transparent; }
.td-left-panel-body::-webkit-scrollbar, .td-layer-column::-webkit-scrollbar, .td-layer-list::-webkit-scrollbar { width: 8px; }
.td-left-panel-body::-webkit-scrollbar-thumb, .td-layer-column::-webkit-scrollbar-thumb, .td-layer-list::-webkit-scrollbar-thumb { background: #d5d5da; border-radius: 999px; }
.td-layer-column .td-layer-panel-header { display: flex; align-items: center; justify-content: space-between; }
.td-layer-column :is(.td-layer-panel, .td-layer-panel-inner, .td-layer-list, .td-layer-row) { min-width: 0; max-width: 100%; box-sizing: border-box; overflow-x: hidden; }
.td-layer-column .td-layer-reopen { width: 100%; flex-direction: column; padding: 6px 0; }
.td-layer-vertical-label { writing-mode: vertical-rl; font-size: 12px; }
.td-layer-count { border-radius: 7px; background: #fff7fb; color: #9f315b; padding: 2px 4px; font-size: 12px; }
@media (max-width: 1180px) {
  .td-mobile-shell-nav .td-shell-button { flex: 0 0 20%; width: 20%; max-width: 20%; min-width: 20%; min-height: 56px; box-sizing: border-box; font-size: 12px; font-weight: 900; border-radius: 0; padding: 4px 2px; }
  .td-mobile-shell-nav .td-shell-button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .td-mobile-shell-nav .td-shell-button svg { width: 22px; height: 22px; }
  .td-mobile-editor-shell .td-context-toolbar .td-shell-button { font-size: 13px; }
  .td-mobile-editor-shell .td-context-toolbar .td-shell-font-button { font-size: 14px; }
}

/* The measurement hook reads intrinsic item widths before paint. */
.td-toolbar-tooltip-host { min-width: 0; height: 56px; flex: 0 0 56px; }
.td-toolbar-item { flex: none; display: flex; }
.td-toolbar-item[hidden] { display: none; }
.td-context-toolbar .td-shell-icon-only .td-shell-button-label { display: none; }
.td-context-toolbar[data-compact="true"] .td-shell-adaptive { width: 36px; }
.td-context-toolbar[data-compact="true"] .td-shell-adaptive .td-shell-button-label { display: none; }
.td-context-toolbar .td-shell-size-unit { display: none; }
.td-toolbar-tooltip { position: fixed; z-index: 10020; transform: translateX(-50%); background: #242124; color: #fff; border-radius: 4px; padding: 5px 8px; font-size: 12px; line-height: 1.4; max-width: 190px; pointer-events: none; }
.td-toolbar-tooltip::before { content: ''; position: absolute; bottom: 100%; left: calc(50% - 4px); border: 4px solid transparent; border-bottom-color: #242124; }
.td-toolbar-more-menu { position: fixed; z-index: 10010; display: grid; gap: 2px; padding: 6px; min-width: 180px; max-height: calc(100dvh - 150px); overflow-y: auto; background: #fff; border: 1px solid #ded7d4; border-radius: 8px; box-shadow: 0 4px 18px #0003; }
.td-toolbar-more-menu .td-toolbar-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 8px; border: 0; border-radius: 5px; background: #fff; color: #4a4447; font-size: 13px; text-align: left; cursor: pointer; }
.td-toolbar-menu-item svg { width: 18px; height: 18px; flex: none; }
.td-toolbar-more-menu .td-toolbar-menu-item:is(:hover, :focus-visible, .is-active) { background: #fff7fb; color: #9f315b; }
.td-toolbar-menu-item:focus-visible { outline: 2px solid #c64b7f; outline-offset: -2px; }
.td-toolbar-menu-item:disabled { opacity: .45; cursor: default; }
@media (min-width: 1181px) {
  .td-shell-toolbar-controls { overflow: hidden; }
  .td-context-toolbar .td-shell-stepper > .td-shell-font-size-picker { width: 44px; min-width: 44px; flex-basis: 44px; }
}
@media (max-width: 1180px) {
  .td-toolbar-tooltip-host { height: 52px; flex-basis: 52px; }
  .td-context-toolbar .td-shell-toolbar-controls { box-sizing: border-box; padding-inline-end: 0; overflow-x: auto; touch-action: pan-x; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .td-mobile-editor-shell .td-context-toolbar:not(.is-background) .td-shell-toolbar-scroll .td-shell-toolbar-scroll-button,
  .td-mobile-editor-shell .td-shell-toolbar-scroll.is-overflowing .td-shell-toolbar-scroll-button { display: flex; align-items: center; justify-content: center; flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; padding: 0; border: 1px solid #e1d9e0; border-radius: 8px; background: #fff7fb; color: #705665; cursor: pointer; touch-action: manipulation; }
  .td-mobile-editor-shell .td-shell-toolbar-scroll-button svg { width: 16px; height: 16px; }
  .td-mobile-editor-shell .td-shell-toolbar-scroll-button:not(:disabled):is(:hover, :focus-visible) { background: #f5e8ef; color: #9f315b; }
  .td-mobile-editor-shell .td-shell-toolbar-scroll-button:disabled { opacity: .45; cursor: default; }
  .td-mobile-editor-shell .td-shell-toolbar-scroll-button-prev svg { transform: rotate(90deg); }
  .td-mobile-editor-shell .td-shell-toolbar-scroll-button-next svg { transform: rotate(-90deg); }
}
@media (max-width: 430px) {
  .td-mobile-editor-shell .td-context-toolbar .td-shell-font-button { flex: 0 0 112px; width: 112px; min-width: 112px; }
  .td-mobile-editor-shell .td-context-toolbar .td-shell-font-label { max-width: 72px; }
}
@media (max-width: 340px) {
  .td-mobile-editor-shell .td-context-toolbar .td-shell-font-button { flex-basis: 60px; width: 60px; min-width: 60px; padding-inline: 4px; }
  .td-mobile-editor-shell .td-context-toolbar .td-shell-font-label { max-width: 24px; }
}
@media (min-width: 1181px) and (max-width: 1280px) {
  .td-context-toolbar { padding-inline: 4px; gap: 2px; }
  .td-shell-toolbar-controls, .td-shell-toolbar-actions { gap: 2px; }
  .td-context-toolbar .td-shell-icon-only, .td-context-toolbar[data-compact="true"] .td-shell-adaptive { width: 28px; padding-inline: 4px; }
  .td-context-toolbar .td-shell-stepper > button { width: 20px; }
  .td-context-toolbar .td-shell-stepper > .td-shell-font-size-picker { width: 34px; min-width: 34px; flex-basis: 34px; }
  .td-shell-toolbar-actions:not(:empty)::before { display: none; }
  .td-context-toolbar .td-shell-selection-count { max-width: 100px; white-space: normal; padding: 0; font-size: 12px; }
}
@media (min-width: 1181px) {
  .td-context-toolbar .td-shell-selection-count { max-width: 100px; white-space: normal; padding: 0; }
}
.td-context-toolbar .td-shell-icon-only:disabled svg { display: none; }
.td-context-toolbar .td-shell-disabled-size { width: 104px; }
@media (min-width: 1181px) and (max-width: 1280px) {
  .td-context-toolbar .td-shell-disabled-size { width: 78px; }
}

.td-layer-status { display: flex; align-items: center; gap: 2px; flex: none; color: #8a8286; }
.td-layer-status [role="img"] svg { width: 14px; height: 14px; display: block; }
.td-layer-visibility { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #4a4447; cursor: pointer; }
.td-layer-visibility:hover { background: #f4eef1; }
.td-layer-visibility.is-off { color: #9f315b; }
.td-layer-visibility svg { width: 18px; height: 18px; }

.td-shell-toolbar-content { display: flex; align-items: center; gap: 4px; width: max-content; min-width: 100%; box-sizing: border-box; height: 100%; }
.td-context-toolbar .td-shell-toolbar-controls { display: block; }
@media (max-width: 1180px) {
  .td-mobile-editor-shell .td-shell-toolbar-content { padding-inline-end: 12px; }
  .td-mobile-editor-shell .td-shell-toolbar-controls { scroll-padding-inline: 8px; }
  .td-mobile-editor-shell .td-shell-toolbar-controls button { scroll-margin-inline: 8px; }
}

@media (max-width: 1180px) { .td-context-toolbar [data-testid="shell-tool-crop"] .td-shell-button-label { display: none; } }
