:root {
  --paper: #eef2f7;
  --surface: #ffffff;
  --ink: #102033;
  --muted: #657487;
  --line: #dce3eb;
  --line-dark: #b7c3d0;
  --accent: #2563eb;
  --accent-dark: #1749b8;
  --green: #148765;
  --green-pale: #e4f5ef;
  --focus: #2563eb;
  --radius: 10px;
  --shadow: 0 20px 60px rgba(36, 58, 83, 0.09);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
[hidden] { display: none !important; }

.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(16, 32, 51, .02);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
}

.system-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  color: var(--green);
  border: 1px solid #cde7dc;
  border-radius: 999px;
  background: #f2fbf7;
  font-size: 13px;
  font-weight: 700;
}

.state-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(19, 116, 91, 0.12);
}

.system-state.offline .state-dot { background: var(--accent); box-shadow: none; }

main {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 64px 0 52px;
}

.intro { max-width: 900px; }

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 800px;
  color: var(--ink);
  font-size: clamp(42px, 6vw, 66px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.045em;
}

.intro-copy {
  max-width: 640px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.workflow-steps { display: flex; align-items: center; gap: 12px; margin-top: 28px; color: var(--muted); }
.workflow-step { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.workflow-step span { display: grid; place-items: center; width: 26px; height: 26px; color: var(--muted); border: 1px solid var(--line-dark); border-radius: 50%; font: 700 10px ui-monospace, monospace; }
.workflow-step.is-active { color: var(--ink); }
.workflow-step.is-active span { color: white; background: var(--accent); border-color: var(--accent); }
.workflow-steps i { width: 34px; height: 1px; background: var(--line-dark); }

.workspace {
  margin-top: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.url-form { padding: 28px 30px 30px; border-bottom: 1px solid var(--line); background: #fff; }

.url-form > label,
.select-field > span {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
}

.url-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; }

.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

input, select {
  width: 100%;
  height: 52px;
  color: var(--ink);
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
}

input { padding: 0 46px; font-size: 15px; }
input::placeholder { color: #9c9990; }
input:focus, select:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13); }

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.clear-button { position: absolute; top: 7px; right: 7px; color: var(--muted); }
.clear-button span { font-size: 22px; line-height: 1; }
.clear-button:hover { color: var(--ink); background: var(--paper); }

.inspect-button,
.download-button,
.save-button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  color: white;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, transform 150ms ease;
}

.inspect-button:hover, .download-button:hover { background: var(--accent-dark); }
.inspect-button:active, .download-button:active, .save-button:active { transform: translateY(1px); }
.inspect-button:disabled, .download-button:disabled { color: #aaa8a1; background: #e5e3dd; cursor: wait; }
.button-symbol { font-size: 22px; line-height: 1; }

.field-message { min-height: 18px; margin: 9px 0 -18px; color: var(--accent-dark); font-size: 13px; }

.inspect-help { margin-top: 18px; padding: 11px 12px; color: #7a4c00; background: #fff6df; border: 1px solid #e8c979; border-radius: var(--radius); font-size: 12px; line-height: 1.55; }
.inspect-help p { margin: 0; }

.initial-state { min-height: 116px; display: grid; place-items: center; padding: 28px; background: #fbfcfe; }

.capability-panel { padding: 26px 30px 30px; border-top: 1px solid var(--line); background: #f8fafc; }
.capability-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-kicker { margin: 0 0 5px; color: var(--accent); font: 700 10px ui-monospace, monospace; letter-spacing: .08em; }
.capability-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.maintenance-button { min-height: 36px; padding: 0 13px; color: var(--muted); background: white; border: 1px solid var(--line-dark); border-radius: 7px; font-size: 12px; cursor: pointer; }
.maintenance-button:hover { color: var(--ink); border-color: var(--ink); }
.maintenance-button:disabled { opacity: .5; cursor: wait; }
.capability-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.capability-item { min-height: 68px; display: flex; align-items: center; gap: 9px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 3px 10px rgba(34, 55, 78, .03); }
.capability-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capability-item strong { font-size: 12px; }
.capability-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.capability-dot { width: 7px; height: 7px; flex: 0 0 auto; background: var(--green); border-radius: 50%; }
.capability-item.limited .capability-dot { background: #b18420; }
.capability-note { margin: 16px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

.supported-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 13px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.supported-line i { width: 3px; height: 3px; background: var(--line-dark); border-radius: 50%; }

.result-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr); background: #fff; }

.media-preview { min-width: 0; padding: 30px; border-right: 1px solid var(--line); }

.thumbnail-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #deddd7;
  border-radius: 9px;
}

.thumbnail-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; }
.duration { position: absolute; right: 10px; bottom: 10px; padding: 5px 7px; color: white; background: rgba(24,24,22,.9); border-radius: 3px; font: 700 11px ui-monospace, monospace; }
.duration:empty { display: none; }
.media-meta { padding: 20px 2px 2px; }
.source { margin: 0 0 7px; color: var(--accent); font: 700 11px ui-monospace, monospace; text-transform: uppercase; }
.media-meta h2 { margin: 0; overflow-wrap: anywhere; font-size: 20px; line-height: 1.35; }
.creator { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.media-type { margin: 12px 0 0; color: var(--ink); font-size: 12px; font-weight: 700; }
.source-warning { margin: 14px 0 0; padding: 11px 12px; color: #7a4c00; background: #fff6df; border: 1px solid #e8c979; border-radius: var(--radius); font-size: 12px; line-height: 1.55; }
.source-warning p { margin: 0; }
.source-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.source-actions label { color: #7a4c00; font-size: 11px; }
.source-actions select, .source-actions button { height: 32px; padding: 0 9px; color: #5f4106; background: #fffdf5; border: 1px solid #d9b65c; border-radius: 4px; font-size: 11px; cursor: pointer; }
.source-actions button { font-weight: 700; }
.source-actions button:hover { background: #fff2c9; }
.source-actions button:disabled { opacity: .55; cursor: wait; }

.download-panel { padding: 30px; background: #fbfcfe; }
.panel-heading { display: flex; align-items: center; gap: 13px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.step-number { color: var(--accent); font: 700 12px ui-monospace, monospace; }
.panel-heading p { margin: 0 0 3px; font-size: 15px; font-weight: 750; }
.panel-heading div span { color: var(--muted); font-size: 12px; }
.select-grid { display: grid; gap: 18px; margin-top: 23px; }
.select-field select { padding: 0 14px; }
.select-field.is-disabled { opacity: .45; }

.download-button { width: 100%; margin-top: 24px; background: var(--accent); box-shadow: 0 8px 18px rgba(37, 99, 235, .18); }
.download-button:hover { background: var(--accent-dark); }

.progress-panel, .ready-panel { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.progress-copy { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.progress-copy p, .ready-copy p { margin: 0 0 4px; font-size: 14px; font-weight: 750; }
.progress-copy span, .ready-copy span { display: block; max-width: 260px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.progress-copy strong { font: 700 20px ui-monospace, monospace; }
.progress-track { height: 6px; margin-top: 15px; overflow: hidden; background: #e5e3dd; border-radius: 2px; }
.progress-track div { width: 0; height: 100%; background: var(--accent); transition: width 300ms ease; }
.cancel-button { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; padding: 7px 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; }
.cancel-button:hover { color: var(--accent-dark); }
.cancel-button span[aria-hidden] { font-size: 17px; line-height: 1; }

.ready-panel { display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 12px; }
.ready-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--green); background: var(--green-pale); border-radius: 50%; }
.ready-icon span { font-size: 19px; font-weight: 800; line-height: 1; }
.save-button { grid-column: 1 / -1; min-height: 48px; margin-top: 6px; background: var(--green); }
.save-button:hover { background: #0d604a; }

footer {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 22px 0 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  color: var(--muted);
  font-size: 11px;
}
footer span:last-child { margin-left: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: min(440px, calc(100% - 32px));
  padding: 12px 16px;
  color: white;
  background: #102033;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(24,24,22,.2);
  font-size: 13px;
  transform: translateX(-50%);
}

@media (max-width: 800px) {
  .topbar { padding-inline: 20px; }
  main { width: min(100% - 32px, 620px); padding-top: 48px; }
  h1 { font-size: 46px; }
  .workspace { margin-top: 36px; }
  .url-form { padding: 22px; }
  .url-row { grid-template-columns: 1fr; }
  .inspect-button { width: 100%; }
  .result-grid { grid-template-columns: 1fr; }
  .capability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-preview { border-right: 0; border-bottom: 1px solid var(--line); }
  footer { width: calc(100% - 32px); }
  footer span:last-child { width: 100%; margin-left: 0; }
}

@media (max-width: 480px) {
  .topbar { height: 60px; }
  .system-state span:last-child { display: none; }
  main { width: calc(100% - 24px); padding-top: 34px; }
  h1 { font-size: 38px; }
  .intro-copy { font-size: 14px; }
  .workspace { margin-top: 28px; }
  .url-form, .media-preview, .download-panel { padding: 18px; }
  .capability-panel { padding: 18px; }
  .capability-heading { align-items: start; flex-direction: column; }
  .maintenance-button { width: 100%; }
  input { font-size: 14px; }
  .supported-line { justify-content: flex-start; }
  .workflow-steps { gap: 7px; }
  .workflow-step { gap: 5px; font-size: 11px; }
  .workflow-steps i { width: 15px; }
  footer { width: calc(100% - 24px); padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
