:root {
  --tdm-ink: #17252c;
  --tdm-muted: #66757c;
  --tdm-line: #d7dfe2;
  --tdm-line-strong: #b8c5ca;
  --tdm-panel: #ffffff;
  --tdm-workspace: #e8ecee;
  --tdm-accent: #0f766e;
  --tdm-accent-soft: #e6f4f1;
  --tdm-production: #b45309;
  --tdm-top-h: 56px;
  --tdm-status-h: 30px;
  --tdm-rail-w: 84px;
  --tdm-context-w: 272px;
  --tdm-inspector-w: 280px;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--tdm-workspace);
  color: var(--tdm-ink);
  font-family: "IBM Plex Sans KR", "Noto Sans KR", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.tdm-editor {
  display: grid;
  grid-template:
    "top top top top top top" var(--tdm-top-h)
    "rail context ctxsplit stage inspplit inspector" minmax(0, 1fr)
    "status status status status status status" var(--tdm-status-h)
    / var(--tdm-rail-w) var(--tdm-context-w) 6px minmax(280px, 1fr) 6px var(--tdm-inspector-w);
  width: 100%;
  height: 100%;
  min-height: 560px;
  background: var(--tdm-workspace);
}

/* 10987P1: TeDAI 열폭 DND 공모래 패턴(tedai-col-resizer) */
.tdm-col-resizer {
  width: 6px;
  cursor: col-resize;
  background: #e5e7eb;
  align-self: stretch;
  touch-action: none;
  position: relative;
  z-index: 4;
}
.tdm-col-resizer[data-side="context"] { grid-area: ctxsplit; }
.tdm-col-resizer[data-side="inspector"] { grid-area: inspplit; }
.tdm-col-resizer:hover,
.tdm-col-resizer.is-active {
  background: #93c5fd;
}

/* 10987P1: 스테이지 전체 사용(메모필드 full-bleed 패턴) */
.tdm-editor.is-ups-fullstage .tdm-stage,
.tdm-editor.is-puz-fullstage .tdm-stage {
  padding: 0;
  place-items: stretch;
  overflow: hidden;
  background: #15191c;
}
.tdm-editor.is-ups-fullstage .tdm-artboard,
.tdm-editor.is-puz-fullstage .tdm-artboard {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.tdm-editor.is-ups-fullstage .tdm-artboard-safe,
.tdm-editor.is-puz-fullstage .tdm-artboard-safe {
  display: none;
}
.tdm-editor.is-ups-fullstage .tdm-stage-viewport,
.tdm-editor.is-puz-fullstage .tdm-stage-viewport {
  inset: 0;
  border: 0;
  border-radius: 0;
  background: #15191c;
}

.tdm-editor.is-ups-fullstage .tdm-context .tdm-panel-head,
.tdm-editor.is-puz-fullstage .tdm-context .tdm-panel-head {
  display: none;
}

.tdm-editor.is-ups-fullstage .tdm-tool-list,
.tdm-editor.is-puz-fullstage .tdm-tool-list {
  padding-top: 8px;
}

.tdm-editor.is-ups-fullstage .tdm-tool,
.tdm-editor.is-puz-fullstage .tdm-tool {
  min-height: 48px;
}

.tdm-editor.is-ups-fullstage .tdm-tool > span:last-child,
.tdm-editor.is-puz-fullstage .tdm-tool > span:last-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tdm-editor.is-ups-fullstage .tdm-tool-mark,
.tdm-editor.is-puz-fullstage .tdm-tool-mark {
  width: 28px;
  height: 28px;
  font-size: 17px;
}

.tdm-puz-panel .tdm-ups-size {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 8px;
}

.tdm-puz-shape {
  display: grid;
  gap: 4px;
  margin: 0 0 8px;
}

.tdm-puz-shape label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.tdm-puz-shape select {
  min-height: 30px;
  width: 100%;
  padding: 0 8px;
  border: 1px solid var(--tdm-line);
  border-radius: 6px;
}

.tdm-puz-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.tdm-puz-actions button {
  width: 100%;
  appearance: none;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.tdm-puz-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tdm-puz-status {
  min-height: 1.2em;
  font-size: 0.75rem;
  color: #6b7280;
}

.tdm-puz-status.ok { color: #157347; }
.tdm-puz-status.err { color: #e10600; }

.tdm-puz-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
  cursor: pointer;
}

.tdm-puz-preview:not([src]),
.tdm-puz-preview[src=""] {
  display: none;
}

.tdm-puz-svg-preview {
  display: none;
  overflow: auto;
  max-height: 100%;
  background: #fafafa;
}

.tdm-editor.is-puz-fullstage .tdm-stage-img,
.tdm-editor.is-puz-fullstage .tdm-ups-live-preview,
.tdm-editor.is-puz-fullstage .tdm-ups-region-overlay,
.tdm-editor.is-puz-fullstage .tdm-ups-sector-proof,
.tdm-editor.is-puz-fullstage .tdm-ups-crop {
  display: none !important;
}

.tdm-editor:not(.is-puz-fullstage) .tdm-puz-preview,
.tdm-editor:not(.is-puz-fullstage) .tdm-puz-svg-preview {
  display: none !important;
}

/* author display 규칙이 HTML hidden 속성을 덮지 않도록 명시 */
.tdm-editor [hidden] {
  display: none !important;
}

/* 10987P2: 오른쪽 정보열은 필요할 때만 표시 */
.tdm-editor.is-inspector-hidden {
  grid-template:
    "top top top top top top" var(--tdm-top-h)
    "rail context ctxsplit stage inspplit inspector" minmax(0, 1fr)
    "status status status status status status" var(--tdm-status-h)
    / var(--tdm-rail-w) var(--tdm-context-w) 6px minmax(280px, 1fr) 0 0;
}

.tdm-editor.is-inspector-hidden .tdm-inspector,
.tdm-editor.is-inspector-hidden #tdm-resize-inspector {
  display: none;
}

.tdm-inspector-toggle {
  position: fixed;
  top: 50%;
  right: calc(var(--tdm-inspector-w) - 14px);
  z-index: 12;
  width: 28px;
  height: 52px;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid #9aa6ab;
  border-radius: 8px 0 0 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(15 23 42 / 16%);
  color: #405159;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.tdm-editor.is-inspector-hidden .tdm-inspector-toggle {
  right: 8px;
  border-radius: 8px;
}

.tdm-topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--tdm-line);
  background: var(--tdm-panel);
}

.tdm-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 166px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tdm-brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--tdm-accent);
  color: #fff;
  font-size: 13px;
}

/* 10979P2: CAT1 드롭다운 → CAT2 서브 → CAT3 서브서브 */
.tdm-menubar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tdm-menu-root {
  position: relative;
}

.tdm-menu-trigger {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--tdm-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.tdm-menu-root.is-open .tdm-menu-trigger,
.tdm-menu-trigger:hover {
  border-color: var(--tdm-accent);
  background: var(--tdm-accent-soft);
  color: #075e57;
}

.tdm-menu-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tdm-menu-panel {
  position: absolute;
  z-index: 40;
  min-width: 188px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.tdm-menu-panel--l1 {
  top: calc(100% + 6px);
  left: 0;
}

.tdm-menu-panel--l2 {
  top: 0;
  left: calc(100% + 4px);
}

.tdm-menu-item-wrap {
  position: relative;
}

.tdm-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--tdm-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

.tdm-menu-item:hover,
.tdm-menu-item.is-active {
  background: var(--tdm-accent-soft);
  color: #075e57;
}

.tdm-menu-item--has-sub::after {
  content: '▸';
  margin-left: 12px;
  color: var(--tdm-muted);
  font-size: 11px;
}

.tdm-menu-item--ups {
  font-weight: 800;
}

.tdm-menu-item:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.tdm-top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.tdm-action,
.tdm-user-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--tdm-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.tdm-action:hover,
.tdm-user-button:hover {
  border-color: var(--tdm-accent);
}

.tdm-action--primary {
  border-color: var(--tdm-accent);
  background: var(--tdm-accent);
  color: #fff;
}

.tdm-toolrail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--tdm-line);
  background: #f8faf9;
}

.tdm-topbar .tdm-cat2-modes {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
}

.tdm-cat2-mode {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--tdm-ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.tdm-cat2-mode[aria-selected="true"] {
  border-color: #b7d8d3;
  background: var(--tdm-accent-soft);
  color: #075e57;
}

.tdm-cat2-mode:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.tdm-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 9px 7px;
  list-style: none;
}

.tdm-context-option {
  width: 100%;
  margin-top: 6px;
  text-align: left;
  cursor: pointer;
}

.tdm-context-tip {
  margin: 10px 0 0;
  color: var(--tdm-muted);
  font-size: 11px;
  line-height: 1.45;
}

.tdm-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 5px 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #405159;
  cursor: pointer;
  font-size: 10px;
}

.tdm-tool-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  font-weight: 800;
}

.tdm-tool:hover,
.tdm-tool[aria-pressed="true"] {
  border-color: #b7d8d3;
  background: var(--tdm-accent-soft);
  color: #075e57;
}

.tdm-tool:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.tdm-context,
.tdm-inspector {
  min-width: 0;
  overflow: auto;
  background: var(--tdm-panel);
}

.tdm-context {
  grid-area: context;
  border-right: 1px solid var(--tdm-line);
}

.tdm-inspector {
  grid-area: inspector;
  border-left: 1px solid var(--tdm-line);
}

.tdm-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--tdm-line);
}

.tdm-panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.tdm-panel-body {
  padding: 14px;
}

.tdm-section {
  margin-bottom: 18px;
}

.tdm-section-label {
  display: block;
  margin-bottom: 8px;
  color: var(--tdm-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tdm-template-card {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--tdm-line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.tdm-template-card strong,
.tdm-template-card span {
  display: block;
}

.tdm-template-card span {
  margin-top: 4px;
  color: var(--tdm-muted);
  font-size: 11px;
}

.tdm-stage {
  grid-area: stage;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 58px;
  background-color: var(--tdm-workspace);
  background-image:
    linear-gradient(#dfe5e7 1px, transparent 1px),
    linear-gradient(90deg, #dfe5e7 1px, transparent 1px);
  background-size: 24px 24px;
}

.tdm-artboard {
  position: relative;
  width: min(620px, 76%);
  aspect-ratio: 210 / 297;
  border: 1px solid #bdc7cb;
  background: #fff;
  box-shadow: 0 8px 24px rgb(25 48 58 / 13%);
}

.tdm-artboard-safe {
  position: absolute;
  inset: 4%;
  border: 1px dashed #d9a15b;
  pointer-events: none;
}

.tdm-artboard-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14%;
  color: #9aa6ab;
  text-align: center;
  pointer-events: none;
  user-select: none;
}

.tdm-artboard-placeholder strong {
  display: block;
  margin-bottom: 8px;
  color: #63737a;
  font-size: 18px;
}

.tdm-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 12px;
}

.tdm-field output {
  color: var(--tdm-muted);
  font-variant-numeric: tabular-nums;
}

.tdm-preflight {
  padding: 11px;
  border: 1px solid #ead3b6;
  border-radius: 8px;
  background: #fff9f0;
  color: #7c430d;
  font-size: 11px;
  line-height: 1.5;
}

.tdm-access-notice {
  position: absolute;
  z-index: 2;
  width: min(390px, calc(100% - 44px));
  padding: 24px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.tdm-access-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--tdm-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.tdm-access-dismiss:hover {
  background: var(--tdm-accent-soft);
  color: var(--tdm-ink);
}

.tdm-access-notice h1 {
  margin: 0 0 8px;
  font-size: 17px;
}

.tdm-access-notice p {
  margin: 0 0 16px;
  color: var(--tdm-muted);
  font-size: 12px;
  line-height: 1.6;
}

.tdm-access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.tdm-access-test-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--tdm-ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tdm-access-test-btn:hover {
  background: var(--tdm-accent-soft);
}

.tdm-statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid var(--tdm-line);
  background: #f8faf9;
  color: var(--tdm-muted);
  font-size: 10px;
}

.tdm-status-spacer {
  margin-left: auto;
}

.tdm-status-ok {
  color: #08766c;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .tdm-editor {
    grid-template:
      "top top top" var(--tdm-top-h)
      "rail context stage" minmax(0, 1fr)
      "status status status" var(--tdm-status-h)
      / var(--tdm-rail-w) 240px minmax(360px, 1fr);
  }

  .tdm-inspector {
    display: none;
  }
}

.tdm-ups-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.tdm-ups-export {
  display: none;
  align-items: center;
  gap: 6px;
}

.tdm-editor.is-ups-fullstage .tdm-ups-export {
  display: flex;
}

.tdm-ups-export select {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--tdm-line-strong);
  border-radius: 7px;
  background: #fff;
}

.tdm-artboard.is-ups-drop {
  outline: 2px dashed var(--tdm-accent);
  outline-offset: -6px;
}

.tdm-ups-file-picker {
  display: flex;
  margin-bottom: 8px;
}

.tdm-ups-file-picker .tdm-action {
  min-width: 72px;
}

.tdm-ups-file-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.tdm-ups-size {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.tdm-ups-size label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.tdm-ups-size input {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--tdm-line);
  border-radius: 6px;
}

.tdm-ups-ratio-lock {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: var(--tdm-ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.tdm-ups-ratio-lock small {
  margin-left: auto;
  color: var(--tdm-muted);
  font-weight: 500;
}

.tdm-ups-dpi {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 650;
}

.tdm-ups-quality {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid #b7d8d3;
  border-radius: 7px;
  background: var(--tdm-accent-soft);
  color: #075e57;
  cursor: pointer;
  font-size: 11px;
}

.tdm-ups-quality span,
.tdm-ups-quality small {
  display: block;
}

.tdm-ups-face-guard {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr);
  gap: 6px 9px;
  align-items: center;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #eff6ff;
}

.tdm-ups-face-guard button {
  min-height: 30px;
  border: 1px solid #64748b;
  border-radius: 5px;
  color: #334155;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.tdm-ups-face-guard button[aria-pressed="true"] {
  border-color: #0284c7;
  color: #075985;
  background: #e0f2fe;
  box-shadow: inset 0 0 0 1px rgba(2, 132, 199, 0.18);
}

.tdm-ups-face-guard label {
  display: grid;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
}

.tdm-ups-face-guard label > span {
  display: flex;
  justify-content: space-between;
}

.tdm-ups-face-guard input[type="range"] {
  width: 100%;
  accent-color: #0284c7;
}

.tdm-ups-face-guard small {
  grid-column: 1 / -1;
  color: #475569;
  font-size: 10px;
  line-height: 1.35;
}

.tdm-ups-fur-synthesis {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(86px, 0.72fr);
  gap: 7px 9px;
  align-items: end;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d6b98c;
  border-radius: 7px;
  background: #fff9ed;
}

.tdm-ups-fur-synthesis label {
  display: grid;
  gap: 4px;
  color: #5b3a18;
  font-size: 10px;
  font-weight: 750;
}

.tdm-ups-fur-synthesis label > span {
  display: flex;
  justify-content: space-between;
}

.tdm-ups-fur-synthesis input[type="range"],
.tdm-ups-fur-synthesis select {
  width: 100%;
  min-width: 0;
}

.tdm-ups-fur-synthesis input[type="range"] {
  accent-color: #b45309;
}

.tdm-ups-fur-synthesis select {
  min-height: 28px;
  border: 1px solid #d6b98c;
  border-radius: 5px;
  color: #5b3a18;
  background: #fff;
  font-size: 10px;
}

.tdm-ups-fur-synthesis small {
  grid-column: 1 / -1;
  color: #725338;
  font-size: 10px;
  line-height: 1.35;
}

.tdm-ups-preview-level {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
}

.tdm-ups-preview-level > span {
  display: flex;
  justify-content: space-between;
}

.tdm-ups-preview-level output {
  color: var(--tdm-accent);
  font-variant-numeric: tabular-nums;
}

.tdm-ups-preview-level input[type="range"] {
  width: 100%;
  accent-color: var(--tdm-accent);
}

.tdm-ups-region-tools {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid #c7d2fe;
  border-radius: 7px;
  background: #f5f7ff;
}

.tdm-ups-region-tools label {
  display: grid;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
}

.tdm-ups-region-tools label > span,
.tdm-ups-region-tools > div {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.tdm-ups-region-tools input[type="range"] {
  width: 100%;
  accent-color: #4f46e5;
}

.tdm-ups-region-tools button {
  flex: 1;
  min-height: 28px;
  border: 1px solid #a5b4fc;
  border-radius: 6px;
  background: #fff;
  color: #3730a3;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.tdm-ups-region-tools button[aria-pressed="true"] {
  background: #4f46e5;
  color: #fff;
}

.tdm-ups-region-tools small {
  color: #626b84;
  font-size: 10px;
  line-height: 1.35;
}

.tdm-ups-region-tools .tdm-ups-region-list {
  display: grid;
  gap: 4px;
  padding-top: 2px;
}

.tdm-ups-region-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 5px;
  background: #fff;
  font-size: 10px;
  color: #3f4760;
}

.tdm-ups-region-item.is-active {
  box-shadow: inset 0 0 0 2px #4f46e5;
  background: #eef2ff;
}

.tdm-ups-region-item button {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 2px 7px;
}

.tdm-ups-font-ai-candidates {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 7px;
  border: 1px solid #a5b4fc;
  border-radius: 6px;
  background: #fff;
}

.tdm-ups-font-ai-candidates[hidden] {
  display: none !important;
}

.tdm-ups-font-ai-candidates > strong {
  grid-column: 1 / -1;
  color: #3730a3;
  font-size: 10px;
}

.tdm-ups-text-suggestions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.tdm-ups-text-suggestions > span {
  margin-right: 2px;
  color: #475569;
  font-size: 9px;
  font-weight: 750;
}

.tdm-ups-text-suggestions button {
  min-height: 24px;
  border: 1px solid #67c7d8;
  border-radius: 999px;
  background: #ecfeff;
  color: #155e75;
  font-size: 9px;
  font-weight: 750;
}

.tdm-ups-text-suggestions button[aria-pressed="true"] {
  border-color: #0891b2;
  background: #0891b2;
  color: #fff;
}

.tdm-ups-font-suggestions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.tdm-ups-font-suggestions > span {
  grid-column: 1 / -1;
  color: #475569;
  font-size: 9px;
  font-weight: 750;
}

.tdm-ups-font-suggestion {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 3px;
  border: 1px solid #94a3b8;
  border-radius: 5px;
  background: #fff;
  color: #334155;
}

.tdm-ups-font-suggestion img {
  box-sizing: border-box;
  width: 100%;
  height: 30px;
  object-fit: contain;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.tdm-ups-font-suggestion strong {
  min-height: 18px;
  font-size: 8px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.tdm-ups-font-suggestion[aria-pressed="true"] {
  border-color: #0891b2;
  box-shadow: 0 0 0 1px #0891b2 inset;
  background: #ecfeff;
}

.tdm-ups-graphic-finalize {
  grid-column: 1 / -1;
  min-height: 28px;
  border: 1px solid #0f766e;
  border-radius: 5px;
  background: #0f766e;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}

.tdm-ups-graphic-finalize:disabled {
  border-color: #94a3b8;
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

.tdm-ups-font-ai-candidates .tdm-ups-font-ai-candidate {
  min-width: 0;
  padding: 5px;
  line-height: 1.3;
  white-space: normal;
}

.tdm-ups-quality small {
  margin-top: 2px;
  color: var(--tdm-muted);
  line-height: 1.35;
}

.tdm-inspector-nav {
  margin: 0 0 10px;
}

.tdm-inspector-nav .tdm-ups-nav {
  margin: 0;
}

.tdm-inspector-props {
  margin: 0 0 10px;
}

.tdm-inspector-props .tdm-ups-props {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tdm-editor.is-ups-fullstage .tdm-inspector [data-inspector-static="1"] {
  display: none;
}

.tdm-editor.is-ups-fullstage {
  grid-template:
    "top top top top top top" var(--tdm-top-h)
    "rail context ctxsplit stage inspplit inspector" minmax(0, 1fr)
    "status status status status status status" var(--tdm-status-h)
    / var(--tdm-rail-w) 0 0 minmax(280px, 1fr) 6px var(--tdm-inspector-w);
}

.tdm-editor.is-ups-fullstage .tdm-context,
.tdm-editor.is-ups-fullstage #tdm-resize-context {
  display: none;
}

.tdm-editor.is-ups-fullstage.is-inspector-hidden {
  grid-template:
    "top top top top top top" var(--tdm-top-h)
    "rail context ctxsplit stage inspplit inspector" minmax(0, 1fr)
    "status status status status status status" var(--tdm-status-h)
    / var(--tdm-rail-w) 0 0 minmax(280px, 1fr) 0 0;
}

.tdm-inspector-props .tdm-ups-object-ai,
.tdm-inspector-props .tdm-ups-face-guard,
.tdm-inspector-props .tdm-ups-fur-synthesis,
.tdm-inspector-props .tdm-ups-graphic-repair {
  margin: 0;
}

.tdm-ups-object-ai {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.tdm-ups-object-ai #tdm-ups-fur-toggle[aria-pressed="true"] {
  border-color: #f59e0b;
  color: #fff7ed;
  background: #92400e;
}

.tdm-ups-nav {
  position: relative;
  margin: 8px 0 10px;
  border: 1px solid var(--tdm-line);
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  min-height: 120px;
}

.tdm-ups-nav-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px;
  color: #e5e7eb;
  background: #20262b;
}

.tdm-ups-nav-toolbar strong {
  margin-right: auto;
  font-size: 11px;
}

.tdm-ups-nav-toolbar button {
  border: 1px solid #56616a;
  border-radius: 5px;
  color: #e5e7eb;
  background: #303940;
  cursor: pointer;
  font-size: 10px;
}

.tdm-ups-nav-toolbar button {
  padding: 4px 6px;
}

.tdm-ups-nav-toolbar button[aria-busy="true"] {
  opacity: 0.65;
  cursor: wait;
}

.tdm-ups-nav-toolbar #tdm-ups-fur-toggle[aria-pressed="true"] {
  border-color: #f59e0b;
  color: #fff7ed;
  background: #92400e;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.32);
}

.tdm-ups-graphic-repair {
  display: grid;
  grid-template-columns: minmax(82px, 0.8fr) minmax(132px, 1.5fr) minmax(100px, 1fr) minmax(82px, 0.8fr);
  gap: 6px;
  padding: 7px;
  border-top: 1px solid #46515a;
  background: #182027;
  color: #dce7eb;
}

.tdm-ups-graphic-repair label {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 9px;
  font-weight: 750;
}

.tdm-ups-graphic-repair label > span {
  display: flex;
  justify-content: space-between;
}

.tdm-ups-graphic-repair input,
.tdm-ups-graphic-repair select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 27px;
  border: 1px solid #56616a;
  border-radius: 4px;
  background: #f8fafc;
  color: #182027;
  font-size: 10px;
}

.tdm-ups-graphic-repair input[type="range"] {
  min-height: 24px;
  accent-color: #06b6d4;
}

@media (max-width: 760px) {
  .tdm-ups-graphic-repair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tdm-ups-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: transparent;
}

.tdm-ups-nav-preview-wrap {
  position: relative;
  margin: 0 auto;
  max-height: 180px;
  background: transparent;
}

.tdm-ups-nav-box {
  position: absolute;
  border: 4px solid #06b6d4;
  background: rgba(34, 211, 238, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.95), 0 0 0 5px rgba(8, 47, 73, 0.32);
  cursor: grab;
  box-sizing: border-box;
}

.tdm-ups-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tdm-ups-status {
  margin: 8px 0 0;
  color: var(--tdm-muted);
  font-size: 11px;
  line-height: 1.4;
}

.tdm-ups-status--ok {
  color: #157347;
}

.tdm-ups-status--err {
  color: #b42318;
}

.tdm-stage-viewport {
  position: absolute;
  inset: 12px;
  overflow: auto;
  border: 1px solid #d5e0de;
  border-radius: 4px;
  background: #15191c;
  cursor: grab;
  overscroll-behavior: contain;
  touch-action: none;
  user-select: none;
}

.tdm-stage-viewport.is-panning {
  cursor: grabbing;
}

.tdm-stage-viewport.is-region-ready,
.tdm-stage-viewport.is-masking {
  cursor: crosshair;
}

.tdm-stage-canvas {
  position: relative;
}

.tdm-stage-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: auto;
  cursor: inherit;
  user-select: none;
  -webkit-user-drag: none;
}

.tdm-ups-sector-proof {
  position: absolute;
  z-index: 2;
  object-fit: fill;
  pointer-events: none;
  box-sizing: border-box;
  animation: tdm-ups-sector-reveal 160ms ease-out;
}

.tdm-ups-sector-outline {
  position: absolute;
  z-index: 6;
  border: 1px solid #06d9f5;
  box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.45);
  pointer-events: none;
  box-sizing: border-box;
}

.tdm-ups-sector-outline.is-processing {
  animation: tdm-ups-sector-processing 900ms ease-in-out infinite alternate;
}

.tdm-ups-stage-progress {
  position: absolute;
  z-index: 20;
  top: 12px;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(520px, calc(100% - 32px));
  padding: 9px 12px;
  border: 1px solid rgba(34, 211, 238, 0.72);
  border-radius: 7px;
  background: rgba(8, 20, 27, 0.94);
  color: #e6fffb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
}

.tdm-ups-stage-progress progress {
  width: 100%;
  height: 9px;
  accent-color: #22d3ee;
}

@keyframes tdm-ups-sector-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tdm-ups-sector-processing {
  from { border-color: #06d9f5; }
  to { border-color: #f8fafc; }
}

.tdm-ups-live-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}

.tdm-ups-region-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.tdm-ups-region-shape {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.tdm-ups-region-shape--base,
.tdm-ups-region-draft--base {
  stroke: #111;
}

.tdm-ups-region-shape--ants,
.tdm-ups-region-draft--ants {
  fill: none;
  stroke: #fff;
  stroke-dasharray: 6 6;
  animation: tdmMarchingAnts .7s linear infinite;
}

.tdm-ups-region-draft {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

@keyframes tdmMarchingAnts {
  to { stroke-dashoffset: -12; }
}

@media (prefers-reduced-motion: reduce) {
  .tdm-ups-region-shape--ants,
  .tdm-ups-region-draft--ants {
    animation: none;
  }
}

.tdm-ups-crop {
  position: absolute;
  border: 2px dashed #f59e0b;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35);
  pointer-events: none;
  box-sizing: border-box;
  z-index: 2;
}

.tdm-ups-suit {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}
.tdm-ups-suit.ok { background: #e8f7ee; color: #157347; border: 1px solid #b7e4c7; }
.tdm-ups-suit.warn { background: #fff8e6; color: #9a6700; border: 1px solid #f5d78e; }
.tdm-ups-suit.fail { background: #fdecea; color: #b42318; border: 1px solid #f5c2c0; }
.tdm-ups-suit.na { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }

.tdm-ups-meta {
  margin: 6px 0 0;
  color: var(--tdm-muted);
  font-size: 11px;
  line-height: 1.4;
}

.tdm-artboard {
  position: relative;
}

.tdm-context-tip {
  margin: 10px 0 0;
  color: var(--tdm-muted);
  font-size: 11px;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .tdm-editor {
    grid-template:
      "top top top" var(--tdm-top-h)
      "rail stage stage" minmax(0, 1fr)
      "status status status" var(--tdm-status-h)
      / 66px 0 minmax(300px, 1fr);
  }

  .tdm-context,
  .tdm-col-resizer,
  .tdm-inspector,
  .tdm-action--secondary {
    display: none;
  }

  .tdm-menu-panel--l2 {
    left: 12px;
    top: calc(100% + 2px);
  }

  .tdm-brand {
    min-width: auto;
  }

  .tdm-stage {
    padding: 28px;
  }

  .tdm-artboard {
    width: min(520px, 88%);
  }
}

:focus-visible {
  outline: 2px solid var(--tdm-accent);
  outline-offset: 2px;
}
