/* Extend the existing application palette; leave the vendor stylesheet intact. */
@import url('./circuit-controls.css');
@import url('./input-controls.css');
@import url('./navigation-icons.css');
@import url('./compact-inputs.css');
@import url('./circuit-waiting.css');
@import url('./error-curve.css');
.qicp-snapshot-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 10px 12px; background: #f6f9fc; border: 1px solid #e2e8f0; border-radius: 8px; }
.qicp-snapshot-heading, .qicp-snapshot-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.qicp-snapshot-caption { color: #334155; font-size: 12px; font-weight: 600; }
.qicp-main .qicp-snapshot-select { width: auto; min-width: 100px; max-width: 160px; padding: 6px 8px; font-size: 12px; }
.qicp-snapshot-actions button { padding: 6px 8px; white-space: nowrap; }
.qicp-snapshot-actions button[aria-pressed="true"] { color: #0e7490; background: #ecfeff; border-color: #a5e5ef; }
.qicp-inspection-label { margin-top: 4px; color: #64748b; font-size: 11px; }
.qicp-workspace-toolbar { display: flex; justify-content: flex-end; }
[data-task-log] > summary { cursor: pointer; list-style: none; gap: 8px; }
[data-task-log] > summary::after { content: '展开'; margin-left: auto; font-size: 11px; color: #cbd5e1; }
[data-task-log][open] > summary::after { content: '收起'; }
.qicp-task-workspace[data-inputs-collapsed="true"] > :first-child { display: none; }
@media (min-width: 1024px) {
  .qicp-main .qicp-task-workspace[data-inputs-collapsed="true"] { grid-template-columns: minmax(0, 1fr) 292px; }
  .qicp-task-workspace[data-inputs-collapsed="true"] > [data-task-center] { grid-column: 1; grid-row: 1; }
  .qicp-task-workspace[data-inputs-collapsed="true"] > :last-child { grid-column: 2; grid-row: 1; }
}
.qicp-main-column { background: #f6f8fb; }
.qicp-main { padding: 24px; }
.qicp-topbar { padding-inline: 24px; background: #fff; }
.qicp-sidebar { width: 240px; position: sticky; top: 0; height: 100dvh; overflow-y: auto; }
.qicp-sidebar a { border-radius: 8px; }
.qicp-sidebar a[href] { padding-block: 10px; gap: 10px; font-size: 13px; }
[data-task-help] { flex-shrink: 0; }
[data-task-help] > button { white-space: nowrap; }
.qicp-main .panel { border-color: #dfe6ef; border-radius: 12px; box-shadow: 0 1px 2px #0f172a03; }
.qicp-main .panel-title { font-size: 14px; line-height: 22px; }
.qicp-main .field-input { border-radius: 8px; border-color: #ccd6e4; background: #fff; }
.qicp-main .field-input:focus { border-color: #06a8cc; outline: 2px solid #06a8cc20; outline-offset: 1px; }
.qicp-main .field-label { font-size: 12px; font-weight: 500; color: #42546d; }
.qicp-main .btn-ghost { border-radius: 7px; }
.qicp-main .btn-primary { border-radius: 8px; }
[data-algorithm-input] > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
[data-algorithm-input] > div > button { min-width: 0; min-height: 44px; padding: 6px 4px; border-radius: 7px; }
[data-algorithm-input] button > span { display: block; margin: 1px 0 0; line-height: 12px; }
[data-algorithm-input] button[aria-pressed="true"] { order: -1; border-color: #13b4ce; }
[data-algorithm-input] > p { line-height: 18px; }
.qicp-task-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}
.qicp-task-workspace > * { min-width: 0; }
.qicp-task-workspace .panel { border-radius: 12px; }
.qicp-task-workspace [data-task-center] > * { min-width: 0; }
.qicp-mobile-tasks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  color: #475569;
}
.qicp-mobile-tasks:hover { background: #f1f5f9; }
@media (min-width: 1024px) {
  .qicp-mobile-tasks { display: none; }
  .qicp-task-workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .qicp-task-workspace > :first-child { grid-row: 1 / span 2; }
  .qicp-task-workspace > :last-child { grid-column: 2; }
}
@media (min-width: 1380px) {
  .qicp-task-workspace { grid-template-columns: 280px minmax(0, 1fr) 292px; }
  .qicp-task-workspace > :first-child { grid-row: auto; }
  .qicp-task-workspace > :last-child { grid-column: auto; }
}
@media (min-width: 1800px) {
  .qicp-task-workspace { grid-template-columns: 304px minmax(0, 1fr) 336px; }
}
@media (max-width: 639px) {
  .qicp-topbar > div:last-child { gap: 6px; }
  .qicp-main { padding: 16px 12px; }
  .qicp-topbar { padding-inline: 12px; }
  .qicp-task-workspace { gap: 16px; }
}

/* Values and the error curve share the same task snapshot selection. */
.qicp-metrics { gap: 0; border: 1px solid #e3eaf2; border-radius: 9px; overflow: hidden; }
.qicp-metrics .qicp-metric { min-width: 0; border: 0; border-radius: 0; padding: 12px; }
.qicp-metric:nth-child(odd) { border-right: 1px solid #e3eaf2; }
.qicp-metric:nth-child(-n+2) { background: #f5fbfd; border-bottom: 1px solid #e3eaf2; }
.qicp-metric > p:nth-child(2) { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.qicp-metric > p:last-child { color: #64748b; }


/* Task illustrations occupy the canvas only while no returned circuit exists. */
.qicp-circuit-empty { display: flex; flex-direction: column; min-height: 400px; padding: 20px; border: 1px solid #e2eaf2; border-radius: 10px; background: linear-gradient(180deg, #f8fbfe 0%, #fff 100%); }
.qicp-circuit-empty-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #8190a5; font-size: 11px; }
.qicp-circuit-empty-label > :first-child { color: #0e7490; border: 1px solid #cdebf1; border-radius: 5px; background: #f1fbfd; padding: 3px 8px; }
.qicp-task-illustration { display: flex; flex: 1; flex-direction: column; justify-content: center; gap: 14px; min-width: 0; margin: 16px 0 20px; text-align: center; }
.qicp-task-illustration > svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.qicp-task-illustration figcaption { margin-inline: auto; max-width: 480px; font-size: 13px; line-height: 23px; color: #52657f; }
.qicp-task-illustration figcaption > :first-child { font-size: 15px; line-height: 24px; font-weight: 600; color: #334155; }
.qicp-task-illustration figcaption p { margin-top: 5px; }
.qicp-circuit-empty-status { border-top: 1px solid #e4ebf3; padding-top: 14px; font-size: 12px; line-height: 22px; color: #64748b; }
.qicp-circuit-empty-title { font-size: 13px; font-weight: 500; color: #42546d; }
@media (max-width: 639px) {
  .qicp-circuit-empty { min-height: 320px; padding: 14px; }
  .qicp-task-illustration { margin-top: 10px; }
}

/* Task help: an explanatory flow, separate from live execution state. */
.qicp-help-dialog { width: min(1040px, calc(100vw - 48px)); max-width: calc(100vw - 48px); max-height: calc(100dvh - 48px); margin: auto; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 80px #0f172a2e; }
.qicp-help-dialog::backdrop { background: #172c4a59; }
.qicp-help-frame { display: flex; flex-direction: column; min-width: 0; height: min(840px, calc(100dvh - 50px)); overflow-wrap: anywhere; }
.qicp-help-header { flex-shrink: 0; background: #fff; padding: 22px 28px; }
.qicp-help-body { display: grid; grid-template-columns: 164px minmax(0, 1fr); min-height: 0; flex: 1; }
.qicp-help-nav { padding: 24px 12px; background: #f8fafc; border-right: 1px solid #e5eaf1; overflow: auto; }
.qicp-help-nav-label { font-size: 11px; color: #64748b; padding: 0 12px; margin-bottom: 12px; letter-spacing: .08em; }
.qicp-help-nav button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; margin-bottom: 4px; padding: 8px 10px; border-radius: 6px; text-align: left; font-size: 12px; color: #475569; white-space: nowrap; }
.qicp-help-nav button > span { font-size: 10px; color: #94a3b8; font-variant-numeric: tabular-nums; }
.qicp-help-nav button:hover { color: #0e7490; background: #eaf5f9; }
.qicp-help-nav button:focus-visible { outline: 2px solid #0891b2; outline-offset: -2px; }
.qicp-help-content { display: grid; align-content: start; gap: 28px; min-width: 0; padding: 24px 28px 32px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.qicp-help-section { display: grid; gap: 10px; min-width: 0; scroll-margin-block: 24px; }
.qicp-help-section:focus { outline: none; }
.qicp-help-section > h3 { font-size: 15px; line-height: 24px; }
.qicp-help-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.qicp-help-field { background: #f8fafc; border-radius: 8px; padding: 14px; min-width: 0; }
.qicp-help-field > dd:last-child { line-height: 24px; font-size: 13px; }
[data-help-section="outputs"], [data-help-section="interpretation"] { border-top: 1px solid #e5eaf1; padding-top: 20px; }
.qicp-help-quickstart { border-left: 3px solid #22d3ee; border-radius: 0 10px 10px 0; padding: 14px 16px; background: #f0fdff; }
.qicp-help-section.qicp-help-technical { display: block; padding: 14px 16px; border: 1px solid #e2e8f0; border-radius: 10px; }
.qicp-help-technical > summary { cursor: pointer; line-height: 24px; }
.qicp-help-technical > summary::marker { color: #0891b2; }
.qicp-help-technical > summary:focus-visible { outline: 2px solid #0891b2; outline-offset: 4px; border-radius: 2px; }
.qicp-help-terms { margin-top: 16px; }
.qicp-task-flow { min-width: 0; }
.qicp-flow-basics { margin: 10px 0 0; color: #475569; font-size: 13px; line-height: 24px; }
.qicp-flow-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  padding: 0;
  margin: 14px 0;
  list-style: none;
}
.qicp-flow-step { position: relative; min-width: 0; }
.qicp-flow-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 106px;
  padding: 10px 5px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #64748b;
  background: #fff;
  cursor: pointer;
  text-align: center;
}
.qicp-flow-button:hover { border-color: #67e8f9; background: #f0fdff; }
.qicp-flow-button[aria-pressed="true"] { border-color: #22d3ee; color: #0e7490; background: #ecfeff; }
.qicp-flow-button:focus-visible { outline: 2px solid #0891b2; outline-offset: 3px; }
.qicp-flow-icon { display: flex; color: #0891b2; }
.qicp-flow-label { display: flex; flex-direction: column; gap: 4px; }
.qicp-flow-number { font-size: 10px; letter-spacing: .08em; color: #94a3b8; }
.qicp-flow-title { font-size: 12px; line-height: 18px; font-weight: 600; color: #334155; }
.qicp-flow-arrow {
  position: absolute;
  right: -16px;
  top: 40px;
  color: #94a3b8;
  font-size: 17px;
  line-height: 24px;
}
.qicp-flow-detail { border: 1px solid #ccecf2; border-radius: 8px; padding: 16px; background: #f8fdfe; }
.qicp-flow-detail-icon { display: flex; flex-shrink: 0; color: #0891b2; }
.qicp-flow-explanation { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px 14px; margin: 18px 0 0; }
.qicp-flow-explanation dt { padding-top: 1px; color: #0e7490; font-size: 12px; font-weight: 600; line-height: 22px; }
.qicp-flow-explanation dd { margin: 0; color: #475569; font-size: 13px; line-height: 24px; overflow-wrap: anywhere; }
.qicp-flow-loop { margin: 14px 0 0; color: #0e7490; font-size: 12px; line-height: 22px; }
.qicp-flow-note { border-top: 1px solid #e2e8f0; margin: 14px 0 0; padding-top: 12px; color: #64748b; font-size: 12px; line-height: 22px; }
.qicp-flow-pending { display: flex; align-items: flex-start; gap: 14px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; padding: 18px; }
@media (max-width: 639px) {
  .qicp-help-dialog { width: calc(100vw - 24px); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .qicp-help-frame { height: calc(100dvh - 26px); }
  .qicp-help-header { padding: 18px 16px; }
  .qicp-help-header h2 { font-size: 16px; line-height: 24px; }
  .qicp-help-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .qicp-help-nav { display: flex; gap: 4px; padding: 8px; border-right: 0; border-bottom: 1px solid #e5eaf1; }
  .qicp-help-nav-label { display: none; }
  .qicp-help-nav button { width: auto; flex-shrink: 0; margin: 0; gap: 6px; }
  .qicp-help-content { padding: 20px 16px 28px; gap: 24px; }
  .qicp-help-fields { grid-template-columns: minmax(0, 1fr); }
  .qicp-flow-steps { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .qicp-flow-button { flex-direction: row; justify-content: flex-start; min-height: 68px; gap: 14px; padding: 10px 14px; text-align: left; }
  .qicp-flow-label { flex-direction: row; align-items: center; gap: 10px; }
  .qicp-flow-title { font-size: 13px; }
  .qicp-flow-arrow { right: auto; top: auto; bottom: -23px; left: 22px; transform: rotate(90deg); }
  .qicp-flow-detail { padding: 14px; }
  .qicp-flow-explanation { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .qicp-flow-explanation dd + dt { margin-top: 8px; }
}

/* Task history: aligned desktop records and self-contained narrow-screen cards. */
.qicp-task-list-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.qicp-task-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.qicp-task-summary-value {
  margin: 8px 0 0;
  font-size: 26px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.qicp-task-filters {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 12px;
}
.qicp-task-filters > * { min-width: 0; }
.qicp-task-status-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.qicp-task-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 12px;
}
.qicp-task-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qicp-task-row > * { min-width: 0; }
.qicp-task-row-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.qicp-task-row-title { overflow-wrap: anywhere; }
.qicp-task-row-progress { font-variant-numeric: tabular-nums; }
.qicp-task-row-metadata { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.qicp-task-row-error { overflow-wrap: anywhere; }
.qicp-task-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; }
.qicp-task-row-actions .btn-ghost { white-space: nowrap; }
@media (min-width: 1200px) {
  .qicp-task-list-grid { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid #dfe6ef; border-radius: 12px; background: #fff; overflow: hidden; }
  .qicp-task-list-grid > .qicp-task-row { border: 0; border-radius: 0; box-shadow: none; }
  .qicp-task-list-grid > .qicp-task-row + .qicp-task-row { border-top: 1px solid #e8edf3; }
  .qicp-task-row {
    display: grid;
    grid-template-columns: minmax(210px, 1.6fr) minmax(110px, .85fr) minmax(155px, 1fr) 148px;
    grid-template-areas: "identity progress metadata actions" "error error error error";
    align-items: center;
    column-gap: 24px;
    row-gap: 0;
  }
  .qicp-task-row-identity { grid-area: identity; flex-direction: column; gap: 8px; }
  .qicp-task-row-progress { grid-area: progress; }
  .qicp-task-row-metadata { grid-area: metadata; }
  .qicp-task-row-actions { grid-area: actions; flex-wrap: nowrap; margin-top: 0; }
  .qicp-task-row-error { grid-area: error; padding-top: 12px; }
}
@media (max-width: 639px) {
  .qicp-task-summary-grid { gap: 8px; }
  .qicp-task-summary { padding: 12px; }
  .qicp-task-summary-value { font-size: 24px; }
  .qicp-task-filters { grid-template-columns: minmax(0, 1fr); }
  .qicp-task-filters > button { justify-self: start; }
}

/* Compact graph matrices retain the workbench input style and scroll locally. */
.qicp-matrix-field { min-width: 0; border: 0; padding: 0; margin: 0; }
.qicp-matrix-scroll { max-width: 100%; overflow-x: auto; padding: 2px 1px 6px; }
.qicp-matrix-grid { display: grid; grid-template-columns: 30px repeat(var(--matrix-size), minmax(38px, 1fr)); gap: 4px; min-width: calc(30px + var(--matrix-size) * 42px); }
.qicp-matrix-axis { display: flex; align-items: center; justify-content: center; font-size: 11px; color: #64748b; min-height: 24px; }
.qicp-matrix-cell { width: 100%; min-width: 0; height: 34px; padding: 3px; border: 1px solid #cbd5e1; border-radius: 6px; background: white; color: #334155; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.qicp-matrix-cell:focus-visible { outline: 2px solid #0891b2; outline-offset: 1px; }
.qicp-matrix-toggle[aria-pressed="true"] { color: #0e7490; background: #ecfeff; border-color: #67e8f9; }
.qicp-matrix-cell:disabled { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; cursor: default; }
.qicp-matrix-cell[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.qicp-matrix-cell::-webkit-inner-spin-button, .qicp-matrix-cell::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Nine task entries share a three-column desktop layout. */
@media (min-width: 1280px) { .qicp-task-entry-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
