:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d8dee6;
  --border-strong: #b8c0cc;
  --text: #17202a;
  --muted: #687386;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #dff3ef;
  --warn: #a15c08;
  --raw: #6d5d1f;
  --shadow: 0 10px 28px rgba(18, 32, 46, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.input-panel,
.result-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-panel {
  align-self: start;
  padding: 16px;
}

.result-panel {
  min-height: calc(100vh - 112px);
  padding: 16px;
}

.panel-title-row,
.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.plan-library {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.plan-select-field {
  display: grid;
  gap: 5px;
}

.plan-select-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.plan-picker {
  position: relative;
  min-width: 0;
}

.plan-picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.plan-picker-button::after {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-left: 10px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #687386;
}

.plan-picker-button:disabled {
  background: #f3f6f8;
  color: #94a3b8;
  cursor: not-allowed;
}

.plan-picker-button:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.plan-picker-menu {
  position: absolute;
  z-index: 35;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(18, 32, 46, 0.18);
}

.plan-picker-option {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid #edf0f4;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.plan-picker-option:last-child {
  border-bottom: 0;
}

.plan-picker-option:hover,
.plan-picker-option:focus {
  background: var(--accent-soft);
  outline: none;
}

.plan-picker-summary {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-picker-summary.icons-only {
  flex-wrap: wrap;
  gap: 5px;
  overflow: visible;
  white-space: normal;
}

.plan-picker-target {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.target-rows {
  display: grid;
  gap: 12px;
}

.target-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px 36px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.item-field {
  position: relative;
}

.item-input-box {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #ffffff;
}

.item-input,
.amount-input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.item-input {
  border: 0;
  border-radius: 0;
  padding: 0;
}

.target-item-icon,
.suggestion-icon,
.plan-picker-icon,
.recipe-material-icon,
.recipe-formula-icon {
  display: inline-block;
  flex: 0 0 auto;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.target-item-icon {
  width: 24px;
  height: 24px;
}

.target-item-icon.empty {
  border: 1px dashed #cbd5e1;
  border-radius: 5px;
  background: #f8fafc;
}

.suggestion-icon,
.recipe-material-icon {
  width: 22px;
  height: 22px;
}

.plan-picker-icon {
  width: 44px;
  height: 44px;
}

.recipe-formula-icon {
  width: 16px;
  height: 16px;
}

.amount-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #ffffff;
}

.amount-input {
  height: 36px;
  border: 0;
  border-radius: 0;
  padding: 0 8px;
}

.unit-label {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.item-input-box:focus-within,
.amount-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.suggestions {
  position: absolute;
  z-index: 20;
  display: none;
  top: calc(100% + 4px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(760px, calc(100vw - 32px));
  max-height: 292px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(18, 32, 46, 0.18);
}

.suggestions.open {
  display: block;
}

.suggestion-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid #edf0f4;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.suggestion-option:last-child {
  border-bottom: 0;
}

.suggestion-option:hover,
.suggestion-option.active {
  background: var(--accent-soft);
}

.suggestion-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.suggestion-name {
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}

.suggestion-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.remove-button,
.tab-button {
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.remove-button,
.tab-button {
  background: #ffffff;
  color: var(--text);
}

.secondary-button:hover,
.remove-button:hover,
.tab-button:hover {
  background: #edf3f5;
}

.secondary-button.is-disabled,
.secondary-button.is-disabled:hover {
  border-color: #d8dee6;
  background: #f3f6f8;
  color: #94a3b8;
  cursor: not-allowed;
}

.recipe-filter-toggle.active,
.recipe-filter-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: #d9f3ee;
  color: #0f766e;
  font-weight: 750;
}

.compact-button {
  white-space: nowrap;
}

.remove-button {
  width: 36px;
  padding: 0;
  color: #7c2d12;
  font-size: 22px;
  line-height: 1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 14px;
}

.tabs {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
}

.tab-button {
  min-width: 118px;
  border: 0;
  border-radius: 0;
}

.tab-button + .tab-button {
  border-left: 1px solid var(--border-strong);
}

.tab-button.active {
  background: var(--accent);
  color: #ffffff;
}

.status-message {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #d2d8e0;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.status-message.error {
  border-color: #f0b6a8;
  background: #fff7ed;
  color: #9a3412;
}

.view-panel.hidden {
  display: none;
}

.graph-viewport {
  overflow: auto;
  min-height: 360px;
  border: 1px solid #1d2a34;
  border-radius: 10px;
  background:
    radial-gradient(circle at 20% 20%, rgba(48, 80, 96, 0.32), transparent 34%),
    linear-gradient(180deg, #232a30 0%, #1e252b 100%);
  cursor: grab;
  touch-action: none;
}

.graph-viewport.panning {
  cursor: grabbing;
  user-select: none;
}

.graph-canvas {
  position: relative;
  min-width: 100%;
  min-height: 560px;
}

.graph-svg {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: visible;
}

.graph-highlight-svg {
  z-index: 32;
  pointer-events: none;
}

.graph-flow {
  fill: none;
  stroke-linecap: round;
  stroke-opacity: 0.52;
  mix-blend-mode: screen;
  transition: stroke-opacity 0.16s ease, filter 0.16s ease;
}

.graph-flow.dimmed {
  stroke-opacity: 0.12;
  mix-blend-mode: normal;
}

.graph-flow.highlight-edge {
  stroke-opacity: 0.98;
  filter: drop-shadow(0 0 7px rgba(250, 204, 21, 0.78));
  mix-blend-mode: normal;
}

.graph-flow.flowing-edge {
  stroke-dasharray: 16 10;
  animation: graph-flow-forward 0.72s linear infinite;
  filter: drop-shadow(0 0 7px rgba(250, 204, 21, 0.86));
}

@keyframes graph-flow-forward {
  to {
    stroke-dashoffset: -26;
  }
}

.graph-edge-label {
  position: absolute;
  z-index: 4;
  display: inline-grid;
  gap: 3px;
  transform: translate(-50%, -50%);
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(35, 42, 48, 0.78);
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: opacity 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.graph-edge-label.dimmed {
  opacity: 0.18;
}

.graph-edge-label.highlight-edge {
  z-index: 42;
  max-width: min(360px, 42vw);
  background: rgba(250, 204, 21, 0.94);
  color: #1f2933;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 8px 18px rgba(0, 0, 0, 0.26);
  text-shadow: none;
}

.graph-edge-label-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.graph-edge-label-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.42));
}

.graph-edge-label-icon.empty {
  width: 14px;
  height: 14px;
  border: 1px dashed rgba(229, 231, 235, 0.72);
  border-radius: 3px;
  filter: none;
}

.graph-edge-label.highlight-edge .graph-edge-label-icon {
  width: 20px;
  height: 20px;
  filter: none;
}

.graph-edge-label-name {
  display: none;
}

.graph-edge-label-rate {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.graph-edge-label-scale {
  flex: 0 0 auto;
  color: rgba(229, 231, 235, 0.78);
  font-variant-numeric: tabular-nums;
}

.graph-edge-label.highlight-edge .graph-edge-label-scale {
  color: rgba(31, 41, 51, 0.78);
}

.graph-edge-label.highlight-edge .graph-edge-label-name {
  display: block;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.graph-node {
  position: absolute;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  box-sizing: border-box;
  overflow: hidden;
  padding: 8px;
  border: 2px solid #2e8dcc;
  border-radius: 2px;
  background: rgba(21, 89, 130, 0.92);
  color: #e8f3fb;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
  transition: opacity 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease, outline-color 0.16s ease;
}

.graph-node.has-media {
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
}

.graph-node.dimmed {
  opacity: 0.24;
  filter: saturate(0.45) brightness(0.72);
}

.graph-node.highlight-upstream,
.graph-node.highlight-downstream {
  z-index: 35;
  opacity: 1;
  filter: none;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.34), 0 0 0 3px rgba(255, 255, 255, 0.58);
}

.graph-node.highlight-upstream {
  outline: 3px solid rgba(56, 189, 248, 0.95);
  outline-offset: 3px;
}

.graph-node.highlight-downstream {
  outline: 3px solid rgba(52, 211, 153, 0.95);
  outline-offset: 3px;
}

.graph-node.selected {
  z-index: 45;
  opacity: 1;
  filter: none;
  outline: 4px solid rgba(250, 204, 21, 0.98);
  outline-offset: 4px;
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.42), 0 0 0 4px rgba(255, 255, 255, 0.72), 0 0 28px rgba(250, 204, 21, 0.62);
}

.graph-node.has-switch-button .graph-node-kind {
  padding-right: 28px;
}

.graph-drag-handle {
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 4px;
  padding: 4px;
  background: rgba(8, 13, 18, 0.36);
  color: rgba(255, 255, 255, 0.88);
  cursor: grab;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  overflow: hidden;
  text-align: center;
  touch-action: none;
  user-select: none;
}

.graph-device-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.42));
}

.graph-material-media {
  display: inline-grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  padding: 6px;
  background: rgba(8, 13, 18, 0.28);
  overflow: hidden;
}

.graph-material-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.42));
}

.graph-drag-zone {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.graph-node.dragging .graph-drag-handle {
  cursor: grabbing;
  background: rgba(0, 0, 0, 0.42);
}

.graph-node.dragging .graph-drag-zone {
  cursor: grabbing;
}

.switch-recipe-button {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(17, 94, 89, 0.74);
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.switch-recipe-button:hover {
  border-color: #ffffff;
  background: rgba(15, 118, 110, 0.96);
}

.graph-check-control {
  position: absolute;
  right: 7px;
  bottom: 7px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(8, 13, 18, 0.12);
  opacity: 0.72;
  cursor: pointer;
}

.graph-check-input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #22c55e;
  cursor: pointer;
}

.graph-check-input:not(:checked) {
  opacity: 0.56;
}

.graph-check-control:hover,
.graph-check-control:focus-within {
  background: rgba(8, 13, 18, 0.34);
  opacity: 1;
}

.graph-check-control:has(.graph-check-input:checked) {
  background: rgba(8, 13, 18, 0.28);
  opacity: 1;
}

.recipe-filter-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.recipe-filter-dialog {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(980px, calc(100vw - 36px));
  max-height: min(860px, calc(100vh - 36px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.recipe-filter-dialog.dragging {
  box-shadow: 0 28px 78px rgba(15, 23, 42, 0.34);
}

.recipe-filter-drag-handle {
  display: grid;
  place-items: center;
  height: 20px;
  border-bottom: 1px solid #edf0f4;
  background: #f8fafc;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.recipe-filter-dialog.dragging .recipe-filter-drag-handle {
  cursor: grabbing;
}

.recipe-filter-drag-grip {
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
}

.recipe-filter-header,
.recipe-filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.recipe-filter-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.recipe-filter-title {
  display: grid;
  gap: 2px;
}

.recipe-filter-title h3 {
  margin: 0;
  font-size: 17px;
}

.recipe-filter-summary {
  color: var(--muted);
  font-size: 12px;
}

.recipe-filter-notice {
  max-width: 760px;
  color: #0f766e;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.recipe-filter-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.recipe-filter-search {
  flex: 1 1 260px;
  height: 36px;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0 10px;
}

.recipe-filter-list {
  overflow: auto;
  padding: 10px 16px 14px;
}

.recipe-material-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.recipe-material-group + .recipe-material-group {
  margin-top: 8px;
}

.recipe-material-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

.recipe-material-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

.recipe-material-meta,
.recipe-row-meta {
  color: var(--muted);
  font-size: 12px;
}

.recipe-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid #edf0f4;
}

.recipe-row:hover {
  background: #f8fbfb;
}

.recipe-row.base-locked {
  color: #64748b;
  cursor: default;
}

.recipe-row.base-locked:hover {
  background: #ffffff;
}

.recipe-filter-checkbox:disabled {
  accent-color: #94a3b8;
  cursor: not-allowed;
}

.recipe-row.required {
  background: #fbfefc;
}

.recipe-row.focused {
  background: #f4fbfa;
  box-shadow: inset 3px 0 0 rgba(20, 184, 166, 0.42);
  animation: recipe-focus-flash 0.9s ease-out 1;
}

@keyframes recipe-focus-flash {
  0% {
    outline: 2px solid rgba(20, 184, 166, 0);
    box-shadow: inset 3px 0 0 rgba(20, 184, 166, 0.42), 0 0 0 0 rgba(20, 184, 166, 0);
  }
  28% {
    outline: 2px solid rgba(20, 184, 166, 0.9);
    box-shadow: inset 3px 0 0 rgba(20, 184, 166, 0.72), 0 0 0 3px rgba(20, 184, 166, 0.22);
  }
  100% {
    outline: 2px solid rgba(20, 184, 166, 0);
    box-shadow: inset 3px 0 0 rgba(20, 184, 166, 0.42), 0 0 0 0 rgba(20, 184, 166, 0);
  }
}

.recipe-row-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 650;
}

.recipe-row-tag {
  flex: 0 0 auto;
  color: #0f766e;
  font-size: 11px;
  font-weight: 850;
}

.recipe-row-formula {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: visible;
  white-space: normal;
}

.recipe-formula-side {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

.recipe-formula-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.recipe-switch-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 18, 24, 0.58);
}

.recipe-switch-dialog {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(9, 18, 24, 0.34);
}

.recipe-switch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid #edf0f4;
}

.recipe-switch-header h3 {
  margin: 0;
  font-size: 18px;
}

.recipe-switch-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.recipe-switch-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 164px);
  overflow-y: auto;
  padding: 14px;
}

.recipe-switch-option {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.recipe-switch-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.recipe-switch-option.current {
  border-color: #0f766e;
  border-width: 2px;
  background: #f0fdfa;
  cursor: default;
  animation: recipe-switch-current-flash 0.9s ease-out 1;
}

@keyframes recipe-switch-current-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
  28% {
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.22);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
}

.recipe-switch-name {
  font-weight: 800;
}

.recipe-switch-formula {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.graph-node.recipe {
  border-color: #2fa84f;
  background: rgba(28, 110, 39, 0.92);
}

.graph-node.recipe.draggable {
  cursor: text;
  user-select: text;
}

.graph-node.recipe.dragging {
  z-index: 55;
  cursor: grabbing;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
}

.graph-node.recipe.alternate {
  border-color: #8a5ec2;
  background: rgba(91, 57, 126, 0.92);
}

.graph-node.raw {
  border-color: #277ec0;
  background: rgba(20, 87, 130, 0.92);
}

.graph-node.target {
  border-color: #935847;
  background: rgba(98, 58, 47, 0.96);
}

.graph-node.surplus {
  border-color: #8a5ec2;
  background: rgba(84, 55, 119, 0.94);
}

.graph-node-content {
  display: grid;
  align-content: start;
  gap: 4px;
  min-width: 0;
}

.graph-node.has-media .graph-node-content {
  align-content: center;
}

.graph-node-kind {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-node-title {
  display: -webkit-box;
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  min-height: 0;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.graph-node.has-media .graph-node-title {
  -webkit-line-clamp: 3;
}

.graph-node-scale {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-node-meta {
  display: -webkit-box;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.merged-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.merged-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #ffffff;
}

.merged-table th,
.merged-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
}

.merged-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.merged-table tr:last-child td {
  border-bottom: 0;
}

.table-switch-recipe-button {
  display: inline-flex;
  align-items: center;
  height: 26px;
  margin-right: 8px;
  border: 1px solid rgba(15, 118, 110, 0.34);
  border-radius: 999px;
  padding: 0 10px;
  background: #f0fdfa;
  color: #0f766e;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.table-switch-recipe-button:hover {
  border-color: #0f766e;
  background: #ccfbf1;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 520px;
  }
}

@media (max-width: 620px) {
  .app-header {
    padding: 14px 16px;
  }

  .app-shell {
    padding: 12px;
  }

  .target-row {
    grid-template-columns: 1fr;
  }

  .remove-button {
    width: 100%;
  }

  .result-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions {
    justify-content: stretch;
  }

  .compact-button {
    width: 100%;
  }

  .recipe-mode-control {
    width: 100%;
  }

  .recipe-mode-option {
    flex: 1;
    justify-content: center;
  }

  .tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
    min-width: 0;
  }

  .graph-viewport {
    min-height: 360px;
  }

}
