:root {
  --bg: #f4f5f8; --surface: #ffffff; --ink: #11141b; --muted: #596172;
  --line: #dde0e8; --accent: #2b50ff; --accent-ink: #ffffff; --danger: #c52a3a;
  --radius: 20px; --shadow: 0 10px 40px -18px rgba(20, 30, 70, .35);
}
:root[data-theme="dark"] {
  --bg: #0c0f16; --surface: #151a25; --ink: #eceff6; --muted: #9aa3b7;
  --line: #262d3d; --accent: #7b98ff; --accent-ink: #0c0f16; --danger: #ff7a87;
  --shadow: 0 10px 40px -18px rgba(0, 0, 0, .8);
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.6 "Manrope", system-ui, sans-serif; transition: background .3s, color .3s; }
main { flex: 1; width: min(920px, 100% - 2rem); margin: 0 auto; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.nav, .footer { width: min(1100px, 100% - 2rem); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 0; }
.logo { font: 700 1.4rem "Bricolage Grotesque", sans-serif; text-decoration: none; letter-spacing: -.02em; }
.icon-btn { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .45rem 1rem; cursor: pointer; font: inherit; font-size: .9rem; }
:root[data-theme="dark"] .icon-sun, :root:not([data-theme="dark"]) .icon-moon { display: none; }
.footer { color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); margin-top: 4rem; }
.footer nav { display: flex; gap: 1.2rem; }

.hero { padding: clamp(2.5rem, 9vw, 6rem) 0 2rem; animation: rise .6s ease both; }
h1, h2 { font-family: "Bricolage Grotesque", sans-serif; letter-spacing: -.03em; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); max-width: 14ch; }
.sub { color: var(--muted); max-width: 52ch; font-size: 1.1rem; margin: 1.2rem 0 2rem; }
.url-bar { display: flex; gap: .5rem; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.url-bar:focus-within { border-color: var(--accent); }
.url-bar input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: .8rem 1.2rem; outline: 0; }
button { font: inherit; }
.url-bar button, .primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: .8rem 1.8rem; font-weight: 700; cursor: pointer; transition: transform .15s, opacity .2s; }
.url-bar button:hover, .primary:hover { transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.error { color: var(--danger); margin: 1rem .5rem 0; font-weight: 500; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-top: 1rem; }
#loading { display: flex; align-items: center; gap: 1rem; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.preview { display: grid; grid-template-columns: 300px 1fr; gap: 1.8rem; animation: rise .4s ease both; }
.thumb { aspect-ratio: 16/9; border-radius: 14px; overflow: hidden; background: var(--bg); display: grid; place-items: center; color: var(--muted); align-self: start; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.info h2 { font-size: 1.6rem; overflow-wrap: anywhere; }
.meta { color: var(--muted); margin: .4rem 0 1.2rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--bg); border-radius: 999px; padding: .25rem; margin-bottom: 1rem; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: .5rem 1.1rem; border-radius: 999px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.options { border: 0; padding: 0; margin: 0 0 1.4rem; }
#options { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: all .15s; }
.chip input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 700; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.progress { margin-top: 1.2rem; }
.bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
#progress-msg { color: var(--muted); margin: .6rem 0; }
.link-btn { display: inline-block; text-decoration: none; }

.doc { max-width: 62ch; padding: 4rem 0; }
.doc h1 { font-size: 2.6rem; margin-bottom: 1.5rem; }
.doc p { color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@media (max-width: 720px) {
  .preview { grid-template-columns: 1fr; }
  .url-bar { flex-direction: column; border-radius: 24px; }
  .url-bar button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.upscale { margin-top: 2rem; }
.upscale h2 { font-size: 1.6rem; }
.muted { color: var(--muted); max-width: 60ch; margin: .6rem 0 1.4rem; }
.file-drop { display: block; border: 2px dashed var(--line); border-radius: 14px; padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; margin-bottom: 1rem; transition: border-color .2s; overflow-wrap: anywhere; }
.file-drop:hover, .file-drop:focus-within { border-color: var(--accent); color: var(--ink); }
.file-drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#up-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s ease; }
