.cad-wb {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-sans, Inter, sans-serif);
  font-size: 13px;
  user-select: none;
}
.cad-wb.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
}
.cad-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-wrap: wrap;
}
.cad-topgroup {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cad-btn, .cad-select {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.cad-btn:hover, .cad-select:hover {
  background: #334155;
  border-color: #64748b;
}
.cad-btn:focus-visible, .cad-select:focus-visible, .cad-cmd-input:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}
.cad-btn-primary {
  background: #1d4ed8;
  border-color: #2563eb;
  color: #ffffff;
}
.cad-btn-primary:hover {
  background: #1e40af;
}
.cad-btn-teal {
  background: #0f766e;
  border-color: #14b8a6;
  color: #ffffff;
}
.cad-btn-teal:hover {
  background: #115e59;
}
.cad-btn.is-active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #ffffff;
}
.cad-btn-danger:hover {
  background: #991b1b;
  border-color: #ef4444;
}
.cad-body {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 256px;
  min-height: 540px;
  height: 62vh;
  max-height: 760px;
}
.cad-wb.is-fullscreen .cad-body {
  height: calc(100vh - 96px);
  max-height: none;
}
.cad-toolrail {
  background: #162032;
  border-right: 1px solid #334155;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.cad-rail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  text-align: center;
  margin: 6px 0 2px;
  font-family: var(--font-mono, monospace);
}
.cad-tool-btn {
  width: 100%;
  min-height: 36px;
  padding: 4px 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.cad-tool-btn:hover {
  background: #1e293b;
  color: #ffffff;
}
.cad-tool-btn.is-active {
  background: #1d4ed8;
  border-color: #60a5fa;
  color: #ffffff;
}
.cad-tool-kbd {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  opacity: 0.75;
}
.cad-stage {
  position: relative;
  overflow: hidden;
  background: #0b1220;
  cursor: crosshair;
}
.cad-stage.is-select {
  cursor: default;
}
.cad-stage.is-pan {
  cursor: grab;
}
.cad-stage.is-panning {
  cursor: grabbing !important;
}
.cad-stage.is-light {
  background: #ffffff;
}
.cad-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.cad-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cad-hud-pill {
  background: rgba(15, 23, 42, 0.86);
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}
.cad-stage.is-light .cad-hud-pill {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border-color: #cbd5e1;
}
.cad-toast {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(15, 118, 110, 0.95);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.cad-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.cad-inspector {
  background: #162032;
  border-left: 1px solid #334155;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cad-inspector-scroll {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cad-drawer-bar,
.cad-drawer-fab {
  display: none;
}
.cad-panel-sec {
  padding: 12px;
  border-bottom: 1px solid #334155;
}
.cad-panel-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cad-prop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.cad-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cad-field-full {
  grid-column: 1 / -1;
}
.cad-field label {
  font-size: 11px;
  color: #94a3b8;
  font-family: var(--font-mono, monospace);
}
.cad-input {
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #f8fafc;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}
.cad-muted-note {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.5;
}
.cad-modify-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.cad-layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cad-layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #0f172a;
  cursor: pointer;
}
.cad-layer-row.is-active {
  border-color: #38bdf8;
  background: #1e293b;
}
.cad-layer-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.3);
}
.cad-layer-name {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cad-layer-act {
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 4px;
  font-size: 10px;
  padding: 2px 5px;
  cursor: pointer;
}
.cad-layer-act.is-off {
  opacity: 0.45;
  text-decoration: line-through;
}
.cad-stats-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #cbd5e1;
}
.cad-stat-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 8px;
}
.cad-stat-box span {
  display: block;
  font-size: 10px;
  color: #94a3b8;
}
.cad-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: #0b1220;
  border-top: 1px solid #334155;
  flex-wrap: wrap;
}
.cad-cmd-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 240px;
}
.cad-cmd-prompt {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: #38bdf8;
  font-weight: 700;
}
.cad-cmd-input {
  flex: 1;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #162032;
  color: #f8fafc;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}
.cad-status-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cad-coords {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: #34d399;
  background: #162032;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 170px;
  text-align: center;
}
.cad-toggle-chip {
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid #475569;
  background: #162032;
  color: #94a3b8;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.cad-toggle-chip.is-on {
  background: #0f766e;
  border-color: #14b8a6;
  color: #ffffff;
}
@media (max-width: 960px) {
  .cad-body {
    grid-template-columns: 68px minmax(0, 1fr);
    height: auto;
    max-height: none;
  }
  .cad-stage {
    min-height: 440px;
  }
  .cad-inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid #334155;
  }
}
@media (max-width: 768px) {
  .cad-body {
    grid-template-columns: 1fr;
  }
  .cad-drawer-fab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 6;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid #38bdf8;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(2, 6, 23, 0.45);
  }
  .cad-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    height: 50vh;
    max-height: 50vh;
    border-left: 0;
    border-top: 1px solid #38bdf8;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(2, 6, 23, 0.55);
    transform: translateY(105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    overflow: hidden;
  }
  .cad-inspector.is-drawer-open {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.2s ease, visibility 0s;
  }
  .cad-inspector.is-dragging {
    transition: none;
  }
  .cad-drawer-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 10px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
  }
  .cad-drawer-grip {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #64748b;
  }
  .cad-drawer-bar-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .cad-drawer-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #93c5fd;
  }
  .cad-drawer-close {
    min-height: 34px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #475569;
    background: #1e293b;
    color: #f8fafc;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }
  .cad-input {
    height: 36px;
    font-size: 13px;
  }
}
@media (max-width: 640px) {
  .cad-body {
    grid-template-columns: 1fr;
  }
  .cad-toolrail {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid #334155;
    padding: 6px;
  }
  .cad-rail-label {
    display: none;
  }
  .cad-tool-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 56px;
    min-height: 44px;
    padding: 8px 12px;
  }
  .cad-stage {
    min-height: 360px;
  }
  .cad-coords {
    min-width: 140px;
  }
}