:root {
  --ink: #171713;
  --paper: #f5f3ed;
  --card: #fffef9;
  --acid: #c9ff37;
  --blue: #5068ff;
  --muted: #77766e;
  --line: #d8d6cd;
  --shadow: 0 18px 50px rgba(23, 23, 19, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 6%, rgba(80,104,255,.13), transparent 26rem),
    linear-gradient(90deg, rgba(23,23,19,.035) 1px, transparent 1px),
    linear-gradient(rgba(23,23,19,.035) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

button, input { font: inherit; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

.hero { padding: 34px 0 64px; position: relative; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 850; letter-spacing: -.03em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--ink); color: var(--acid); border-radius: 9px; transform: rotate(-4deg); }
.eyebrow { margin-top: 72px; color: var(--blue); text-transform: uppercase; font-size: .75rem; font-weight: 850; letter-spacing: .14em; }
h1 { margin: 12px 0 16px; font-size: clamp(3rem, 8vw, 6.6rem); line-height: .91; letter-spacing: -.075em; max-width: 900px; }
h1 span { color: var(--blue); }
.intro { max-width: 680px; color: #55554f; font-size: clamp(1rem, 2vw, 1.22rem); line-height: 1.6; }

.workspace { display: grid; gap: 20px; padding-bottom: 42px; }
.panel { position: relative; background: rgba(255,254,249,.93); border: 1px solid var(--line); border-radius: 24px; padding: 30px; box-shadow: var(--shadow); overflow: hidden; }
.step { position: absolute; right: 24px; top: 18px; font-size: 4rem; line-height: 1; font-weight: 900; letter-spacing: -.08em; color: rgba(23,23,19,.06); }
h2 { margin: 0 0 24px; font-size: 1.25rem; letter-spacing: -.025em; }
label { display: block; margin-bottom: 9px; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.url-row { display: grid; grid-template-columns: 1fr auto; border: 2px solid var(--ink); border-radius: 15px; overflow: hidden; background: white; }
.url-row:focus-within { box-shadow: 0 0 0 4px rgba(80,104,255,.18); border-color: var(--blue); }
input[type="url"] { width: 100%; border: 0; outline: 0; padding: 17px 18px; min-width: 0; background: transparent; }
#process-button { border: 0; border-left: 2px solid var(--ink); padding: 0 22px; background: var(--acid); color: var(--ink); font-weight: 850; display: flex; gap: 14px; align-items: center; cursor: pointer; }
#process-button:hover { background: #b9f21e; }
#process-button:disabled { cursor: wait; opacity: .7; }
.rights-check { margin: 14px 0 0; display: flex; align-items: center; gap: 9px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.rights-check input { accent-color: var(--blue); width: 16px; height: 16px; }
.status { min-height: 22px; margin-top: 15px; color: var(--muted); font-size: .9rem; }
.status.error { color: #b62a2a; }
.status.success { color: #257338; }

.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.pill { font-size: .74rem; font-weight: 800; padding: 7px 10px; background: #ecebe5; border-radius: 999px; color: var(--muted); }
.source-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
figure { margin: 0; }
.image-frame { aspect-ratio: 1; border-radius: 16px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.image-frame.light { background: #fff; }
.image-frame.dark { background: #191919; }
.image-frame img { display: none; width: 100%; height: 100%; object-fit: contain; }
.image-frame img.ready { display: block; }
figcaption { margin-top: 9px; color: var(--muted); font-size: .8rem; }

.result-panel { background: var(--ink); color: white; border-color: var(--ink); }
.result-panel .step { color: rgba(255,255,255,.08); }
.result-panel h2 { margin-bottom: 4px; }
#result-meta { margin: 0; color: #aaa9a1; font-size: .8rem; }
.download { background: var(--acid); color: var(--ink); border: 0; border-radius: 11px; padding: 12px 16px; font-weight: 850; cursor: pointer; }
.download:disabled { opacity: .3; cursor: not-allowed; }
.result-stage { min-height: 420px; border-radius: 16px; position: relative; display: grid; place-items: center; overflow: hidden; }
.checkerboard { background-color: #ddd; background-image: linear-gradient(45deg,#bbb 25%,transparent 25%),linear-gradient(-45deg,#bbb 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#bbb 75%),linear-gradient(-45deg,transparent 75%,#bbb 75%); background-size: 24px 24px; background-position: 0 0,0 12px,12px -12px,-12px 0; }
#result-canvas { display: none; width: min(100%, 630px); height: auto; }
#result-canvas.ready { display: block; }
.empty-result { color: #555; font-weight: 750; background: rgba(255,255,255,.72); padding: 10px 14px; border-radius: 999px; }
footer { display: flex; justify-content: space-between; gap: 24px; padding: 20px 0 44px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; line-height: 1.55; }
footer p { margin: 0; max-width: 620px; }

@media (min-width: 820px) {
  .workspace { grid-template-columns: .88fr 1.12fr; }
  .input-panel, .result-panel { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1120px); }
  .hero { padding-top: 22px; }
  .eyebrow { margin-top: 52px; }
  .panel { padding: 22px 18px; border-radius: 18px; }
  .url-row { grid-template-columns: 1fr; }
  #process-button { border-left: 0; border-top: 2px solid var(--ink); justify-content: space-between; padding: 14px 18px; }
  .source-grid { gap: 10px; }
  .panel-heading { align-items: center; }
  .result-stage { min-height: 300px; }
  footer { flex-direction: column; }
}
