:root {
  --brand: #00BCC9; --brand-600: #009BA7; --brand-700: #007C86;
  --brand-100: #D9F5F7; --cloud: #E0F7F9; --soft: #F2FBFC;
  --pink: #D93D86; --orange: #F38D04; --dark: #141419; --muted: #6B7280;
  --surface: #FAFAFA; --white: #fff;
  --shadow-card: 0 14px 34px -10px rgba(0,0,0,.06);
  --shadow-hover: 0 20px 40px -15px rgba(0,188,201,.35);
  --r: 1.5rem; --r-lg: 2.5rem;
}
* { box-sizing: border-box; }
/* Any class below this line may set `display` on an element that also
   carries the `hidden` attribute (e.g. .cat-card, .actions). Without this,
   the class selector's `display` wins over the UA stylesheet's `[hidden]`
   rule by specificity, and `hidden` stops hiding anything. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--surface); color: var(--dark); font-family: Poppins, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: "Amatic SC", cursive; font-weight: 700; letter-spacing: .02em; color: var(--brand-700); margin: 0 0 .5rem; }
h1 { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1; }
h2 { font-size: 2.4rem; }
a { color: var(--brand-700); }
.top { display: flex; align-items: baseline; gap: .8rem; padding: 1rem 1.5rem; }
.logo { font-family: "Amatic SC", cursive; font-size: 2rem; font-weight: 700; text-decoration: none; color: var(--brand-700); }
.tag { color: var(--muted); font-size: .9rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem; }
.card { background: var(--white); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 1.5rem; }
.narrow { max-width: 380px; margin: 3rem auto; }
.cloud { background: var(--cloud); border-radius: var(--r-lg); padding: 2rem; display: grid; gap: 1.5rem; grid-template-columns: 1fr; margin-bottom: 2.5rem; }
@media (min-width: 820px) { .cloud { grid-template-columns: 1.1fr 1fr; align-items: center; padding: 2.5rem; } }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; font-weight: 500; font-size: .95rem; }
.input { font: inherit; padding: .8rem 1rem; border: 2px solid var(--brand-100); border-radius: 999px; background: var(--soft); }
.input:focus { outline: none; border-color: var(--brand); }
.input[type=file] { border-radius: var(--r); }
.pills { display: flex; gap: .5rem; }
.pill {
  position: relative; width: 3rem; height: 3rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--soft); border: 2px solid var(--brand-100); cursor: pointer;
}
.pill:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.pill:has(input:focus-visible) { outline: 2px solid var(--brand-700); outline-offset: 2px; }
.btn { display: inline-block; font: inherit; font-weight: 700; padding: .85rem 1.6rem; border-radius: 999px; border: 0; background: var(--brand); color: #fff; text-decoration: none; cursor: pointer; text-align: center; transition: transform .2s, box-shadow .2s; }
.btn:hover { background: var(--brand-600); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn-ghost { background: var(--white); color: var(--brand-700); border: 2px solid var(--brand-100); }
.muted { color: var(--muted); }
.small { font-size: .8rem; margin: .3rem 0 0; }
.error { color: var(--pink); margin: 0; }
.grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.cat-card { display: block; background: var(--white); border-radius: var(--r); box-shadow: var(--shadow-card); overflow: hidden; text-decoration: none; color: inherit; transition: transform .28s cubic-bezier(.34,1.56,.64,1), box-shadow .28s; }
.cat-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); }
.cat-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #fff; }
.placeholder { aspect-ratio: 1; display: grid; place-items: center; font-size: 3rem; background: var(--soft); }
.placeholder.big { font-size: 6rem; border-radius: var(--r); }
.cat-meta { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; padding: .8rem 1rem; font-size: .9rem; }
.badge { padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-done { background: #DCFCE7; color: #065F46; }
.badge-running, .badge-queued, .badge-new { background: #FEF3C7; color: #92400E; }
.badge-error { background: #FEE2E2; color: #991B1B; }
.back { display: inline-block; margin: .5rem 0 1rem; text-decoration: none; }
.cat-page { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 820px) { .cat-page { grid-template-columns: 1fr 1fr; align-items: start; } }
.preview-box img { width: 100%; border-radius: var(--r); display: block; }
.status { padding: .8rem 1.2rem; border-radius: 999px; font-weight: 500; background: var(--soft); }
.status-running, .status-queued { background: #FEF3C7; }
.status-done { background: #DCFCE7; }
.status-error { background: #FEE2E2; color: #DC2626; }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--brand-700); font-weight: 500; }
.atlases { display: grid; gap: .8rem; margin-top: .8rem; }
.atlases img { width: 100%; border-radius: 1rem; box-shadow: var(--shadow-card); }
.search-field input[type=search] { max-width: 320px; }

@media (max-width: 524px) {
  /* Grid/flex items default to a content-based minimum width, which lets long
     headings and the native file-input widget push their container wider
     than the viewport. Let them shrink to fit instead. */
  .cloud > *, .stack, .field, .cat-page > * { min-width: 0; }
  h1 { overflow-wrap: break-word; }

  .cloud { padding: 1.25rem; border-radius: var(--r); }
  .card { padding: 1.1rem; }
  .input[type=file] { width: 100%; }

  .grid { grid-template-columns: repeat(auto-fit, minmax(160px, 220px)); justify-content: center; }
}
