:root {
  --bg: #EDF0F5;
  --card: #FFFFFF;
  --ink: #111827;
  --muted: #6B7280;
  --faint: #9CA3AF;
  --line: #CBD2DC;
  --soft: #E3E7EE;
  --rim: #DE2100;
  --rim-dark: #B31B00;
  --ok: #15803D;
  --err: #B91C1C;
  --zone-h: 390px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1 { font-size: 44px; line-height: 1.1; font-weight: 700; letter-spacing: 0; margin: 0; }
.sub { color: var(--muted); font-size: 18px; margin: 10px 0 0; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--rim); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 10px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--ink); color: #fff;
  font: 600 15px/1 'Inter', sans-serif;
  padding: 15px 22px; border-radius: 12px;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { background: #000; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--card); }
.link-btn { appearance: none; border: 0; background: none; color: var(--muted); font: 500 14px 'Inter', sans-serif; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--ink); }

/* ---------- Login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 24px; padding: 40px 36px;
  box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 20px 50px rgba(17,24,39,.06);
}
.login-card .sub { margin-bottom: 30px; font-size: 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 16px; }
.login-card input {
  display: block; width: 100%; margin-top: 8px;
  font: 400 16px 'Inter', sans-serif; color: var(--ink);
  padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17,24,39,.08); }
.login-card .btn { width: 100%; margin-top: 8px; }
.error { color: var(--err); font-size: 14px; min-height: 20px; margin: 14px 0 0; }

/* ---------- Upload screen ---------- */
#app { max-width: 1080px; margin: 0 auto; padding: 80px 80px 60px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.top .logo-sm { margin-bottom: 0; }
.score {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--soft); border-radius: 999px; padding: 12px 22px;
  font-size: 16px; color: var(--muted); white-space: nowrap;
}
.score strong { color: var(--ink); font-size: 20px; font-weight: 700; display: inline-block; min-width: 12px; }
.score.bump strong { animation: bump .5s ease; }
@keyframes bump { 0%{transform:scale(1)} 40%{transform:scale(1.5);color:var(--rim)} 100%{transform:scale(1)} }

.court { position: relative; width: min(580px, 100%); margin: 70px auto 0; padding-bottom: 170px; }
.zone {
  position: relative; height: var(--zone-h);
  background: var(--card); border: 2px dashed var(--line); border-radius: 22px;
  text-align: center; padding-top: 46px; cursor: pointer; outline: none;
  transition: border-color .2s ease, background .2s ease;
}
.zone:focus-visible, .zone.over { border-color: var(--rim); }
.zone.over { background: #FFF5F3; }
.zone-icon { width: 40px; height: 40px; color: #6B7280; }
.zone-title { font-size: 30px; font-weight: 500; margin: 18px 0 8px; }
.zone-sub { font-size: 20px; color: var(--faint); margin: 0; }
.backboard {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  width: 200px; height: 118px; border: 4px solid var(--rim); border-radius: 4px; background: #fff;
}
.hoop { position: absolute; left: 50%; top: calc(var(--zone-h) - 24px); width: 240px; height: 180px; transform: translateX(-50%); overflow: visible; pointer-events: none; }
.net { transform-origin: 120px 20px; }
.net line { stroke: #AEB5C0; stroke-width: 2.4; stroke-linecap: round; }
@keyframes swish { 0%{transform:scaleY(1)} 30%{transform:scaleY(1.18) scaleX(.94)} 60%{transform:scaleY(.94)} 100%{transform:scaleY(1)} }

.flyer {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  width: 54px; height: 66px; margin: -33px 0 0 -27px;
  background: #fff; border-radius: 6px 14px 6px 6px;
  box-shadow: 0 8px 22px rgba(17,24,39,.18);
  display: grid; place-items: end center; padding-bottom: 9px;
}
.flyer b { background: #DE2100; color: #fff; font-size: 10px; font-weight: 700; padding: 3px 6px; border-radius: 4px; }

/* ---------- Results ---------- */
.list { list-style: none; margin: 0 auto; padding: 0; width: min(580px, 100%); display: grid; gap: 12px; }
.row {
  display: grid; grid-template-columns: 48px 1fr; gap: 16px; align-items: start;
  background: var(--card); border-radius: 16px; padding: 18px 20px;
  animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ext {
  width: 48px; height: 48px; border-radius: 12px; background: var(--soft);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
}
.meta { min-width: 0; }
.name { font-weight: 600; font-size: 16px; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info { color: var(--muted); font-size: 14px; margin: 0; }
.info.err { color: var(--err); }
.bar { height: 4px; background: var(--soft); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--rim); border-radius: 4px; transition: width .2s ease; }
.share { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.url {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none;
  background: var(--bg); border-radius: 10px; padding: 11px 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.url:hover { text-decoration: underline; }
.share .btn { padding: 11px 18px; font-size: 14px; border-radius: 10px; flex: none; }
.swishtag { color: var(--rim); font-weight: 600; }

.foot { width: min(580px, 100%); margin: 36px auto 0; display: flex; justify-content: flex-end; color: var(--faint); font-size: 14px; }
.demo { width: min(580px, 100%); margin: 0 auto 16px; background: #FFF4E5; color: #92400E; border-radius: 12px; padding: 12px 16px; font-size: 14px; }

/* ---------- Download page ---------- */
.dl { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.dl-card {
  width: 100%; max-width: 460px; background: var(--card); border-radius: 24px; padding: 44px 36px 36px;
  text-align: center; box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 20px 50px rgba(17,24,39,.06);
}
.doc {
  position: relative; width: 84px; height: 104px; margin: 6px auto 26px;
  background: var(--bg); border-radius: 8px 22px 8px 8px;
  display: grid; place-items: end center; padding-bottom: 14px;
}
.doc b { background: var(--rim); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 5px; text-transform: uppercase; }
.dl-card h1 { font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
.dl-card .sub { font-size: 15px; margin: 10px 0 30px; }
.dl-card .btn { display: block; width: 100%; text-decoration: none; text-align: center; }
.dl-card .btn + .btn { margin-top: 10px; }
.brandline { margin-top: 28px; font-size: 13px; color: var(--faint); }
.brandline b { color: var(--ink); font-weight: 600; }
.spinner { width: 28px; height: 28px; margin: 30px auto; border: 3px solid var(--soft); border-top-color: var(--rim); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  :root { --zone-h: 340px; }
  #app { padding: 36px 16px 40px; }
  h1 { font-size: 32px; }
  .sub { font-size: 16px; }
  .top { gap: 16px; }
  .court { margin-top: 36px; }
  .zone { padding-top: 34px; }
  .zone-title { font-size: 24px; }
  .zone-sub { font-size: 17px; }
  .backboard { width: 180px; height: 104px; }
  .share { flex-wrap: wrap; }
  .share .btn { flex: 1; }
  .login-card, .dl-card { padding: 34px 24px 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Logo ---------- */
.logo { display: block; height: 26px; width: auto; margin: 0 0 22px; }
.logo-sm { height: 22px; margin-bottom: 18px; }
.dl { align-content: center; }
.logo-dl { height: 28px; margin: 0 auto 28px; }

/* ---------- Upload limit ---------- */
.zone-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.zone-limit { margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); background: var(--soft); padding: 5px 12px; border-radius: 999px; display: inline-block; }

/* ---------- History ---------- */
.hist-btn {
  appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  background: var(--soft); color: var(--ink); font: 600 15px 'Inter', sans-serif;
  padding: 12px 18px; border-radius: 999px; transition: background .2s;
}
.hist-btn:hover { background: var(--line); }
.hist-btn svg { width: 18px; height: 18px; }
.scrim { position: fixed; inset: 0; background: rgba(17,24,39,.18); opacity: 0; transition: opacity .25s; z-index: 40; }
.scrim.on { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); z-index: 50;
  box-shadow: -20px 0 50px rgba(17,24,39,.08); padding: 28px 24px; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.3,.1,.3,1); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 24px; font-weight: 700; }
.close-btn { appearance: none; border: 0; background: var(--soft); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.close-btn:hover { background: var(--line); }
.close-btn svg { width: 16px; height: 16px; }
.drawer-sub { color: var(--muted); font-size: 14px; margin: 6px 0 20px; }
.hist-list { list-style: none; margin: 0 -8px; padding: 0; overflow-y: auto; flex: 1; }
.hist-item { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--soft); }
.hist-item:last-child { border-bottom: 0; }
.hist-item .ext { flex: none; }
.hist-meta { flex: 1; min-width: 0; }
.hist-meta .name { margin: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-meta .info { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; flex: none; margin: 0; }
.hist-empty { color: var(--muted); font-size: 14px; padding: 24px 8px; }


/* ---------- Alignment ---------- */
.top { width: min(580px, 100%); margin: 0 auto; }
.logo-out { display: none; }
@media (max-width: 720px) {
  #login { place-items: center; align-content: center; }
  .logo-out { display: block; height: 28px; margin: 0 auto 28px; }
  .logo-in { display: none; }
}

/* ---------- Manual copy ---------- */
.share { flex-wrap: wrap; }
.manual { flex-basis: 100%; margin: 2px 0 0; font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }
.manual-link { color: var(--muted); -webkit-user-select: all; user-select: all; }

/* ---------- Header actions ---------- */
.top-actions { display: flex; align-items: center; gap: 18px; }
@media (max-width: 720px) { .top-actions { gap: 12px; } .top .logo-sm { height: 20px; } .hist-btn { padding: 10px 14px; font-size: 14px; } }
@media (max-width: 400px) { .zone-tags { gap: 6px; } .zone-limit { font-size: 12px; padding: 5px 10px; } }

/* ---------- Zone note ---------- */
.zone-note { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
@media (max-width: 400px) { .zone-note { font-size: 12px; } }
