:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: #0d1b2d;
  --panel-2: #10243a;
  --panel-glass: rgba(13, 27, 45, 0.82);
  --panel-soft: rgba(8, 17, 31, 0.66);
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(148, 163, 184, 0.32);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --green: #22c55e;
  --blue: #38bdf8;
  --gold: #d6b36a;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

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

body {
  background: linear-gradient(135deg, #07111f 0%, #0c1424 44%, #050a12 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 460px);
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 45, 0.82);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  padding: 34px;
  backdrop-filter: blur(18px);
}

.login-mark {
  display: flex;
  width: 84px;
  height: 44px;
  align-items: end;
  gap: 7px;
  margin-bottom: 26px;
}

.login-mark span {
  display: block;
  width: 20px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--green), #0ea5e9);
}

.login-mark span:nth-child(1) {
  height: 30px;
}

.login-mark span:nth-child(2) {
  height: 44px;
}

.login-mark span:nth-child(3) {
  height: 22px;
}

.login-mark.compact {
  width: 58px;
  height: 34px;
  align-items: end;
  gap: 5px;
  margin: 0;
}

.login-mark.compact span {
  width: 14px;
  border-radius: 5px;
}

.login-mark.compact span:nth-child(1) {
  height: 23px;
}

.login-mark.compact span:nth-child(2) {
  height: 34px;
}

.login-mark.compact span:nth-child(3) {
  height: 18px;
}

.login-kicker,
.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-panel h1,
.topbar h1 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.login-copy {
  margin: 12px 0 28px;
  color: var(--muted);
  line-height: 1.65;
}

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

.login-form label:not(.checkbox-row) {
  display: grid;
  gap: 7px;
}

.login-form label > span {
  color: var(--muted);
  font-size: 13px;
}

.login-form input:not([type="checkbox"]) {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 17, 31, 0.86);
  color: var(--text);
  outline: none;
  padding: 0 14px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.login-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #04130a;
  font-weight: 750;
  transition:
    transform 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #4ade80;
}

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

.app-screen {
  overflow: hidden;
}

.workbench {
  display: grid;
  height: 100%;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 16px;
}

.topbar {
  display: flex;
  min-height: 86px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding: 18px 20px;
  backdrop-filter: blur(18px);
}

.topbar-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.topbar h1 {
  font-size: clamp(19px, 2vw, 24px);
}

.topbar-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: end;
}

.assistant-figure {
  --look-x: 0px;
  --look-y: 0px;
  --tilt: 0deg;
  display: grid;
  width: 48px;
  height: 54px;
  place-items: center;
  margin-right: 6px;
  transform: rotate(var(--tilt));
  transform-origin: 50% 72%;
  transition: transform 180ms ease;
}

.assistant-head {
  position: relative;
  z-index: 1;
  width: 38px;
  height: 34px;
  border: 1px solid rgba(187, 247, 208, 0.3);
  border-radius: 16px 16px 14px 14px;
  background:
    radial-gradient(circle at 28% 28%, rgba(255, 255, 255, 0.22), transparent 20%),
    linear-gradient(180deg, #22c55e, #0ea5e9);
  box-shadow:
    0 10px 26px rgba(34, 197, 94, 0.18),
    inset 0 -8px 14px rgba(2, 6, 23, 0.18);
}

.assistant-head::before {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 2px;
  height: 8px;
  border-radius: 999px;
  background: #86efac;
  content: "";
  transform: translateX(-50%);
}

.assistant-head::after {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #bbf7d0;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
  content: "";
  transform: translateX(-50%);
}

.assistant-eye {
  position: absolute;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #04130a;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
  transform: translate(var(--look-x), var(--look-y));
  transition: transform 120ms ease-out;
}

.assistant-eye.left {
  left: 10px;
}

.assistant-eye.right {
  right: 10px;
}

.assistant-body {
  width: 34px;
  height: 18px;
  margin-top: -7px;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 10px 10px 14px 14px;
  background: rgba(8, 17, 31, 0.72);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

.topbar-state span {
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.09);
  color: #bbf7d0;
  font-size: 12px;
  font-weight: 750;
  padding: 7px 11px;
}

.main-grid {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr);
  gap: 14px;
}

.terminal-pane,
.ingest-pane,
.preview-pane,
.queue-pane,
.asset-pane,
.model-strip-pane {
  display: grid;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-glass);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.terminal-pane {
  border-color: rgba(34, 197, 94, 0.2);
}

.terminal-pane {
  grid-template-rows: auto 1fr;
}

.side-rail {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(190px, 1fr) minmax(180px, 1.4fr) auto;
  grid-template-areas:
    "ingest  ingest"
    "preview queue"
    "library library"
    "models  models";
  gap: 12px;
}

.ingest-pane {
  grid-area: ingest;
}

.preview-pane {
  grid-area: preview;
}

.queue-pane {
  grid-area: queue;
}

.asset-pane {
  grid-area: library;
}

.model-strip-pane {
  grid-area: models;
}

.ingest-pane,
.preview-pane,
.queue-pane {
  grid-template-rows: auto 1fr;
}

.asset-pane {
  grid-template-rows: auto auto 1fr;
}

.model-strip-pane {
  grid-template-rows: auto auto;
}

.pane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 17, 31, 0.2);
  padding: 13px 15px;
}

.pane-title.compact {
  padding-block: 10px;
}

.pane-title span {
  font-size: 14px;
  font-weight: 750;
}

.pane-title small {
  color: var(--muted);
  font-size: 12px;
}

#terminal {
  min-height: 0;
  background: #08111f;
  padding: 12px;
}

.xterm {
  height: 100%;
}

.model-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-width: 0;
  gap: 3px 8px;
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 8px 10px;
}

.model-card-head {
  grid-column: 1;
}

.model-card-body {
  grid-column: 1 / -1;
}

.model-card-foot {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

.model-card.muted {
  border-color: var(--line);
  opacity: 0.72;
}

.model-card-head {
  display: grid;
  gap: 3px;
}

.model-card-head span {
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.model-card-head strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-card-body {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.model-card-body code,
.model-card-body small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-card-body code {
  color: #d9f99d;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
}

.model-card-body small {
  color: var(--muted);
  display: none;
  font-size: 10px;
}

.model-card-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted-2);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.13);
}

.media-preview {
  display: grid;
  min-height: 0;
  align-content: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(8, 17, 31, 0.82), rgba(8, 17, 31, 0.58));
  padding: 14px;
}

.media-preview.empty {
  place-items: center;
  color: var(--muted-2);
  font-size: 14px;
}

.media-preview img,
.media-preview video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  object-fit: contain;
  background: #020617;
}

.file-preview {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 190px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.62);
  color: inherit;
  padding: 20px;
  text-align: center;
  text-decoration: none;
}

.file-preview:hover,
.file-preview:focus-visible {
  border-color: rgba(34, 197, 94, 0.35);
  outline: none;
}

.file-preview-icon {
  display: grid;
  min-width: 58px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.1);
  color: #bbf7d0;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.file-preview strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview small {
  color: var(--muted);
}

.queue-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.queue-list.empty,
.media-list.empty {
  place-items: center;
  color: var(--muted-2);
  font-size: 13px;
}

.queue-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: inherit;
  padding: 9px 10px;
  text-align: left;
}

.queue-item:hover,
.queue-item:focus-visible {
  border-color: var(--line-strong);
  outline: none;
  background: rgba(30, 41, 59, 0.78);
}

.queue-main {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.queue-main strong,
.queue-main small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-main strong {
  font-size: 13px;
}

.queue-main small,
.queue-time {
  color: var(--muted);
  font-size: 11px;
}

.media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.media-meta strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start;
  gap: 9px;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

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

.upload-zone {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 10px;
  min-height: 56px;
  border: 1px dashed rgba(34, 197, 94, 0.4);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(14, 165, 233, 0.08)),
    rgba(8, 17, 31, 0.54);
  color: inherit;
  cursor: pointer;
  padding: 14px;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone.dragging,
.upload-zone:focus-within,
.upload-zone:hover {
  border-color: rgba(34, 197, 94, 0.72);
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 0.22), rgba(14, 165, 233, 0.12)),
    rgba(8, 17, 31, 0.62);
  outline: none;
}

.upload-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(187, 247, 208, 0.34);
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
  font-size: 24px;
  font-weight: 500;
}

.upload-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.upload-copy strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.upload-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.asset-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
}

.asset-tab {
  flex: 0 0 auto;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(8, 17, 31, 0.55);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 0 12px;
}

.asset-tab:hover,
.asset-tab:focus-visible,
.asset-tab.active {
  border-color: rgba(34, 197, 94, 0.35);
  outline: none;
  background: rgba(34, 197, 94, 0.12);
  color: var(--text);
}

.media-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: inherit;
  padding: 8px;
  text-align: left;
}

.media-item:hover,
.media-item:focus-visible {
  border-color: var(--line-strong);
  outline: none;
  background: rgba(30, 41, 59, 0.84);
}

.thumb {
  position: relative;
  display: block;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 6px;
  background: #020617;
}

.thumb img,
.thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item:hover .thumb,
.media-item:focus-visible .thumb {
  border-color: rgba(34, 197, 94, 0.45);
}

.hover-zoom {
  position: fixed;
  z-index: 50;
  display: block;
  width: 300px;
  max-width: 44vw;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.92);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
  padding: 8px;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.hover-zoom[hidden] {
  display: none;
}

.hover-zoom img,
.hover-zoom video {
  display: block;
  width: 100%;
  max-height: 60vh;
  border-radius: 6px;
  object-fit: contain;
  background: #020617;
}

.hover-zoom small {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-thumb {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #bbf7d0;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
}

.file-info {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 4px;
}

.file-info strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.09);
  color: #cbd5e1;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
}

.source-pill.generated {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

.source-pill.uploaded {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.11);
  color: #bae6fd;
}

@media (max-width: 900px) {
  .app-screen {
    overflow: auto;
  }

  .workbench {
    min-height: 100%;
  }

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

  .topbar-state {
    justify-content: start;
  }

  .main-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 52vh) minmax(620px, 1fr);
  }

  .side-rail {
    min-height: 780px;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(240px, 30%) minmax(120px, 16%) minmax(0, 1fr) auto;
    grid-template-areas:
      "ingest"
      "preview"
      "queue"
      "library"
      "models";
  }
}

@media (max-width: 560px) {
  .workbench {
    padding: 10px;
  }

  .topbar {
    min-height: auto;
    padding: 16px;
  }

  .topbar-brand {
    align-items: start;
  }

  .login-mark.compact {
    display: none;
  }

  .assistant-figure {
    width: 42px;
    height: 48px;
    margin-right: 2px;
  }

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

  .login-panel {
    padding: 26px;
  }
}

@media (hover: none) {
  .hover-zoom {
    display: none !important;
  }
}

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

  .assistant-figure,
  .assistant-eye {
    transform: none !important;
  }
}
