/* 模型向导 */
.model-wizard-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.model-wizard-shell .alert {
  flex-shrink: 0;
}

.model-wizard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--surface)), var(--surface));
  flex-shrink: 0;
}

.model-wizard-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.model-wizard-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.model-wizard-steps {
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--bg) 40%, var(--surface));
}

.model-wizard-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.model-wizard-step:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.model-wizard-step.is-active {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.model-wizard-step.is-done .mw-step-num {
  background: var(--accent);
  color: #fff;
}

.model-wizard-step.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mw-step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--border);
}

.mw-step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mw-step-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.mw-step-value {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.model-wizard-main {
  padding: 16px 18px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.mw-form-tabpanels {
  min-height: 0;
}

.model-wizard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.model-wizard-toolbar h4 {
  margin: 0;
  font-size: 0.95rem;
}

.model-wizard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-wizard-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.model-wizard-item:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.mw-item-main {
  min-width: 0;
}

.mw-item-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.mw-item-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.mw-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.mw-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  margin-left: 6px;
}

.model-wizard-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.model-wizard-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-wizard-footer-hint {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
}

.model-wizard-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

@media (max-width: 760px) {
  .model-wizard-body {
    grid-template-columns: 1fr;
  }
  .model-wizard-steps {
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .model-wizard-form-grid {
    grid-template-columns: 1fr;
  }
}

.model-wizard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  padding-top: 4px;
}

.mw-form-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, var(--surface)), var(--surface));
}

.mw-form-context-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  line-height: 1.4;
}

.mw-context-sep {
  color: var(--muted);
  font-size: 0.78rem;
}

.mw-form-context-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
}

.mw-context-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
  color: var(--muted);
}

.mw-context-badge--ok {
  background: color-mix(in srgb, #16a34a 14%, var(--surface));
  color: #15803d;
}

.mw-form-section {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 35%, var(--surface));
}

.mw-form-section:last-child {
  margin-bottom: 0;
}

.mw-form-section-head {
  margin-bottom: 12px;
}

.mw-form-section-head h5 {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 650;
}

.mw-form-section-head p {
  margin: 0;
  font-size: 0.76rem;
}

.mw-model-id-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--text);
}

.mw-model-id-input {
  font-weight: 600;
}

.mw-input-readonly {
  background: color-mix(in srgb, var(--muted) 8%, var(--bg));
  color: var(--muted);
}

.mw-cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.mw-cap-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mw-cap-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.mw-cap-toggle input {
  margin-top: 3px;
  flex-shrink: 0;
}

.mw-cap-toggle-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mw-cap-toggle-label {
  font-size: 0.84rem;
  font-weight: 600;
}

.mw-cap-toggle-id {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mw-request-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

@media (max-width: 760px) {
  .mw-request-fields {
    grid-template-columns: 1fr;
  }
  .mw-cap-grid {
    grid-template-columns: 1fr;
  }
}

.model-wizard-tab {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
}

.model-wizard-tab.is-active {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.model-wizard-edit-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
}

.model-wizard-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.mw-btn-danger {
  color: #dc2626;
  border-color: color-mix(in srgb, #dc2626 35%, var(--border));
}

.mw-btn-danger:hover {
  background: color-mix(in srgb, #dc2626 8%, var(--surface));
}

.model-wizard-shell .btn-secondary {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  color: inherit;
}

.model-wizard-shell .btn-secondary:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.model-wizard-code {
  width: 100%;
  min-height: 240px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  color: inherit;
  resize: vertical;
}

.model-wizard-schema-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-wizard-select {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  color: inherit;
  font: inherit;
  font-size: 13px;
}

.mw-inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mw-field-hint {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
}

.mw-provider-field {
  grid-column: 1 / -1;
}
