:root {
  --bg: #09090d;
  --bg-soft: #111118;
  --bg-glow: #221a4a;
  --surface: rgba(28, 28, 36, 0.92);
  --surface-soft: rgba(34, 34, 44, 0.9);
  --surface-strong: #2a2a36;
  --panel: var(--surface);
  --text: #f4f5ff;
  --muted: #b0b0c0;
  --primary: #16057d;
  --primary-strong: #1a08a0;
  --primary-soft: #6b5bff;
  --brand: #6b5bff;
  --accent: #6b5bff;
  --success: #18b88f;
  --danger: #eb596b;
  --border: rgba(122, 122, 156, 0.35);
  --border-strong: rgba(139, 127, 252, 0.62);
  --shadow: 0 26px 56px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.34);
  --focus-ring: 0 0 0 2px rgba(107, 91, 255, 0.36);
}

* {
  box-sizing: border-box;
}

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

body,
body.dark {
  position: relative;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Space Grotesk", "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% -10%, rgba(63, 37, 146, 0.32) 0%, transparent 40%),
    radial-gradient(circle at 92% -12%, rgba(28, 100, 160, 0.18) 0%, transparent 34%),
    radial-gradient(circle at 50% 120%, rgba(54, 44, 120, 0.22) 0%, transparent 42%),
    linear-gradient(160deg, #07070b 0%, #0a0a0f 45%, #11111a 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(rgba(136, 131, 180, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(136, 131, 180, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.46;
  z-index: -2;
}

body::after {
  background: radial-gradient(circle at 62% 16%, rgba(69, 52, 164, 0.22) 0%, transparent 34%);
  z-index: -1;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: #d8d6eb;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 15, 24, 0.92);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: #8f8fa7;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

input[type="range"] {
  accent-color: var(--accent);
}

input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid rgba(141, 129, 255, 0.36);
  border-radius: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(22, 5, 125, 0.96), rgba(77, 61, 189, 0.96));
  color: #f5fbff;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
  background: linear-gradient(135deg, rgba(26, 8, 160, 0.98), rgba(94, 79, 245, 0.98));
  border-color: rgba(173, 165, 255, 0.5);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: var(--focus-ring);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

code,
pre {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(88, 80, 148, 0.4);
  border-radius: 12px;
  background: rgba(13, 13, 21, 0.95);
  color: #d8d8ef;
}

hr {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107, 91, 255, 0.5), transparent);
}

.container {
  width: min(1240px, 92vw);
  margin: 24px auto 40px;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 16px clamp(16px, 3vw, 28px);
  background:
    linear-gradient(180deg, rgba(10, 10, 16, 0.94), rgba(15, 15, 26, 0.88)),
    radial-gradient(circle at top left, rgba(107, 91, 255, 0.16), transparent 38%);
  border-bottom: 1px solid rgba(101, 92, 165, 0.34);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.nav a {
  text-decoration: none;
  color: #d5d4e8;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(20, 20, 30, 0.72);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav a:hover,
.nav a:focus-visible {
  color: #f8f7ff;
  background: linear-gradient(90deg, rgba(22, 5, 125, 0.62), rgba(107, 91, 255, 0.32));
  border-color: rgba(139, 127, 252, 0.56);
  box-shadow: 0 0 0 1px rgba(22, 5, 125, 0.26);
  transform: translateX(2px);
}

.user-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.user-switch label {
  color: #b8b7cc;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.user-switch select {
  width: auto;
  min-width: 180px;
}

.user-switch span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 15, 24, 0.92);
  color: var(--text);
}

body.dark > header:not(.navbar) {
  width: min(1240px, 92vw);
  margin: 24px auto 0;
  padding: 20px 22px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.9), rgba(24, 24, 33, 0.88));
  box-shadow: var(--shadow);
}

body.dark > header:not(.navbar) h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

body.dark > header:not(.navbar) nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

body.dark > header:not(.navbar) a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(20, 20, 30, 0.75);
}

body.dark > header:not(.navbar) a:hover,
body.dark > header:not(.navbar) a:focus-visible {
  background: linear-gradient(90deg, rgba(22, 5, 125, 0.62), rgba(107, 91, 255, 0.32));
  border-color: rgba(139, 127, 252, 0.56);
}

.panel,
.card,
.feature-card,
.box-form,
.result-card {
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.92), rgba(24, 24, 33, 0.9));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(8px);
  animation: card-enter 0.45s ease both;
}

.panel:hover,
.card:hover,
.feature-card:hover,
.box-form:hover,
.result-card:hover {
  border-color: rgba(139, 127, 252, 0.46);
  box-shadow: 0 28px 52px rgba(0, 0, 0, 0.48);
}

.panel h1,
.panel h2,
.panel h3,
.panel h4,
.card h1,
.card h2,
.card h3,
.card h4 {
  margin-top: 0;
  color: #fafafe;
}

.row,
.toolbar,
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.toolbar {
  justify-content: space-between;
}

.row-buttons {
  justify-content: flex-end;
}

.row > *,
.toolbar > *,
.grid > *,
.compare > *,
.two-cols > *,
.col-left,
.col-right {
  min-width: 0;
}

.row > input,
.row > select,
.row > textarea {
  flex: 1 1 180px;
}

.row > input[type="range"] {
  flex: 1 1 160px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.compare img,
#img-orig,
#img-proc,
.preview-img {
  width: 100%;
  min-height: 240px;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  padding: 10px;
  border: 1px solid rgba(103, 94, 161, 0.3);
  background: linear-gradient(180deg, rgba(10, 10, 18, 0.95), rgba(23, 23, 36, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.placeholder {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(10, 10, 18, 0.95), rgba(23, 23, 36, 0.9));
  border: 1px dashed rgba(130, 120, 188, 0.44);
  border-radius: 14px;
}

.center {
  display: grid;
  place-items: center;
}

.top-gap {
  margin-top: 18px;
}

.top-gap-small {
  margin-top: 10px;
}

.multi-layout {
  gap: 22px;
}

.multi-top-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.multi-section {
  height: 100%;
}

.multi-workspace {
  display: flex;
  flex-direction: column;
}

.multi-workspace-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 18px;
}

.multi-workspace-header p {
  margin: 6px 0 0;
}

.multi-reference-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.multi-reference-controls input[type="file"] {
  flex: 1 1 360px;
}

.multi-reference-controls .switch {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(122, 122, 156, 0.35);
  border-radius: 12px;
  background: rgba(20, 20, 30, 0.76);
}

.multi-canvas-area .canvas-wrap {
  width: 100%;
  max-width: none;
}

.multi-score-wrap {
  width: 100%;
  margin: 16px 0 0;
}

.multi-legend {
  text-align: left;
}

.multi-advanced {
  margin-top: 16px;
}

.two-cols {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.25fr);
  gap: 22px;
  align-items: start;
}

.visual-pane {
  gap: 14px;
}

.visual-tools {
  padding: 16px;
  border: 1px solid rgba(122, 122, 156, 0.35);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.9), rgba(20, 20, 30, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.visual-tools-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.visual-tools-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #f4f4ff;
}

.visual-tools-row {
  justify-content: flex-start;
}

.visual-tools .muted {
  margin: 4px 0 0;
}

.batch-main,
.batch-side {
  min-width: 0;
}

.batch-side {
  padding-left: 20px;
  border-left: 1px solid rgba(101, 92, 165, 0.34);
}

button,
.button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid rgba(141, 129, 255, 0.4);
  border-radius: 12px;
  background: linear-gradient(135deg, #16057d, #4d3dbd);
  color: #f5fbff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24);
}

button:hover,
.button:hover,
.btn:hover {
  background: linear-gradient(135deg, #1a08a0, #5e4ff5);
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(22, 5, 125, 0.45), 0 10px 22px rgba(0, 0, 0, 0.35);
}

button:focus-visible,
.button:focus-visible,
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 10px 22px rgba(0, 0, 0, 0.35);
}

button:disabled,
.btn:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary,
.button.secondary,
.btn.secondary {
  background: rgba(31, 31, 41, 0.9);
  color: #d0cfdf;
  border-color: rgba(122, 122, 156, 0.35);
  box-shadow: none;
}

button.secondary:hover,
.button.secondary:hover,
.btn.secondary:hover {
  color: #fff;
  border-color: rgba(107, 91, 255, 0.62);
  background: rgba(43, 34, 98, 0.42);
  box-shadow: 0 0 0 1px rgba(22, 5, 125, 0.32);
}

button.success,
.button.success,
.btn.success {
  background: linear-gradient(135deg, #1f8f7b, #18b88f);
  border-color: rgba(91, 234, 200, 0.28);
}

button.success:hover,
.button.success:hover,
.btn.success:hover {
  background: linear-gradient(135deg, #15947d, #12a983);
  box-shadow: 0 0 18px rgba(31, 160, 135, 0.26), 0 10px 22px rgba(0, 0, 0, 0.35);
}

button.danger,
.button.danger,
.btn.danger {
  background: linear-gradient(135deg, #ef6073, #cb3f55);
  border-color: rgba(255, 165, 177, 0.25);
}

button.danger:hover,
.button.danger:hover,
.btn.danger:hover {
  background: linear-gradient(135deg, #ea4f66, #bf354d);
  box-shadow: 0 0 16px rgba(213, 64, 88, 0.24), 0 10px 22px rgba(0, 0, 0, 0.35);
}

button.small,
.button.small,
.btn.small {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.tool-btn {
  letter-spacing: 0.01em;
}

button.tool-btn.active,
.tool-btn.active {
  box-shadow: inset 0 0 0 2px rgba(107, 91, 255, 0.42), 0 0 24px rgba(44, 33, 115, 0.26);
}

button.tool-btn.active.tool-pos,
.tool-btn.active.tool-pos {
  box-shadow: inset 0 0 0 2px rgba(21, 230, 182, 0.45), 0 0 24px rgba(21, 230, 182, 0.18);
}

button.tool-btn.active.tool-neg,
.tool-btn.active.tool-neg {
  box-shadow: inset 0 0 0 2px rgba(255, 90, 122, 0.45), 0 0 24px rgba(255, 90, 122, 0.18);
}

button.tool-pos,
.tool-pos {
  border-color: rgba(21, 230, 182, 0.58);
  background: rgba(21, 230, 182, 0.18);
  color: #dffef7;
}

button.tool-pos:hover,
.tool-pos:hover {
  background: rgba(21, 230, 182, 0.26);
  box-shadow: 0 0 0 1px rgba(21, 230, 182, 0.18), 0 10px 26px rgba(21, 230, 182, 0.16);
}

button.tool-neg,
.tool-neg {
  border-color: rgba(255, 90, 122, 0.58);
  background: rgba(255, 90, 122, 0.18);
  color: #ffe7eb;
}

button.tool-neg:hover,
.tool-neg:hover {
  background: rgba(255, 90, 122, 0.26);
  box-shadow: 0 0 0 1px rgba(255, 90, 122, 0.18), 0 10px 26px rgba(255, 90, 122, 0.16);
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.subtle {
  opacity: 0.84;
}

.error {
  color: #ffcad1;
}

.status {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(107, 91, 255, 0.46);
  background: rgba(22, 17, 50, 0.78);
  color: #ccc4ff;
  font-size: 12px;
}

.legend {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
}

.thr-val,
#thr-val {
  color: #f6f7ff;
  font-variant-numeric: tabular-nums;
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(122, 122, 156, 0.35);
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.9), rgba(20, 20, 30, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.prompt-row > .stack {
  flex: 1 1 220px;
}

.prompt-label {
  font-weight: 700;
  color: #f4f4ff;
}

.prompt-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.prompt-controls input[type="range"] {
  width: min(220px, 48vw);
}

.prompt-thr-val {
  min-width: 48px;
  text-align: right;
  color: #f6f7ff;
  font-variant-numeric: tabular-nums;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-field span {
  font-size: 13px;
  font-weight: 600;
  color: #d8d6eb;
}

.settings-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(122, 122, 156, 0.35);
  border-radius: 12px;
  background: rgba(20, 20, 30, 0.76);
}

.settings-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.accordion {
  margin-top: 14px;
  background: rgba(20, 20, 30, 0.76);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
}

.accordion > summary {
  cursor: pointer;
  list-style: none;
  outline: none;
  user-select: none;
  font-weight: 600;
  color: #d8d4ef;
}

.accordion > summary::-webkit-details-marker {
  display: none;
}

.accordion > summary::after {
  content: "▸";
  float: right;
  transition: transform 0.15s ease;
  color: #8b7ffc;
}

.accordion[open] > summary::after {
  transform: rotate(90deg);
}

#ac-infer-empty {
  color: var(--muted);
}

#infer-json {
  margin-top: 10px;
  padding: 12px 0 0;
  border-top: 1px solid rgba(88, 80, 148, 0.3);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.stage-wrap,
.canvas-wrap {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, rgba(10, 10, 18, 0.95), rgba(23, 23, 36, 0.9));
  border: 1px solid rgba(103, 94, 161, 0.3);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.stage-wrap {
  min-height: 420px;
  height: min(75vh, 720px);
}

.canvas-wrap {
  width: min(100%, 960px);
  aspect-ratio: 16 / 9;
}

#mainImage,
#feat-img,
#mp-main-img {
  width: 100%;
  height: 100%;
  display: block;
}

#mainImage {
  object-fit: contain;
}

#feat-img {
  position: absolute;
  inset: 0;
  object-fit: fill;
  display: none;
}

#mp-main-img {
  display: none;
}

#drawCanvas,
#draw-canvas,
#result-canvas,
#mp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#drawCanvas {
  cursor: crosshair;
}

#draw-canvas,
#result-canvas {
  pointer-events: none;
}

#draw-canvas.active {
  pointer-events: auto;
  cursor: crosshair;
}

#mp-canvas {
  touch-action: none;
  cursor: crosshair;
}

.features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-card,
.box-form {
  position: relative;
}

.box-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.xbtn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(122, 122, 156, 0.35);
  border-radius: 999px;
  background: rgba(20, 20, 30, 0.86);
  color: var(--muted);
  box-shadow: none;
}

.xbtn:hover {
  color: var(--text);
  border-color: rgba(139, 127, 252, 0.56);
  background: rgba(43, 34, 98, 0.4);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.upload input[type="file"] {
  flex: 1 1 260px;
}

.file,
.prompt-input {
  width: 100%;
}

.drop-zone {
  border: 1.5px dashed rgba(139, 127, 252, 0.44);
  border-radius: 18px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(160deg, rgba(20, 20, 32, 0.82), rgba(14, 14, 22, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--border-strong);
  background: linear-gradient(160deg, rgba(34, 28, 75, 0.8), rgba(18, 18, 30, 0.94));
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.drop-zone p {
  margin: 0;
  font-size: 1.02rem;
  color: var(--muted);
}

.progress-container {
  width: 100%;
  height: 18px;
  display: none;
  overflow: hidden;
  border: 1px solid rgba(122, 122, 156, 0.35);
  border-radius: 999px;
  background: rgba(16, 16, 26, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.progress-bar {
  width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #16057d, #6b5bff);
  color: #f5f5ff;
  font-size: 12px;
  font-weight: 700;
  transition: width 0.3s ease;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.status-waiting {
  background: rgba(22, 17, 50, 0.78);
  color: #d6d0ff;
  border-color: rgba(107, 91, 255, 0.4);
}

.status-processing {
  background: rgba(240, 188, 84, 0.12);
  color: #ffd886;
  border-color: rgba(240, 188, 84, 0.35);
}

.status-done {
  background: rgba(24, 184, 143, 0.15);
  color: #a9ffe6;
  border-color: rgba(91, 234, 200, 0.32);
}

.status-error {
  background: rgba(235, 89, 107, 0.14);
  color: #ffcad1;
  border-color: rgba(255, 165, 177, 0.28);
}

.meta-details {
  max-height: 100px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid rgba(122, 122, 156, 0.28);
  border-radius: 10px;
  background: rgba(16, 16, 26, 0.92);
  font-size: 0.85rem;
  color: var(--muted);
}

.card {
  padding: 14px;
}

.p-2 {
  padding: 12px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.login-header {
  padding: 22px 24px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-brand {
  font-size: clamp(3rem, 7vw, 4.5rem);
  letter-spacing: 0.04em;
  font-weight: 650;
  color: #f7f7ff;
  text-shadow: 0 12px 26px rgba(8, 8, 18, 0.42);
}

.login-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 460px;
  padding: 24px 22px;
  border-radius: 22px;
  border: 1px solid rgba(139, 127, 252, 0.24);
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.94), rgba(24, 24, 33, 0.9));
  box-shadow: 0 30px 64px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(10px);
}

.login-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0 0 18px;
  line-height: 1.45;
  color: var(--muted);
}

.login-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 111, 134, 0.28);
  background: rgba(235, 89, 107, 0.12);
  color: #ffd1d8;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-field {
  display: grid;
  gap: 8px;
}

.login-field label {
  font-size: 13px;
  opacity: 0.9;
}

.login-button {
  width: 100%;
  margin-top: 4px;
}

.login-help {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
}

.mp-thr-wrap {
  width: min(100%, 720px);
  margin: 16px auto 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(122, 122, 156, 0.35);
  background: linear-gradient(160deg, rgba(31, 31, 40, 0.9), rgba(24, 24, 33, 0.88));
  box-shadow: var(--shadow-soft);
}

.mp-thr-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.mp-thr-title {
  font-size: 0.95rem;
  color: #dfddf0;
}

.mp-thr-value {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  color: #f5f5ff;
}

.mp-thr-slider {
  width: 100%;
  height: 10px;
  cursor: pointer;
}

.mp-thr-hints {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.mp-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 22, 0.62);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.hidden {
  display: none !important;
}

.mp-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
}

.mp-spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: mpSpin 0.9s linear infinite;
}

.mp-loading-title {
  font-weight: 650;
  letter-spacing: 0.2px;
}

.mp-loading-sub {
  margin-top: 2px;
  font-size: 0.88rem;
  opacity: 0.8;
}

.footer {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@keyframes mpSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1040px) {
  .multi-top-grid,
  .compare,
  .two-cols {
    grid-template-columns: 1fr;
  }

  .batch-side {
    padding-top: 20px;
    padding-left: 0;
    border-top: 1px solid rgba(101, 92, 165, 0.34);
    border-left: 0;
  }
}

@media (max-width: 820px) {
  .container {
    width: min(94vw, 1240px);
  }

  .navbar {
    position: static;
  }

  .nav,
  .user-switch {
    width: 100%;
  }

  .row,
  .toolbar,
  .prompt-controls,
  .multi-reference-controls {
    align-items: stretch;
  }

  .prompt-controls input[type="range"] {
    width: 100%;
  }

  .stage-wrap {
    min-height: 340px;
    height: 65vh;
  }
}

@media (max-width: 640px) {
  .panel,
  .card,
  .feature-card,
  .box-form,
  .result-card {
    padding: 16px;
  }

  .compare img,
  #img-orig,
  #img-proc,
  .preview-img,
  .placeholder {
    min-height: 200px;
  }

  .login-main {
    padding: 18px;
  }

  .login-card {
    padding: 20px 18px;
  }
}
