:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #5f6670;
  --line: #d9dde3;
  --surface: #f7f8fa;
  --panel: #ffffff;
  --accent: #d42620;
  --accent-dark: #a91813;
  --sky: #dbe9f4;
  --gold: #f0b84f;
  --green: #1f8a5b;
  --shadow: 0 18px 50px rgba(27, 31, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

a {
  color: inherit;
}

.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
}

.top-nav a,
.site-footer a {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.top-nav a:hover,
.site-footer a:hover {
  color: var(--ink);
}

.tool-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: end;
  gap: 28px;
  width: min(1120px, calc(100% - 32px));
  margin: 12px auto 20px;
  padding: 10px 0 6px;
}

.hero-copy h1 {
  max-width: 820px;
  margin: 8px 0 10px;
  font-size: clamp(40px, 5vw, 68px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.eyebrow {
  color: var(--accent) !important;
  font-size: 14px !important;
  font-weight: 800;
  text-transform: uppercase;
}

.featured-link,
.trend-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}

.featured-link span,
.trend-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
}

.generator-shell {
  display: grid;
  grid-template-columns: minmax(420px, 620px) 390px;
  gap: 22px;
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  align-items: start;
  justify-content: center;
}

.canvas-panel,
.controls-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.canvas-panel {
  padding: 14px;
  min-height: 0;
}

#memeCanvas {
  display: block;
  width: min(100%, 520px);
  max-height: 650px;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
  background: #e8edf1;
}

.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: min(100%, 520px);
  margin: 12px auto 0;
}

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

button,
select,
input[type="file"],
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
}

button {
  min-height: 44px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.controls-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.desktop-compact-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group > label,
.checkbox-row label {
  color: #303640;
  font-size: 13px;
  font-weight: 800;
}

textarea,
select,
input[type="file"] {
  width: 100%;
  background: #fff;
  color: var(--ink);
  padding: 10px;
}

.file-picker {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.file-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.file-button:hover {
  border-color: #a9b1bc;
  background: #f8fafc;
}

.file-name {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  min-height: 52px;
  resize: vertical;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.split-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.triple-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
}

.checkbox-row input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.template-grid {
  display: grid;
  grid-template-columns: minmax(0, 132px);
  gap: 8px;
}

.template-button {
  overflow: hidden;
  min-height: 132px;
  padding: 0;
  border: 2px solid transparent;
  background: #edf2f6;
}

.template-button[aria-pressed="true"] {
  border-color: var(--accent);
}

.template-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.template-button span {
  display: block;
  min-height: 32px;
  padding: 8px 6px;
  background: #fff;
  color: #303640;
  font-size: 12px;
  line-height: 1.15;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-grid button {
  min-height: 40px;
  padding: 8px;
  background: #fff;
  color: #303640;
  font-size: 12px;
  line-height: 1.2;
  text-align: left;
}

.preset-grid button:hover,
.secondary-button:hover,
.template-button:hover {
  border-color: #a9b1bc;
  background: #f8fafc;
}

.content-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  width: min(1040px, calc(100% - 32px));
  margin: 26px auto 0;
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.faq-band {
  grid-template-columns: repeat(3, 1fr);
}

.seo-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 4px 0 28px;
}

.seo-band h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.seo-band p,
.seo-band li {
  color: var(--muted);
  line-height: 1.6;
}

.seo-band ol {
  margin: 0;
  padding-left: 20px;
}

.content-band h2 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: 0;
}

.content-band p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.site-footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 940px) {
  .tool-hero,
  .generator-shell,
  .content-band,
  .faq-band,
  .seo-band {
    grid-template-columns: 1fr;
  }

  .generator-shell {
    gap: 14px;
  }

  .canvas-panel {
    min-height: 0;
  }

  #memeCanvas {
    width: 100%;
    max-height: none;
  }

  .controls-panel {
    order: -1;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .desktop-compact-row {
    grid-template-columns: 1fr;
  }

  .template-grid {
    grid-template-columns: minmax(0, 180px);
  }

  .template-button {
    min-height: 180px;
  }
}

@media (max-width: 620px) {
  .site-header,
  .site-footer {
    width: min(100% - 24px, 1180px);
  }

  .tool-hero,
  .generator-shell,
  .content-band,
  .seo-band {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .hero-copy h1 {
    font-size: 42px;
  }

  .hero-copy p {
    font-size: 16px;
  }

  .split-controls,
  .triple-controls,
  .export-row,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .template-grid {
    grid-template-columns: minmax(0, 180px);
  }

  .file-picker {
    grid-template-columns: 1fr;
  }
}
