:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #697185;
  --line: #dce3ef;
  --primary: #3662ff;
  --primary-soft: #ebf0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.hero {
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0;
  font-size: 2rem;
}

.title-reset-btn {
  display: inline-block;
  width: auto;
  min-height: 0;
  text-align: left;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: 1.1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.title-reset-btn:hover {
  color: #274ecf;
}

.title-reset-btn:focus-visible {
  outline: 2px solid #7aa2ff;
  outline-offset: 4px;
  border-radius: 6px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(12, 25, 55, 0.05);
}

h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.canvas-container {
  width: 100%;
  min-height: 500px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f0f3fb;
  position: relative;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: pointer;
}

.canvas-container.dragover {
  border-color: var(--primary);
  background: #eaf0ff;
}

.canvas-container.dragover .quick-upload-hint {
  border-color: var(--primary);
  background: rgba(235, 241, 255, 0.95);
}

.canvas-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  line-height: 0;
}

.canvas-stage canvas {
  width: 100%;
  height: auto;
  display: block;
}

#overlayCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: pan-y;
}

#imageInput {
  display: none;
}

.preview-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  display: none;
  gap: 8px;
}

.preview-actions button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid #c9d4ee;
  background: rgba(255, 255, 255, 0.95);
  color: #1f325f;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preview-actions button:hover {
  border-color: var(--primary);
  background: #eef3ff;
}

.quick-upload-hint {
  position: absolute;
  inset: 14px;
  border: 1.5px dashed #94a8d6;
  border-radius: 12px;
  background: rgba(248, 251, 255, 0.95);
  color: #2f4e9d;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 4px;
  pointer-events: none;
}

.quick-upload-hint strong {
  font-size: 1.02rem;
}

.controls {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 10px;
}

.status {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.button-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
}

button,
select,
input[type="range"] {
  width: 100%;
}

button,
select {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px 10px;
  min-height: 42px;
  font-size: 0.9rem;
  background: #fff;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: #2344aa;
}


.edit-toggle {
  margin-top: 8px;
}

button.danger {
  border-color: #f2c8cb;
  color: #b8333e;
}

button.danger:hover {
  border-color: #e69ca2;
  background: #fff7f7;
}

.control-group {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fcfdff;
}

.slider-group {
  margin-top: 2px;
  display: grid;
  gap: 6px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
}

.slider-value {
  color: #2f58f0;
  font-weight: 600;
}

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

.why-like {
  margin-top: 14px;
}

.why-like h2 {
  margin-bottom: 12px;
}

.why-like-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.why-like-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdff;
  padding: 10px 12px;
}

.why-like-list h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.why-like-list p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

  .controls {
    position: static;
  }

  .canvas-container {
    min-height: 360px;
  }
}

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

  .hero h1 {
    font-size: 1.62rem;
  }

  .canvas-container {
    min-height: 200px;
    overflow: hidden;
    touch-action: pan-y;
  }

  .canvas-stage {
    width: 100%;
    max-width: 100%;
  }

  .status,
  #selectedFaceMeta {
    min-height: 2.6em;
  }

  .preview-actions {
    top: 12px;
    right: 12px;
    gap: 6px;
  }

  .preview-actions button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    font-size: 1rem;
  }

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

.site-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-bottom: 8px;
}

.site-footer a {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
}

.site-footer-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-shell--static {
  max-width: 640px;
}

.page-header {
  margin-bottom: 20px;
}

.page-brand {
  display: inline-block;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
}

.page-brand:hover {
  color: var(--primary);
}

.static-page {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.static-page a:not(.static-cta) {
  color: var(--primary);
  text-decoration: none;
}

.static-page a:not(.static-cta):hover {
  text-decoration: underline;
}

.static-hero {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.static-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.static-hero h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.static-lede {
  margin: 10px 0 0;
  max-width: 36ch;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

.step-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.step-card__num {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
}

.step-card__body h2 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.step-card__body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.faq-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.faq-item {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.faq-item:last-child {
  border-bottom: 0;
}

.faq-item h2 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.faq-item p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.static-aside {
  margin-top: 28px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--primary-soft);
}

.static-aside__label {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

.static-aside__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.static-aside__list li {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}

.static-cta {
  display: block;
  width: 100%;
  margin-top: 28px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.static-cta:hover {
  background: #274ecf;
  color: #fff;
  text-decoration: none;
}

/* Internal analytics debug (?analytics_debug=1) — owner only */
#fte-analytics-debug {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 9999;
  width: min(280px, calc(100vw - 20px));
  max-height: 50vh;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #c9d4ee;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 28px rgba(12, 25, 55, 0.18);
  font-size: 0.78rem;
  line-height: 1.35;
  color: #1c2333;
  pointer-events: auto;
}

#fte-analytics-debug header {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 700;
}

#fte-analytics-debug .fte-analytics-note {
  margin: 0 0 8px;
  color: #697185;
  font-size: 0.72rem;
}

#fte-analytics-debug dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  margin: 0 0 8px;
}

#fte-analytics-debug dt {
  margin: 0;
  font-weight: 500;
}

#fte-analytics-debug dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

#fte-analytics-debug .fte-analytics-session {
  margin: 0 0 8px;
  font-size: 0.7rem;
  color: #4a5568;
  word-break: break-word;
}

#fte-analytics-debug button {
  width: 100%;
  min-height: 32px;
  font-size: 0.75rem;
  padding: 6px 8px;
}

/* Embedded in Catholic Kids Crafts /play/face-to-emoji */
html.embed-mode .why-like,
html.embed-mode .site-footer {
  display: none;
}

html.embed-mode .app-shell {
  max-width: none;
  padding: 8px 4px 12px;
}

html.embed-mode .hero {
  margin-bottom: 10px;
}

html.embed-mode .hero h1 {
  font-size: 1.5rem;
}
