/* ===== 在线编辑器（参考嘉立创 EDA 专业版布局） ===== */

.container-wide {
  width: min(1280px, 94%);
  margin-inline: auto;
}

.editor {
  background: #0c1424;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  color: #dbe6f4;
  user-select: none;
  -webkit-user-select: none;
}

.editor * {
  box-sizing: border-box;
}

/* ---------- 菜单栏 ---------- */
.ed-menubar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0a1220;
  border-bottom: 1px solid var(--line);
  padding: 0 10px;
  height: 36px;
}

.ed-menu-group {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.ed-menu {
  position: relative;
}

.ed-menu-btn {
  font-family: inherit;
  font-size: 0.83rem;
  color: #c4d1e2;
  background: none;
  border: none;
  padding: 7px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ed-menu-btn:hover,
.ed-menu.open .ed-menu-btn {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.ed-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 80;
  min-width: 168px;
  background: #131e33;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  padding: 6px;
}

.ed-menu.open .ed-dropdown {
  display: block;
}

.ed-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 0.83rem;
  color: #c4d1e2;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.ed-dropdown button:hover {
  background: rgba(34, 211, 238, 0.12);
  color: #fff;
}

.ed-menu-title {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-menu-title span {
  color: #5c6b82;
}

/* ---------- 工具栏 ---------- */
.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: #0e1728;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.ed-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #aebbd0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.ed-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

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

.ed-btn.ed-tool.is-active {
  color: #04101d;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
}

.ed-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 6px;
}

.ed-spacer {
  flex: 1;
}

.ed-grid-btn {
  width: auto;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #aebbd0;
}

.ed-order {
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  color: #04101d;
  background: linear-gradient(135deg, var(--amber), #f59e0b);
  border: none;
  border-radius: 9px;
  padding: 8px 18px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.ed-order:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(251, 191, 36, 0.38);
}

/* ---------- 工作区 ---------- */
.ed-workspace {
  display: grid;
  grid-template-columns: 190px 1fr 240px;
  height: clamp(460px, 58vh, 640px);
  min-height: 460px;
}

.ed-layers,
.ed-props {
  background: #0d1526;
  overflow-y: auto;
  padding: 10px;
}

.ed-layers {
  border-right: 1px solid var(--line);
}

.ed-props {
  border-left: 1px solid var(--line);
}

.ed-panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #66758d;
  text-transform: uppercase;
  padding: 8px 6px 6px;
}

/* 侧栏选项卡 */
.ed-side-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--line);
}

.ed-side-tab {
  flex: 1;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: #8494ad;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 1px;
}

.ed-side-tab:hover {
  color: var(--text);
}

.ed-side-tab.is-active {
  color: #04101d;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
}

.ed-side-panel[hidden] {
  display: none;
}

.ed-side-panel {
  padding: 4px;
}

/* 图层栏 */
.ed-layer-list {
  display: grid;
  gap: 2px;
}

.ed-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 7px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ed-layer-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ed-layer-row.is-active {
  background: rgba(34, 211, 238, 0.1);
}

.ed-layer-row.is-hidden .ed-layer-name {
  color: #4d5a70;
  text-decoration: line-through;
}

.ed-layer-eye {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: #8494ad;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
}

.ed-layer-eye:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.ed-layer-eye svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ed-layer-swatch {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  position: relative;
}

.ed-layer-row.is-active .ed-layer-swatch::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.9) 0 1.5px, transparent 2.5px);
}

.ed-layer-name {
  flex: 1;
  font-size: 0.8rem;
  color: #c4d1e2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-layer-lock {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: #66758d;
  cursor: pointer;
  border-radius: 5px;
  flex-shrink: 0;
}

.ed-layer-lock:hover {
  color: #fff;
}

.ed-layer-lock.is-locked {
  color: var(--amber);
}

.ed-layer-lock svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.ed-object-stats {
  display: grid;
  gap: 6px;
  padding: 4px 6px;
  font-size: 0.8rem;
  color: #8494ad;
}

.ed-object-stats b {
  color: var(--cyan);
  float: right;
}

/* 器件库 */
.ed-lib-search {
  width: 100%;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ed-lib-search:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.ed-lib-search::placeholder {
  color: #5c6b82;
}

.ed-lib-cat {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #66758d;
  text-transform: uppercase;
  padding: 10px 6px 4px;
}

.ed-lib-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  margin-bottom: 6px;
  cursor: pointer;
  color: #c4d1e2;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.ed-lib-item:hover {
  background: rgba(34, 211, 238, 0.09);
  border-color: rgba(34, 211, 238, 0.4);
  transform: translateX(2px);
}

.ed-lib-item.is-placing {
  background: rgba(34, 211, 238, 0.14);
  border-color: var(--cyan);
}

.ed-lib-preview {
  width: 46px;
  height: 34px;
  border-radius: 6px;
  background: #0a111f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.ed-lib-info {
  min-width: 0;
}

.ed-lib-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-lib-ref {
  display: block;
  font-size: 0.68rem;
  color: #66758d;
}

/* 画布 */
.ed-canvas-wrap {
  position: relative;
  background: #0a111f;
  overflow: hidden;
  cursor: default;
}

.ed-canvas-wrap.ed-panning {
  cursor: grabbing;
}

#edCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ed-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 17, 31, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #7f90a9;
  font-size: 0.72rem;
  padding: 5px 12px;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}

.ed-zoom-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(10, 17, 31, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #aebbd0;
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: 8px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* 属性面板 */
.ed-prop-body {
  display: grid;
  gap: 10px;
  padding: 6px;
}

.ed-prop-empty {
  color: #5c6b82;
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.8;
  padding: 26px 8px;
}

.ed-prop-field {
  display: grid;
  gap: 5px;
}

.ed-prop-field label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #8494ad;
  letter-spacing: 0.4px;
}

.ed-prop-field input[type="number"],
.ed-prop-field input[type="text"],
.ed-prop-field select {
  font-family: inherit;
  font-size: 0.83rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ed-prop-field input:focus,
.ed-prop-field select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.ed-prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ed-prop-delete {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 8px;
  padding: 8px 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ed-prop-delete:hover {
  background: rgba(248, 113, 113, 0.18);
}

.ed-prop-type {
  font-size: 0.78rem;
  color: #66758d;
}

/* 状态栏 */
.ed-statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #0a1220;
  border-top: 1px solid var(--line);
  padding: 6px 14px;
  font-size: 0.74rem;
  color: #7f90a9;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.ed-statusbar .ed-status-right {
  margin-left: auto;
  display: flex;
  gap: 18px;
}

/* 右键菜单 */
.ed-ctxmenu {
  position: fixed;
  z-index: 120;
  min-width: 158px;
  background: #131e33;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  padding: 6px;
  display: none;
}

.ed-ctxmenu.open {
  display: block;
}

.ed-ctxmenu button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 0.8rem;
  color: #c4d1e2;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.ed-ctxmenu button:hover {
  background: rgba(34, 211, 238, 0.12);
  color: #fff;
}

/* 快捷键弹窗 */
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  margin: 6px 0 22px;
}

.help-grid div {
  font-size: 0.85rem;
  color: #c4d1e2;
}

.help-grid b {
  display: inline-block;
  min-width: 74px;
  color: var(--cyan);
  font-weight: 700;
}

/* 图层管理器 */
.layer-manager-list {
  display: grid;
  gap: 10px;
  margin: 8px 0 22px;
  max-height: 46vh;
  overflow-y: auto;
}

.layer-manager-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.layer-manager-row input[type="color"] {
  width: 40px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: none;
  cursor: pointer;
  padding: 0;
}

.layer-manager-row input[type="range"] {
  width: 90px;
  accent-color: var(--cyan);
}

.layer-manager-row label {
  font-size: 0.8rem;
  color: #8494ad;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.layer-manager-row input[type="checkbox"] {
  accent-color: var(--cyan);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .ed-workspace {
    grid-template-columns: 160px 1fr 200px;
  }
}

@media (max-width: 900px) {
  .ed-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .ed-layers {
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .ed-layers .ed-panel-title {
    display: none;
  }

  .ed-side-tabs {
    border-bottom: none;
    padding: 6px;
    flex-shrink: 0;
  }

  .ed-side-tab {
    flex: none;
    padding: 6px 12px;
  }

  .ed-side-panel {
    display: contents;
  }

  .ed-side-panel[hidden] {
    display: none;
  }

  .ed-layer-list {
    display: flex;
    gap: 4px;
    flex: 1;
    min-width: max-content;
  }

  #sideLib .ed-lib-search {
    display: none;
  }

  #sideLib .ed-lib-list {
    display: flex;
    gap: 6px;
    min-width: max-content;
    padding: 4px;
  }

  .ed-lib-cat {
    display: none;
  }

  .ed-lib-item {
    flex-direction: column;
    width: 74px;
    gap: 4px;
    text-align: center;
    margin-bottom: 0;
    padding: 6px;
  }

  .ed-lib-name {
    font-size: 0.7rem;
  }

  .ed-layer-row {
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
  }

  .ed-layer-row .ed-layer-lock {
    display: none;
  }

  .ed-canvas-wrap {
    height: 440px;
  }

  .ed-props {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: 300px;
  }

  .ed-menu-title {
    display: none;
  }
}

@media (max-width: 560px) {
  .ed-toolbar {
    gap: 2px;
  }

  .ed-order {
    width: 100%;
    margin-top: 4px;
  }

  .ed-statusbar {
    gap: 10px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}
