:root {
  color-scheme: dark;
  --bg: #070810;
  --panel: rgba(18, 20, 31, 0.86);
  --panel-2: rgba(30, 31, 47, 0.9);
  --line: rgba(149, 255, 250, 0.22);
  --line-soft: rgba(255, 255, 255, 0.1);
  --text: #f7fbff;
  --muted: #aab1ca;
  --cyan: #42f5e9;
  --pink: #ff4fc3;
  --violet: #8c6dff;
  --green: #75ffb8;
  --warn: #ffd166;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 16%, rgba(66, 245, 233, 0.2), transparent 28rem),
    radial-gradient(circle at 82% 10%, rgba(255, 79, 195, 0.16), transparent 30rem),
    linear-gradient(135deg, #080912 0%, #111321 44%, #05060a 100%);
  color: var(--text);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 26px auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 24%),
    rgba(7, 8, 16, 0.84);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(66, 245, 233, 0.08);
  overflow: hidden;
}

.top-frame {
  min-height: 86px;
  padding: 18px 28px;
  display: grid;
  grid-template-columns: 210px 1fr auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.035);
}

.brand {
  color: inherit;
  text-decoration: none;
  display: grid;
  gap: 4px;
}

.brand-glow {
  font-size: 34px;
  font-weight: 950;
  letter-spacing: 0.04em;
  color: #dff;
  text-shadow: 0 0 18px rgba(66, 245, 233, 0.9);
}

.brand small,
.status-pill,
.identity-row span,
.mock-message p,
.switch-row small,
.output-overlay small,
.rail-panel dt {
  color: var(--muted);
  font-size: 12px;
}

.crumb {
  justify-self: center;
  width: min(480px, 100%);
  min-height: 50px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(66, 245, 233, 0.1), rgba(255, 255, 255, 0.035));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 0 34px rgba(66, 245, 233, 0.11);
}

.crumb span {
  font-weight: 800;
  text-align: center;
}

.icon-button,
.close-button,
.mini-button,
.rail-tab,
.primary-button,
.secondary-button {
  border: 1px solid var(--line-soft);
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.icon-button,
.close-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.status-pill span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 14px currentColor;
}

.status-pill.ready span {
  background: var(--green);
}

.status-pill.error span {
  background: #ff6378;
}

.studio-grid {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 360px;
  gap: 14px;
  padding: 18px;
}

.rail,
.control-panel,
.image-card,
.prompt-console,
.output-dock {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.rail {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-tab {
  min-height: 44px;
  border-radius: 12px;
  text-align: left;
  padding: 0 12px;
  font-weight: 750;
}

.rail-tab.active {
  color: #061014;
  background: linear-gradient(135deg, var(--cyan), #b4fff9);
  box-shadow: 0 10px 26px rgba(66, 245, 233, 0.2);
}

.rail-panel {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.045);
}

.rail-panel h2,
.output-dock h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.rail-panel dl,
.rail-panel dd {
  margin: 0;
}

.rail-panel div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.rail-panel dd {
  font-size: 12px;
  font-weight: 800;
  color: var(--cyan);
}

.workspace {
  display: grid;
  gap: 14px;
}

.canvas-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.image-card {
  overflow: hidden;
}

.card-head,
.panel-title {
  min-height: 54px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2,
.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.mini-button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.drop-zone,
.output-stage {
  position: relative;
  display: block;
  min-height: 430px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.drop-zone img,
.output-stage img {
  width: 100%;
  height: 430px;
  display: block;
  object-fit: cover;
}

.face-mesh {
  position: absolute;
  inset: 24% 22% 31%;
  border: 1px solid rgba(66, 245, 233, 0.75);
  clip-path: polygon(50% 0, 88% 18%, 100% 55%, 68% 100%, 32% 100%, 0 55%, 12% 18%);
  filter: drop-shadow(0 0 12px rgba(66, 245, 233, 0.9));
}

.drop-zone strong,
.drop-zone small,
.output-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  z-index: 2;
}

.drop-zone strong {
  bottom: 44px;
  font-size: 18px;
}

.drop-zone small {
  bottom: 22px;
  color: rgba(255, 255, 255, 0.72);
}

.output-overlay {
  bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  background: rgba(5, 6, 10, 0.72);
  backdrop-filter: blur(16px);
}

.output-overlay strong,
.output-overlay small {
  display: block;
}

.identity-row {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

#referenceInput {
  display: none;
}

.prompt-console {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.prompt-console label {
  font-size: 14px;
  font-weight: 850;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

textarea {
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
}

select {
  min-height: 42px;
  padding: 0 10px;
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mock-progress {
  display: none;
  padding: 12px;
  border: 1px solid rgba(66, 245, 233, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.mock-progress.active {
  display: grid;
  gap: 9px;
}

.mock-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.mock-progress-top b {
  color: var(--cyan);
}

.mock-progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.mock-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--pink));
  box-shadow: 0 0 18px rgba(66, 245, 233, 0.45);
  transition: width 260ms ease;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 13px;
  font-weight: 850;
}

.primary-button {
  color: #071015;
  background: linear-gradient(135deg, var(--cyan), #a8fff7);
  box-shadow: 0 12px 34px rgba(66, 245, 233, 0.25);
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.control-panel {
  padding-bottom: 14px;
}

.control-panel.collapsed > :not(.panel-title) {
  display: none;
}

.segmented {
  margin: 14px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  font-size: 12px;
}

.segmented button.active {
  color: #061014;
  background: var(--cyan);
}

.switch-row,
.range-row,
.two-cols,
.mock-message {
  margin: 14px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.switch-row strong,
.switch-row small {
  display: block;
}

input[type="checkbox"] {
  width: 46px;
  height: 26px;
  accent-color: var(--cyan);
}

.range-row {
  display: grid;
  gap: 9px;
}

.range-row span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.range-row b {
  color: var(--cyan);
}

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

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.two-cols label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mock-message {
  padding: 14px;
  border: 1px solid rgba(66, 245, 233, 0.2);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(66, 245, 233, 0.12), rgba(255, 79, 195, 0.08));
}

.mock-message strong {
  color: var(--cyan);
}

.mock-message p {
  margin: 7px 0 0;
  line-height: 1.4;
}

.output-dock {
  margin: 0 18px 18px;
  padding: 14px;
}

.output-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.output-item {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.output-item img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: cover;
}

.output-item a {
  display: block;
  padding: 9px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 120%);
  z-index: 20;
  padding: 12px 16px;
  border-radius: 999px;
  color: #071015;
  background: var(--cyan);
  font-weight: 900;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  transition: 220ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .top-frame,
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .crumb {
    justify-self: stretch;
  }

  .rail {
    flex-direction: row;
    overflow-x: auto;
  }

  .rail-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  .shell {
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .top-frame,
  .studio-grid {
    padding: 14px;
  }

  .canvas-pair,
  .two-cols,
  .output-list {
    grid-template-columns: 1fr;
  }

  .drop-zone,
  .output-stage,
  .drop-zone img,
  .output-stage img {
    min-height: 360px;
    height: 360px;
  }

  .brand-glow {
    font-size: 29px;
  }
}
