.node-actions .kai-upscale-tool {
  width: 31px;
  min-width: 31px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}
.node-actions .kai-upscale-tool svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.node-actions .kai-upscale-tool:focus-visible {
  outline: 2px solid #78a8ff;
  outline-offset: 2px;
}

.kai-upscale-dialog {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(4, 5, 8, .78);
  backdrop-filter: blur(13px);
}
.kai-upscale-dialog.open { display: flex; }
.kai-upscale-shell {
  width: min(1010px, calc(100vw - 44px));
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  color: #f1f2f4;
  border: 1px solid #383a40;
  border-radius: 20px;
  background: #1d1a19;
  box-shadow: 0 34px 100px rgba(0, 0, 0, .64);
}
.kai-upscale-head {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid #353231;
  background: rgba(29, 26, 25, .96);
  backdrop-filter: blur(14px);
}
.kai-upscale-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.kai-upscale-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #aaa6a3;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}
.kai-upscale-close:hover { background: #302c2a; color: #fff; }
.kai-upscale-close:focus-visible,
.kai-upscale-option:focus-visible,
.kai-upscale-generate:focus-visible {
  outline: 2px solid #8bb4ff;
  outline-offset: 2px;
}
.kai-upscale-body {
  display: grid;
  grid-template-columns: minmax(320px, .95fr) minmax(380px, 1.05fr);
  gap: 30px;
  padding: 28px;
}
.kai-upscale-preview {
  min-width: 0;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #373433;
  border-radius: 17px;
  background: #181615;
}
.kai-upscale-preview-stage {
  min-height: 340px;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
}
.kai-upscale-preview-stage img {
  max-width: 100%;
  max-height: 390px;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  background: #f4f4f4;
  box-shadow: 0 14px 38px rgba(0, 0, 0, .28);
}
.kai-upscale-source-meta {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-top: 1px solid #302d2c;
  color: #888583;
  font-size: 14px;
}
.kai-upscale-source-meta strong { color: #c6c3c0; font-weight: 650; }
.kai-upscale-settings { min-width: 0; display: flex; flex-direction: column; gap: 25px; }
.kai-upscale-field { display: flex; flex-direction: column; gap: 10px; }
.kai-upscale-label { color: #b7b3b0; font-size: 15px; font-weight: 650; }
.kai-upscale-segments {
  display: grid;
  gap: 0;
  padding: 3px;
  border-radius: 11px;
  background: #080808;
}
.kai-upscale-targets { grid-template-columns: repeat(3, 1fr); }
.kai-upscale-algorithms { grid-template-columns: repeat(3, 1fr); }
.kai-upscale-option {
  min-height: 47px;
  padding: 8px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aaa6a3;
  font: inherit;
  cursor: pointer;
}
.kai-upscale-option:hover:not(:disabled) { color: #fff; background: #211f1e; }
.kai-upscale-option.on { color: #fff; background: #2d2927; box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }
.kai-upscale-option:disabled { opacity: .3; cursor: not-allowed; }
.kai-upscale-option b { display: block; color: inherit; font-size: 15px; line-height: 1.2; }
.kai-upscale-option small { display: block; margin-top: 3px; color: #777472; font-size: 12px; white-space: nowrap; }
.kai-upscale-output {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  border: 1px solid #393532;
  border-radius: 14px;
  color: #8e8a87;
  font-size: 15px;
}
.kai-upscale-output strong { color: #d9d6d3; font-size: 16px; }
.kai-upscale-unavailable {
  display: none;
  margin: -10px 0 0;
  color: #d5a16e;
  font-size: 13px;
  line-height: 1.5;
}
.kai-upscale-unavailable.visible { display: block; }
.kai-upscale-spacer { flex: 1; min-height: 8px; }
.kai-upscale-generate {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  align-self: flex-end;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: #f1f0ef;
  color: #1c1a19;
  font: 650 15px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.kai-upscale-generate:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.kai-upscale-generate:active:not(:disabled) { transform: translateY(0); }
.kai-upscale-generate:disabled { opacity: .52; cursor: wait; }
.kai-upscale-generate svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kai-upscale-generate.busy svg { animation: kaiUpscaleSpin .8s linear infinite; }
@keyframes kaiUpscaleSpin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .kai-upscale-dialog { padding: 12px; align-items: flex-start; }
  .kai-upscale-shell { width: 100%; max-height: calc(100vh - 24px); border-radius: 16px; }
  .kai-upscale-body { grid-template-columns: 1fr; gap: 20px; padding: 18px; }
  .kai-upscale-preview { min-height: 310px; }
  .kai-upscale-preview-stage { min-height: 240px; }
  .kai-upscale-preview-stage img { max-height: 300px; }
  .kai-upscale-generate { width: 100%; }
}
@media (max-width: 560px) {
  .kai-upscale-head { min-height: 62px; padding: 0 14px 0 18px; }
  .kai-upscale-head h2 { font-size: 21px; }
  .kai-upscale-algorithms { grid-template-columns: 1fr; gap: 3px; }
  .kai-upscale-option small { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .kai-upscale-generate { transition: none; }
}
