/* formula-morph round 2 · 20261009-morph-2 */
#formula-morph-panel {
  --morph-ink: #f4f4f5;
  --morph-muted: #d4d4d8;
  --morph-soft: #a1a1aa;
  --morph-line: #52525b;
  position: fixed;
  z-index: 980;
  inset: 84px 24px auto auto;
  width: min(720px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 108px));
  overflow: auto;
  padding: 16px;
  color: var(--morph-ink);
  background: #18181b;
  border: 1px solid var(--morph-line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(24, 24, 27, .32);
  font: 13px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#formula-morph-panel[hidden] { display: none; }
#formula-morph-panel * { box-sizing: border-box; }
.morph-header, .morph-toolbar, .morph-example-row { display: flex; align-items: center; gap: 8px; }
.morph-header { justify-content: space-between; margin-bottom: 12px; }
.morph-header h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.morph-close, .morph-icon-button { border: 1px solid var(--morph-line); background: transparent; color: var(--morph-ink); border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.morph-close:hover, .morph-icon-button:hover { background: #27272a; }
.morph-steps { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 8px; margin-bottom: 12px; }
.morph-step { min-width: 0; border: 1px solid #3f3f46; background: #27272a; border-radius: 10px; padding: 10px; }
.morph-step.is-active { border-color: var(--morph-muted); }
.morph-step-label, .morph-section-label { display: block; color: var(--morph-muted); font-size: 11px; margin: 0 0 6px; font-weight: 650; }
.morph-card { display: grid; place-items: center; min-height: 56px; overflow: hidden; }
.morph-card-svg { display: block; width: 100%; height: 62px; color: var(--morph-ink); }
.morph-card-empty, .morph-card-error { color: var(--morph-soft); }
.morph-arrow { align-self: center; color: var(--morph-muted); font-size: 18px; }
.morph-stage-wrap { border: 1px solid #3f3f46; border-radius: 10px; padding: 8px; background: #09090b; }
.morph-stage { display: block; width: 100%; min-height: 164px; height: clamp(164px, 24vw, 220px); color: var(--morph-ink); }
.morph-stage [data-morph-token] { vector-effect: non-scaling-stroke; }
.morph-empty { display: grid; place-items: center; min-height: 164px; color: var(--morph-muted); text-align: center; }
.morph-status { min-height: 20px; margin: 8px 0 0; color: var(--morph-muted); }
.morph-toolbar { justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
.morph-toolbar-group { display: flex; gap: 6px; flex-wrap: wrap; }
.morph-primary, .morph-secondary, .morph-library-choice, .morph-board-choice, .morph-example { border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.morph-primary { border: 1px solid #f4f4f5; color: #18181b; background: #f4f4f5; font-weight: 700; }
.morph-primary:hover { background: #d4d4d8; }
.morph-secondary, .morph-library-choice, .morph-board-choice, .morph-example { border: 1px solid var(--morph-line); color: var(--morph-ink); background: #27272a; }
.morph-secondary:hover, .morph-library-choice:hover, .morph-board-choice:hover, .morph-example:hover { background: #3f3f46; }
.morph-primary:focus-visible, .morph-secondary:focus-visible, .morph-close:focus-visible, .morph-icon-button:focus-visible, .morph-example:focus-visible, .morph-board-choice:focus-visible, .morph-library-choice:focus-visible, .morph-library-search:focus-visible, .morph-tex-input:focus-visible, .morph-advanced summary:focus-visible { outline: 2px solid var(--focus-ring, #86efac); outline-offset: 2px; }
.morph-board-list, .morph-library, .morph-example-list, .morph-advanced { border-top: 1px solid #3f3f46; margin-top: 14px; padding-top: 12px; }
.morph-empty-note, .morph-library-empty, .morph-library-loading, .morph-advanced-note { margin: 0; color: var(--morph-muted); }
.morph-board-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.morph-board-choice, .morph-library-choice { min-width: 0; display: grid; gap: 4px; text-align: left; }
.morph-choice-name, .morph-library-name { color: var(--morph-ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.morph-choice-card, .morph-library-card, .morph-example-card { display: block; min-height: 34px; overflow: hidden; }
.morph-choice-card svg, .morph-library-card svg, .morph-example-card svg { display: block; width: 100%; height: 42px; color: var(--morph-ink); }
.morph-library-search, .morph-tex-input { width: 100%; min-height: 38px; border: 1px solid var(--morph-line); border-radius: 8px; background: #09090b; color: var(--morph-ink); padding: 8px 10px; }
.morph-library-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.morph-example { flex: 1; min-width: 0; display: grid; gap: 4px; text-align: left; }
.morph-example strong { color: var(--morph-ink); }
.morph-advanced summary { color: var(--morph-muted); cursor: pointer; font-weight: 700; }
.morph-tex-label { display: grid; gap: 5px; margin-top: 8px; color: var(--morph-muted); }
.morph-tex-apply { margin-top: 10px; }
.morph-hint { margin: 10px 0 0; color: var(--morph-muted); font-size: 11px; }
#formula-actions .morph-launch { border-color: #3f3f46; background: #18181b; color: #fff; }
#formula-actions .morph-launch:hover { background: #27272a; }
@media (max-width: 700px) {
  #formula-morph-panel { inset: auto 8px 8px; width: calc(100vw - 16px); max-height: calc(100dvh - 24px); }
  .morph-steps { grid-template-columns: 1fr; }
  .morph-arrow { display: none; }
  .morph-example-row { flex-direction: column; align-items: stretch; }
  .morph-primary, .morph-secondary { min-height: 40px; }
  .morph-library-results { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .morph-stage [data-morph-token] { transition: none !important; } }
