:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: rgba(22, 24, 32, 0.9);
  --panel-strong: rgba(32, 34, 43, 0.94);
  --ink: #f8fbff;
  --muted: #9aa3b2;
  --soft: #cfd5df;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.24);
  --violet: #704dff;
  --blue: #447cff;
  --cyan: #5dd2f7;
  --gold: #e8cc80;
  --green: #56d89c;
  --amber: #f0b657;
  --red: #ff6a76;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% 24%, rgba(112, 77, 255, 0.34), transparent 34%),
    radial-gradient(circle at 86% 14%, rgba(93, 210, 247, 0.22), transparent 34%),
    var(--bg);
  background-size: 74px 74px, 74px 74px, auto, auto, auto;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-shell {
  width: min(100%, 560px);
}

.auth-card,
.upload-panel,
.capability-panel,
.rules-panel,
.metric-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(34, 36, 45, 0.94), rgba(12, 14, 21, 0.94));
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 32px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(79, 106, 255, 0.38);
}

.brand-row strong,
.brand-row span {
  display: block;
}

.brand-row strong {
  font-size: 19px;
}

.brand-row span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.auth-copy {
  margin: 34px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow.accent {
  color: var(--cyan);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 7vw, 44px);
  line-height: 1;
}

.tool-page h1 {
  margin-bottom: 6px;
  font-size: 32px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.auth-copy p:not(.eyebrow),
.asset-meta p,
.rules-panel li,
.empty-state span {
  color: var(--muted);
  line-height: 1.6;
}

.auth-form,
.tool-controls {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--ink);
  outline: none;
}

select {
  color: var(--soft);
}

input:focus,
select:focus {
  border-color: rgba(93, 210, 247, 0.8);
  box-shadow: 0 0 0 3px rgba(93, 210, 247, 0.12);
}

.primary-action,
.secondary-action,
.ghost-button,
.mini-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary-action {
  color: #fff;
  background: linear-gradient(100deg, var(--violet), var(--blue) 52%, var(--cyan));
  box-shadow: 0 14px 34px rgba(68, 124, 255, 0.26);
}

.secondary-action {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--line-strong);
}

.ghost-button,
.mini-button {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--gold);
  font-size: 13px;
}

.auth-footer {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  color: var(--gold);
  font-size: 13px;
}

.auth-footer span + span::before {
  content: "·";
  margin-right: 10px;
}

.tool-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 13, 0.78);
  backdrop-filter: blur(20px);
}

.session-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tool-shell {
  width: min(100%, 1420px);
  margin: 0 auto;
  padding: 24px 24px 40px;
}

.upload-panel,
.capability-panel,
.queue-panel,
.rules-panel {
  padding: 18px 20px;
}

.capability-panel {
  margin-bottom: 14px;
  padding: 24px;
  background:
    linear-gradient(100deg, rgba(11, 22, 28, 0.84), rgba(17, 13, 37, 0.92)),
    rgba(20, 22, 31, 0.94);
}

.capability-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(232, 204, 128, 0.35);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--gold);
  background: rgba(232, 204, 128, 0.06);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.capability-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.55;
}

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

.capability-grid article {
  min-height: 112px;
  padding: 0 18px;
  border-left: 1px solid rgba(93, 210, 247, 0.28);
}

.capability-grid h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.capability-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.compact {
  margin-bottom: 14px;
}

.status-pill,
.asset-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--cyan);
  background: rgba(93, 210, 247, 0.12);
  border: 1px solid rgba(93, 210, 247, 0.22);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.asset-card-head .asset-status {
  min-height: 32px;
  max-width: 100%;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-strong);
  font-size: 13px;
  white-space: nowrap;
  text-align: center;
}

.drop-zone {
  position: relative;
  min-height: 54px;
  display: grid;
  place-items: center start;
  padding: 12px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone strong {
  font-size: 14px;
}

.drop-zone span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone.is-active {
  border-color: var(--cyan);
  background: rgba(93, 210, 247, 0.1);
}

.intake-panel {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(520px, 0.86fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.tool-controls {
  grid-template-columns: minmax(240px, 1fr) 118px 126px;
  align-items: end;
  gap: 12px;
  margin-top: 0;
}

.tool-controls label {
  gap: 5px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.metric-card {
  min-height: 78px;
  padding: 14px 16px;
  box-shadow: none;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 7px 0 5px;
  font-size: 24px;
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.queue-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.empty-state {
  width: min(100%, 380px);
  min-height: 182px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  margin-top: 4px;
  padding: 24px;
  color: var(--soft);
  text-align: center;
  box-shadow: none;
}

.empty-state.is-hidden {
  display: none;
}

.asset-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(30, 31, 39, 0.96), rgba(20, 21, 28, 0.96));
}

.asset-card-head {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.asset-name {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.asset-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}

.asset-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

figure {
  margin: 0;
  min-width: 0;
  background: rgba(8, 10, 16, 0.88);
}

.image-stage {
  width: 100%;
  min-height: clamp(230px, 21vw, 330px);
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(7, 9, 15, 0.92);
}

.output-canvas {
  position: relative;
  background:
    linear-gradient(135deg, rgba(112, 77, 255, 0.14), rgba(93, 210, 247, 0.12)),
    rgba(8, 10, 16, 0.95);
}

.image-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
}

.output-canvas img[src=""],
.output-canvas img:not([src]) {
  display: none;
}

.output-placeholder {
  width: min(100%, 230px);
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.output-canvas.has-output {
  background: rgb(235, 235, 232);
}

.output-canvas.has-output .output-placeholder {
  display: none;
}

.media-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.media-labels span {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.media-labels span + span {
  border-left: 1px solid var(--line);
}

.asset-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.asset-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  font-size: 15px;
  font-weight: 900;
}

.asset-button:disabled {
  cursor: not-allowed;
  color: rgba(248, 251, 255, 0.38);
  background: rgba(255, 255, 255, 0.035);
}

.asset-button.rerun {
  grid-column: 1 / -1;
}

.asset-footnote {
  margin: 0;
  padding: 12px 14px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.asset-status.pending {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

.asset-status.preparing {
  color: var(--amber);
  background: rgba(240, 182, 87, 0.12);
  border-color: rgba(240, 182, 87, 0.28);
}

.asset-status.running {
  color: var(--amber);
  background: rgba(240, 182, 87, 0.12);
  border-color: rgba(240, 182, 87, 0.28);
}

.asset-status.success {
  color: var(--green);
  background: rgba(86, 216, 156, 0.12);
  border-color: rgba(86, 216, 156, 0.28);
}

.asset-status.review {
  color: var(--red);
  background: rgba(255, 106, 118, 0.12);
  border-color: rgba(255, 106, 118, 0.3);
}

.rules-panel ul {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding-left: 18px;
}

@media (max-width: 1180px) {
  .asset-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .intake-panel {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .tool-header,
  .panel-head {
    flex-direction: column;
  }

  .tool-controls,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .capability-head {
    flex-direction: column;
  }

  .asset-list {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .auth-page,
  .tool-shell {
    padding: 14px;
  }

  .auth-card,
  .upload-panel,
  .capability-panel,
  .queue-panel,
  .rules-panel {
    padding: 18px;
  }

  .tool-header {
    padding: 14px;
  }

  .metric-grid,
  .capability-grid,
  .asset-media,
  .media-labels,
  .asset-actions {
    grid-template-columns: 1fr;
  }

  .capability-grid article {
    min-height: auto;
    padding: 0 0 14px;
  }

  .media-labels span + span {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .asset-card-head {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .image-stage {
    min-height: 320px;
    padding: 18px;
  }

  .asset-summary,
  .asset-footnote {
    font-size: 15px;
  }

  .asset-button {
    min-height: 64px;
    font-size: 22px;
  }

  .session-tools {
    width: 100%;
    justify-content: space-between;
  }
}
