.editor-shell {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.editor-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--nav-h) + 0.5rem);
  z-index: 100;
}

.tb-sep {
  width: 1px;
  height: 24px;
  background: var(--border2);
  margin: 0 0.2rem;
  flex-shrink: 0;
}

.tb-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text2);
  transition: all 0.15s;
  flex-shrink: 0;
  position: relative;
}

.tb-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

.tb-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.tb-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tb-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tb-btn::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
}

.tb-btn:hover::after {
  opacity: 1;
}

.tb-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.tb-color input {
  width: 200%;
  height: 200%;
  margin: -50%;
  cursor: pointer;
  border: none;
  padding: 0;
}

.tb-size-wrap {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.tb-size {
  width: 46px;
  height: 30px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  padding: 0 4px;
}

.tb-size-label {
  font-size: 11px;
  color: var(--text3);
}

.tb-zoom {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 12px;
  color: var(--text2);
  flex-shrink: 0;
}

.tb-zoom-val {
  min-width: 38px;
  text-align: center;
  font-weight: 500;
}

.editor-viewport {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  min-height: 420px;
  max-height: calc(100vh - 280px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem;
  position: relative;
}

.canvas-wrap {
  position: relative;
  display: inline-block;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

#main-cv {
  display: block;
}

#overlay-cv {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.page-nav span {
  font-size: 0.85rem;
  color: var(--text2);
  min-width: 90px;
  text-align: center;
}

.layers-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.layers-header {
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layers-list {
  max-height: 180px;
  overflow-y: auto;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.layer-item:hover {
  background: var(--bg3);
}

.layer-item:last-child {
  border-bottom: none;
}

.layer-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.layer-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-del {
  opacity: 0;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  background: transparent;
  border: none;
  font-size: 13px;
}

.layer-del:hover {
  background: var(--error-bg);
  color: var(--error);
}

.layer-item:hover .layer-del {
  opacity: 1;
}

.layer-drag-handle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: grab;
  padding: 2px 4px;
  flex-shrink: 0;
  opacity: 0.4;
}

.layer-drag-handle:hover {
  opacity: 0.8;
}

.layer-drag-handle span {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--text2);
  border-radius: 2px;
}

.layer-item.dragging {
  opacity: 0.4;
}

.layer-item.drag-over {
  background: var(--accent-bg);
  border-top: 2px solid var(--accent);
}

.cursor-select #overlay-cv {
  cursor: default;
}

.cursor-pan #overlay-cv {
  cursor: grab;
}

.cursor-pen #overlay-cv,
.cursor-marker #overlay-cv,
.cursor-rect #overlay-cv,
.cursor-circle #overlay-cv,
.cursor-arrow #overlay-cv,
.cursor-line #overlay-cv {
  cursor: crosshair;
}

.cursor-text #overlay-cv {
  cursor: text;
}

.cursor-image #overlay-cv {
  cursor: copy;
}

.cursor-erase #overlay-cv {
  cursor: cell;
}

.result-zone {
  display: none;
}

.result-zone.show {
  display: flex;
}

@media (max-width: 640px) {
  .editor-toolbar {
    gap: 0.15rem;
    padding: 0.35rem 0.4rem;
    top: calc(var(--nav-h) + 0.25rem);
  }

  .tb-btn {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .tb-sep {
    display: none;
  }

  .tb-btn::after {
    display: none;
  }

  .editor-viewport {
    padding: 0.5rem;
    min-height: 300px;
    max-height: calc(100vh - 220px);
  }

  .tb-size-wrap .tb-size-label {
    display: none;
  }

  .tb-zoom-val {
    min-width: 28px;
  }
}
