:root {
  color-scheme: dark;
  --bg: #0d0f10;
  --surface: #141719;
  --surface-2: #191d1f;
  --surface-3: #222729;
  --line: #303638;
  --line-soft: #252a2c;
  --text: #f4f2ec;
  --muted: #9ca4a5;
  --muted-2: #707879;
  --coral: #ff6b58;
  --coral-strong: #ff4f3a;
  --cyan: #67d5db;
  --lime: #b9e769;
  --amber: #f3bd54;
  --danger: #ff6f76;
  --rail-width: 106px;
  --radius: 6px;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

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

button {
  border: 0;
}

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

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.side-rail {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--rail-width);
  flex-direction: column;
  align-items: stretch;
  border-right: 1px solid var(--line-soft);
  background: #101213;
}

.brand-mark {
  display: flex;
  height: 102px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  text-decoration: none;
}

.brand-glyph {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #596063;
  background: #f0eee8;
  color: #111315;
  font-size: 18px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.brand-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-name strong {
  color: var(--coral);
}

.rail-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 16px 10px;
}

.rail-button {
  display: flex;
  min-height: 62px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.rail-button svg {
  width: 20px;
  height: 20px;
}

.rail-button span {
  font-size: 11px;
  line-height: 1;
}

.rail-button:hover,
.rail-button.active {
  border-left-color: var(--coral);
  background: #1a1d1f;
  color: var(--text);
}

.rail-account {
  margin: 10px;
}

.main-workspace {
  min-height: 100vh;
  margin-left: var(--rail-width);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 3.2%, 48px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(13, 15, 16, 0.94);
  backdrop-filter: blur(14px);
}

.topbar h1,
.panel-heading h2,
.section-heading h2,
.drawer-panel h2 {
  margin: 3px 0 0;
  font-size: 21px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.topbar-status,
.status-pill,
.account-chip {
  display: flex;
  align-items: center;
}

.topbar-status {
  gap: 9px;
}

.status-pill,
.account-chip,
.private-badge {
  height: 36px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 0 11px;
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(243, 189, 84, 0.1);
}

.status-pill.online .status-dot {
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(185, 231, 105, 0.1);
}

.status-pill.busy .status-dot {
  background: var(--cyan);
  animation: status-pulse 1.5s ease-in-out infinite;
}

@keyframes status-pulse {
  50% { opacity: 0.45; }
}

.account-avatar {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  color: #151515;
  font-size: 11px;
  font-weight: 900;
}

.app-view {
  min-height: calc(100vh - 82px);
  padding: 28px clamp(20px, 3.2%, 48px) 52px;
}

.create-grid {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(440px, 1fr);
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.creator-panel {
  min-width: 0;
  padding: 27px;
  border-right: 1px solid var(--line);
  background: #151819;
}

.panel-heading,
.section-heading,
.drawer-panel header,
.quality-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.private-badge {
  height: 29px;
  color: var(--lime);
}

.private-badge svg {
  width: 14px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 25px 0 22px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1112;
}

.mode-switch button,
.quality-switch button,
.library-filters button {
  display: flex;
  min-height: 36px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.mode-switch button.active,
.quality-switch button.active,
.library-filters button.active {
  background: var(--surface-3);
  color: var(--text);
}

.mode-switch svg {
  width: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #d5d3cd;
  font-size: 12px;
  font-weight: 700;
}

.prompt-field {
  position: relative;
}

.prompt-field textarea {
  width: 100%;
  min-height: 134px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1112;
  color: var(--text);
  line-height: 1.55;
  padding: 13px 14px 29px;
}

.prompt-field textarea::placeholder,
.search-field input::placeholder {
  color: #62696b;
}

.prompt-field textarea:focus,
.search-field:focus-within {
  border-color: #667175;
}

.character-count {
  position: absolute;
  right: 11px;
  bottom: 9px;
  color: var(--muted-2);
  font-size: 10px;
}

.control-block {
  margin-top: 19px;
}

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

.category-grid button {
  display: flex;
  min-width: 0;
  height: 62px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #111314;
  color: var(--muted);
}

.category-grid button:hover,
.category-grid button.active {
  border-color: #6d7374;
  background: #222628;
  color: var(--text);
}

.category-grid button.active {
  box-shadow: inset 0 -2px var(--coral);
}

.category-grid svg {
  width: 18px;
}

.category-grid span {
  overflow: hidden;
  max-width: 100%;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.style-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-chip {
  display: inline-flex;
  min-height: 32px;
  cursor: pointer;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 9px;
  font-size: 11px;
}

.style-chip:hover,
.style-chip.active {
  border-color: #646c6e;
  background: #202426;
  color: var(--text);
}

.swatch {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.swatch-gothic { background: #d9d4c8; }
.swatch-apocalypse { background: #b95d3e; }
.swatch-cyber { background: #5fcfd5; }
.swatch-handmade { background: #d2a958; }

.quality-row {
  margin-top: 20px;
}

.quality-row .field-label {
  margin: 0 0 3px;
}

.quality-row p {
  margin: 0;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.35;
}

.quality-switch {
  display: grid;
  min-width: 150px;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f1112;
}

.quality-switch button {
  min-height: 31px;
  font-size: 11px;
}

.primary-button {
  display: grid;
  width: 100%;
  min-height: 48px;
  cursor: pointer;
  grid-template-columns: 24px 1fr 24px;
  place-items: center;
  margin-top: 22px;
  border-radius: var(--radius);
  background: var(--coral);
  color: #171717;
  padding: 0 15px;
  font-weight: 900;
  transition: background-color 160ms ease, transform 160ms ease;
}

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

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.primary-button svg {
  width: 18px;
}

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

.upload-zone {
  position: relative;
  min-height: 82px;
  margin-bottom: 18px;
  border: 1px dashed #4a5254;
  border-radius: var(--radius);
  background: #101213;
}

.upload-zone.dragging {
  border-color: var(--cyan);
  background: #142022;
}

.upload-action {
  display: flex;
  width: 100%;
  min-height: 80px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: transparent;
}

.upload-action svg {
  width: 24px;
  color: var(--cyan);
}

.upload-action span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.upload-action small {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 10px;
}

.upload-zone > p {
  margin: -11px 42px 11px;
  overflow: hidden;
  color: var(--lime);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-upload {
  position: absolute;
  top: 8px;
  right: 8px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  cursor: pointer;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(17, 19, 20, 0.8);
  color: var(--text);
}

.icon-button:hover {
  background: #292e30;
}

.icon-button svg {
  width: 16px;
}

.stage-panel {
  position: relative;
  min-width: 0;
  min-height: 620px;
  overflow: hidden;
  background: #101213;
}

.stage-panel > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.stage-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 9, 10, 0.2) 30%, rgba(8, 9, 10, 0.88) 100%);
}

.stage-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-label {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(15, 17, 18, 0.78);
  padding: 0 10px;
  font-size: 10px;
  font-weight: 800;
}

.stage-label svg {
  width: 15px;
  color: var(--cyan);
}

.stage-copy {
  position: absolute;
  right: 28px;
  bottom: 28px;
  left: 28px;
  max-width: 630px;
}

.stage-copy > p {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 10px;
  font-weight: 900;
}

.stage-copy h2 {
  max-width: 580px;
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.stage-progress {
  display: grid;
  grid-template-columns: minmax(130px, 340px) auto;
  align-items: center;
  gap: 13px;
  margin-top: 20px;
}

.progress-track,
.mini-progress,
.table-progress {
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: #353a3c;
}

.progress-track span,
.mini-progress span,
.table-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width 400ms ease;
}

.stage-progress > span {
  color: #d4d5d0;
  font-size: 11px;
}

.recent-section {
  padding-top: 34px;
}

.section-heading {
  margin-bottom: 15px;
}

.text-button {
  display: inline-flex;
  cursor: pointer;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

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

.text-button svg {
  width: 15px;
}

.job-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 10px;
}

.job-card,
.asset-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  padding: 0;
  text-align: left;
}

.job-card {
  cursor: pointer;
}

.job-card:hover,
.asset-card:hover {
  border-color: #4a5355;
}

.job-visual,
.asset-visual {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0b0d0e;
}

.job-visual img,
.asset-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.job-visual img {
  object-fit: contain;
}

.status-tag,
.asset-type {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  background: rgba(12, 14, 15, 0.84);
  color: #d5d6d1;
  padding: 0 7px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-tag.completed { color: var(--lime); }
.status-tag.failed { color: var(--danger); }
.status-tag.running { color: var(--cyan); }

.job-body,
.asset-body {
  padding: 12px;
}

.job-body h3,
.asset-body h3 {
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta,
.asset-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 7px 0 10px;
  color: var(--muted-2);
  font-size: 10px;
}

.empty-state {
  display: grid;
  min-height: 190px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted-2);
  text-align: center;
}

.job-strip > .empty-state,
.asset-grid > .empty-state {
  grid-column: 1 / -1;
}

.empty-state svg {
  width: 28px;
  margin-bottom: 8px;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.search-field {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
}

.search-field svg {
  width: 17px;
  color: var(--muted-2);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.library-filters {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.library-filters button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 11px;
}

.library-count {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.library-count strong {
  color: var(--text);
  font-size: 19px;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 11px;
}

.asset-card {
  cursor: pointer;
}

.asset-body {
  min-height: 81px;
}

.verified-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--lime);
}

.verified-mark svg {
  width: 12px;
}

.queue-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.queue-summary > div {
  display: flex;
  min-height: 92px;
  flex-direction: column;
  justify-content: center;
  padding: 17px 21px;
  border-right: 1px solid var(--line);
}

.queue-summary > div:last-child {
  border-right: 0;
}

.queue-summary span {
  color: var(--muted);
  font-size: 11px;
}

.queue-summary strong {
  margin-top: 5px;
  font-size: 26px;
}

.queue-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.queue-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.queue-table th,
.queue-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.queue-table .status-tag {
  position: static;
}

.progress-track span.p0, .mini-progress span.p0, .table-progress span.p0 { width: 0%; }
.progress-track span.p5, .mini-progress span.p5, .table-progress span.p5 { width: 5%; }
.progress-track span.p10, .mini-progress span.p10, .table-progress span.p10 { width: 10%; }
.progress-track span.p15, .mini-progress span.p15, .table-progress span.p15 { width: 15%; }
.progress-track span.p20, .mini-progress span.p20, .table-progress span.p20 { width: 20%; }
.progress-track span.p25, .mini-progress span.p25, .table-progress span.p25 { width: 25%; }
.progress-track span.p30, .mini-progress span.p30, .table-progress span.p30 { width: 30%; }
.progress-track span.p35, .mini-progress span.p35, .table-progress span.p35 { width: 35%; }
.progress-track span.p40, .mini-progress span.p40, .table-progress span.p40 { width: 40%; }
.progress-track span.p45, .mini-progress span.p45, .table-progress span.p45 { width: 45%; }
.progress-track span.p50, .mini-progress span.p50, .table-progress span.p50 { width: 50%; }
.progress-track span.p55, .mini-progress span.p55, .table-progress span.p55 { width: 55%; }
.progress-track span.p60, .mini-progress span.p60, .table-progress span.p60 { width: 60%; }
.progress-track span.p65, .mini-progress span.p65, .table-progress span.p65 { width: 65%; }
.progress-track span.p70, .mini-progress span.p70, .table-progress span.p70 { width: 70%; }
.progress-track span.p75, .mini-progress span.p75, .table-progress span.p75 { width: 75%; }
.progress-track span.p80, .mini-progress span.p80, .table-progress span.p80 { width: 80%; }
.progress-track span.p85, .mini-progress span.p85, .table-progress span.p85 { width: 85%; }
.progress-track span.p90, .mini-progress span.p90, .table-progress span.p90 { width: 90%; }
.progress-track span.p95, .mini-progress span.p95, .table-progress span.p95 { width: 95%; }
.progress-track span.p100, .mini-progress span.p100, .table-progress span.p100 { width: 100%; }

.queue-table th {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.queue-table td {
  color: #c6c9c7;
  font-size: 12px;
}

.queue-table tbody tr:last-child td {
  border-bottom: 0;
}

.queue-title {
  display: flex;
  max-width: 310px;
  align-items: center;
  gap: 10px;
}

.queue-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 4px;
  object-fit: cover;
  background: #0c0e0f;
}

.queue-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-title small {
  color: var(--muted-2);
}

.table-progress-wrap {
  display: grid;
  width: 135px;
  grid-template-columns: 1fr 32px;
  align-items: center;
  gap: 8px;
}

.table-progress-wrap span {
  color: var(--muted);
  font-size: 10px;
}

.detail-drawer {
  position: fixed;
  z-index: 70;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.detail-drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  cursor: default;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  transition: opacity 180ms ease;
}

.detail-drawer.open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(470px, 94vw);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #121516;
  padding: 24px;
  transform: translateX(100%);
  transition: transform 220ms ease;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.4);
}

.detail-drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  object-fit: contain;
  background: #090b0c;
}

.drawer-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.drawer-status strong {
  color: var(--cyan);
  font-size: 12px;
}

.drawer-description {
  margin: 17px 0;
  color: var(--muted);
  line-height: 1.55;
}

.drawer-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.drawer-facts div {
  min-height: 64px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 11px;
}

.drawer-facts span,
.drawer-facts strong {
  display: block;
}

.drawer-facts span {
  color: var(--muted-2);
  font-size: 9px;
  text-transform: uppercase;
}

.drawer-facts strong {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 19px;
}

.download-button,
.secondary-button {
  display: inline-flex;
  min-height: 42px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 0 15px;
  font-weight: 800;
  text-decoration: none;
}

.download-button {
  background: var(--lime);
  color: #101310;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.danger-button {
  color: var(--danger);
}

.preview-dialog {
  width: min(1100px, 94vw);
  max-width: none;
  height: min(760px, 90vh);
  max-height: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080a0b;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.preview-dialog img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(390px, calc(100vw - 44px));
  min-height: 44px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--lime);
  border-radius: var(--radius);
  background: #1a1e20;
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: var(--danger);
}

/* Login */
.login-page {
  min-height: 100vh;
  overflow: hidden;
  background: #0a0c0d;
}

.login-stage {
  position: relative;
  display: flex;
  min-height: 100vh;
  align-items: flex-end;
  padding: clamp(28px, 5%, 72px);
  isolation: isolate;
}

.login-stage::before {
  position: absolute;
  z-index: -2;
  inset: 0;
  background: url("/ava3d/assets/ava3d-studio-sword.png") center / cover no-repeat;
  content: "";
}

.login-stage::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 10, 11, 0.96) 0%, rgba(8, 10, 11, 0.78) 38%, rgba(8, 10, 11, 0.1) 75%), linear-gradient(0deg, rgba(8, 10, 11, 0.82), transparent 55%);
  content: "";
}

.login-brand {
  position: absolute;
  top: 30px;
  left: clamp(28px, 5%, 72px);
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 17px;
  font-weight: 800;
}

.login-brand strong {
  color: var(--coral);
}

.login-content {
  width: min(430px, 100%);
  padding-bottom: 2vh;
}

.login-content h1 {
  margin: 8px 0 10px;
  font-size: 44px;
  line-height: 1.05;
}

.login-lead {
  max-width: 390px;
  margin: 0 0 27px;
  color: #aeb4b3;
  font-size: 14px;
  line-height: 1.55;
}

.login-form label {
  display: block;
  margin-bottom: 8px;
  color: #d8dad5;
  font-size: 12px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 49px;
  border: 1px solid #3b4244;
  border-radius: var(--radius);
  background: rgba(15, 18, 19, 0.9);
  padding: 0 14px;
}

.login-form .primary-button {
  margin-top: 10px;
}

.login-error {
  min-height: 18px;
  margin: 9px 0 0;
  color: var(--danger);
  font-size: 11px;
}

.approval-state {
  border-left: 2px solid var(--cyan);
  padding: 4px 0 4px 18px;
}

.approval-state h2 {
  margin: 7px 0 8px;
  font-size: 23px;
}

.approval-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.approval-meta {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 18px;
}

.approval-timer {
  min-width: 70px;
  color: var(--lime);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.approval-cancel {
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-footer {
  position: absolute;
  right: clamp(28px, 5%, 72px);
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.54);
  font-size: 10px;
}

.login-footer svg {
  width: 14px;
}

@media (max-width: 1180px) {
  .create-grid {
    grid-template-columns: minmax(330px, 390px) minmax(360px, 1fr);
  }

  .job-strip,
  .asset-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .library-toolbar {
    grid-template-columns: 1fr auto;
  }

  .library-count {
    display: none;
  }
}

@media (max-width: 900px) {
  :root { --rail-width: 82px; }

  .brand-name,
  .rail-button span {
    display: none;
  }

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

  .creator-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage-panel {
    min-height: 500px;
  }

  .job-strip,
  .asset-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .queue-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .queue-summary > div:nth-child(2) {
    border-right: 0;
  }

  .queue-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 660px) {
  :root { --rail-width: 0px; }

  .side-rail {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 66px;
    flex-direction: row;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand-mark {
    display: none;
  }

  .rail-nav {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 4px;
  }

  .rail-button {
    min-height: 56px;
    border-bottom: 2px solid transparent;
    border-left: 0;
  }

  .rail-button span {
    display: block;
  }

  .rail-button:hover,
  .rail-button.active {
    border-bottom-color: var(--coral);
    border-left-color: transparent;
  }

  .rail-account {
    width: 62px;
    margin: 4px;
  }

  .rail-account span {
    display: none;
  }

  .main-workspace {
    margin: 0;
    padding-bottom: 66px;
  }

  .topbar {
    min-height: 70px;
    padding: 12px 15px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .status-pill {
    display: none;
  }

  .account-chip {
    max-width: 145px;
  }

  .account-chip > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-view {
    min-height: calc(100vh - 70px);
    padding: 14px 12px 30px;
  }

  .creator-panel {
    padding: 20px 16px;
  }

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

  .category-grid button {
    height: 54px;
    flex-direction: row;
  }

  .quality-row {
    align-items: flex-end;
  }

  .quality-row p {
    max-width: 150px;
  }

  .quality-switch {
    min-width: 138px;
  }

  .stage-panel {
    min-height: 410px;
  }

  .stage-copy {
    right: 18px;
    bottom: 18px;
    left: 18px;
  }

  .stage-copy h2 {
    font-size: 23px;
  }

  .job-strip,
  .asset-grid {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .job-body,
  .asset-body {
    padding: 9px;
  }

  .library-toolbar {
    grid-template-columns: 1fr;
  }

  .library-filters {
    overflow-x: auto;
  }

  .library-filters button {
    flex: 0 0 auto;
  }

  .queue-summary > div {
    min-height: 74px;
    padding: 12px 15px;
  }

  .queue-summary strong {
    font-size: 22px;
  }

  .drawer-panel {
    width: 100%;
    padding: 19px;
  }

  .toast {
    right: 12px;
    bottom: 78px;
    max-width: calc(100vw - 24px);
  }

  .login-stage {
    align-items: flex-end;
    padding: 92px 22px 74px;
  }

  .login-stage::before {
    background-position: 63% center;
  }

  .login-stage::after {
    background: linear-gradient(0deg, rgba(8, 10, 11, 0.98) 0%, rgba(8, 10, 11, 0.86) 48%, rgba(8, 10, 11, 0.18) 100%);
  }

  .login-brand {
    top: 22px;
    left: 22px;
  }

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

  .login-footer {
    right: 22px;
    bottom: 20px;
  }
}

@media (max-width: 420px) {
  .job-strip,
  .asset-grid {
    grid-template-columns: 1fr;
  }

  .quality-row {
    align-items: stretch;
    flex-direction: column;
  }

  .quality-switch {
    width: 100%;
  }
}

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