:root {
  --bg: #f8fafc;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #e7eaf0;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--fg); background: var(--bg);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* Top nav */
.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 20px;
  padding: 12px max(20px, calc((100% - 900px) / 2));
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .brand { display: inline-flex; align-items: center; margin-right: auto; }
.top .brand img { height: 26px; width: auto; display: block; }
.top a:not(.brand) { color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 500; }
.top a:not(.brand):hover { color: var(--accent); }

/* Hero */
header {
  text-align: center; padding: 60px 20px 44px;
  background: radial-gradient(900px 320px at 50% -40px, var(--accent-soft), transparent 70%);
}
header h1, header .sub { max-width: 720px; margin-left: auto; margin-right: auto; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 14px; }
.sub { color: var(--muted); font-size: 1.1rem; margin: 0; }

/* Layout */
main { max-width: 820px; margin: 0 auto; padding: 0 20px; }
section { margin: 44px 0; }
h2 { font-size: 1.45rem; letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 22px 0 4px; }
ol, p { color: #334155; }

/* Tool */
#tool { margin-top: 28px; }
#drop {
  background: var(--card); border: 2px dashed #cbd5e1; border-radius: 18px;
  padding: 52px 24px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .18s, background .18s, transform .18s, box-shadow .18s;
}
#drop p { margin: 0; color: var(--muted); }
#drop:hover, #drop.over { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 18px 2px; }
#qlabel { color: var(--muted); font-size: .92rem; display: inline-flex; align-items: center; gap: 8px; }
#quality { accent-color: var(--accent); }
#status { color: var(--muted); min-height: 1.4em; margin: 6px 2px; }

button, .dl {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 18px; font-size: .92rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block; box-shadow: 0 1px 2px rgba(79, 70, 229, .35);
  transition: background .15s, transform .15s;
}
button:hover, .dl:hover { background: var(--accent-hover); transform: translateY(-1px); }

#results { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; text-align: center; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }
.card.err { color: #b91c1c; display: flex; align-items: center; justify-content: center; min-height: 90px; }
.dl { font-size: .82rem; word-break: break-all; }

/* Footer */
footer { margin-top: 64px; padding: 32px 20px 56px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .9rem; }
footer .tools { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
footer .tools a { color: var(--muted); text-decoration: none; }
footer .tools a:hover { color: var(--accent); }

/* nav dropdown */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; color: var(--muted); font-size: .9rem; font-weight: 500; padding: 4px 2px; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " \25BE"; }
.menu summary:hover, .menu[open] summary { color: var(--accent); }
.menu-panel { position: absolute; right: 0; top: 160%; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px; min-width: 230px; display: grid; gap: 1px; z-index: 60; }
.menu-panel strong { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; margin-top: 10px; padding: 0 8px; }
.menu-panel strong:first-child { margin-top: 0; }
.menu-panel a { color: var(--fg); text-decoration: none; font-size: .9rem; padding: 7px 8px; border-radius: 8px; }
.menu-panel a:hover { background: var(--accent-soft); color: var(--accent); }
