:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef1f4;
    --text: #171a1f;
    --muted: #68717d;
    --border: #d9dee5;
    --green: #167a56;
    --green-hover: #116245;
    --red: #b42318;
    --red-bg: #fff1f0;
    --amber: #a15c00;
    --blue: #2463a7;
    --shadow: 0 12px 30px rgba(23, 26, 31, 0.08);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

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

.topbar {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(20px, 4vw, 58px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
    width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: 7px; background: var(--text); color: #fff;
    font-size: 12px; font-weight: 700;
}
.brand div { display: flex; flex-direction: column; line-height: 1.25; }
.brand strong { font-size: 15px; }
.brand div span { color: var(--muted); font-size: 12px; }

.health { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.health-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.health.ready .health-dot { background: var(--green); }
.health.error .health-dot { background: var(--red); }
.top-actions { display: flex; align-items: center; gap: 16px; }
.language-switch {
    display: grid; grid-template-columns: 48px 38px; height: 34px;
    padding: 2px; border: 1px solid var(--border); border-radius: 7px;
    background: var(--surface-muted);
}
.language-switch button {
    min-width: 0; border: 0; border-radius: 5px; background: transparent;
    color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
}
.language-switch button[aria-pressed="true"] {
    background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(23, 26, 31, .12);
}
.language-switch button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

main { min-height: calc(100vh - 118px); }

.workspace {
    width: min(1040px, calc(100% - 40px));
    margin: 0 auto;
    padding: 58px 0 52px;
}

.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 28px; line-height: 1.25; }
.section-heading p { color: var(--muted); margin-bottom: 0; }

.url-form > label, .field label {
    display: block; color: #3e4651; font-size: 13px; font-weight: 600; margin-bottom: 8px;
}
.input-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; }
input, select {
    height: 46px; border: 1px solid var(--border); border-radius: 7px;
    background: var(--surface); color: var(--text); outline: none;
}
input { width: 100%; padding: 0 15px; }
select { min-width: 142px; padding: 0 36px 0 12px; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 122, 86, .12); }

.button {
    min-height: 42px; padding: 0 18px; border: 1px solid transparent;
    border-radius: 7px; cursor: pointer; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; white-space: nowrap;
}
.button:disabled { opacity: .55; cursor: wait; }
.button.primary { background: var(--text); color: #fff; }
.button.primary:hover:not(:disabled) { background: #303640; }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button.secondary:hover { background: var(--surface-muted); }
.button.download { align-self: end; height: 46px; background: var(--green); color: #fff; }
.button.download:hover { background: var(--green-hover); }

.message {
    margin-top: 16px; padding: 12px 14px; border: 1px solid #f2b8b5;
    border-radius: 7px; color: var(--red); background: var(--red-bg);
}

.result {
    display: grid; grid-template-columns: 300px 1fr; gap: 28px;
    margin-top: 34px; padding: 22px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.preview { position: relative; aspect-ratio: 16/9; background: var(--surface-muted); overflow: hidden; border-radius: 6px; }
.preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.duration { position: absolute; right: 8px; bottom: 8px; padding: 3px 7px; border-radius: 4px; background: rgba(0,0,0,.78); color: #fff; font-size: 12px; }
.metadata { min-width: 0; display: flex; flex-direction: column; }
.platform { width: fit-content; color: var(--blue); font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.metadata h2 { margin-bottom: 7px; font-size: 20px; line-height: 1.4; overflow-wrap: anywhere; }
.metadata > p { color: var(--muted); margin-bottom: 20px; }
.download-options { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; margin-top: auto; align-items: end; }

.task { margin-top: 22px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.task-row, .task-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.eyebrow { color: var(--muted); font-size: 12px; }
.task h2 { font-size: 16px; margin: 3px 0 0; }
#progress-text { color: var(--green); font-variant-numeric: tabular-nums; }
.progress { height: 8px; margin: 16px 0 13px; overflow: hidden; border-radius: 4px; background: var(--surface-muted); }
.progress span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s ease; }
.task-footer { color: var(--muted); font-size: 13px; }
.task-footer .button { min-height: 36px; }

.support-band {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--border);
}
.support-band > div { padding: 24px clamp(20px, 4vw, 58px); background: var(--surface); }
.support-band strong, .support-band span { display: block; }
.support-band strong { margin-bottom: 5px; }
.support-band span { color: var(--muted); font-size: 13px; line-height: 1.5; }

footer {
    min-height: 50px; display: flex; align-items: center; justify-content: space-between;
    gap: 20px; padding: 0 clamp(20px, 4vw, 58px); color: var(--muted); font-size: 12px;
}

[hidden] { display: none !important; }

@media (max-width: 760px) {
    .topbar { height: 60px; }
    .workspace { width: min(100% - 24px, 1040px); padding: 32px 0 36px; }
    h1 { font-size: 23px; }
    .section-heading p { font-size: 13px; }
    .input-row { grid-template-columns: 1fr auto; }
    .input-row input { grid-column: 1 / -1; }
    #parse-button { flex: 1; }
    .result { grid-template-columns: 1fr; gap: 18px; padding: 14px; }
    .preview { width: 100%; }
    .download-options { grid-template-columns: 1fr 1fr; }
    .button.download { grid-column: 1 / -1; }
    select { width: 100%; min-width: 0; }
    .support-band { grid-template-columns: 1fr; }
    footer { padding: 14px 20px; }
}

@media (max-width: 420px) {
    .brand div span, footer span:last-child { display: none; }
    .topbar { padding-inline: 12px; }
    .top-actions { gap: 12px; }
    .health { gap: 0; }
    #health-text { display: none; }
    .download-options { grid-template-columns: 1fr; }
    .button.download { grid-column: auto; }
}
