:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: #181a1d;
  --panel-2: #202329;
  --line: #30343b;
  --text: #f3f5f7;
  --muted: #a7afb9;
  --soft: #d7dce2;
  --accent: #46d7c8;
  --accent-2: #8f6bff;
  --danger: #ff6b7a;
  --warning: #f4be5e;
  --success: #5fe28f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.guest-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.guest-wrap {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 620px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(70, 215, 200, 0.12), transparent 38%), var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.guest-wrap.setup-wrap {
  width: min(1160px, 100%);
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  align-items: stretch;
  min-height: min(900px, calc(100vh - 48px));
}

.setup-wrap .brand-panel {
  justify-content: flex-start;
  gap: 14px;
  min-width: 0;
  padding: clamp(28px, 4vw, 42px);
}

.setup-wrap .auth-panel {
  align-self: stretch;
  overflow: auto;
  min-width: 0;
  padding: clamp(28px, 4vw, 44px);
}

.setup-wrap .brand-panel h1 {
  max-width: 100%;
  font-size: clamp(36px, 3.8vw, 48px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.setup-wrap .brand-panel p:not(.eyebrow) {
  max-width: 24ch;
  font-size: 16px;
  line-height: 1.45;
}

.setup-wrap .logo-mark {
  width: 56px;
  height: 56px;
}

.brand-panel,
.auth-panel {
  padding: clamp(28px, 5vw, 56px);
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.brand-panel h1 {
  margin: 12px 0 14px;
  font-size: clamp(40px, 7vw, 74px);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.brand-panel p {
  max-width: 520px;
  color: var(--soft);
  font-size: 18px;
}

.auth-panel {
  align-self: center;
  min-width: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #141618;
}

.main-panel {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1,
.content-card h2,
.auth-panel h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
}

.logo-mark {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(70, 215, 200, 0.18);
}

.logo-mark.small {
  width: 38px;
  height: 38px;
}

.logo-mark span {
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 18px solid #081010;
  margin-left: 4px;
}

.logo-mark.small span {
  border-top-width: 8px;
  border-bottom-width: 8px;
  border-left-width: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--panel-2);
}

.guest-logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--panel-2);
  padding: 4px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a,
.ghost-button,
.primary-button,
.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.nav-list a {
  justify-content: flex-start;
  padding: 10px 12px;
  color: var(--muted);
}

.nav-list a:hover,
.nav-list a.active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

.nav-title,
.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

.logout-form {
  margin-top: auto;
}

.full {
  width: 100%;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  padding: 10px 14px;
  color: var(--text);
  background: var(--panel-2);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #07100f;
  border-color: transparent;
  font-weight: 800;
}

.ghost-button:hover,
.icon-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.compact {
  min-height: 36px;
  padding: 8px 11px;
}

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

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 900;
}

.icon::before {
  line-height: 1;
}

.icon.plus::before { content: "+"; }
.icon.search::before { content: "⌕"; }
.icon.grid::before { content: "▦"; }
.icon.clock::before { content: "◷"; }
.icon.user::before { content: "◉"; }
.icon.users::before { content: "◎"; }
.icon.shield::before { content: "⬟"; }
.icon.queue::before { content: "☰"; }
.icon.chart::before { content: "▥"; }
.icon.settings::before { content: "⚙"; }
.icon.pulse::before { content: "∿"; }
.icon.file::before { content: "▤"; }
.icon.logout::before { content: "↳"; }
.icon.login::before { content: "↲"; }
.icon.save::before { content: "✓"; }
.icon.gauge::before { content: "◒"; }
.icon.disk::before { content: "▣"; }
.icon.download::before { content: "↓"; }
.icon.trash::before { content: "×"; }
.icon.filter::before { content: "≡"; }
.icon.film::before { content: "▧"; }
.icon.paint::before { content: "◫"; }
.icon.refresh::before { content: "↻"; }
.icon.help::before { content: "?"; }

.user-chip,
.status {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--soft);
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  font-size: 12px;
  font-weight: 800;
}

.status-done { color: var(--success); }
.status-failed,
.status-expired,
.status-canceled { color: var(--danger); }
.status-pending,
.status-analyzing,
.status-downloading,
.status-converting { color: var(--warning); }

.notice,
.async-message {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.notice.success,
.async-message.success {
  border-color: rgba(95, 226, 143, 0.42);
  color: var(--success);
}

.notice.error,
.async-message.error {
  border-color: rgba(255, 107, 122, 0.42);
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.content-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
}

.metric-card {
  min-height: 142px;
  padding: 18px;
}

.metric-card p,
.metric-card small,
.muted,
small {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 28px;
}

.metric-card.warn {
  border-color: rgba(244, 190, 94, 0.4);
}

.content-card {
  padding: 20px;
}

.content-card.narrow {
  max-width: 560px;
}

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

.conversion-panel .section-heading,
.conversion-panel .notice,
.conversion-panel .async-message,
.conversion-panel > .muted {
  margin-bottom: 0;
}

.split-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.form-stack,
.form-grid,
.url-form,
.filter-grid,
.setup-form {
  display: grid;
  gap: 14px;
}

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

.setup-heading {
  display: grid;
  gap: 8px;
}

.setup-heading h2 {
  margin: 0;
}

.setup-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(32, 35, 41, 0.58);
}

.setup-section h3 {
  margin: 0;
  font-size: 16px;
}

.setup-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.setup-section-head h3,
.setup-section-head p {
  margin: 0;
}

.setup-section-head p {
  margin-top: 6px;
}

.setup-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.setup-checks div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #111316;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: linear-gradient(180deg, transparent, var(--panel) 28%);
}

.media-default-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(70, 215, 200, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: rgba(70, 215, 200, 0.08);
}

.media-default-panel strong {
  display: block;
  margin-bottom: 4px;
}

.media-default-panel p {
  margin: 0;
  color: var(--muted);
}

.media-tool-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.media-tools-advanced {
  display: grid;
  gap: 12px;
}

.media-tools-advanced[hidden] {
  display: none;
}

.appearance-form {
  align-items: start;
}

.appearance-preview {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-2);
}

.appearance-preview-brand,
.appearance-preview-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.appearance-preview-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.appearance-preview-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--panel-2);
}

.appearance-preview-brand strong,
.appearance-preview-card h3 {
  overflow-wrap: anywhere;
}

.appearance-preview-card {
  display: grid;
  gap: 10px;
}

.appearance-preview-card h3,
.appearance-preview-card p {
  margin: 0;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.color-field {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.color-field span {
  grid-column: 1 / -1;
}

.color-field input[type="color"] {
  height: 38px;
  padding: 4px;
}

.color-field code {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 980px) {
  .guest-wrap.setup-wrap {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .setup-wrap .brand-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 26px;
  }

  .setup-wrap .brand-panel h1 {
    margin: 8px 0;
    font-size: clamp(36px, 8vw, 52px);
  }

  .setup-wrap .brand-panel p:not(.eyebrow) {
    max-width: 62ch;
  }

  .setup-wrap .auth-panel {
    overflow: visible;
  }

  .media-default-panel {
    grid-template-columns: 1fr;
  }

  .media-tool-actions {
    justify-content: flex-start;
  }

  .appearance-preview {
    grid-template-columns: 1fr;
  }
}

.form-grid.dense,
.filter-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
}

.url-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111316;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

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

.wide {
  grid-column: 1 / -1;
}

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

.checkline input {
  width: auto;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(260px, 46%) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.preview-visual {
  min-height: 240px;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0d0f;
}

.preview-visual iframe,
.preview-visual img {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: cover;
}

.preview-details {
  display: grid;
  align-content: center;
  gap: 8px;
}

.preview-details h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.preview-details p,
.definition-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.preview-details span,
.definition-list dt {
  color: var(--muted);
}

.definition-list {
  margin: 12px 0 0;
}

.definition-list dd {
  margin: 0;
  text-align: right;
}

.format-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.format-picker {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-2);
}

.format-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
}

.format-choice {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #111316;
}

.format-choice strong {
  overflow-wrap: anywhere;
}

.format-choice small {
  color: var(--muted);
}

.format-choice.is-disabled {
  border-color: rgba(244, 190, 94, 0.48);
}

.format-choice.is-disabled small {
  color: var(--warning);
}

.format-action-row {
  display: flex;
  justify-content: flex-end;
}

.job-progress {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-2);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-head strong,
.progress-detail {
  overflow-wrap: anywhere;
}

.progress-percent {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #0d0f11;
  overflow: hidden;
}

.progress-track span {
  position: relative;
  display: block;
  min-width: 8px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.job-progress.is-active .progress-track span {
  background-image:
    linear-gradient(90deg, var(--accent), var(--accent-2)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.26) 0 8px, transparent 8px 16px);
  background-blend-mode: screen;
  background-size: 100% 100%, 34px 34px;
  animation: progress-stripes 0.8s linear infinite, progress-pulse 1.8s ease-in-out infinite alternate;
}

.progress-detail {
  margin: 10px 0 0;
  color: var(--muted);
}

.progress-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

@keyframes progress-stripes {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 0, 34px 0; }
}

@keyframes progress-pulse {
  from { filter: brightness(0.94); }
  to { filter: brightness(1.14); }
}

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

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 4px;
}

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

.row-details {
  min-width: 240px;
}

.row-details summary {
  cursor: pointer;
  color: var(--accent);
}

.inline-reset {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.empty-state,
.empty-inline {
  display: grid;
  place-items: center;
  min-height: 140px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
}

.empty-state h1,
.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
}

.bar-row,
.check-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.ok { color: var(--success); }
.ko { color: var(--danger); }

.diagnostic-tutorial {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.diagnostic-tutorial[hidden] {
  display: none;
}

.diagnostic-tutorial article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-2);
}

.diagnostic-tutorial h3,
.diagnostic-tutorial p {
  margin: 0;
}

.diagnostic-tutorial p {
  margin-top: 8px;
  color: var(--muted);
}

.diagnostic-tutorial ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--soft);
}

.diagnostic-tutorial li + li {
  margin-top: 8px;
}

.diagnostic-tutorial code {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 6, 8, 0.72);
}

.modal-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal-box h2 {
  margin: 0 0 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 14px;
    align-items: center;
  }

  .brand strong,
  .nav-list a span:last-child,
  .nav-title,
  .logout-form span:last-child {
    display: none;
  }

  .nav-list a {
    justify-content: center;
    width: 48px;
  }

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

@media (max-width: 760px) {
  .guest-wrap,
  .app-shell,
  .split-layout,
  .preview-grid,
  .form-grid,
  .form-grid.dense,
  .filter-grid,
  .url-form {
    grid-template-columns: 1fr;
  }

  .guest-wrap.setup-wrap,
  .setup-checks {
    grid-template-columns: 1fr;
  }

  .guest-wrap {
    min-height: 0;
  }

  .guest-shell {
    padding: 12px;
    place-items: start center;
  }

  .guest-wrap {
    width: 100%;
  }

  .brand-panel,
  .auth-panel,
  .setup-wrap .brand-panel,
  .setup-wrap .auth-panel {
    padding: 22px;
  }

  .brand-panel h1 {
    font-size: clamp(34px, 14vw, 54px);
  }

  .setup-actions {
    position: static;
    justify-content: stretch;
  }

  .setup-actions .primary-button,
  .setup-actions .ghost-button,
  .media-tool-actions .primary-button,
  .media-tool-actions .ghost-button {
    width: 100%;
  }

  .setup-section-head {
    flex-direction: column;
  }

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    display: flex;
  }

  .logout-form {
    margin-top: 0;
    margin-left: auto;
  }

  .main-panel {
    padding: 18px;
  }

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

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

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

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

  .diagnostic-tutorial {
    grid-template-columns: 1fr;
  }

  .format-action-row .primary-button,
  .progress-actions .primary-button,
  .progress-actions .ghost-button {
    width: 100%;
  }

  .progress-head {
    flex-direction: column;
  }

  .inline-reset,
  .actions {
    flex-wrap: wrap;
  }
}
