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

:root {
  --bg: #eceae2;
  --surface: #fbfaf7;
  --card: var(--surface);
  --text: #17160f;
  --ink: var(--text);
  --muted: #8c897e;
  --border: rgba(23, 22, 15, 0.12);
  --line: var(--border);
  --line-soft: rgba(23, 22, 15, 0.07);
  --dot: rgba(23, 22, 15, 0.07);
  --accent: #e8593a;
  --accent-hover: #d9492b;
  --accent-h: var(--accent-hover);
  --focus: rgba(232, 89, 58, 0.5);
  --accent-soft: rgba(232, 89, 58, 0.1);
  --control-bg: rgba(23, 22, 15, 0.05);
  --control-bg-hover: rgba(23, 22, 15, 0.08);
  --shadow-soft: 0 4px 16px rgba(23, 22, 15, 0.05);
  --shadow-toast: 0 12px 40px rgba(23, 22, 15, 0.25);
  --radius-xs: 6px;
  --radius-sm: 7px;
  --radius-md: 8px;
  --radius-lg: 9px;
  --radius-xl: 12px;
  --f-display: 'Micro 5', monospace;
  --f-ui: 'Inter', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', monospace;
  --content-max: 1000px;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-ui);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: rgba(23, 22, 15, 0.18) transparent;
  scrollbar-width: thin;
}

body.meme-page {
  --content-max: 860px;
  display: flex;
  flex-direction: column;
}

body.font-page {
  --content-max: 1000px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.is-hidden {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.meme-header {
  position: relative;
  padding-inline: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-name {
  color: var(--text);
  font-family: var(--f-display);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.04em;
}

.site-tagline {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 400;
}

.nav {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.nav a {
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: rgba(23, 22, 15, 0.05);
  color: var(--text);
}

.nav a.active {
  background: var(--text);
  color: var(--bg);
}

/* Meme maker */
.meme-app {
  display: grid;
  flex: none;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 62px);
  overflow: hidden;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  padding: 0.72rem 0.85rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.upload-zone {
  padding: 0.62rem 0.75rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.upload-zone:hover,
.upload-zone.over {
  background: rgba(232, 89, 58, 0.06);
  border-color: rgba(232, 89, 58, 0.5);
  color: var(--text);
}

.upload-zone .icon {
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto 0.18rem;
  opacity: 0.35;
}

.upload-zone .hint {
  display: block;
  margin-top: 0.05rem;
  color: var(--muted);
  font-size: 0.7rem;
}

hr.sep {
  margin: 0.08rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

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

.layers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.layer-add {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(232, 89, 58, 0.32);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.layer-add:hover {
  border-color: rgba(232, 89, 58, 0.58);
  background: rgba(232, 89, 58, 0.15);
  transform: translateY(-1px);
}

.layer-add:focus-visible,
.layer-item:focus-visible,
.layer-action:focus-visible {
  outline: 2px solid rgba(232, 89, 58, 0.42);
  outline-offset: 2px;
}

.layer-list {
  display: flex;
  max-height: 76px;
  flex-direction: column;
  gap: 0.3rem;
  overflow-y: auto;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 22, 15, 0.2) transparent;
}

.layer-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  padding: 0.34rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 22, 15, 0.025);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.layer-item:hover {
  border-color: rgba(23, 22, 15, 0.22);
  color: var(--text);
}

.layer-item.on {
  border-color: rgba(232, 89, 58, 0.4);
  background: rgba(232, 89, 58, 0.09);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.layer-index {
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.layer-name {
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-depth {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.52rem;
  text-transform: uppercase;
}

.layer-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
}

.layer-action {
  min-width: 0;
  padding: 0.28rem 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.54rem;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.layer-action:hover:not(:disabled) {
  border-color: rgba(232, 89, 58, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.layer-action:disabled {
  cursor: default;
  opacity: 0.34;
}

.fl,
.style-name,
.use-tag,
.lp-label {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lp-label {
  color: var(--accent);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  margin-bottom: 0.7rem;
}

textarea,
#srcText {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  min-height: 56px;
  max-height: 72px;
  padding: 0.48rem 0.62rem;
  resize: none;
  font-size: 0.88rem;
  line-height: 1.5;
}

textarea:focus,
#srcText:focus {
  border-color: var(--focus);
}

#srcText:focus {
  box-shadow: 0 0 0 3px rgba(232, 89, 58, 0.12);
}

textarea::placeholder,
#srcText::placeholder {
  color: var(--muted);
}

.font-sel {
  position: relative;
}

.font-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
  padding: 0.42rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}

.font-trigger:hover {
  background: var(--control-bg-hover);
  border-color: rgba(23, 22, 15, 0.2);
}

.font-trigger.open {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  border-color: rgba(232, 89, 58, 0.55);
}

.font-trigger .arr {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s;
}

.font-trigger.open .arr {
  transform: rotate(180deg);
}

.font-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 200;
  display: none;
  max-height: 260px;
  overflow: hidden auto;
  border: 1px solid rgba(232, 89, 58, 0.55);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.font-menu.open {
  display: block;
}

.font-opt {
  padding: 0.5rem 0.75rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.05rem;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.font-opt:hover {
  background: rgba(23, 22, 15, 0.06);
  color: var(--text);
}

.font-opt.active {
  background: rgba(232, 89, 58, 0.16);
  color: var(--accent);
}

.font-face-barlow {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
}

.font-face-oswald {
  font-family: Oswald, sans-serif;
  font-weight: 700;
}

.font-face-anton {
  font-family: Anton, sans-serif;
}

.font-face-bebas {
  font-family: 'Bebas Neue', sans-serif;
}

.font-face-roboto-condensed {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
}

.font-face-playfair {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-weight: 700;
}

.font-face-dancing {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
}

.font-face-lobster {
  font-family: Lobster, cursive;
}

.srow {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sval {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.range-readout {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.range-reset {
  padding: 0.18rem 0.42rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(23, 22, 15, 0.035);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.58rem;
  line-height: 1.2;
  text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.range-reset:hover {
  border-color: rgba(232, 89, 58, 0.42);
  background: var(--accent-soft);
  color: var(--accent);
}

.range-reset:focus-visible {
  outline: 2px solid rgba(232, 89, 58, 0.45);
  outline-offset: 2px;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin-top: 0.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.pos-wrap {
  display: flex;
  justify-content: center;
}

.pos-mini {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 22, 15, 0.04) center / cover;
}

.pos-dim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.pos-cursor {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(232, 89, 58, 0.4), 0 0 5px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.pos-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.pc {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.pc:focus {
  outline: none;
}

.pc:focus-visible {
  outline: none;
}

.pc:focus-visible::after {
  background: rgba(23, 22, 15, 0.65);
  transform: scale(1.3);
}

.pc::after {
  width: 6px;
  height: 6px;
  border: 1.5px solid rgba(23, 22, 15, 0.4);
  border-radius: 50%;
  background: rgba(23, 22, 15, 0.22);
  content: '';
  transition: background 0.12s, transform 0.12s;
}

.pc:hover::after {
  background: rgba(23, 22, 15, 0.65);
  transform: scale(1.3);
}

.crow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.sw,
input[type="color"] {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.sw {
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.12s;
}

.sw:hover {
  transform: scale(1.12);
}

.sw.on {
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--text);
}

.sw-white { --swatch: #fff; }
.sw-warm { --swatch: #ffe9a0; }
.sw-sky { --swatch: #a8d8ff; }
.sw-rose { --swatch: #ffb0b0; }
.sw-mint { --swatch: #b0ffd4; }
.sw-black { --swatch: #000; }
.sw-red { --swatch: #f44; }
.sw-yellow { --swatch: #fe4; }
.sw-blue { --swatch: #4af; }

input[type="color"] {
  overflow: hidden;
  padding: 0;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.effects-panel {
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 22, 15, 0.018);
}

.effects-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.48rem 0.6rem;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  transition: background 0.15s;
}

.effects-summary::-webkit-details-marker {
  display: none;
}

.effects-summary:hover {
  background: rgba(232, 89, 58, 0.06);
}

.effects-summary:focus-visible {
  outline: 2px solid rgba(232, 89, 58, 0.42);
  outline-offset: -2px;
}

.effects-summary > span {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.effects-title {
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.effects-copy {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.effects-arrow {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.18s;
}

.effects-panel[open] .effects-arrow {
  transform: rotate(180deg);
}

.effects-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem 0.65rem;
  border-top: 1px solid var(--border);
}

.trow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.tog {
  position: relative;
  flex-shrink: 0;
  width: 32px;
  height: 17px;
}

.tog input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.tog-track {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: rgba(23, 22, 15, 0.1);
  cursor: pointer;
  transition: background 0.2s;
}

.tog-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  transition: transform 0.2s;
}

.tog input:checked ~ .tog-track {
  background: var(--accent);
}

.tog input:checked ~ .tog-thumb {
  transform: translateX(15px);
}

.tog-txt {
  color: var(--muted);
  font-size: 0.8rem;
}

.stroke-opts {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.3rem;
}

.stroke-opts.off {
  display: none;
}

.dl-btn,
.copy-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-family: var(--f-ui);
  font-weight: 600;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.dl-btn {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  z-index: 5;
  flex-shrink: 0;
  padding: 0.58rem;
  font-size: 0.88rem;
  box-shadow: 0 -7px 16px rgba(252, 251, 247, 0.92);
}

.copy-all {
  margin-left: auto;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 6px 18px rgba(232, 89, 58, 0.28);
}

.dl-btn:hover,
.copy-all:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.dl-btn:active,
.copy-all:active {
  transform: none;
}

.dl-btn:disabled {
  cursor: default;
  opacity: 0.28;
  transform: none;
}

.preview-area {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2rem;
}

#canvas {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#canvas.grabbing {
  cursor: grabbing;
}

#canvas.can-rotate {
  cursor: crosshair;
}

#canvas.rotating {
  cursor: grabbing;
}

.empty-hint {
  color: var(--muted);
  text-align: center;
}

.empty-hint svg {
  display: block;
  margin: 0 auto 0.7rem;
  opacity: 0.16;
}

.empty-hint p {
  font-size: 0.85rem;
}

.controls,
.font-menu {
  scrollbar-color: rgba(23, 22, 15, 0.12) transparent;
  scrollbar-width: thin;
}

.controls::-webkit-scrollbar,
.font-menu::-webkit-scrollbar {
  width: 4px;
}

.controls::-webkit-scrollbar-track,
.font-menu::-webkit-scrollbar-track {
  background: transparent;
}

.controls::-webkit-scrollbar-thumb,
.font-menu::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: rgba(23, 22, 15, 0.12);
}

.controls::-webkit-scrollbar-thumb:hover,
.font-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(23, 22, 15, 0.22);
}

/* Font generator */
.hero {
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 20px 20px;
  border-bottom: 1px solid var(--border);
}

.tool {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.75rem 1.5rem 2rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: '';
}

.lcd {
  min-height: 0.9em;
  margin: 1.25rem 0 0.4rem;
  color: var(--text);
  font-family: var(--f-display);
  font-size: clamp(3.5rem, 12vw, 8rem);
  line-height: 0.9;
  letter-spacing: 0.02em;
  word-break: break-word;
}

.tool h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 700;
  line-height: 1.15;
}

.tool h1 .dim,
.lede {
  color: var(--muted);
}

.lede {
  max-width: 620px;
  margin-bottom: 1.6rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

#srcText {
  padding: 1rem 1.1rem;
  background: var(--surface);
  font-size: 1.05rem;
}

.tool-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.case-group {
  display: flex;
  gap: 0.25rem;
  padding: 0.22rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.case-btn {
  padding: 0.4rem 0.7rem;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.78rem;
  transition: background 0.15s, color 0.15s;
}

.case-btn:hover {
  color: var(--text);
}

.case-btn.on {
  background: var(--text);
  color: var(--bg);
}

.controls .case-group {
  padding: 0.16rem;
}

.controls .case-btn {
  padding: 0.3rem 0.58rem;
  font-size: 0.72rem;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 2.5rem;
}

.style-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.style-row:hover {
  border-color: rgba(23, 22, 15, 0.28);
  box-shadow: var(--shadow-soft);
}

.style-body {
  flex: 1;
  min-width: 0;
}

.style-name {
  display: inline-block;
  margin-bottom: 0.3rem;
  font-size: 0.62rem;
}

.style-out {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1.28rem;
  line-height: 1.4;
  word-break: break-word;
}

.copy-btn {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.74rem;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.copy-btn:hover {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.copy-btn.done {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 500;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--text);
  box-shadow: var(--shadow-toast);
  color: var(--bg);
  font-family: var(--f-mono);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(1rem);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Content sections */
.lp-section {
  padding: 4.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.meme-page .lp-section {
  padding-block: 5rem;
}

.lp-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.lp-h2 {
  max-width: 640px;
  margin-bottom: 1rem;
  color: var(--text);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0;
}

.meme-page .lp-h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
}

.lp-p {
  max-width: 640px;
  margin-bottom: 0.9rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.8;
}

.lp-p:last-child {
  margin-bottom: 0;
}

.lp-p strong {
  color: var(--text);
  font-weight: 600;
}

.inline-link {
  color: var(--text);
  font-weight: 600;
  text-decoration-color: rgba(232, 89, 58, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.inline-link:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.what-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 3rem;
  margin-top: 2.5rem;
}

.what-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  aspect-ratio: 1;
  padding: 2rem;
  border-radius: 14px;
  background: #071225;
  box-shadow: 0 24px 60px rgba(8, 18, 37, 0.16);
}

.what-visual-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.what-visual:hover .what-visual-img {
  transform: scale(1.025);
}

.what-visual::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(4, 10, 22, 0.08), rgba(4, 10, 22, 0.38)),
    radial-gradient(ellipse at 50% 55%, rgba(4, 10, 22, 0.04) 0%, rgba(4, 10, 22, 0.32) 78%);
  content: '';
  pointer-events: none;
}

.what-visual-aesthetic::before {
  background:
    linear-gradient(180deg, rgba(48, 31, 21, 0.01), rgba(48, 31, 21, 0.1)),
    radial-gradient(ellipse at 52% 46%, rgba(255, 250, 242, 0.02) 0%, rgba(76, 48, 32, 0.08) 82%);
}

.wm-text {
  position: relative;
  z-index: 2;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000, 0 0 14px rgba(0, 0, 0, 0.9);
}

.wm-text-aesthetic {
  max-width: 82%;
  color: #4f3428;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(1.2rem, 2.6vw, 1.65rem);
  font-style: italic;
  line-height: 1.45;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.92), 0 3px 22px rgba(255, 250, 242, 0.84);
}

.what-text p {
  margin-bottom: 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.8;
}

.what-text p:last-child {
  margin-bottom: 0;
}

.feat-grid,
.use-grid {
  display: grid;
  gap: 1rem;
  margin-top: 2.5rem;
}

.feat-grid {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}

.use-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 2.25rem;
}

.feat-card,
.use-card {
  padding: 1.35rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  transition: border-color 0.2s;
}

.use-card {
  padding-inline: 1.2rem;
}

.feat-card:hover {
  border-color: rgba(232, 89, 58, 0.35);
}

.use-card:hover {
  border-color: rgba(23, 22, 15, 0.28);
}

.feat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-bottom: 0.9rem;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent);
}

.feat-name,
.use-name,
.step-title {
  color: var(--text);
  font-weight: 600;
}

.feat-name {
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.feat-desc,
.use-desc,
.step-text {
  color: var(--muted);
}

.feat-desc {
  font-size: 0.8rem;
  line-height: 1.6;
}

.use-tag {
  color: var(--accent);
  font-size: 0.6rem;
}

.use-name {
  margin: 0.55rem 0 0.3rem;
  font-size: 0.95rem;
}

.use-desc {
  font-size: 0.85rem;
  line-height: 1.65;
}

.steps {
  display: flex;
  flex-direction: column;
  margin-top: 2.5rem;
}

.semantic-steps {
  list-style: none;
}

.step {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 0 1.25rem;
  margin-bottom: 2rem;
}

.step:last-child {
  margin-bottom: 0;
}

.step-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step-num {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(232, 89, 58, 0.3);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
}

.step-line {
  flex: 1;
  width: 1px;
  margin: 0.45rem auto;
  background: var(--border);
}

.step:last-child .step-line {
  display: none;
}

.step-body {
  padding-top: 0.7rem;
  padding-bottom: 1rem;
}

.step-title {
  margin-bottom: 0.35rem;
  font-size: 0.97rem;
}

.step-text {
  font-size: 0.86rem;
  line-height: 1.7;
}

.style-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 2.25rem;
}

.style-sample-card {
  min-width: 0;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.style-sample-card span {
  display: block;
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.style-sample-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--f-ui);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 500;
  line-height: 1.3;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.compare-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  text-align: left;
}

.compare-table th,
.compare-table td {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
  vertical-align: top;
}

.compare-table thead th {
  background: rgba(23, 22, 15, 0.035);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.compare-table tbody th {
  width: 28%;
  color: var(--text);
  font-weight: 600;
}

.compare-table tr:last-child th,
.compare-table tr:last-child td {
  border-bottom: 0;
}

.related-tool-grid,
.not-found-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 2.25rem;
}

.tool-link-card,
.not-found-card {
  display: block;
  min-width: 0;
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
}

.tool-link-card:hover,
.not-found-card:hover {
  border-color: rgba(232, 89, 58, 0.5);
  transform: translateY(-2px);
}

.tool-link-card > span,
.not-found-card > span {
  display: block;
  margin-bottom: 1.1rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tool-link-card strong,
.not-found-card strong {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 1rem;
}

.tool-link-card p,
.not-found-card p {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.ex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
  margin-top: 2.5rem;
}

.ex-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: var(--radius-xl);
}

.ex-img {
  display: block;
  width: 100%;
  height: 110%;
  object-fit: cover;
  object-position: top;
}

.faq {
  max-width: 760px;
  margin-top: 2.25rem;
}

.meme-page .faq {
  max-width: none;
  margin-top: 2.5rem;
}

.faq-item {
  border-top: 1px solid var(--border);
}

.faq-item:last-child {
  border-bottom: 1px solid var(--border);
}

.faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
  padding: 1.1rem 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--f-ui);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}

.meme-page .faq-q {
  padding-block: 1.05rem;
  font-size: 0.93rem;
}

.faq-q .arr {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s;
}

.faq-item.open .arr {
  transform: rotate(180deg);
}

.faq-a {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease;
}

.faq-a-in {
  padding-bottom: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.75;
}

.meme-page .faq-a-in {
  padding-bottom: 1.05rem;
  font-size: 0.86rem;
}

.faq-item.open .faq-a {
  max-height: 400px;
}

/* Trust, policy, and contact pages */
body.legal-page {
  --content-max: 1000px;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.legal-page main {
  flex: 1;
}

.legal-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(4.5rem, 10vw, 7rem) 1.5rem clamp(3.5rem, 7vw, 5rem);
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 82% 18%, rgba(232, 89, 58, 0.11), transparent 26rem),
    var(--bg);
}

.legal-hero::after {
  position: absolute;
  top: 0;
  right: 0;
  width: min(34vw, 380px);
  height: 100%;
  background-image: radial-gradient(var(--dot) 0.8px, transparent 0.8px);
  background-size: 18px 18px;
  content: '';
  opacity: 0.7;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
  mask-image: linear-gradient(90deg, transparent, #000);
}

.legal-wrap {
  position: relative;
  z-index: 1;
  width: min(100%, var(--content-max));
  margin: 0 auto;
}

.legal-title {
  max-width: 790px;
  margin-top: 0.7rem;
  color: var(--text);
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.legal-lede {
  max-width: 700px;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.8;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.8rem;
}

.legal-meta span {
  padding: 0.38rem 0.68rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(251, 250, 247, 0.5);
  color: rgba(23, 22, 15, 0.62);
  font-family: var(--f-mono);
  font-size: 0.62rem;
}

.legal-section {
  padding: clamp(3.5rem, 8vw, 5.5rem) 1.5rem;
}

.not-found-hero {
  padding-block: clamp(5rem, 12vw, 8rem);
}

.not-found-page .legal-section {
  padding-top: clamp(3.5rem, 7vw, 5rem);
}

.trust-grid,
.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.trust-card,
.contact-card {
  min-width: 0;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: rgba(251, 250, 247, 0.66);
  box-shadow: var(--shadow-soft);
}

.trust-card > span {
  display: block;
  margin-bottom: 1.55rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.trust-card strong,
.contact-card h2 {
  display: block;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.3;
}

.trust-card p,
.contact-card p {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.contact-icon {
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.35rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.legal-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 700px);
  justify-content: center;
  gap: clamp(2.5rem, 7vw, 5rem);
  margin-top: clamp(3.5rem, 8vw, 5.5rem);
  align-items: start;
}

.legal-toc {
  position: sticky;
  top: 6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(232, 89, 58, 0.36);
}

.legal-toc > p {
  margin-bottom: 0.35rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legal-toc a {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s, transform 0.15s;
}

.legal-toc a:hover {
  color: var(--text);
  transform: translateX(2px);
}

.legal-content {
  min-width: 0;
}

.legal-content section {
  scroll-margin-top: 6.5rem;
  margin-bottom: 3.2rem;
  padding-top: 3.2rem;
  border-top: 1px solid var(--border);
}

.legal-content section:first-child {
  padding-top: 0;
  border-top: 0;
}

.legal-content section:last-child {
  margin-bottom: 0;
}

.legal-content h2 {
  margin-bottom: 1rem;
  color: var(--text);
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.legal-content h3 {
  margin: 1.55rem 0 0.45rem;
  color: var(--text);
  font-size: 0.95rem;
}

.legal-content p,
.legal-content li {
  color: rgba(23, 22, 15, 0.66);
  font-size: 0.92rem;
  line-height: 1.85;
}

.legal-content p + p {
  margin-top: 0.95rem;
}

.legal-content ul {
  display: grid;
  gap: 0.7rem;
  padding-left: 1.15rem;
}

.legal-content a {
  color: var(--accent-hover);
  text-decoration-color: rgba(217, 73, 43, 0.32);
  text-underline-offset: 3px;
}

.legal-content a:hover {
  text-decoration-color: currentColor;
}

.legal-note {
  margin-top: 1.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(232, 89, 58, 0.22);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: rgba(232, 89, 58, 0.055);
}

.legal-note strong {
  display: block;
  margin-bottom: 0.28rem;
  color: var(--text);
  font-size: 0.78rem;
}

.legal-note p {
  font-size: 0.82rem;
}

.legal-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.65rem;
  padding: 0.72rem 1rem;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg) !important;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
}

.legal-cta:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.legal-small {
  margin-top: 0.8rem !important;
  color: var(--muted) !important;
  font-family: var(--f-mono);
  font-size: 0.64rem !important;
  line-height: 1.6 !important;
}

.site-footer {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.site-footer::before {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--dot) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  content: '';
  opacity: 0.7;
  pointer-events: none;
}

.footer-inner {
  position: relative;
  z-index: 1;
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 3.4rem 1.75rem 1.5rem;
}

.footer-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(150px, 0.7fr) minmax(170px, 0.75fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.footer-about {
  max-width: 430px;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-family: var(--f-display);
  font-size: 1.7rem;
  letter-spacing: 0.06em;
  line-height: 1;
  text-decoration: none;
}

.footer-logo img {
  display: block;
  border-radius: 7px;
  box-shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(23, 22, 15, 0.12);
}

.footer-about > p {
  max-width: 390px;
  margin-top: 1.05rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.75;
}

.footer-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.72rem;
}

.footer-kicker {
  margin-bottom: 0.28rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(23, 22, 15, 0.68);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.15s, transform 0.15s;
}

.footer-links a span {
  color: rgba(23, 22, 15, 0.28);
  font-size: 0.72rem;
  transition: color 0.15s, transform 0.15s;
}

.footer-links a:hover {
  color: var(--text);
  transform: translateX(2px);
}

.footer-links a:hover span {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: rgba(23, 22, 15, 0.42);
  font-family: var(--f-mono);
  font-size: 0.66rem;
}

.footer-private {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-private i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #81d89a;
  box-shadow: 0 0 0 4px rgba(129, 216, 154, 0.1);
}

@media (max-width: 900px) {
  .meme-app {
    grid-template-columns: 260px 1fr;
  }
}

@media (min-width: 641px) and (max-height: 820px) {
  .controls {
    gap: 0.36rem;
    padding: 0.55rem 0.75rem;
  }

  .upload-zone {
    padding: 0.45rem 0.65rem;
  }

  .upload-zone .icon {
    width: 16px;
    height: 16px;
    margin-bottom: 0.1rem;
  }

  .field {
    gap: 0.18rem;
  }

  textarea {
    min-height: 50px;
    max-height: 60px;
    padding: 0.35rem 0.55rem;
  }

  .pos-mini {
    width: 72px;
    height: 72px;
  }

  .effects-summary {
    padding: 0.4rem 0.55rem;
  }

  .dl-btn {
    padding: 0.5rem;
  }
}

@media (max-width: 720px) {
  .what-grid {
    grid-template-columns: 1fr;
  }

  .legal-layout {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .legal-toc {
    position: static;
    flex-flow: row wrap;
    gap: 0.45rem;
    padding: 0;
    border: 0;
  }

  .legal-toc > p {
    width: 100%;
    margin-bottom: 0.2rem;
  }

  .legal-toc a {
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(251, 250, 247, 0.55);
    font-family: var(--f-mono);
    font-size: 0.58rem;
  }

  .legal-toc a:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  .site-header {
    gap: 0.45rem;
    padding: 0.7rem 0.75rem;
  }

  .brand {
    gap: 0.45rem;
  }

  .brand-name {
    font-size: 1.45rem;
  }

  .site-tagline {
    display: none;
    font-size: 0.72rem;
  }

  .nav a {
    padding: 0.36rem 0.52rem;
    font-size: 0.72rem;
  }

  .meme-app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .controls {
    max-height: 68vh;
    gap: 0.55rem;
    padding: 0.7rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .preview-area {
    min-height: 55vw;
    padding: 1rem;
  }

  #canvas {
    max-height: calc(100vw - 2rem);
  }

  .dl-btn {
    position: static;
    margin-top: 0.5rem;
    box-shadow: 0 6px 18px rgba(232, 89, 58, 0.2);
  }

  .tool {
    padding: 1.9rem 1rem 1.5rem;
  }

  .results {
    grid-template-columns: 1fr;
    padding: 1.25rem 1rem 2rem;
  }

  .style-out {
    font-size: 1.12rem;
  }

  .lp-section,
  .meme-page .lp-section {
    padding: 3.5rem 1.2rem;
  }

  .font-page .lp-section {
    padding-block: 3.25rem;
  }

  .feat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .legal-hero {
    padding: 4rem 1.2rem 3.25rem;
  }

  .legal-section {
    padding: 3.5rem 1.2rem;
  }

  .trust-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .trust-card > span {
    margin-bottom: 0.9rem;
  }

  .footer-inner {
    padding: 2.8rem 1.2rem 1.35rem;
  }

  .footer-main {
    grid-template-columns: 1fr 1fr;
    gap: 2.25rem 1.5rem;
  }

  .footer-about {
    grid-column: 1 / -1;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
    margin-top: 2.35rem;
  }

  .footer-logo {
    font-size: 1.55rem;
  }
}

@media (max-width: 520px) {
  .site-header {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .nav a {
    flex: 1;
    padding-inline: 0.3rem;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .site-header {
    gap: 0.4rem;
    padding: 0.58rem 0.45rem;
  }

  .brand {
    gap: 0.3rem;
  }

  .brand-mark {
    width: 22px;
    height: 22px;
  }

  .brand-name {
    font-size: 1.05rem;
  }

  .nav {
    gap: 0.12rem;
  }

  .nav a {
    padding: 0.3rem 0.28rem;
    font-size: 0.62rem;
  }
}

/* The Night Before template generator */
.template-page {
  --content-max: 960px;
}

.template-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: clamp(2.5rem, 7vw, 6rem);
  align-items: end;
  width: min(100% - 3rem, 1080px);
  margin: 0 auto;
  padding: clamp(4.25rem, 9vw, 7rem) 0 clamp(3.5rem, 7vw, 5.5rem);
}

.template-hero::before {
  position: absolute;
  top: 2rem;
  right: 39%;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(232, 89, 58, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 89, 58, 0.12) 0 2px, transparent 3px) 0 0 / 18px 18px;
  content: '';
  opacity: 0.55;
  pointer-events: none;
}

.template-hero-copy {
  position: relative;
  z-index: 1;
}

.template-hero h1 {
  max-width: 720px;
  margin: 1.35rem 0 1.15rem;
  font-size: clamp(2.8rem, 7vw, 5.8rem);
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: -0.055em;
}

.template-lede {
  max-width: 670px;
  color: var(--muted);
  font-size: clamp(0.96rem, 1.5vw, 1.08rem);
  line-height: 1.75;
}

.template-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1.65rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--text);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.template-jump span {
  color: var(--accent);
  transition: transform 0.18s;
}

.template-jump:hover span {
  transform: translateY(3px);
}

.template-hero-note {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 1rem 0.75rem;
  padding: 1.2rem 0 0 1.25rem;
  border-left: 1px solid var(--border);
}

.template-hero-note > span {
  padding-top: 0.12rem;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.62rem;
}

.template-hero-note p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.template-hero-note strong {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.template-editor-shell {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  width: min(100% - 2rem, 1120px);
  min-height: 710px;
  margin: 0 auto clamp(4rem, 8vw, 7rem);
  overflow: hidden;
  border: 1px solid rgba(23, 22, 15, 0.18);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(23, 22, 15, 0.14);
}

.template-controls {
  display: flex;
  flex-direction: column;
  gap: 0.78rem;
  padding: 1.25rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.template-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}

.template-step-label {
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.template-panel-head h2 {
  margin-top: 0.25rem;
  font-size: 1.15rem;
  line-height: 1.2;
}

.template-reset {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.template-reset:hover {
  border-color: rgba(232, 89, 58, 0.4);
  background: var(--accent-soft);
  color: var(--accent);
}

.template-caption-input,
.template-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(23, 22, 15, 0.035);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.template-caption-input {
  padding: 0.75rem 0.8rem;
  font-family: 'Luckiest Guy', Impact, sans-serif;
  font-size: 1.18rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.template-select {
  min-height: 40px;
  padding: 0.55rem 2rem 0.55rem 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
}

.template-caption-input:focus,
.template-select:focus {
  border-color: rgba(232, 89, 58, 0.6);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(232, 89, 58, 0.1);
}

.template-help {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.5;
}

.template-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.template-suggestions button {
  padding: 0.36rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.6rem;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

.template-suggestions button:hover {
  border-color: rgba(23, 22, 15, 0.3);
  color: var(--text);
  transform: translateY(-1px);
}

.template-color-row {
  display: flex;
  gap: 0.55rem;
}

.template-color {
  position: relative;
  width: 28px;
  height: 28px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--caption-color);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.template-color:hover {
  transform: scale(1.08);
}

.template-color.on {
  box-shadow: 0 0 0 2px var(--text);
}

.template-position-panel {
  margin-top: 0.1rem;
}

.template-position-panel .field + .field {
  margin-top: 0.5rem;
}

.template-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(110px, 0.8fr);
  gap: 0.5rem;
  margin-top: auto;
}

.template-download {
  position: static;
  margin: 0;
  padding: 0.7rem 0.75rem;
  box-shadow: 0 8px 22px rgba(232, 89, 58, 0.24);
}

.template-secondary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.68rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.template-secondary-action:hover {
  border-color: rgba(23, 22, 15, 0.28);
  background: rgba(23, 22, 15, 0.04);
}

.template-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.56rem;
  text-align: center;
}

.template-privacy i,
.template-stage-bar i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #81d89a;
  box-shadow: 0 0 0 4px rgba(129, 216, 154, 0.1);
}

.template-stage {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 1.1rem;
  background:
    radial-gradient(circle at 65% 30%, rgba(89, 96, 151, 0.2), transparent 42%),
    linear-gradient(145deg, #171823, #0d0e16 70%);
  color: rgba(255, 255, 255, 0.68);
}

.template-stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.15rem 0.25rem 0.85rem;
  font-family: var(--f-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-stage-bar span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.template-canvas-wrap {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%);
  background-position: 0 0, 10px 10px;
  background-size: 20px 20px;
}

#templateCanvas {
  display: block;
  width: min(100%, 640px);
  height: auto;
  max-height: 640px;
  border-radius: 5px;
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.5);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#templateCanvas.dragging {
  cursor: grabbing;
}

.template-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #11121c;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--f-mono);
  font-size: 0.7rem;
}

.template-loading[hidden] {
  display: none;
}

.template-stage-tip {
  padding: 0.8rem 0.25rem 0.1rem;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.7rem;
  text-align: center;
}

.template-how {
  background: rgba(251, 250, 247, 0.55);
}

.template-idea-grid .use-card {
  min-height: 190px;
}

.template-origin {
  background: var(--text);
  color: var(--bg);
}

.template-origin-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
  gap: clamp(2rem, 7vw, 5rem);
}

.template-origin .lp-h2,
.template-origin .lp-p,
.template-origin .inline-link {
  color: var(--bg);
}

.template-origin .lp-p {
  opacity: 0.72;
}

.template-origin .inline-link {
  opacity: 1;
  text-decoration-color: var(--accent);
}

/* Homepage entry to the first template page */
.template-callout {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: center;
  margin-top: 1.5rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.template-callout-thumb {
  display: block;
  width: 150px;
  aspect-ratio: 640 / 628;
  object-fit: cover;
  border-radius: 9px;
}

.template-callout-copy .lp-label {
  margin-bottom: 0.35rem;
}

.template-callout-copy h3 {
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
}

.template-callout-copy p:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.template-callout-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-lg);
  background: var(--text);
  color: var(--bg);
  font-family: var(--f-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}

.template-callout-link:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.template-callout-actions {
  display: grid;
  gap: 0.45rem;
}

.template-library-browse {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.template-library-browse:hover {
  color: var(--accent);
}

.template-popular-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 0.45rem;
  max-width: 220px;
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 0.57rem;
  line-height: 1.5;
  text-align: center;
}

.template-popular-links > span {
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
}

.template-popular-links a {
  color: var(--muted);
  text-decoration-color: rgba(232, 89, 58, 0.45);
  text-underline-offset: 0.18em;
}

.template-popular-links a:hover {
  color: var(--accent);
}

@media (max-width: 900px) {
  .template-hero {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .template-hero::before {
    right: 4%;
  }

  .template-hero-note {
    grid-template-columns: repeat(3, 30px minmax(0, 1fr));
    padding: 1rem 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .template-editor-shell {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  .template-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 740px) {
  .template-editor-shell {
    grid-template-columns: 1fr;
    width: min(100% - 1.25rem, 640px);
  }

  .template-controls {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .template-actions {
    grid-template-columns: minmax(0, 1.4fr) minmax(110px, 0.8fr);
  }

  .template-stage {
    min-height: 580px;
  }

  .template-origin-grid {
    grid-template-columns: 1fr;
  }

  .template-callout {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .template-callout-thumb {
    width: 110px;
  }

  .template-callout-link {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .template-callout-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .template-hero {
    width: min(100% - 2rem, 1080px);
    padding-top: 3.25rem;
  }

  .template-hero h1 {
    font-size: clamp(2.55rem, 13vw, 4rem);
  }

  .template-hero-note {
    grid-template-columns: 28px 1fr;
  }

  .template-editor-shell {
    border-radius: 12px;
  }

  .template-controls {
    padding: 1rem;
  }

  .template-actions {
    grid-template-columns: 1fr;
  }

  .template-stage {
    min-height: 0;
    padding: 0.75rem;
  }

  .template-canvas-wrap {
    min-height: calc(100vw - 2.75rem);
  }

  .template-stage-bar {
    font-size: 0.53rem;
  }

  .template-callout {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 0.85rem;
  }

  .template-callout-thumb {
    width: 82px;
  }

  .template-callout-copy p:last-child {
    display: none;
  }
}
