*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  font-family: var(--font-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }
a:hover { color: var(--ink); }

input, button, select, textarea { font-family: inherit; }

h1, h2, h3, p { margin: 0; }

@keyframes jwspin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes jwpop  { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes jwrise { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- App shell ---------- */

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
}
.screen--dark { background: var(--dark); color: var(--paper); }

/* ---------- Top bar ---------- */

.topbar {
  height: 76px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 48px;
  border-bottom: 2px solid var(--ink);
}
.screen--dark .topbar { border-bottom-color: var(--dark-700); }

/* ---------- Wordmark ---------- */

.mark { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.mark__jw {
  background: var(--purple);
  border: 2px solid var(--ink);
  box-shadow: var(--sh-1);
  padding: 1px 10px;
  font-weight: 800;
  font-size: 22px;
  transform: rotate(-4deg);
  color: var(--ink);
}
.mark__name { font-weight: 800; font-size: 24px; letter-spacing: -0.02em; }
.screen--dark .mark__jw { border-color: var(--paper); box-shadow: none; }

.mark--lg .mark__jw {
  padding: 4px 18px; font-size: 56px; border-width: 3px; box-shadow: var(--sh-3);
}
.mark--lg .mark__name { font-size: 64px; letter-spacing: -0.03em; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 58px;
  padding: 0 24px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover:not(:disabled) { background: var(--paper); transform: scale(1.05) rotate(-2deg); }
.btn:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }

.btn--primary {
  background: var(--purple);
  box-shadow: var(--sh-2);
  font-weight: 800;
  font-size: 20px;
}
.btn--primary:hover:not(:disabled) { background: var(--purple-lift); transform: scale(1.05) rotate(-2deg); }
.btn--primary:active:not(:disabled) { transform: scale(0.97) rotate(1deg); box-shadow: 1px 1px 0 var(--ink); }

.btn--ink {
  background: var(--ink); color: var(--surface);
  box-shadow: 4px 4px 0 var(--surface);
  font-weight: 800;
}
.btn--ink:hover:not(:disabled) { background: var(--dark-800); transform: scale(1.05) rotate(-2deg); }

.btn--ghost-light {
  background: transparent; color: var(--paper); border-color: var(--paper);
}
.btn--ghost-light:hover:not(:disabled) { background: rgba(243,238,228,.12); transform: scale(1.05) rotate(-2deg); }

.btn--lg { height: 64px; font-size: 22px; }
.btn--sm { height: 48px; font-size: 16px; border-radius: var(--r-md); }

.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: var(--sh-5);
  border-radius: var(--r-xl);
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- Form primitives ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-weight: 600; font-size: 15px; }

.input {
  height: 58px;
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  padding: 0 16px;
  font-size: 19px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  width: 100%;
  transition: box-shadow .12s;
}
.input:focus { box-shadow: var(--sh-2); }
.input::placeholder { color: var(--ink-500); }

/* ---------- Mono / pills ---------- */

.mono { font-family: var(--font-mono); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: .08em;
}

.pill {
  font-family: var(--font-mono);
  font-size: 15px;
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}

.tag {
  background: var(--purple);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: 4px 14px;
  font-weight: 800;
  font-size: 16px;
}

/* ---------- Avatars ---------- */

.avatar {
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--ink);
  line-height: 1;
  user-select: none;
}

/* ---------- Segmented control ---------- */

.seg {
  display: flex;
  border: 2px solid var(--ink);
  border-radius: var(--r-md);
  overflow: hidden;
}
.seg__opt {
  flex: 1;
  height: 48px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
  background: var(--surface);
  border: 0;
  color: var(--ink);
  transition: background .12s;
}
.seg__opt:hover { background: var(--paper); }
.seg__opt[aria-pressed="true"] { background: var(--purple); }

/* ---------- Meme frame ---------- */

.meme {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--ink);
  background: repeating-linear-gradient(135deg, var(--pastel-sand-2) 0 14px, var(--pastel-sand) 14px 28px);
  flex-shrink: 0;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Captions size themselves against this box, not the viewport. */
  container-type: size;
}
.meme--shadow { box-shadow: var(--sh-6); }
.meme__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.meme__placeholder span {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-500);
  background: var(--paper);
  padding: 4px 8px;
}
.meme__text {
  position: absolute;
  font-family: var(--font-meme);
  font-size: calc(var(--meme-fs, 6.8) * 1cqw);
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  line-height: 1.05;
  text-shadow: var(--meme-outline-3);
  display: grid;
  place-items: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  pointer-events: none;
}
/* Caption font and outline, as set per template in the studio. */
.meme__text--bold { font-family: var(--font-ui); font-weight: 800; }
.meme__text--mono { font-family: var(--font-mono); font-weight: 500; }
.meme__text--dark { text-shadow: -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff; }
.meme__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Dashed placeholders on admin thumbnails. */
.meme__marker {
  position: absolute;
  border: 2px dashed var(--ink);
  border-radius: 4px;
  background: rgba(255, 253, 248, .55);
  font-family: var(--font-mono);
  font-size: 11px;
  display: grid;
  place-items: center;
  color: var(--ink);
}

/* Timer ring (create screen). */
.timerRing {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--ink);
  flex-shrink: 0;
}
.timerRing__inner {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--paper);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 500;
}
.meme--on-dark {
  border-color: var(--paper);
  background: repeating-linear-gradient(135deg, var(--dark-700) 0 14px, var(--dark-800) 14px 28px);
}
.meme--on-dark .meme__placeholder span { color: var(--ink-400); background: transparent; }

/* ---------- Utility ---------- */

.spacer { flex: 1; }
.noscript { padding: 48px; font-family: system-ui, sans-serif; }
.row { display: flex; align-items: center; gap: 12px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
