/* =========================
   Design Tokens
   ========================= */
:root{
  --bg: #0b1020;
  --bg-grad: radial-gradient(1200px 800px at 70% -10%, #1a2447 0%, #0b1020 60%);
  --surface: #0f1530cc;
  --surface-strong:#141b3a;
  --text: #eaf0ff;
  --muted:#a8b0cf;
  --brand:#4f8cff;
  --brand-2:#8f7fff;
  --success:#18c29c;
  --danger:#ff6b6b;

  --radius:16px;
  --shadow: 0 8px 30px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.35);
  --outline: 0 0 0 3px #4f8cff40;
}

@media (prefers-color-scheme: light){
  :root{
    --bg:#f6f8ff;
    --bg-grad: radial-gradient(1200px 800px at 70% -10%, #e9edff 0%, #f6f8ff 60%);
    --surface:#ffffffee;
    --surface-strong:#ffffff;
    --text:#0d1224;
    --muted:#5d6786;
    --shadow: 0 8px 24px rgba(20,24,40,.12), 0 2px 6px rgba(20,24,40,.08);
    --outline: 0 0 0 3px #4f8cff33;
  }
}

/* =========================
   Base
   ========================= */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
.container{
  width:min(1100px, 92vw);
  margin: clamp(16px, 2.5vh, 24px) auto 72px;
}

/* =========================
   Topbar (optional)
   ========================= */
.topbar{
  position:sticky; top:0; z-index:10;
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  background: color-mix(in oklab, var(--surface) 65%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--surface-strong) 60%, transparent);
}
.topbar .brand{display:flex; align-items:center; gap:10px; text-decoration:none; padding:14px 0 12px; color:var(--text); font-weight:700;}
.brand-mark{display:block; filter: drop-shadow(0 2px 8px rgba(0,0,0,.25));}
.topbar .container{display:flex; align-items:center; justify-content:space-between;}
.topnav a{color:var(--muted); text-decoration:none; margin-left:18px; font-weight:500}
.topnav a:hover{color:var(--text)}

/* =========================
   Header / Hero
   ========================= */
header.site{
  text-align:center;
  padding:2.5rem 1rem;
  color:#fff;
  background:linear-gradient(135deg, #2563eb, #1e40af);
  border-bottom:3px solid #1e3a8a;
}
.site h1{
  font-size: clamp(28px, 3.6vw, 44px);
  line-height:1.1;
  margin: 32px 0 10px;
  letter-spacing:-0.02em;
}
header .lede{
  max-width:60ch;
  margin:.5rem auto 0;
  color: rgba(255,255,255,0.9);
  font-weight:400;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* =========================
   Tool Card
   ========================= */
.tool{ margin-top:18px; }

.drop{
  background: var(--surface);
  border: 1px dashed color-mix(in srgb, var(--muted) 60%, transparent);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 32px);
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s, transform .1s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.drop:hover{ transform: translateY(-1px) }
.drop.dragover{
  border-color: var(--brand);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 25%, transparent), var(--shadow);
}
.drop-inner{
  display:grid;
  place-items:center;
  gap:10px;
  text-align:center;
  padding: 28px 10px;
}
.hint{ color:var(--muted); margin-top:4px }

.drop-inner p strong {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere; /* allows breaking mid-word */
  word-break: break-word;  /* breaks long strings */
  text-overflow: ellipsis;
  overflow: hidden;
}
/* =========================
   Options Panel
   ========================= */
.options{
  margin-top:18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3.6vw, 26px);
  overflow:hidden; /* prevent overflow artifacts */
}
.options .row{
  display:grid;
  grid-template-columns: 160px 1fr;
  gap:16px;
  align-items:center;
  margin: 12px 0;
}
.options label{ color:var(--muted) }

/* Inputs & selects */
select, input[type="file"]{
  background: var(--surface-strong);
  border:1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  color:var(--text);
  padding:12px 14px;
  border-radius: 12px;
  outline:none;
  display:block;
  width:100%;
  max-width:100%;
  box-sizing:border-box;
}
select:focus{ box-shadow: var(--outline); border-color: transparent }

/* Totals/sizes */
.mono{ font-variant-numeric: tabular-nums; color:var(--muted); margin-top:10px }
#orig, #est, #save { font-variant-numeric: tabular-nums; }
#save { color: var(--success); }

/* =========================
   Buttons
   ========================= */
.btn{
  appearance:none; border:0; cursor:pointer;
  padding:12px 18px; border-radius:12px;
  font-weight:600; letter-spacing:.01em;
  background: color-mix(in srgb, var(--surface-strong) 85%, #000 0%);
  color:var(--text);
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
}
.btn:hover{ transform:translateY(-1px) }
.btn:active{ transform:translateY(0) }
.btn:focus-visible{ box-shadow: var(--outline) }

/* Big blue picker button */
#pick.btn{
  background: var(--brand);
  color:#fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}
#pick.btn:hover{ background: var(--brand-2); }

/* Primary gradient button */
.btn.primary{
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color:#fff;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}
.btn.primary:hover{
  box-shadow: 0 12px 26px color-mix(in srgb, var(--brand) 35%, transparent);
}

/* Ghost button */
.btn.ghost{
  background: transparent;
  border:1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  color:var(--muted);
}

/* =========================
   Progress
   ========================= */
.progress{
  margin-top:18px;
  background: var(--surface-strong);
  border-radius: 12px;
  overflow:hidden;
  border:1px solid color-mix(in srgb, var(--muted) 25%, transparent);
}
.bar{
  height:10px;
  width:0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .25s ease;
}

/* =========================
   Result
   ========================= */
.result{
  margin-top:18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border:1px solid color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius: 12px;
  padding:16px;
}

/* =========================
   Privacy note
   ========================= */
.privacy{
  color:var(--muted);
  margin: 16px 2px 0;
  display:flex; align-items:center; gap:10px;
}
.privacy::before{
  content:"";
  inline-size:18px; block-size:18px;
  border-radius:6px;
  background: color-mix(in srgb, var(--success) 85%, white 0%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent);
}

/* =========================
   FAQ
   ========================= */
.faq{
  margin-top: 28px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3.6vw, 26px);
}
.faq h2{ margin:0 0 10px }
details{
  background: var(--surface-strong);
  border:1px solid color-mix(in srgb, var(--muted) 30%, transparent);
  border-radius:12px;
  padding: 12px 14px;
  margin: 10px 0;
}
details[open]{ border-color: color-mix(in srgb, var(--brand) 35%, transparent) }
summary{ cursor:pointer; font-weight:600 }

/* =========================
   Footer
   ========================= */
footer.site{
  text-align:center; color:var(--muted);
  padding:40px 0 60px;
}

/* =========================
   Mode Toggle (Video / Photo)
   ========================= */
.mode{ display:flex; gap:8px; margin: 0 0 12px; }
.chip{
  appearance:none;
  border:1px solid color-mix(in srgb, var(--muted) 40%, transparent);
  background: color-mix(in srgb, var(--surface-strong) 85%, transparent);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight:600;
}
.chip:hover{ border-color: var(--brand); }
.chip.selected{
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color:#fff;
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 28%, transparent);
}

/* =========================
   Manifesto Block
   ========================= */
.manifesto{
  text-align:center;
  background: radial-gradient(900px 400px at center, rgba(79,140,255,0.08), transparent 70%);
  color: #a8b0cf;
  max-width: 800px;
  margin: 5rem auto 3rem;
  padding: 2.8rem 1.8rem;
  border-radius: 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(79,140,255,0.15);
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
  animation: fadeInUp 1.2s ease-out;
}
.manifesto h2{
  color: #4f8cff;
  font-size: clamp(2rem, 3vw, 2.5rem);
  margin-bottom: 0.8rem;
  letter-spacing: -0.015em;
}
.manifesto p{
  line-height: 1.65;
  font-size: 1.05rem;
  margin: 1rem 0;
  color: #c3c9e6;
}
.manifesto strong{ color: #4f8cff; }
.manifesto .signoff{
  font-style: italic;
  color: #8f98c9;
  margin-top: 1.8rem;
  font-size: 1rem;
  line-height: 1.5;
}
@keyframes fadeInUp{
  from{ opacity:0; transform: translateY(25px); }
  to  { opacity:1; transform: translateY(0); }
}

/* =========================
   Utilities
   ========================= */
.hidden{ display:none !important }

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

/* Responsive polish */
@media (max-width: 720px){
  .options .row{ grid-template-columns:1fr; gap:8px }
  .topnav{ display:none }
}
/* Hide native file input field */
#file {
  display: none !important;
}
/* Visually hide but keep focusability and layout presence */
.sr-only-file {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);           /* legacy clip */
  clip-path: inset(50%);         /* modern */
  white-space: nowrap;
}
/* keep input programmatically clickable on iOS (not display:none) */
.sr-only-file{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
  opacity:0;
}