/* drop.baase.site — an after-hours deposit counter for images.
   IBM Plex (Mono for structure, Sans for prose). The receipt card is the one
   designed object; the rest is the quiet counter around it. */

:root {
  --desk:   #d9d9cf;   /* page */
  --paper:  #fbfaf5;   /* slot + receipts */
  --ink:    #262521;   /* receipt / stamp ink */
  --muted:  #6d6659;
  --line:   #d4cfc1;
  --stamp:  #a8500c;   /* expiry time, claim tick, copied state */
  --soon:   #97281a;   /* under five minutes */
  --danger: #97281a;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --maxw: 37rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk:   #14171a;
    --paper:  #232019;
    --ink:    #ece7db;
    --muted:  #9d9686;
    --line:   #3c392f;
    --stamp:  #e79a44;
    --soon:   #e5735a;
    --danger: #e5735a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--desk);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  padding: 1.1rem 1.15rem 3rem;
  display: flex;
  flex-direction: column;
}
.wrap--wide { max-width: 64rem; }

/* ---------- header / footer ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.9rem;
  margin-bottom: 1.9rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--mono);
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark b { font-weight: 600; }
.wordmark__rest { color: var(--muted); font-weight: 400; }

.topbar__admin {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}
.topbar__admin:hover { color: var(--ink); }

main { flex: 1; }

.foot {
  margin-top: 2.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}
.foot p { margin: 0; max-width: 34rem; }
.foot__v {
  margin-top: 0.5rem !important;
  font-family: var(--mono);
  font-size: 0.72rem;
  opacity: 0.7;
}

/* ---------- lede ---------- */

.lede { margin-bottom: 1.7rem; }

.lede h1 {
  margin: 0 0 0.65rem;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.45rem, 4.4vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.lede p {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.98rem;
}

/* ---------- uploader ---------- */

.uploader { display: flex; flex-direction: column; gap: 1.15rem; }

/* the deposit slot */
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 9.5rem;
  padding: 1.9rem 1.25rem;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: inset 0 9px 20px -16px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.slot:focus-within { outline: 2px solid var(--stamp); outline-offset: 3px; }
.slot.is-drag {
  border-color: var(--stamp);
  border-top-color: var(--stamp);
  background: color-mix(in srgb, var(--stamp) 8%, var(--paper));
}

.slot__icon { width: 2rem; height: 1.4rem; color: var(--stamp); }
.slot__title { font-family: var(--mono); font-weight: 500; font-size: 1rem; }
.slot__hint { color: var(--muted); font-size: 0.83rem; }

/* ---------- fields ---------- */

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field__label {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.field input,
.field select {
  font-family: var(--sans);
  font-size: 1rem;              /* keeps iOS from zooming */
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
  width: 100%;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--stamp);
  outline-offset: 1px;
}

.controls { display: flex; flex-direction: column; gap: 0.7rem; }

.field--expiry select {
  border-left: 3px solid var(--stamp);
  font-family: var(--mono);
  font-size: 0.95rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236d6659' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: calc(100% - 0.9rem) center;
  background-size: 12px 8px;
  background-repeat: no-repeat;
  padding-right: 2.6rem;
}
@media (prefers-color-scheme: dark) {
  .field--expiry select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%239a9384' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

.fineprint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

@media (min-width: 34rem) {
  .controls {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
  }
  .controls .field--expiry { flex: 1; max-width: 18rem; }
  .fineprint { text-align: right; }
}

/* ---------- meme captioner ---------- */

.linkbtn {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--ink); }
.linkbtn:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

.meme-launch { margin: 1.1rem 0 0; }

.meme {
  margin-top: 1.1rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.meme__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 8rem;
  background: color-mix(in srgb, var(--ink) 5%, var(--paper));
  border: 1px dashed var(--line);
  border-radius: 3px;
}
#meme-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
#meme-canvas[width="0"], #meme-canvas:not([width]) { display: none; }
.meme__empty { margin: 0; padding: 2rem 1rem; color: var(--muted); font-size: 0.85rem; }

.meme__fields { display: flex; flex-direction: column; gap: 0.5rem; }
.meme__fields input {
  font-family: var(--mono);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.65rem 0.7rem;
}
.meme__fields input:focus { outline: 2px solid var(--stamp); outline-offset: 1px; }

.meme__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.meme__actions .btn { flex: 0 0 auto; }

/* ---------- results ---------- */

.results { margin-top: 2.4rem; }
.results h2 {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.tickets { display: flex; flex-direction: column; gap: 1.3rem; }

/* ---------- the receipt ---------- */

.ticket {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 3px;
  overflow: hidden;
  animation: print 0.22s ease-out;
}
@keyframes print { from { transform: translateY(6px); opacity: 0; } }

.ticket--solo { margin-top: 0.5rem; }

.ticket__img {
  display: block;
  background: color-mix(in srgb, var(--ink) 5%, var(--paper));
}
.ticket__img img {
  display: block;
  width: 100%;
  max-height: 15rem;
  object-fit: contain;
}

/* torn edge: half-circle bites out of each side, dashed line beneath */
.ticket__perf {
  height: 15px;
  background:
    radial-gradient(circle at left, var(--desk) 7px, transparent 7.5px) left center / 15px 15px no-repeat,
    radial-gradient(circle at right, var(--desk) 7px, transparent 7.5px) right center / 15px 15px no-repeat;
  border-bottom: 1px dashed var(--line);
}

.ticket__body { padding: 0.9rem 1.05rem 1.05rem; }

.ticket__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.code {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  text-decoration: none;
}
.code::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.5rem;
  border-radius: 1px;
  background: var(--stamp);
  vertical-align: middle;
}

.countdown {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}
.countdown.is-warn { color: var(--stamp); }
.countdown.is-soon { color: var(--soon); font-weight: 600; }

.ticket__specs, .specs {
  margin: 0 0 0.9rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.copyrow { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.42rem 0.7rem;
  min-height: 2.1rem;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.chip:hover { border-color: var(--ink); }
.chip:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.chip.is-copied { border-color: var(--stamp); color: var(--stamp); }

.delline { margin: 0.85rem 0 0; font-size: 0.8rem; }
.delline a { color: var(--muted); }
.delline a:hover { color: var(--danger); }

.ticket__error {
  padding: 0.85rem 1.05rem;
  font-size: 0.86rem;
  color: var(--soon);
}
.ticket__error .code { color: inherit; font-size: 0.84rem; }
.ticket__error .code::before { background: var(--soon); }

.ticket.is-uploading .ticket__body { opacity: 0.55; }
.bar {
  height: 2px;
  width: 0;
  background: var(--stamp);
  transition: width 0.2s;
}

/* ---------- cards (view / delete / 404 / admin login) ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 2px solid var(--ink);
  border-radius: 3px;
  padding: 1.4rem 1.3rem;
}
.card h1 {
  margin: 0 0 0.65rem;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}
.card p { margin: 0 0 0.7rem; }
.card p:last-child { margin-bottom: 0; }
.card code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
.notice .code { font-size: 0.9rem; }

.delpreview { margin: 0 0 0.9rem; }
.delpreview img {
  max-width: 100%;
  max-height: 13rem;
  border-radius: 2px;
  border: 1px solid var(--line);
}

.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.delform { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.6rem 1rem;
  min-height: 2.6rem;
  border-radius: 3px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.alert {
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 3px;
  font-size: 0.88rem;
  background: color-mix(in srgb, var(--soon) 12%, var(--paper));
  color: var(--soon);
  border: 1px solid color-mix(in srgb, var(--soon) 30%, transparent);
}
.alert--ok {
  background: color-mix(in srgb, var(--stamp) 12%, var(--paper));
  color: var(--stamp);
  border-color: color-mix(in srgb, var(--stamp) 30%, transparent);
}

/* ---------- admin ---------- */

.admin__bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.admin__bar h1 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.inline { display: inline; margin: 0; }

.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.6rem;
  margin: 1.1rem 0 1.6rem;
  padding: 1rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.stats > div { display: flex; flex-direction: column; }
.stats__n { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; }
.stats__l { font-size: 0.74rem; color: var(--muted); }
.stats form { margin-left: auto; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 3px; }

.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 46rem;
  font-size: 0.84rem;
}
.grid th, .grid td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid th {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 4%, var(--paper));
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .thumb { width: 3rem; }
.grid .thumb img {
  width: 3rem; height: 3rem;
  object-fit: cover;
  border-radius: 2px;
  border: 1px solid var(--line);
  display: block;
}
.grid .dim { display: block; color: var(--muted); font-size: 0.75rem; }
.grid .code { font-size: 0.82rem; }
.grid .code::before { width: 5px; height: 5px; margin-right: 0.4rem; }
.row--expired { opacity: 0.5; }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}
.tag--soon { background: color-mix(in srgb, var(--soon) 16%, transparent); color: var(--soon); }

.rowacts form { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.rowacts button {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.28rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.rowacts button:hover { border-color: var(--ink); }
.rowacts button.danger { color: var(--danger); }

.muted { color: var(--muted); font-size: 0.85rem; }

.diag {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.diag summary { cursor: pointer; font-family: var(--mono); }
.diag dl { display: grid; gap: 0.6rem; margin: 0.9rem 0 0; }
.diag dt { font-family: var(--mono); color: var(--ink); }
.diag dd { margin: 0.15rem 0 0; word-break: break-all; }
.diag p { margin: 0.9rem 0 0; }
.diag code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 34rem) {
  .slot { min-height: 11rem; }
}
