/* Layout: airmail desk. Panel docked left, a sky of stamps and luggage tags drifting with the pointer on the right. */
:root {
  --sky: #e8eef5;          /* page ground, airmail paper with a blue bias */
  --sky-deep: #d3deea;
  --paper: #fbfcfe;        /* panel surface */
  --ink: #15233f;          /* text */
  --ink-soft: #5a6885;
  --line: #d6dde8;
  --red: #c8283c;          /* airmail stripe red */
  --blue: #2346c8;         /* airmail stripe blue, primary action */
  --blue-ink: #ffffff;
  --stamp: #fffdf6;
  --ok: #1f7a4d;
  --shadow: 0 1px 2px rgb(21 35 63 / .08), 0 12px 32px rgb(21 35 63 / .12);
  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #0f1a30; --sky-deep: #0a1324; --paper: #16233d; --ink: #e9eef7; --ink-soft: #9aa8c2;
    --line: #2a3a5c; --red: #ef5568; --blue: #6f8cff; --blue-ink: #0b1430; --stamp: #f3efe2; --ok: #4fc58a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky: #0f1a30; --sky-deep: #0a1324; --paper: #16233d; --ink: #e9eef7; --ink-soft: #9aa8c2;
  --line: #2a3a5c; --red: #ef5568; --blue: #6f8cff; --blue-ink: #0b1430; --stamp: #f3efe2; --ok: #4fc58a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px rgb(0 0 0 / .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* iOS only honors a horizontal lock set on the root, so both get it; clip avoids creating a scroll box. */
html, body { overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
body {
  background: radial-gradient(120% 90% at 75% 40%, var(--sky) 0%, var(--sky-deep) 100%), var(--sky);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
a { color: var(--blue); }

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 24px;
  position: relative;
  overflow-x: clip; /* decorations may poke past the edge; they never widen the page */
}

/* top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 3; }
.brand { display: flex; align-items: center; gap: 10px; font: 800 22px/1 var(--font-display); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; height: 22px; border-radius: 5px; background: var(--paper); border: 2px solid var(--ink); position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 6px; right: 6px; top: -6px; height: 6px; border: 2px solid var(--ink); border-bottom: 0; border-radius: 4px 4px 0 0; }
.who { display: flex; align-items: center; gap: 4px; background: var(--paper); border-radius: 999px; padding: 4px 4px 4px 14px; box-shadow: var(--shadow); min-width: 0; }
.who span { font-size: 13px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who button { border: 0; background: var(--sky); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; }
@media (max-width: 520px) { .who span { display: none; } .who { padding-left: 4px; } } /* phones: keep the buttons, drop the email */
.who button:hover { background: var(--line); }

/* footer credit: an airmail label with the stripes on both ends */
.credit {
  justify-self: center; position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  font: 500 11px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
}
.credit span { color: var(--ink); font-weight: 500; }
.credit::before, .credit::after {
  content: ""; width: 44px; height: 6px; border-radius: 2px;
  background: repeating-linear-gradient(-45deg, var(--red) 0 5px, transparent 5px 8px, var(--blue) 8px 13px, transparent 13px 16px);
}

/* main */
.main { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 32px; align-items: center; padding-block: 24px; position: relative; }

/* panel: an airmail envelope */
.panel { position: relative; z-index: 2; background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); padding: 10px; }
.panel::before {
  content: ""; position: absolute; inset: 0; border-radius: 18px; padding: 6px; pointer-events: none;
  background: repeating-linear-gradient(-45deg, var(--red) 0 14px, var(--paper) 14px 22px, var(--blue) 22px 36px, var(--paper) 36px 44px);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.panel-inner { display: grid; gap: 14px; padding: 18px; }
.panel-inner h2 { font: 800 22px/1.15 var(--font-display); margin: 0; text-wrap: balance; }
.panel-inner > p { margin: 0; color: var(--ink-soft); }

.drop {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 10px; justify-items: start;
  transition: border-color .15s, background-color .15s;
}
.drop.over { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent); }
.drop-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; transition: background-color .15s, border-color .15s; }
.chip-btn:hover { border-color: var(--ink-soft); background: var(--sky); }
.hint { color: var(--ink-soft); font-size: 13px; margin: 0; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 148px; overflow: auto; }
.files li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; min-width: 0; }
.files li.too-big .fsize { color: var(--red); }
.files .thumb { width: 42px; height: 28px; border-radius: 5px; cursor: default; }
.ext { font: 500 11px/1 var(--font-mono); text-transform: uppercase; background: var(--sky); border-radius: 5px; padding: 5px 6px; min-width: 42px; text-align: center; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fsize { font: 500 12px/1 var(--font-mono); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rm { border: 0; background: none; cursor: pointer; color: var(--ink-soft); width: 24px; height: 24px; border-radius: 6px; }
.rm:hover { background: var(--sky); color: var(--red); }

.weight { display: grid; gap: 6px; }
.weight-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); }
.weight-row b { font: 500 13px/1 var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: var(--sky); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: inherit; transition: width .3s ease; }
.meter.full i { background: var(--red); }

.field { display: grid; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 6px 0; outline: none; border-radius: 0;
}
.field input:focus, .field textarea:focus, .field select:focus { border-bottom-color: var(--blue); }
.field textarea { resize: none; min-height: 44px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.err { color: var(--red); font-size: 13px; margin: 0; min-height: 1em; }
.msg { font-size: 14px; margin: 0; min-height: 1em; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--red); }

.send {
  border: 0; border-radius: 12px; padding: 13px 18px; cursor: pointer; font-weight: 600; font-size: 16px;
  background: var(--blue); color: var(--blue-ink); text-decoration: none; text-align: center;
  transition: transform .15s cubic-bezier(.3,.7,.4,1), filter .15s;
}
.send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.send:active { transform: translateY(0); }
.send:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

/* link from the send form to "Mis envíos" */
.mine-link {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 0 0; cursor: pointer;
  font-weight: 600; color: var(--blue); text-align: left;
}
.mine-link:hover span:last-child { transform: translateX(3px); }
.mine-link span:last-child { transition: transform .15s; }

/* "Mis envíos" */
.h-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.h-empty { background: var(--sky); border-radius: 12px; padding: 14px; color: var(--ink-soft); }
.hist { list-style: none; margin: 0; padding: 0; display: grid; }
.hist > li { display: grid; gap: 8px; padding-block: 14px; border-top: 1px solid var(--line); min-width: 0; }
.hist > li:first-child { border-top: 0; padding-top: 4px; }
.h-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.h-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 16px; }
.h-when { flex: none; font: 500 11px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); background: var(--sky); border-radius: 999px; padding: 5px 8px; }
.h-meta { margin: 0; color: var(--ink-soft); font-size: 13px; }
.h-files summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--blue); width: max-content; }
.h-files ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.h-files li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; min-width: 0; }
.h-acts, .h-confirm { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.h-acts .ghost, .h-confirm .ghost { padding: 6px 12px; font-size: 13px; }
.h-confirm span { flex-basis: 100%; font-size: 13px; color: var(--ink-soft); }
.ghost.danger { color: var(--red); }
.ghost.danger:hover { background: color-mix(in srgb, var(--red) 10%, var(--paper)); }

/* progress + done */
.status { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 18px; }
.ring { width: 132px; height: 132px; }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--sky); }
.ring .val { stroke: var(--blue); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .2s linear; }
.ring text { fill: var(--ink); font: 800 28px var(--font-display); }
.status h2 { font: 800 22px/1.15 var(--font-display); margin: 0; text-wrap: balance; }
.status p { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }
.link-box { display: flex; gap: 8px; width: 100%; }
.link-box input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--sky); font: 500 13px var(--font-mono); }
.ghost { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); }
.ghost:hover { background: var(--sky); }

/* download list */
.dl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dl li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; min-width: 0; }
.dl .acts { display: flex; gap: 6px; }
.dl button.ext { border: 0; cursor: pointer; }
.thumb { width: 42px; height: 42px; border-radius: 6px; overflow: hidden; background: var(--sky); border: 0; padding: 0; cursor: pointer; flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
span.thumb { cursor: default; }

/* preview viewer */
.viewer {
  border: 0; padding: 0; color: var(--ink); background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
  width: min(1100px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); max-width: none; max-height: none;
}
.viewer[open] { display: grid; grid-template-rows: auto 1fr; }
.viewer::backdrop { background: rgb(10 19 36 / .72); backdrop-filter: blur(4px); }
.v-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.v-title { display: grid; min-width: 0; flex: 1 1 200px; }
.v-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-title small { font: 500 12px/1.4 var(--font-mono); color: var(--ink-soft); }
.v-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.v-actions .send { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.v-actions button:disabled { opacity: .4; cursor: default; }
.v-body { min-height: 0; display: grid; place-items: center; background: var(--sky); overflow: auto; }
.v-body img, .v-body video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.v-body audio { width: min(520px, 90%); }
.v-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.v-body pre { align-self: stretch; justify-self: stretch; margin: 0; padding: 16px; font: 500 13px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.v-msg { padding: 24px; margin: 0; text-align: center; color: var(--ink-soft); max-width: 40ch; }
.dl .meta { min-width: 0; }
.dl .fname { display: block; }
.dl .fsize { display: block; margin-top: 2px; }
.note { white-space: pre-wrap; background: var(--sky); border-radius: 10px; padding: 10px 12px; margin: 0; overflow-wrap: anywhere; }

/* the sky */
/* Text and decorations get separate areas so the stamps never sit on the words. */
.stage { position: relative; min-height: 600px; container-type: inline-size; }
.copy { position: absolute; left: 0; top: 6%; width: 54%; z-index: 2; display: grid; gap: 16px; }
.sky { position: absolute; top: 0; right: 0; bottom: 0; width: 44%; }
.headline { margin: 0; font: 800 clamp(36px, 8.5cqi, 92px)/.95 var(--font-display); letter-spacing: -.035em; text-wrap: balance; max-width: 9ch; }
.headline em { font-style: normal; color: var(--red); }
.sub { max-width: 34ch; color: var(--ink-soft); margin: 0; }
.layer { position: absolute; z-index: 1; will-change: transform; pointer-events: none; }

.stamp {
  /* perforated edge: holes tile the padding ring, the content box stays solid */
  background: var(--stamp); color: #15233f; padding: 10px;
  filter: drop-shadow(0 6px 12px rgb(21 35 63 / .2));
  -webkit-mask: radial-gradient(circle 3px, transparent 97%, #000) -5px -5px / 10px 10px round, linear-gradient(#000 0 0) content-box;
  mask: radial-gradient(circle 3px, transparent 97%, #000) -5px -5px / 10px 10px round, linear-gradient(#000 0 0) content-box;
}
.stamp-art { width: 100%; aspect-ratio: 4/5; border-radius: 2px; display: grid; place-items: end start; padding: 8px; font: 800 18px/1 var(--font-display); }
.stamp small { display: flex; justify-content: space-between; font: 500 10px/1 var(--font-mono); margin-top: 8px; letter-spacing: .06em; }

.tag {
  background: var(--stamp); color: #15233f; border-radius: 10px; padding: 12px 14px 12px 26px; position: relative;
  box-shadow: 0 6px 18px rgb(21 35 63 / .18); font: 500 12px/1.3 var(--font-mono);
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
}
.tag::before { content: ""; position: absolute; left: 12px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--sky-deep); box-shadow: inset 0 0 0 2px #15233f33; }
.tag b { display: block; font: 800 22px/1 var(--font-display); letter-spacing: -.02em; }

.postmark { width: 120px; height: 120px; border: 2px solid currentColor; border-radius: 50%; color: color-mix(in srgb, var(--ink) 35%, transparent); display: grid; place-items: center; font: 500 11px/1.3 var(--font-mono); text-align: center; letter-spacing: .08em; }
.postmark::after { content: ""; position: absolute; left: 100%; top: 38%; width: 90px; height: 26px; background: repeating-linear-gradient(transparent 0 4px, currentColor 4px 6px); border-radius: 50%; }

/* Narrow desktops: the sky column is too thin for every piece, keep the main four. */
@media (min-width: 861px) and (max-width: 1180px) {
  .layer.extra, .sky .l-c { display: none; }
}

/* Phones: headline first, then the envelope panel with the stamps tucked behind it,
   their tops peeking out above the envelope's edge. */
@media (max-width: 860px) {
  /* wider side margin on phones so text never sits on the screen edge */
  .app {
    padding-left: max(24px, env(safe-area-inset-left, 0px));
    padding-right: max(24px, env(safe-area-inset-right, 0px));
  }
  .main {
    grid-template-columns: 1fr;
    grid-template-areas: "copy" "deck";
    row-gap: 72px; /* room for the stamps that peek out above the panel */
    align-items: start;
    align-content: center; /* short pages sit in the middle instead of leaving a hole at the bottom */
  }
  .stage { display: contents; }
  .copy { position: static; grid-area: copy; width: 100%; }
  .panel { grid-area: deck; margin-bottom: 84px; } /* room for the pieces hanging below the panel */
  .sky { position: relative; grid-area: deck; width: auto; height: auto; top: auto; margin-top: -72px; align-self: stretch; z-index: 0; }
  .layer { scale: .7; }
  .layer.extra { display: none; }
  /* two pieces peek out above the envelope... */
  .sky .l-mark { left: -6px !important; right: auto !important; top: -4px !important; bottom: auto !important; }
  .sky .l-b    { left: 36% !important; right: auto !important; top: 4px !important; bottom: auto !important; }
  .sky .l-a    { right: -6px !important; left: auto !important; top: -16px !important; bottom: auto !important; }
  /* ...and two hang below it, mirroring the top so the composition is balanced */
  .sky .l-c    { left: 4% !important; right: auto !important; top: auto !important; bottom: -22px !important; }
  .sky .l-tag  { right: 0 !important; left: auto !important; top: auto !important; bottom: 14px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .send, .meter i, .ring .val { transition: none; }
}
