:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-soft: #10161d;
  --surface: #151c24;
  --surface-2: #1b2530;
  --surface-3: #22303d;
  --text: #edf2f7;
  --muted: #94a3b3;
  --line: #2d3a48;
  --accent: #32c98d;
  --accent-2: #5ea7ff;
  --danger: #ef5f67;
  --warning: #d99a2b;
  --button-text: #06110c;
  --shadow: 0 18px 42px rgba(0, 0, 0, .24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-soft: #edf2f7;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --surface-3: #e8eef5;
  --text: #111827;
  --muted: #607086;
  --line: #d7e0ea;
  --accent: #16875c;
  --accent-2: #2563eb;
  --danger: #c2414b;
  --warning: #a16207;
  --button-text: #ffffff;
  --shadow: 0 18px 42px rgba(31, 41, 55, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 32rem),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, textarea, input, select { font: inherit; }
button { cursor: pointer; min-height: 40px; }

main {
  width: min(840px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 18px 48px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  box-shadow: 0 20px 70px rgba(0, 0, 0, .16);
}

.hero {
  min-height: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

nav, .title-row, .tabs, .quality-row, .preview-head, .recent-head, .job, .job-actions {
  display: flex;
  align-items: center;
}

nav {
  gap: 10px;
  color: var(--muted);
  font-size: .82rem;
}

nav a {
  margin-left: auto;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.theme-button {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: transparent;
  color: var(--muted);
  font-size: .76rem;
}

.theme-button.active {
  background: var(--surface-3);
  color: var(--text);
}

.title-row {
  justify-content: space-between;
  gap: 18px;
  padding-top: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  position: relative;
  width: 46px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.logo-mark .play {
  position: absolute;
  left: 25%;
  top: 24%;
  width: 35%;
  height: 35%;
  background: var(--accent-2);
  clip-path: polygon(18% 0, 100% 50%, 18% 100%);
}

.logo-mark .arrow {
  position: absolute;
  right: 23%;
  top: 18%;
  width: 16%;
  height: 45%;
  border-radius: 999px;
  background: var(--accent);
}

.logo-mark .arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -16%;
  width: 190%;
  aspect-ratio: 1;
  background: var(--accent);
  transform: translateX(-50%) rotate(45deg);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.logo-mark .dock {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 18%;
  height: 11%;
  border: 2px solid var(--accent-2);
  border-top: 0;
  border-radius: 0 0 7px 7px;
}

.logo-mark.small {
  width: 42px;
  margin: 0 auto 10px;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4.2vw, 2.75rem);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.uptime {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  min-width: 180px;
}

.uptime strong, .uptime span { display: block; }
.uptime strong { color: var(--accent); margin-bottom: 5px; }
.uptime span { color: var(--muted); font-size: .66rem; line-height: 1.3; }

.console, .panel-block, .stats div, .guide article, .platforms-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.console { padding: 12px; }

.tabs {
  gap: 6px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px;
  background: var(--surface-2);
}

.tab, .quality, .preview button, .recent button, .remove {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 11px;
}

.tab {
  flex: 1;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab.active, .quality.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}

.dropzone {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}

.dropzone span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .66rem;
}

textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: .82rem;
  line-height: 1.45;
}

input {
  width: 100%;
  min-height: 40px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: .82rem;
}

.access-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px);
}

.access-box {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  text-align: center;
}

.access-box p {
  margin-top: 8px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}

.access-box input {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  padding: 10px 12px;
}

.access-box button {
  width: 100%;
  margin-top: 10px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--button-text);
  font-weight: 800;
}

#accessMessage {
  display: block;
  min-height: 18px;
  margin-top: 9px;
  color: var(--warning);
  font-size: .72rem;
}

.dropzone.drag {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 16%, transparent);
}

.platform-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.platform-chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 5px 8px;
  font-size: .6rem;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}

.platform-chips span.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}

.section-label {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 700;
  text-transform: uppercase;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 10px auto;
  max-width: 560px;
}

.format-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

@media (min-width: 761px) {
  .format-column {
    width: 230px;
  }

  .format-column:first-child {
    justify-self: start;
  }

  .format-column:last-child {
    justify-self: center;
  }
}

.format-column > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .58rem;
  font-weight: 700;
  line-height: 1;
}

.format {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 4px;
  min-width: 0;
}

.format strong, .format small { display: block; }
.format strong { color: var(--text); font-size: .78rem; line-height: 1.05; }
.format small { color: var(--muted); margin-top: 2px; font-size: .48rem; line-height: 1.05; }
.format.active {
  border-color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 12%, var(--surface));
}

.quality-row {
  gap: 7px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .72rem;
}

.quality-row > span { margin-right: auto; }

.download {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 9px;
  padding: 13px 16px;
  background: var(--accent);
  color: var(--button-text);
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  margin-top: 12px;
}

.panel-block { padding: 12px; }

.preview-head, .recent-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.preview-head h2, .recent-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.preview-head button, .recent-head button {
  flex: 0 0 auto;
  white-space: nowrap;
}

h2, h3, p { margin: 0; }
h2 { font-size: .98rem; }

.preview-box {
  position: relative;
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface-2);
}

.preview-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-box div {
  position: relative;
  z-index: 1;
  align-self: end;
  width: 100%;
  min-width: 0;
  padding: 14px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg) 88%, transparent));
}

.preview-box span { color: var(--accent-2); font-weight: 800; }
.preview-box p {
  margin-top: 7px;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

.batch-actions {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.batch-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  padding: 9px;
}

.batch-action span {
  min-width: 0;
  color: var(--muted);
  font-size: .58rem;
  overflow-wrap: anywhere;
}

.batch-action button,
.batch-action a {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .66rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

.batch-action .primary {
  border-color: var(--accent);
  color: var(--button-text);
  background: var(--accent);
  font-weight: 800;
}

.job {
  gap: 8px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  padding: 8px;
}

.job > div:first-child {
  min-width: 0;
  flex: 1;
}

.job-title {
  display: block;
  font-size: .68rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.job-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: .56rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.job-log {
  display: none;
  margin-top: 6px;
  color: var(--muted);
  font-size: .52rem;
}

.job.error .job-log { display: block; }

.job-log summary {
  color: var(--warning);
  cursor: pointer;
}

.job-log pre {
  max-height: 150px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  margin-top: 7px;
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.job-actions {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file {
  display: none;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--accent);
  color: var(--button-text);
  font-size: .66rem;
  text-decoration: none;
  font-weight: 800;
  text-align: center;
  justify-content: center;
  align-items: center;
}

.job.done .file { display: inline-flex; }
.job.error .bar span { background: var(--danger); }
.job-progress { min-width: 42px; text-align: right; color: var(--accent); font-size: .62rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.stats div, .guide article { padding: 12px; }
.stats strong { display: block; font-size: 1.25rem; color: var(--accent-2); }
.stats span { color: var(--muted); font-size: .7rem; }

.guide { margin-top: 24px; }
.guide > h2 { margin-bottom: 12px; font-size: 1.12rem; }

.platforms-section {
  margin-top: 12px;
  padding: 14px;
}

.platforms-section h2 { margin-bottom: 8px; }

.platforms-section p {
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.6;
}

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

.guide article span { color: var(--accent-2); font-weight: 800; }
.guide article h3 { margin-top: 12px; }
.guide article p { color: var(--muted); margin-top: 7px; font-size: .72rem; line-height: 1.45; }

@media (max-width: 760px) {
  main { width: min(100% - 20px, 840px); padding-top: 14px; }
  .title-row, .content-grid, .stats, .steps { grid-template-columns: 1fr; display: grid; }
  .format-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .format-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .uptime { min-width: 0; }
  .job, .job-actions { align-items: stretch; flex-direction: column; }
  .job-progress { text-align: left; }
  .recent { order: 1; }
  .preview { order: 2; }
}

@media (max-width: 520px) {
  main {
    width: min(100% - 12px, 840px);
    padding: 8px 0 32px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  textarea,
  input {
    font-size: .76rem;
  }

  textarea {
    min-height: 42px;
  }

  nav {
    align-items: flex-start;
    flex-wrap: wrap;
    font-size: .76rem;
  }

  nav a {
    margin-left: 0;
  }

  .theme-switch {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .theme-button {
    flex: 1;
  }

  .hero {
    gap: 12px;
  }

  .logo-mark {
    width: 42px;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 2.6rem);
  }

  .uptime {
    display: none;
  }

  .console, .panel-block, .stats div, .guide article, .platforms-section {
    padding: 10px;
    box-shadow: none;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tab, .quality, .preview button, .recent button, .remove {
    padding: 8px 9px;
  }

  .dropzone {
    padding: 10px;
  }

  .dropzone span,
  .section-label {
    font-size: .64rem;
  }

  .platform-chips {
    gap: 5px;
  }

  .platform-chips span {
    padding: 5px 7px;
    font-size: .6rem;
  }

  .format-grid {
    gap: 6px;
  }

  .format-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .format {
    min-height: 40px;
    padding: 5px 4px;
  }

  .format strong {
    font-size: .74rem;
  }

  .format small {
    font-size: .48rem;
    margin-top: 2px;
  }

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

  .quality-row > span {
    grid-column: 1 / -1;
    margin-right: 0;
  }

  .preview-head, .recent-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .preview-head h2, .recent-head h2 {
    font-size: .95rem;
  }

  .preview-head button, .recent-head button {
    min-height: 36px;
    padding: 7px 9px;
    font-size: .78rem;
  }

  .batch-action {
    grid-template-columns: 1fr;
  }

  .batch-action button,
  .batch-action a {
    width: 100%;
    white-space: normal;
  }

  .preview-box {
    min-height: 164px;
  }

  .stats {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats div {
    min-width: 0;
    text-align: center;
  }

  .stats strong {
    font-size: 1.05rem;
    word-break: break-word;
  }

  .stats span {
    font-size: .62rem;
  }

  .guide {
    margin-top: 22px;
  }

  .guide > h2 {
    font-size: 1.02rem;
  }

  .platforms-section p {
    font-size: .72rem;
    line-height: 1.6;
  }
}
