:root {
  --bg: #12151a;
  --bg-2: #1a1e26;
  --bg-3: #252b36;
  --ink: #eef2f6;
  --muted: #9aa6b4;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #5ec2c0;
  --accent-ink: #06201f;
  --ok: #8fd0b0;
  --warn: #e8c56b;
  --danger: #e07a7a;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang HK", "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100dvh;
  min-height: 100vh;
}
button, input, label { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app {
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  max-width: 820px;
  margin: 0 auto;
}

.top { flex: 0 0 auto; }
.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}
h1 {
  margin: 2px 0 0;
  font-size: 28px;
  letter-spacing: 0.02em;
  font-weight: 650;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  margin-top: 12px;
  background: #0c0e12;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: auto;
}

.empty {
  padding: 28px 22px;
  text-align: center;
  max-width: 440px;
  margin: 0 auto;
}
.empty-lead {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 15px;
}

.workspace {
  padding: 14px 14px 18px;
}
.workspace.hidden, .hidden { display: none !important; }

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  max-height: 280px;
  background: #08090c;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.preview img, .preview video {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
}

.file-name {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  word-break: break-all;
}
.file-kind {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.size-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(232, 197, 107, 0.12);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.55;
}
.size-note.is-block {
  background: rgba(224, 122, 122, 0.12);
  color: var(--danger);
}

.section-label {
  margin: 16px 0 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.format-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.format-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--ink);
  border-radius: 14px;
  min-height: 52px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.format-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.format-label { display: block; }

.slider-row {
  display: grid;
  grid-template-columns: 44px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  font-size: 14px;
}
.slider-row .val {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 32px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.footer-row {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}
.grow { flex: 1 1 auto; width: 100%; }

.btn {
  appearance: none;
  border: 0;
  background: var(--bg-3);
  color: var(--ink);
  border-radius: 999px;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn.large { min-height: 52px; padding: 12px 22px; font-size: 17px; }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.text-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: 13px;
  cursor: pointer;
}
.pick-any-wrap { margin-top: 12px; }

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.install-hint { margin-top: 18px; text-align: left; }
.quality-hint { margin-top: 8px; }

.busy {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 16, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  padding: 20px;
  text-align: center;
  z-index: 5;
}
.busy.hidden { display: none !important; }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.bar {
  width: min(240px, 70%);
  height: 6px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
#barFill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

.status {
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.status.is-ok { color: var(--ok); }
.status.is-error { color: var(--danger); }
.status.is-warn { color: var(--warn); }

.result {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.result-note {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
}
.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.result-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  background: #000;
}
.result-video, .result-audio {
  width: 100%;
  border-radius: 12px;
  background: #000;
}

@media (min-width: 720px) {
  h1 { font-size: 32px; }
  .stage { min-height: 360px; }
}
