:root {
  color-scheme: light;
  --ink: #1d2025;
  --muted: #68707c;
  --line: #d9dde3;
  --paper: #fff8ec;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #e85d4f;
  --sun: #ffd166;
  --mint: #a7f3d0;
  --sky: #8ecae6;
  --shadow: 0 18px 45px rgba(26, 35, 45, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 209, 102, 0.45), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(142, 202, 230, 0.42), transparent 24%),
    linear-gradient(315deg, rgba(232, 93, 79, 0.12), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 22px;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid rgba(217, 221, 227, 0.75);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 4vw, 2.55rem);
  line-height: 1.05;
}

.lead {
  max-width: 620px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.lead strong {
  color: var(--ink);
  font-weight: 900;
}

.hero-image-wrap {
  overflow: hidden;
  border: 4px solid white;
  border-radius: 8px;
  background: #d9edf9;
  box-shadow: 0 14px 28px rgba(26, 35, 45, 0.16);
}

.hero-image-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 1;
  object-fit: cover;
  object-position: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.result-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 221, 227, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 18px;
  border-top: 6px solid var(--sun);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 12px;
}

.section-title span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
}

.section-title h2 {
  font-size: 1rem;
}

.upload-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 150px;
  align-content: center;
  gap: 5px;
  overflow: hidden;
  border: 1.5px dashed #b7bec8;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.18), transparent 58%),
    #fbfbfa;
  padding: 16px;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-title {
  position: relative;
  z-index: 1;
  font-weight: 800;
}

.drop-copy {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 0.9rem;
}

.drop-zone img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 160ms ease;
}

.drop-zone.has-image {
  border-style: solid;
  color: white;
}

.drop-zone.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.58), rgba(0, 0, 0, 0.08));
}

.drop-zone.has-image img {
  opacity: 1;
}

.drop-zone.has-image .drop-copy {
  color: rgba(255, 255, 255, 0.82);
}

.toggle-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(167, 243, 208, 0.24), transparent 64%),
    #fbfbfa;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: #c8ced6;
  transition: background 160ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle-track {
  background: var(--coral);
}

.toggle-row input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.mask-state {
  display: grid;
  place-items: center;
  min-width: 58px;
  min-height: 34px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.mask-state .state-on {
  display: none;
}

.toggle-row input:checked ~ .mask-state {
  background: var(--coral);
  border-color: var(--coral);
  color: white;
}

.toggle-row input:checked ~ .mask-state .state-off {
  display: none;
}

.toggle-row input:checked ~ .mask-state .state-on {
  display: inline;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 76px;
  padding: 10px 12px;
}

.generate-button {
  width: 100%;
  min-height: 50px;
  margin-top: 16px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.generate-button:hover {
  background: var(--teal-dark);
}

.generate-button:disabled {
  background: #99a3ae;
  cursor: wait;
}

.result-panel {
  position: sticky;
  top: 18px;
  min-height: calc(100vh - 128px);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 18px;
  border-top: 6px solid var(--sky);
}

.result-empty,
.result-loading {
  display: grid;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
}

.loading-important {
  display: block;
  margin-top: 10px;
  color: #d83b2d;
  font-weight: 800;
}

.phone-frame {
  width: min(310px, 70vw);
  aspect-ratio: 9 / 16;
  border: 10px solid var(--ink);
  border-radius: 28px;
  background: #eff1f2;
  padding: 10px;
  box-shadow: 0 20px 50px rgba(26, 35, 45, 0.18);
}

.photo-placeholder {
  height: 100%;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.28), transparent 44%),
    linear-gradient(315deg, rgba(232, 93, 79, 0.22), transparent 42%),
    linear-gradient(180deg, #f7f7f4, #dfe5e4);
}

.result-ready {
  width: 100%;
  display: grid;
  gap: 14px;
}

.result-ready img {
  width: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
  border-radius: 8px;
  background: #eef0f2;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.result-actions a,
.result-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.result-actions a {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.result-actions .save-photo-button,
.result-actions .x-post-button {
  background: #111111;
  color: white;
  border-color: #111111;
  font-weight: 800;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid #ccd4dc;
  border-top-color: var(--teal);
  animation: spin 900ms linear infinite;
}

.error-box {
  width: 100%;
  border: 1px solid rgba(232, 93, 79, 0.45);
  border-radius: 8px;
  background: rgba(232, 93, 79, 0.08);
  color: #9b2b23;
  padding: 12px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.fan-site-footer {
  margin-top: 22px;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.support-note {
  margin: 0;
  color: #4f5963;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

.support-note a {
  color: var(--coral);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.fan-site-banner {
  display: block;
  width: min(760px, 100%);
  overflow: hidden;
  border: 1px solid rgba(217, 221, 227, 0.9);
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 28px rgba(26, 35, 45, 0.12);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.fan-site-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(26, 35, 45, 0.16);
}

.fan-site-banner img {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .hero-image-wrap img {
    aspect-ratio: 3 / 1;
  }

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

  .result-panel {
    position: static;
    min-height: 420px;
  }
}

@media (max-width: 470px) {
  .toggle-row {
    grid-template-columns: 48px 1fr;
  }

  .mask-state {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .result-actions {
    flex-direction: column;
  }
}
