:root {
  color-scheme: dark;
  --bg: #08090d;
  --surface: #111319;
  --surface-raised: #171a22;
  --surface-soft: #1d2029;
  --border: #292d38;
  --border-bright: #3b4150;
  --text: #f4f5f7;
  --muted: #9ba2b1;
  --faint: #6f7685;
  --accent: #dfff52;
  --accent-strong: #c8f02e;
  --accent-text: #121600;
  --danger: #ff6d7a;
  --danger-soft: rgba(255, 109, 122, 0.12);
  --success: #69e6ad;
  --warning: #ffc65c;
  --radius-large: 22px;
  --radius-medium: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(203, 255, 51, 0.075), transparent 24rem),
    radial-gradient(circle at 90% 35%, rgba(105, 143, 255, 0.055), transparent 28rem),
    var(--bg);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
}

.noscript {
  padding: 12px;
  color: #1a1200;
  text-align: center;
  background: var(--warning);
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 48px 0;
}

.login-card {
  width: min(430px, 100%);
  padding: 42px;
  background: linear-gradient(155deg, rgba(28, 31, 39, 0.97), rgba(14, 16, 21, 0.98));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.brand-lockup,
.topbar-brand,
.topbar-actions,
.connection-pill,
.serving-actions,
.label-row,
.card-heading,
.result-heading,
.prompt-meta,
footer {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 11px;
  margin-bottom: 44px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  color: var(--accent-text);
  font-weight: 900;
  line-height: 1;
  background: var(--accent);
  border-radius: 10px;
  place-items: center;
  transform: rotate(-4deg);
}

.brand-mark-small {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand-name {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.eyebrow,
.section-kicker {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

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

h1 {
  margin-bottom: 11px;
  font-size: clamp(32px, 5vw, 48px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.login-card h1 {
  font-size: 36px;
}

.login-copy,
.page-heading p,
.status-description {
  color: var(--muted);
}

.login-copy {
  margin-bottom: 32px;
  line-height: 1.55;
}

form label,
.field > label,
.label-row label {
  display: block;
  margin-bottom: 9px;
  color: #d8dbe2;
  font-size: 13px;
  font-weight: 680;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input,
select {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 178px;
  padding: 14px;
  line-height: 1.55;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-bright);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(223, 255, 82, 0.72);
  box-shadow: 0 0 0 3px rgba(223, 255, 82, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: #626977;
}

.login-card input {
  margin-bottom: 20px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  color: #727987;
  cursor: not-allowed;
  background: #20232b;
  border-color: #2b2f38;
}

.button-primary {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button-secondary,
.button-ghost {
  background: var(--surface-soft);
  border-color: var(--border-bright);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  background: #292d38;
}

.button-danger-quiet {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(255, 109, 122, 0.25);
}

.button-danger-quiet:hover:not(:disabled) {
  background: rgba(255, 109, 122, 0.18);
}

.button-wide {
  width: 100%;
}

.button-small {
  min-height: 36px;
  padding: 0 13px;
  font-size: 12px;
}

.form-error,
.task-error {
  min-height: 20px;
  margin: 7px 0 10px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.console-view {
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 54px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.topbar-brand {
  gap: 11px;
}

.topbar-brand div {
  display: grid;
  gap: 2px;
}

.topbar-brand strong {
  font-size: 14px;
}

.topbar-brand span:last-child {
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.topbar-actions {
  gap: 12px;
}

.connection-pill {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  background: var(--warning);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 198, 92, 0.08);
}

.connection-dot.connected {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(105, 230, 173, 0.08);
}

.connection-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 109, 122, 0.08);
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.page-heading p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  line-height: 1.6;
}

.status-badge,
.task-status,
.resolution-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 11px;
  white-space: nowrap;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-neutral,
.task-status,
.resolution-chip {
  color: #c7cbd4;
  background: #20232b;
  border: 1px solid #30343e;
}

.status-ready {
  color: var(--success);
  background: rgba(105, 230, 173, 0.1);
  border: 1px solid rgba(105, 230, 173, 0.24);
}

.status-busy,
.task-running {
  color: var(--warning);
  background: rgba(255, 198, 92, 0.1);
  border: 1px solid rgba(255, 198, 92, 0.24);
}

.status-error,
.task-failed {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(255, 109, 122, 0.24);
}

.task-succeeded {
  color: var(--success);
  background: rgba(105, 230, 173, 0.1);
  border: 1px solid rgba(105, 230, 173, 0.24);
}

.notice {
  margin-bottom: 20px;
  padding: 13px 15px;
  color: #e6ddc5;
  font-size: 13px;
  line-height: 1.45;
  background: rgba(255, 198, 92, 0.09);
  border: 1px solid rgba(255, 198, 92, 0.2);
  border-radius: 12px;
}

.status-panel,
.card {
  background: linear-gradient(145deg, rgba(21, 24, 31, 0.96), rgba(15, 17, 22, 0.97));
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}

.status-panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.status-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 26px;
}

.status-description {
  margin: 8px 0 0;
  font-size: 13px;
}

.serving-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  border-top: 1px solid var(--border);
}

.metric {
  min-width: 0;
  padding: 18px 26px;
  border-right: 1px solid var(--border);
}

.metric:last-child {
  border-right: 0;
}

.metric dt {
  margin-bottom: 7px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}

.metric dd {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 18px;
}

.card {
  padding: 26px;
}

.card-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.generation-card form {
  display: grid;
}

.prompt-meta {
  justify-content: space-between;
  gap: 12px;
  margin: 8px 2px 21px;
  color: var(--faint);
  font-size: 11px;
}

.prompt-meta span:last-child {
  white-space: nowrap;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin-bottom: 18px;
}

.field {
  min-width: 0;
}

.generation-card .field:not(.field-grid .field) {
  margin-bottom: 10px;
}

.label-row {
  justify-content: space-between;
}

.label-row label {
  margin-bottom: 9px;
}

.optional {
  margin-left: 4px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 500;
}

.text-button {
  padding: 2px;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.task-card {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.task-card .card-heading {
  margin-bottom: 20px;
}

.empty-state {
  display: grid;
  flex: 1;
  min-height: 300px;
  align-content: center;
  justify-items: center;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  margin: 14px 0 7px;
  color: #d9dce3;
  font-size: 14px;
}

.empty-state span:last-child {
  max-width: 260px;
  font-size: 12px;
  line-height: 1.5;
}

.empty-symbol {
  display: grid;
  width: 50px;
  height: 50px;
  color: var(--accent);
  background: rgba(223, 255, 82, 0.08);
  border: 1px solid rgba(223, 255, 82, 0.16);
  border-radius: 50%;
  place-items: center;
}

.task-progress {
  height: 4px;
  margin: 10px 0 25px;
  overflow: hidden;
  background: #262a34;
  border-radius: 999px;
}

.task-progress span {
  display: block;
  width: 35%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.task-progress span.active {
  animation: task-pulse 1.8s ease-in-out infinite alternate;
}

@keyframes task-pulse {
  from {
    transform: translateX(-95%);
  }
  to {
    transform: translateX(285%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.task-stage {
  margin-bottom: 22px;
  color: #dedfe4;
  font-size: 15px;
  font-weight: 680;
}

.task-metadata {
  display: grid;
  gap: 0;
  margin: 0 0 20px;
}

.task-metadata div {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.task-metadata dt {
  color: var(--faint);
  font-size: 11px;
}

.task-metadata dd {
  margin: 0;
  overflow: hidden;
  color: #ced2da;
  font-size: 12px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card,
.recent-card {
  margin-top: 18px;
}

.result-heading {
  margin-bottom: 18px;
}

.video-frame {
  overflow: hidden;
  background: #030405;
  border: 1px solid #282c35;
  border-radius: var(--radius-medium);
}

.video-frame video {
  display: block;
  width: 100%;
  max-height: min(72vh, 760px);
  background: #000;
}

.history-note {
  color: var(--faint);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  color: var(--faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  color: #c9cdd5;
  font-size: 12px;
}

td:last-child,
th:last-child {
  width: 1%;
  text-align: right;
}

.history-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.history-status::before {
  width: 7px;
  height: 7px;
  content: "";
  background: var(--faint);
  border-radius: 50%;
}

.history-status.status-succeeded::before {
  background: var(--success);
}

.history-status.status-running::before,
.history-status.status-queued::before {
  background: var(--warning);
}

.history-status.status-failed::before,
.history-status.status-cancelled::before {
  background: var(--danger);
}

.history-open {
  min-height: 32px;
  padding: 0 11px;
  color: #d7dae1;
  font-size: 11px;
  cursor: pointer;
  background: #1f222a;
  border: 1px solid #303540;
  border-radius: 8px;
}

.history-open:hover {
  border-color: var(--border-bright);
}

.history-empty {
  margin: 4px 0 0;
  padding: 38px 10px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

footer {
  justify-content: space-between;
  padding: 24px 4px 0;
  color: #555c69;
  font-size: 10px;
}

.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;
}

@media (max-width: 850px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 24px, 1180px);
  }

  .login-card {
    padding: 30px 22px;
    border-radius: 22px;
  }

  .console-view {
    padding-top: 12px;
  }

  .topbar {
    margin-bottom: 36px;
  }

  .connection-pill {
    display: none;
  }

  .page-heading,
  .status-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading {
    gap: 18px;
  }

  .status-badge {
    align-self: flex-start;
  }

  .status-summary,
  .card {
    padding: 21px;
  }

  .serving-actions {
    justify-content: stretch;
  }

  .serving-actions .button {
    width: 100%;
  }

  .metric {
    padding: 16px 18px;
  }

  .metric dd {
    font-size: 14px;
  }

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

  .prompt-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-heading .button {
    width: 100%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    display: none;
  }

  footer {
    gap: 8px;
    align-items: flex-start;
    flex-direction: column;
  }
}
