:root {
  color-scheme: light;
  --bg: #edf2f8;
  --bg-2: #e4ebf4;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: rgba(255, 255, 255, 0.98);
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #61708a;
  --accent: #1497db;
  --accent-2: #0f6fd8;
  --success: #13af6f;
  --warning: #dd9a24;
  --danger: #e05576;
  --shadow: 0 24px 64px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 26px rgba(15, 23, 42, 0.08);
  --input: rgba(245, 248, 252, 0.96);
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050914;
  --bg-2: #0b1323;
  --panel: rgba(8, 14, 28, 0.82);
  --panel-solid: rgba(12, 18, 34, 0.98);
  --border: rgba(148, 163, 184, 0.16);
  --text: #eef4ff;
  --muted: #8da0be;
  --accent: #59c8ff;
  --accent-2: #3797ff;
  --success: #31d28e;
  --warning: #ffb74b;
  --danger: #ff7190;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.28);
  --input: rgba(4, 10, 20, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(89, 200, 255, 0.12), transparent 28%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0.84), transparent 92%);
  opacity: 0.16;
  pointer-events: none;
}

.aurora {
  position: fixed;
  inset: -18%;
  background:
    radial-gradient(circle at 18% 22%, rgba(89, 200, 255, 0.16), transparent 20%),
    radial-gradient(circle at 76% 16%, rgba(55, 151, 255, 0.12), transparent 18%);
  filter: blur(34px);
  pointer-events: none;
}

.app-shell,
.login-shell {
  position: relative;
  z-index: 1;
}

.app-shell {
  width: calc(100vw - 18px);
  max-width: 1720px;
  margin: 9px auto 18px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar-mini,
.topbar-actions,
.mini-stats,
.app-layout,
.tab-list,
.sidebar-tools,
.tab-button,
.composer-toolbar,
.toolbar-left,
.toolbar-right,
.panel-head,
.history-grid,
.detail-grid,
.detail-item-grid,
.job-meta,
.detail-metadata,
.preview-body,
.preview-meta,
.preview-actions,
.brand-lockup {
  display: flex;
}

.topbar-mini,
.sidebar,
.workspace-panel,
.history-panel,
.detail-panel,
.login-card {
  padding: 18px;
}

.topbar-mini {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

.topbar-actions {
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 7px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--accent);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.03;
  font-family: "Eurostile", "Space Grotesk", sans-serif;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
}

h2 {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

h3 {
  font-size: 1.05rem;
}

.mini-stats,
.toolbar-left,
.toolbar-right,
.job-meta,
.detail-metadata,
.preview-meta,
.preview-actions {
  gap: 10px;
}

.mini-stats,
.toolbar-left,
.toolbar-right,
.detail-metadata,
.preview-meta {
  flex-wrap: wrap;
}

.mini-pill,
.checkbox-pill,
.meta-pill,
.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.84rem;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.primary-button,
.secondary-button,
.ghost-button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 11px 16px;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover,
.preview-card:hover,
.job-card:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-soft);
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

.ghost-button {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: default;
  opacity: 0.6;
  transform: none;
}

.security-banner {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-color: rgba(255, 183, 75, 0.28);
  background: linear-gradient(90deg, rgba(255, 183, 75, 0.12), rgba(224, 85, 118, 0.08));
}

.hidden {
  display: none !important;
}

.app-layout {
  align-items: flex-start;
  gap: 12px;
}

.sidebar {
  width: 270px;
  position: sticky;
  top: 10px;
}

.tab-list {
  flex-direction: column;
  gap: 10px;
}

.tab-button {
  width: 100%;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 15px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.tab-button.active {
  border-color: rgba(89, 200, 255, 0.4);
  background: linear-gradient(135deg, rgba(89, 200, 255, 0.14), rgba(55, 151, 255, 0.08));
}

.tab-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.tab-icon svg {
  width: 20px;
  height: 20px;
}

.tab-button strong,
.tab-button small {
  display: block;
}

.tab-button small {
  margin-top: 4px;
  color: var(--muted);
}

.status-line {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.55;
}

.sidebar-tools {
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.tool-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.tool-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.tool-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.status-line[data-tone="warning"] {
  color: var(--warning);
}

.status-line[data-tone="error"] {
  color: var(--danger);
}

.status-line[data-tone="success"] {
  color: var(--success);
}

.workspace {
  flex: 1;
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.workspace-panel {
  display: grid;
  gap: 18px;
}

.panel-copy {
  max-width: 70ch;
}

.section-copy,
.field span,
.form-note,
.job-card p,
.detail-grid dd,
.detail-item p,
.login-copy {
  color: var(--muted);
}

.section-copy {
  margin: 12px 0 0;
  line-height: 1.65;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.88rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--input);
  color: var(--text);
  padding: 14px 15px;
  resize: vertical;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
textarea:focus {
  border-color: rgba(89, 200, 255, 0.44);
  box-shadow: 0 0 0 4px rgba(89, 200, 255, 0.12);
}

.form-actions,
.composer-toolbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.form-note {
  margin: 0;
}

.checkbox-pill input {
  accent-color: var(--accent);
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.queue-head .eyebrow {
  margin: 0;
}

.preview-grid {
  display: grid;
  gap: 12px;
}

.preview-card,
.job-card,
.detail-hero,
.detail-item {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

.preview-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  overflow: hidden;
}

.preview-thumb {
  min-height: 92px;
  background: linear-gradient(135deg, rgba(89, 200, 255, 0.16), rgba(55, 151, 255, 0.08));
}

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

.preview-body {
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  min-width: 0;
}

.preview-title {
  font-size: 0.98rem;
  line-height: 1.32;
}

.preview-actions {
  justify-content: space-between;
  align-items: center;
}

.link-button {
  color: var(--accent);
  text-decoration: none;
}

.remove-link {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--danger);
}

.history-grid {
  align-items: flex-start;
  gap: 12px;
}

.history-panel {
  flex: 0 0 360px;
}

.detail-panel {
  flex: 1;
  min-width: 0;
}

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

.jobs-list,
.detail-items {
  display: grid;
  gap: 12px;
}

.job-card {
  width: 100%;
  text-align: left;
  padding: 15px;
  color: var(--text);
}

.job-card-grid {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  align-items: flex-start;
}

.job-card-thumb {
  width: 112px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(89, 200, 255, 0.16), rgba(55, 151, 255, 0.08));
}

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

.job-card-thumb.fallback {
  display: grid;
  place-items: center;
  padding: 10px;
}

.job-card-thumb.fallback span {
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.job-card-copy {
  min-width: 0;
}

.job-card.active {
  border-color: rgba(89, 200, 255, 0.4);
  background: linear-gradient(135deg, rgba(89, 200, 255, 0.12), rgba(55, 151, 255, 0.06));
}

.job-card h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.job-card p,
.detail-item p {
  margin: 0;
  line-height: 1.55;
}

.meta-pill {
  font-size: 0.8rem;
  color: var(--muted);
}

.status-pill {
  font-size: 0.78rem;
}

.status-pill.queued {
  color: var(--warning);
}

.status-pill.running {
  color: var(--accent);
}

.status-pill.completed {
  color: var(--success);
}

.status-pill.completed_with_errors,
.status-pill.failed {
  color: var(--danger);
}

.job-detail {
  display: grid;
  gap: 14px;
}

.detail-hero,
.detail-item {
  padding: 16px;
}

.detail-item-grid {
  gap: 14px;
  align-items: flex-start;
}

.detail-item-copy {
  min-width: 0;
  flex: 1;
}

.detail-thumb {
  width: 148px;
  min-width: 148px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(89, 200, 255, 0.16), rgba(55, 151, 255, 0.08));
}

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

.detail-grid {
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 14px;
}

.detail-grid > div {
  min-width: 180px;
  flex: 1 1 220px;
}

.detail-grid dt {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.detail-grid dd {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.brand-lockup {
  align-items: center;
  gap: 16px;
}

.brand-lockup.compact {
  align-items: flex-start;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.login-card {
  width: min(480px, calc(100vw - 24px));
}

.login-copy {
  margin: 18px 0;
  line-height: 1.65;
}

.form-error {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(224, 85, 118, 0.92);
  color: white;
}

@media (max-width: 1040px) {
  .app-layout,
  .history-grid {
    display: grid;
  }

  .sidebar {
    width: auto;
    position: static;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: calc(100vw - 10px);
    margin: 5px auto 12px;
  }

  .topbar-mini,
  .sidebar,
  .workspace-panel,
  .history-panel,
  .detail-panel {
    padding: 14px;
  }

  .topbar-mini,
  .topbar-actions,
  .form-actions,
  .composer-toolbar,
  .toolbar-left,
  .toolbar-right,
  .detail-item-grid {
    display: grid;
  }

  .topbar-actions {
    justify-items: start;
  }

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

  .preview-card {
    grid-template-columns: 110px 1fr;
  }

  .preview-thumb {
    min-height: 76px;
  }

  .job-card-grid,
  .detail-item-grid {
    grid-template-columns: 1fr;
  }

  .job-card-thumb {
    width: 100%;
  }

  .detail-thumb {
    width: 100%;
    min-width: 0;
    max-width: 220px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
