:root {
  color-scheme: dark;
  --bg: #020204;
  --bg-elevated: #07080b;
  --bg-field: #0a0b0f;
  --bg-soft: #101116;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --text-soft: #c9cbd2;
  --muted: #777b86;
  --muted-2: #555a64;
  --cyan: #53d8ff;
  --violet: #9a7cff;
  --green: #58e69a;
  --amber: #ffbe5c;
  --red: #ff5d73;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  text-rendering: geometricPrecision;
}

body.viewer-open {
  overflow: hidden;
}

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

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 2, 4, 0.82);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(18px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.slot-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  letter-spacing: 0.02em;
}
.slot-badge.at-limit {
  color: var(--amber);
  border-color: rgba(255, 190, 92, 0.3);
}

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(83, 216, 255, 0.06);
  border: 1px solid rgba(83, 216, 255, 0.2);
  cursor: pointer;
  user-select: none;
}
.admin-toggle:hover { color: var(--cyan); }
.admin-toggle input { margin: 0; cursor: pointer; }

.brand {
  font-weight: 820;
  font-size: 19px;
  letter-spacing: 0;
}

.subtle,
.results-header p,
.login-panel p {
  color: var(--muted);
  margin: 4px 0 0;
}

.subtle {
  font-size: 13px;
}

.workspace {
  --composer-min: 320px;
  --composer-max: 9999px;
  --composer-width: 420px;
  --split-width: 22px;
  --results-min: 320px;
  --media-tile-width: 280px;
  display: grid;
  grid-template-columns:
    clamp(
      var(--composer-min),
      var(--composer-width),
      min(var(--composer-max), calc(100% - var(--split-width) - var(--results-min)))
    )
    var(--split-width)
    minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  width: min(100%, 1740px);
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 30px 40px;
  overflow-x: clip;
}

.tool-pane,
.results-pane {
  min-width: 0;
}

.tool-pane {
  width: 100%;
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 124px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.results-pane {
  min-width: 0;
  max-width: 100%;
  min-height: calc(100vh - 126px);
  padding-left: 22px;
  overflow-x: clip;
}

.split-resizer {
  align-self: stretch;
  width: var(--split-width);
  min-height: calc(100vh - 126px);
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: col-resize;
  position: sticky;
  top: 96px;
}

.split-resizer::before {
  content: "";
  display: block;
  width: 1px;
  height: 100%;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.08);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.split-resizer:hover::before,
.split-resizer:focus-visible::before,
body.resizing-layout .split-resizer::before {
  background: rgba(83, 216, 255, 0.72);
  box-shadow: 0 0 18px rgba(83, 216, 255, 0.24);
}

body.resizing-layout {
  cursor: col-resize;
  user-select: none;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050609;
}

.tab,
.ghost-button,
.primary-button,
.icon-button,
.viewer-download,
.viewer-button,
.viewer-nav,
.details-value .copy-detail {
  appearance: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  letter-spacing: 0;
}

.tab {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 720;
}

.tab:hover {
  color: var(--text-soft);
}

.tab.active {
  background: var(--text);
  color: #050609;
}

.ghost-button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 690;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.primary-button {
  width: 100%;
  min-height: 54px;
  border-radius: 6px;
  background: var(--cyan);
  color: #020204;
  font-weight: 830;
  margin-top: 18px;
  box-shadow: 0 0 0 1px rgba(83, 216, 255, 0.25), 0 18px 44px rgba(83, 216, 255, 0.14);
}

.primary-button:hover {
  background: #7be2ff;
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.tool-form {
  display: block;
}

.tool-form h1 {
  margin: 0 0 20px;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 820;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 720;
  margin-bottom: 15px;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: var(--bg-field);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 12px 13px;
  outline: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

textarea {
  resize: none;
  overflow: hidden;
  line-height: 1.45;
  min-height: 92px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:hover,
select:hover,
textarea:hover {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(83, 216, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(83, 216, 255, 0.5), 0 0 0 4px rgba(83, 216, 255, 0.07);
}

select {
  cursor: pointer;
}

.grid-3,
.grid-4 {
  display: grid;
  gap: 12px;
}

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

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

details {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 14px 0 0;
  background: transparent;
}

summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 780;
  margin-bottom: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
  box-shadow: none;
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.results-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 820;
}

.jobs {
  display: grid;
}

.job-card {
  min-width: 0;
  max-width: 100%;
  border-top: 1px solid var(--line);
  background: transparent;
  overflow: visible;
  padding: 22px 0;
}

.job-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.job-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 14px;
  border-bottom: 0;
}

.job-title {
  font-weight: 800;
  font-size: 15px;
}

.job-head-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.icon-button:hover {
  color: var(--cyan);
  background: rgba(83, 216, 255, 0.07);
}

.icon-button.danger-button:hover {
  color: var(--red);
  background: rgba(255, 93, 115, 0.08);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.status.succeeded {
  background: rgba(88, 230, 154, 0.1);
  color: var(--green);
}

.status.failed {
  background: rgba(255, 93, 115, 0.11);
  color: var(--red);
}

.status.partial {
  background: rgba(154, 124, 255, 0.12);
  color: var(--violet);
}

.status.running,
.status.queued {
  background: rgba(255, 190, 92, 0.11);
  color: var(--amber);
}

.job-body {
  min-width: 0;
  max-width: 100%;
  padding: 0;
}

.prompt-preview {
  color: var(--text-soft);
  line-height: 1.45;
  margin: 0 0 12px;
  max-height: 68px;
  overflow: hidden;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 13px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 14px;
}

.meta-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.generation-details {
  margin-top: 16px;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.generation-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
}

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

.generation-details summary::marker {
  content: "";
}

.generation-details summary::before {
  content: "›";
  color: var(--cyan);
  font-size: 18px;
  font-weight: 320;
  line-height: 1;
  transform: translateY(-1px);
  transition: transform 160ms ease;
}

.generation-details[open] summary::before {
  transform: rotate(90deg) translateX(-1px);
}

.generation-details summary:hover {
  color: var(--text-soft);
}

.details-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 7px 16px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.details-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.details-row.multiline {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.details-label {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 720;
  line-height: 1.3;
  text-transform: uppercase;
}

.details-value {
  color: var(--text-soft);
  white-space: nowrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: none;
  font-size: 11px;
  line-height: 1.3;
}

.details-row:not(.multiline) .details-label::after {
  content: ":";
}

.details-row.multiline .details-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  white-space: normal;
}

.details-row.multiline .details-value span {
  display: block;
  max-height: 74px;
  overflow: auto;
  padding: 2px 0 2px 8px;
  border-left: 1px solid var(--line);
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.details-value .copy-detail {
  margin: 0;
  border-radius: 6px;
  background: rgba(83, 216, 255, 0.08);
  color: var(--cyan);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 760;
}

.details-value .copy-detail:hover {
  background: rgba(83, 216, 255, 0.14);
}

.empty-state {
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 22px 0;
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--media-tile-width));
  gap: 8px;
  justify-content: start;
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.output-tile {
  width: var(--media-tile-width);
  min-width: 0;
  max-width: 100%;
  border: 0;
  border-radius: 6px;
  background: #050609;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
}

.media-output {
  cursor: zoom-in;
  position: relative;
}

.media-output:hover {
  box-shadow: inset 0 0 0 1px rgba(83, 216, 255, 0.28);
}

.media-output:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.pending-output {
  aspect-ratio: var(--media-aspect, 1 / 1);
  min-height: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  box-shadow: none;
}

.output-tile img,
.output-tile video {
  width: 100%;
  aspect-ratio: var(--media-aspect, 1 / 1);
  object-fit: contain;
  display: block;
  background: #020204;
}

.media-standin {
  width: 100%;
  aspect-ratio: var(--media-aspect, 1 / 1);
  background: #020204;
}

.viewer-video-cache {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.82);
  background: rgba(0, 0, 0, 0.18);
}

.output-link {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: block;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 12px;
  font-weight: 780;
  background: rgba(2, 2, 4, 0.74);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.media-output:hover .output-link,
.media-output:focus-within .output-link {
  opacity: 1;
  transform: translateY(0);
}

.media-output.media-load-error::after {
  content: "Retry";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 820;
  background: rgba(2, 2, 4, 0.76);
}

.media-debug-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 120;
  width: min(660px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(2, 2, 4, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.media-debug-head,
.media-debug-metrics,
.media-debug-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-debug-head {
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.media-debug-head strong {
  margin-right: auto;
  font-size: 12px;
}

.media-debug-head button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
}

.media-debug-head button:hover {
  color: var(--cyan);
  background: rgba(83, 216, 255, 0.1);
}

.media-debug-metrics {
  flex-wrap: wrap;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.media-debug-metrics span {
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
}

.media-debug-list {
  overflow: auto;
  padding: 5px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.media-debug-row {
  min-width: 0;
  padding: 5px 12px;
  color: var(--muted);
  font-size: 11px;
}

.media-debug-row span,
.media-debug-row strong,
.media-debug-row em {
  min-width: 0;
}

.media-debug-row strong {
  color: var(--text-soft);
  white-space: nowrap;
}

.media-debug-row em {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.media-debug-row.network > span:first-child {
  color: var(--amber);
}

.media-debug-row.cache > span:first-child {
  color: var(--green);
}

.media-debug-row.browser-cache > span:first-child {
  color: var(--violet);
}

.media-debug-row.timing-limited > span:first-child {
  color: var(--muted);
}

.media-debug-row.revalidated > span:first-child,
.media-debug-row.element > span:first-child {
  color: var(--cyan);
}

.media-debug-row.hydrate > span:first-child {
  color: var(--violet);
}

.media-debug-row.video-event > span:first-child {
  color: var(--green);
}

.jobs-sentinel {
  width: 100%;
  height: 1px;
}

.error-text {
  color: var(--red);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 14px;
}

.hidden {
  display: none;
}

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(18px);
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-out;
}

.viewer-shell {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 18px;
  pointer-events: none;
}

.viewer-toolbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: auto;
}

.viewer-title {
  font-weight: 820;
  color: var(--text);
  max-width: min(760px, 62vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-counter {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer-download,
.viewer-button,
.viewer-nav {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 8, 11, 0.82);
  color: var(--text);
  text-decoration: none;
}

.viewer-download {
  padding: 10px 14px;
  color: var(--cyan);
  font-weight: 760;
}

.viewer-button {
  width: 42px;
  height: 42px;
  font-size: 28px;
  line-height: 1;
}

.viewer-stage {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: auto;
}

.viewer-stage img,
.viewer-stage video {
  max-width: calc(100vw - 76px);
  max-height: calc(100vh - 112px);
  object-fit: contain;
  border-radius: 6px;
  background: #020204;
  box-shadow: var(--shadow);
}

.viewer-stage img {
  cursor: zoom-in;
}

.viewer-stage.zoomed {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  padding: 18px;
}

.viewer-stage.zoomed img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 52px;
  height: 72px;
  transform: translateY(-50%);
  font-size: 54px;
  line-height: 1;
  pointer-events: auto;
}

.viewer-nav.previous {
  left: 18px;
}

.viewer-nav.next {
  right: 18px;
}

.viewer-nav:hover,
.viewer-button:hover,
.viewer-download:hover {
  border-color: rgba(83, 216, 255, 0.32);
  background: rgba(10, 11, 15, 0.96);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050609;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--cyan);
  color: #020204;
  font-weight: 850;
  margin-bottom: 20px;
}

.login-panel h1 {
  margin: 0;
}

.login-form {
  margin-top: 24px;
}

.error-banner {
  margin-top: 18px;
  padding: 12px;
  border-left: 2px solid var(--red);
  background: rgba(255, 93, 115, 0.08);
  color: var(--red);
}

@media (max-width: 1180px) {
  .workspace {
    width: 100%;
    padding: 24px 22px 36px;
  }

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

@media (max-width: 920px) {
  .topbar {
    padding: 0 18px;
  }

  .workspace {
    display: block;
    padding: 22px 18px 34px;
    overflow-x: visible;
  }

  .split-resizer {
    display: none;
  }

  .tool-pane {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .results-pane {
    padding-left: 0;
    margin-top: 28px;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 14px 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    padding: 18px 14px 28px;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .results-header,
  .job-head {
    flex-direction: column;
  }

  .job-head-actions {
    justify-content: flex-start;
  }

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

  .output-tile {
    width: 100%;
  }

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

  .details-label {
    padding: 10px 0 0;
  }

  .viewer-title {
    max-width: 48vw;
  }

  .viewer-download {
    display: none;
  }
}
