:root {
  --bg: #f2f0ea;
  --surface: #fffdf8;
  --surface-strong: #f7f4ed;
  --ink: #171a18;
  --muted: #676d67;
  --line: #d8d4ca;
  --line-strong: #bdb8ad;
  --accent: #d7ff55;
  --accent-ink: #1d2800;
  --danger: #bd3a2f;
  --success: #276548;
  --shadow: 0 18px 50px rgba(43, 38, 27, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 26, 24, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 26, 24, 0.028) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

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

[hidden] {
  display: none !important;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 999px;
  filter: blur(40px);
  pointer-events: none;
  opacity: 0.42;
}

.page-glow-one {
  top: -170px;
  right: -90px;
  background: #e4ff86;
}

.page-glow-two {
  bottom: -230px;
  left: -130px;
  background: #c7e4dc;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  place-items: center;
  color: var(--accent);
  background: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  font-family: "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.8);
  font-size: 12px;
  font-weight: 650;
  backdrop-filter: blur(12px);
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #c99d20;
  box-shadow: 0 0 0 4px rgba(201, 157, 32, 0.12);
}

.health.ready .health-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(39, 101, 72, 0.12);
}

.health.warning .health-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(189, 58, 47, 0.12);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 54px;
  align-items: end;
  padding: 31px 0 48px;
}

.eyebrow,
.step-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 760px;
  margin: 13px 0 0;
  font-family: Georgia, "Times New Roman", "Microsoft YaHei", serif;
  font-size: clamp(42px, 7vw, 80px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
}

.hero h1 span {
  color: var(--muted);
}

.hero-copy {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.source-grid,
.result-grid {
  display: grid;
  gap: 18px;
}

.hero > *,
.source-grid > *,
.result-grid > * {
  min-width: 0;
}

.source-grid {
  grid-template-columns: minmax(0, 1.22fr) minmax(310px, 0.78fr);
}

.result-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.source-panel,
.media-panel,
.settings-panel {
  padding: 28px;
}

.panel-heading,
.media-summary,
.task-heading,
.range-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel h2,
.empty-panel h2 {
  margin: 7px 0 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.text-button {
  padding: 7px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

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

.field-label {
  display: block;
  margin: 25px 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface-strong);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 144px;
  padding: 17px;
  resize: vertical;
  line-height: 1.6;
}

input[type="text"] {
  height: 50px;
  padding: 0 15px;
}

.path-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.secondary-button {
  min-width: 70px;
  padding: 0 15px;
  border-radius: 14px;
}

.secondary-button.compact {
  min-width: auto;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--ink);
  background: #f4ffcb;
}

.field-help {
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(23, 26, 24, 0.07);
}

.source-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
}

.helper,
.candidate-note,
.empty-panel p,
.task-message,
.range-scale {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.helper {
  max-width: 390px;
  margin: 0;
}

.primary-button {
  position: relative;
  display: inline-flex;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 10px 26px rgba(169, 204, 38, 0.2);
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(169, 204, 38, 0.28);
}

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

.button-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(29, 40, 0, 0.25);
  border-top-color: var(--accent-ink);
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

.primary-button.loading .button-spinner {
  display: block;
}

.empty-panel {
  position: relative;
  display: flex;
  min-height: 354px;
  padding: 34px;
  flex-direction: column;
  justify-content: flex-end;
  background:
    radial-gradient(circle at 70% 18%, rgba(215, 255, 85, 0.3), transparent 32%),
    var(--ink);
  color: #fff;
}

.empty-panel .step-label,
.empty-panel p {
  color: #a9afa9;
}

.empty-panel h2 {
  color: #fff;
}

.empty-graphic {
  position: absolute;
  top: 28px;
  right: 28px;
  width: 112px;
  height: 112px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.play-shape {
  width: 0;
  height: 0;
  margin-left: 7px;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 23px solid var(--accent);
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 17px;
}

.feature-list span,
.post-badge,
.codec-badge {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.feature-list span {
  color: #d7dbd7;
}

.result-section {
  margin-top: 18px;
  animation: rise 380ms ease both;
}

.media-summary {
  align-items: flex-start;
  margin-bottom: 22px;
}

.media-summary h2 {
  max-width: 600px;
}

.media-meta {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.post-badge {
  flex: none;
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-strong);
}

.candidate-list {
  display: grid;
  gap: 10px;
}

.candidate-card {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.candidate-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.candidate-card.selected {
  border-color: var(--ink);
  background: #f6ffd9;
}

.candidate-radio {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ink);
}

.candidate-main {
  min-width: 0;
}

.candidate-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.candidate-title {
  font-size: 15px;
  font-weight: 780;
}

.codec-badge {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface-strong);
}

.codec-badge.bytevc2 {
  border-color: #d9c9a7;
  color: #6d4d13;
  background: #fff6dc;
}

.candidate-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.candidate-size {
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.candidate-note {
  margin: 17px 2px 0;
}

.settings-panel {
  position: sticky;
  top: 18px;
}

.range-heading {
  align-items: center;
  margin-top: 24px;
}

.range-heading .field-label {
  margin: 0;
}

.range-heading output {
  min-width: 38px;
  padding: 4px 9px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--accent);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.range-input {
  width: 100%;
  margin: 16px 0 7px;
  accent-color: var(--ink);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.check-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin: 24px 0;
  cursor: pointer;
}

.check-row input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--ink);
}

.check-row span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.check-row strong {
  font-size: 12px;
}

.check-row small {
  color: var(--muted);
  font-size: 10px;
}

.convert-button {
  width: 100%;
}

.task-panel {
  margin-top: 18px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.task-heading {
  align-items: center;
  font-size: 12px;
}

.task-heading span {
  color: var(--muted);
  font-weight: 700;
}

.task-heading strong {
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1ded5;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transition: width 400ms ease;
}

.task-message,
.task-error {
  margin: 10px 0 0;
}

.task-message {
  overflow-wrap: anywhere;
  user-select: text;
  word-break: break-all;
}

.task-error {
  color: var(--danger);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.folder-button {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 780;
  cursor: pointer;
  transition:
    color 160ms ease,
    background 160ms ease;
}

.folder-button:hover {
  color: var(--surface);
  background: var(--ink);
}

.json-panel {
  margin-top: 18px;
  overflow: hidden;
}

.json-panel summary {
  display: flex;
  min-height: 62px;
  padding: 0 22px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.json-panel summary::-webkit-details-marker {
  display: none;
}

.json-panel summary .step-label {
  display: block;
  margin-bottom: 4px;
}

.json-panel pre {
  max-height: 520px;
  margin: 0;
  overflow: auto;
  padding: 22px;
  border-top: 1px solid #303630;
  color: #dfe8df;
  background: #171b18;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.65;
  tab-size: 2;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 3px 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(380px, calc(100% - 44px));
  padding: 13px 16px;
  border-radius: 12px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(9px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

.toast.error {
  background: var(--danger);
}

.dialog-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  padding: 22px;
  place-items: center;
  background: rgba(14, 17, 15, 0.48);
  backdrop-filter: blur(8px);
}

.directory-dialog {
  width: min(680px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
}

.dialog-heading,
.directory-current,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.dialog-heading h2 {
  margin: 5px 0 0;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 20px;
  line-height: 1;
}

.directory-current {
  justify-content: flex-start;
  margin-top: 22px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-strong);
}

.directory-current span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.drive-button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.drive-button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.directory-list {
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.directory-item {
  display: flex;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.directory-item:last-child {
  border-bottom: 0;
}

.directory-item:hover {
  background: #f4ffcb;
}

.directory-icon {
  width: 22px;
  height: 16px;
  border-radius: 4px;
  background: #e4c96b;
  box-shadow: inset 0 0 0 1px rgba(72, 54, 8, 0.16);
}

.directory-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-empty {
  margin: 18px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.dialog-actions {
  margin-top: 18px;
}

.dialog-actions .primary-button {
  min-height: 44px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .hero-copy {
    max-width: 540px;
  }

  .source-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
  }

  .empty-panel {
    min-height: 280px;
  }
}

@media (max-width: 580px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 22px;
  }

  .health {
    min-height: 34px;
  }

  .hero {
    padding: 18px 0 34px;
  }

  .hero h1 {
    font-size: clamp(36px, 12vw, 52px);
  }

  .source-panel,
  .media-panel,
  .settings-panel {
    padding: 21px;
  }

  .source-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .path-field {
    grid-template-columns: 1fr;
  }

  .path-field .secondary-button {
    min-height: 44px;
  }

  .primary-button {
    width: 100%;
  }

  .candidate-card {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  .candidate-size {
    grid-column: 2;
  }

  footer {
    flex-direction: column;
    gap: 8px;
  }

  .dialog-backdrop {
    padding: 12px;
  }

  .directory-dialog {
    padding: 19px;
    border-radius: 18px;
  }

  .dialog-actions .text-button {
    white-space: nowrap;
  }

  .dialog-actions .primary-button {
    width: auto;
  }
}

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