.upscale-page {
    --upscale-panel: #fff;
    --upscale-soft: #f5f7fb;
    --upscale-preview: #eef1f6;
    --upscale-selected: #eaf2ff;
    --upscale-accent: #367bed;
    --upscale-muted: var(--secondary-text, #667085);
    width: 100%;
    max-width: 1760px;
    min-height: 100%;
    margin-inline: auto;
    padding: 12px clamp(18px, 2.6vw, 40px) 36px;
    color: var(--text-color, #263244);
    font: 14px/1.5 system-ui, sans-serif;
}
html[data-theme="dark"] .upscale-page {
    --upscale-panel: #15181e;
    --upscale-soft: #1c2028;
    --upscale-preview: #0e1014;
    --upscale-selected: #243b5d;
    --upscale-accent: #82b3ff;
}
.upscale-page, .upscale-page * { box-sizing: border-box; }
.upscale-page [hidden] { display: none !important; }
.upscale-page button, .upscale-page input { font: inherit; }
.upscale-page button { cursor: pointer; }
.upscale-page button:disabled { cursor: not-allowed; opacity: .5; }
.upscale-page button:focus-visible, .upscale-page a:focus-visible {
    outline: 2px solid var(--upscale-accent);
    outline-offset: 3px;
}
.upscale-page .workspace-public-nav--top {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 22px;
    min-height: 32px;
    margin-bottom: 24px;
    font-size: 13px;
}
.upscale-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.upscale-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.upscale-heading-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; color: var(--upscale-accent); border: 1px solid var(--border-color); border-radius: 13px; background: var(--upscale-soft); font-size: 18px; }
.upscale-header h1 { margin: 0; font-size: clamp(22px, 2vw, 28px); line-height: 1.3; font-weight: 650; letter-spacing: -.03em; }
.upscale-header p { margin: 5px 0 0; color: var(--upscale-muted); font-size: 13px; }
.upscale-kind-switch { display: inline-flex; flex-shrink: 0; gap: 4px; padding: 4px; background: var(--upscale-soft); border: 1px solid var(--border-color); border-radius: 11px; }
.upscale-kind-switch a { padding: 7px 13px; border-radius: 7px; color: var(--upscale-muted); text-decoration: none; white-space: nowrap; }
.upscale-kind-switch a[aria-current="page"] { color: var(--upscale-accent); background: var(--upscale-selected); }
.upscale-page .layout { display: grid; grid-template-columns: 304px minmax(0, 1fr); align-items: start; gap: 22px; }
.upscale-page .panel { min-width: 0; margin: 0; padding: 20px; border: 1px solid var(--border-color); border-radius: 16px; background: var(--upscale-panel); }
.upscale-page #settings { display: flex; flex-direction: column; gap: 16px; align-self: start; }
.upscale-section-heading { display: flex; align-items: center; gap: 9px; margin: 0; }
.upscale-section-heading h2 { font-size: 13px; line-height: 1.5; font-weight: 600; margin: 0; }
.upscale-step { display: grid; place-items: center; flex: 0 0 22px; height: 22px; border-radius: 7px; background: var(--upscale-soft); color: var(--upscale-muted); font-size: 11px; }
.upscale-page .drop { position: relative; display: grid; justify-items: center; align-content: center; gap: 5px; min-height: 174px; margin: 0; padding: 16px; text-align: center; background: var(--upscale-soft); border: 1px dashed var(--border-color); border-radius: 12px; cursor: pointer; }
.upscale-page .drop > i { margin-bottom: 7px; font-size: 24px; color: var(--upscale-accent); }
.upscale-page .drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upscale-page .drop strong { font-size: 13px; font-weight: 550; }
.upscale-page .drop small { font-size: 11px; color: var(--upscale-muted); }
.upscale-page .drop:focus-within, .upscale-page .drop.dragging { border-color: var(--upscale-accent); background: var(--upscale-selected); }
.upscale-page .upscale-library-button { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 9px; background: transparent; color: inherit; font-size: 12px; }
.upscale-page .upscale-library-button:hover { background: var(--upscale-soft); }
.upscale-source-summary { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--upscale-soft); border-radius: 10px; }
.upscale-source-summary > img, .upscale-source-summary > video { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 6px; object-fit: cover; }
.upscale-source-summary strong { display: block; font-weight: 500; font-size: 12px; }
.upscale-page #metadata { margin: 3px 0 0; color: var(--upscale-muted); font-size: 11px; overflow-wrap: anywhere; }
.upscale-page fieldset { min-width: 0; border: 0; padding: 0; margin: 2px 0 0; }
.upscale-page legend { float: none; width: auto; margin-bottom: 12px; padding: 0; font: inherit; font-size: 13px; font-weight: 550; border: 0; }
.upscale-page .choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.upscale-page .choices label { position: relative; display: block; min-width: 0; margin: 0; text-align: center; cursor: pointer; }
.upscale-page .choices input { position: absolute; opacity: 0; }
.upscale-page .choices span { display: grid; gap: 6px; justify-items: center; padding: 12px 4px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--upscale-soft); }
.upscale-page .choices strong { font-size: 14px; font-weight: 550; }
.upscale-page .choices small { color: var(--upscale-muted); font-size: 10px; }
.upscale-page .choices input:checked + span { border-color: var(--upscale-accent); background: var(--upscale-selected); }
.upscale-page .choices input:checked + span strong { color: var(--upscale-accent); }
.upscale-page .choices input:focus-visible + span { outline: 2px solid var(--upscale-accent); outline-offset: 2px; }
.upscale-page .choices input:disabled + span { opacity: .4; cursor: not-allowed; }
.upscale-page #error { margin: 0; color: #da5260; font-size: 12px; overflow-wrap: anywhere; }
.upscale-page #error:empty { display: none; }
.upscale-page .submit { display: grid; gap: 9px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.upscale-page #estimate { color: var(--upscale-muted); font-size: 12px; text-align: center; }
.upscale-page #start { width: 100%; padding: 12px 16px; border: 1px solid #367bed; border-radius: 10px; background: #367bed; color: #fff; font-weight: 600; }
.upscale-page #start:hover:not(:disabled) { background: #2469d8; }
.upscale-page .results { padding: 0; overflow: hidden; }
.upscale-result-tabs { display: flex; gap: 22px; padding: 0 22px; border-bottom: 1px solid var(--border-color); }
.upscale-result-tabs button { position: relative; padding: 17px 0; border: 0; background: transparent; color: var(--upscale-muted); font-size: 13px; }
.upscale-result-tabs button[aria-pressed="true"] { color: var(--text-color); }
.upscale-result-tabs button[aria-pressed="true"]::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--upscale-accent); }
.upscale-page #current, .upscale-page #history { padding: 18px; }
.upscale-page .actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.upscale-compare-options { display: inline-flex; gap: 3px; padding: 3px; border-radius: 8px; background: var(--upscale-soft); }
.upscale-compare-options button { padding: 6px 11px; border: 0; border-radius: 6px; background: transparent; color: var(--upscale-muted); font-size: 12px; }
.upscale-compare-options button[aria-pressed="true"] { background: var(--upscale-selected); color: var(--upscale-accent); }
.upscale-page .preview { display: grid; place-items: center; height: clamp(340px, calc(100dvh - 440px), 800px); min-width: 0; overflow: hidden; border-radius: 11px; background: var(--upscale-preview); }
.upscale-page .preview > video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
.upscale-page .preview-open { display: grid; place-items: center; min-width: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: zoom-in; }
.upscale-page .preview-open:hover:not(:disabled) { background: transparent; }
.upscale-page .preview-open:focus-visible { outline-offset: -3px; }
.upscale-page .preview-open img { display: block; width: 100%; height: 100%; min-height: 0; max-height: 100%; object-fit: contain; }
.upscale-empty { padding: 30px; text-align: center; color: var(--upscale-muted); }
.upscale-empty > i { display: inline-grid; place-items: center; width: 68px; height: 68px; margin-bottom: 12px; border: 1px solid var(--border-color); border-radius: 18px; font-size: 26px; }
.upscale-empty p { max-width: 280px; margin: 0; font-size: 13px; }
.upscale-task-status { margin-top: 14px; }
.upscale-page #status { margin: 0; color: var(--upscale-muted); font-size: 12px; overflow-wrap: anywhere; }
.upscale-page #status:empty { display: none; }
.upscale-page progress { display: block; width: 100%; height: 5px; margin-top: 10px; accent-color: var(--upscale-accent); }
.upscale-page .download-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--upscale-soft); color: inherit; font-size: 12px; }
.upscale-page .download-button:hover:not(:disabled) { border-color: var(--upscale-accent); }
.upscale-page .download-button[aria-busy="true"] .download-icon { display: none; }
.upscale-page .download-spinner { width: 1em; height: 1em; flex: 0 0 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: upscale-download-spin .8s linear infinite; }
@keyframes upscale-download-spin { to { transform: rotate(360deg); } }
.upscale-page .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 0 0 18px; }
.upscale-page .upscale-media-card { display: flex; min-width: 0; flex-direction: column; align-items: stretch; gap: 7px; padding: 0 0 12px; overflow: hidden; border: 1px solid var(--border-color); border-radius: 11px; text-align: left; background: var(--upscale-soft); color: inherit; }
.upscale-page .upscale-media-card:hover { border-color: var(--upscale-accent); }
.upscale-page .upscale-media-card img, .upscale-page .upscale-card-placeholder { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.upscale-page .upscale-card-placeholder { display: grid; place-items: center; color: var(--upscale-muted); background: var(--upscale-preview); font-size: 24px; }
.upscale-page .upscale-card-title { padding: 3px 11px 0; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.upscale-page .upscale-card-meta { padding-inline: 11px; color: var(--upscale-muted); font-size: 11px; overflow-wrap: anywhere; }
.upscale-page .upscale-media-card[data-status="failed"] .upscale-card-meta { color: #da5260; }
.upscale-page #historyMessage, .upscale-page #assetMessage { color: var(--upscale-muted); font-size: 13px; }
.upscale-page #moreHistory, .upscale-page #moreAssets { display: block; margin: 0 auto; padding: 8px 16px; border: 1px solid var(--border-color); border-radius: 8px; background: transparent; color: inherit; }
.upscale-page dialog { width: min(720px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 20px; border: 1px solid var(--border-color); border-radius: 16px; color: var(--text-color); background: var(--upscale-panel); }
.upscale-page dialog::backdrop { background: #05080eb3; backdrop-filter: blur(5px); }
.upscale-page .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.upscale-page .dialog-heading h2 { margin: 0; font-size: 16px; }
.upscale-page .dialog-heading form { margin: 0; }
.upscale-page .dialog-heading button { width: 32px; height: 32px; padding: 0; border: 1px solid var(--border-color); border-radius: 8px; background: var(--upscale-soft); color: inherit; font-size: 20px; }
.upscale-page dialog.image-preview-dialog { width: min(1600px, calc(100vw - 32px)); }
.upscale-page .image-preview-dialog > img { display: block; max-width: 100%; max-height: calc(100dvh - 140px); margin-inline: auto; object-fit: contain; }
@media (max-width: 1100px) {
    .upscale-page .layout { grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
    .upscale-page .panel { padding: 16px; }
    .upscale-page .results { padding: 0; }
    .upscale-kind-switch a { padding-inline: 9px; }
}
@media (max-width: 768px) {
    .upscale-page { padding: 20px 16px 32px; }
    .upscale-page .upscale-public-nav { display: none; }
    .upscale-header { align-items: stretch; flex-direction: column; gap: 16px; margin-bottom: 20px; }
    .upscale-kind-switch { align-self: flex-start; }
    .upscale-page .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .upscale-page .drop { min-height: 130px; }
    .upscale-page .preview { height: clamp(260px, 50dvh, 520px); }
    .upscale-page #current, .upscale-page #history { padding: 12px; }
    .upscale-page .list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    .upscale-page .download-spinner { animation: none; }
}
