* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: sans-serif;
  background: #f5f6f8;
  color: #0f172a;
}

:focus-visible {
  outline: 3px solid #0ea5e9;
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  padding: 1rem;
}

.screen {
  display: none;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
}

#screen-landing {
  overflow: auto;
  align-items: stretch;
  justify-content: flex-start;
}

.landing-panel {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1rem;
  align-items: center;
}

.landing-copy h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  line-height: 1.05;
}

.landing-copy p {
  margin: 0.55rem 0 1rem;
  color: #334155;
  max-width: 36ch;
}

.landing-cta {
  min-width: 170px;
}

.landing-demo {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  padding: 0.45rem;
}

.landing-demo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 10px;
}

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

.trust-item {
  border: 1px solid #d8e4f1;
  border-radius: 12px;
  background: #f8fbff;
  color: #0f172a;
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.35;
  padding: 0.55rem 0.65rem;
  text-align: center;
  text-wrap: balance;
}

.landing-how {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fcfdff;
  padding: 0.8rem;
}

.landing-how h2,
.landing-faq h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.landing-how ol {
  margin: 0;
  padding-left: 1.1rem;
  color: #334155;
  display: grid;
  gap: 0.2rem;
  line-height: 1.35;
}

.landing-validity {
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
  padding: 0.8rem;
}

.landing-faq {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fcfdff;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.faq-item {
  border: 1px solid #dbe5f0;
  border-radius: 10px;
  background: #ffffff;
  padding: 0.4rem 0.55rem;
}

.faq-item summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}

.faq-item p {
  margin: 0.45rem 0 0;
  color: #334155;
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.screen-footer {
  width: min(960px, 100%);
  margin: 0 auto;
  text-align: center;
}

.screen-footer a {
  color: #64748b;
  font-size: 0.8rem;
  text-decoration: none;
}

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

#screen-builder {
  overflow: auto;
  padding-right: 0.25rem;
}

#screen-result {
  overflow: auto;
  padding-right: 0.25rem;
}

.result-content {
  --result-link-color: #0f766e;
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.result-content h2 {
  margin: 0;
}

.result-content > .result-preview-panel,
.result-content > .result-facts-cta,
.result-content > .alignment-summary,
.result-content > .share-actions,
.result-content > .result-actions,
.result-content > .ad-slot {
  width: 100%;
  margin: 0;
}

.result-facts-cta {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.7rem 1rem;
  min-width: 0;
}

.result-facts-cta a {
  display: inline-block;
  max-width: 100%;
  color: var(--result-link-color);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.result-facts-cta a:hover {
  text-decoration: underline;
}

.result-preview-panel {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  padding: 0.75rem;
}

.builder-panel {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.field,
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-group {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #334155;
}

.field input[type="text"],
.field input[type="file"] {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  background: #fff;
  color: #0f172a;
}

.breed-field {
  position: relative;
}

.breed-typeahead {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.breed-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  background: transparent;
  color: #0f172a;
  text-align: left;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
}

.breed-option:last-child {
  border-bottom: 0;
}

.breed-option:hover {
  background: #f8fafc;
}

.breed-tools {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.breed-tools-head h3 {
  margin: 0;
  font-size: 1rem;
}

.show-all-breeds {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.popular-breed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.breed-chip {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.breed-chip.active {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f766e;
}

.breed-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.breed-modal[hidden] {
  display: none !important;
}

.breed-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.breed-modal-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

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

.breed-modal-head h3 {
  margin: 0;
}

.breed-modal-close {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.68rem;
  cursor: pointer;
}

.breed-modal-list {
  min-height: 0;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.6rem;
}

.breed-group {
  margin-bottom: 0.7rem;
}

.breed-group:last-child {
  margin-bottom: 0;
}

.breed-letter {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.breed-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.breed-modal-item {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.breed-modal-empty {
  margin: 0;
  padding: 0.5rem;
  color: #64748b;
}

.swatch-list {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.swatch-item {
  position: relative;
  display: inline-flex;
}

.swatch-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--sw);
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
}

.swatch-item input:checked + .swatch {
  box-shadow: 0 0 0 2px #0f172a;
}

.font-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.font-item {
  position: relative;
}

.font-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.font-label {
  display: block;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  font-size: 0.95rem;
  text-align: center;
  cursor: pointer;
}

.font-item input:checked + .font-label {
  border-color: #0f766e;
  background: #ecfdf5;
}

.font-a {
  font-family: Georgia, "Times New Roman", serif;
}

.font-b {
  font-family: "Segoe UI", Arial, sans-serif;
}

.font-c {
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

.trait-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.85rem;
}

.trait-sliders h3 {
  margin: 0;
  font-size: 1rem;
}

.trait-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.8rem;
  align-items: center;
}

.trait-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
}

.trait-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
}

.trait-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #14b8a6 0%, #99f6e4 100%);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.trait-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: #cbd5e1;
}

.trait-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #0f766e;
  box-shadow: 0 2px 7px rgba(15, 118, 110, 0.35);
}

.trait-row input[type="range"]::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
}

.trait-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #0f766e;
  box-shadow: 0 2px 7px rgba(15, 118, 110, 0.35);
}

.total-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.75rem 0.9rem;
}

.total-display strong {
  font-size: 1.1rem;
}

.build-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font-weight: 700;
  background: #0f766e;
  color: #fff;
  min-height: 42px;
}

.build-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.build-btn:not(:disabled) {
  opacity: 1;
  cursor: pointer;
}

.form-error {
  margin: 0;
  border: 1px solid #fda4af;
  border-radius: 10px;
  background: #fff1f2;
  color: #9f1239;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
}

.ad-slot {
  width: min(960px, 100%);
  margin: 0 auto;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.8rem;
  text-align: center;
}

.adsense-wrap {
  width: min(960px, 100%);
  margin: 0 auto;
}

.result-contact-link {
  margin: 0;
  font-size: 0.88rem;
  text-align: center;
}

.result-contact-link a {
  color: var(--result-link-color);
  text-decoration: none;
}

.result-contact-link a:hover {
  text-decoration: underline;
}

.builder-nav {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.builder-nav button,
.result-actions button {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
  padding: 0.6rem 0.95rem;
  cursor: pointer;
  min-height: 40px;
}

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

  .landing-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .landing-copy p {
    max-width: 32ch;
  }

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

  .builder-grid,
  .font-picker {
    grid-template-columns: 1fr;
  }

  .breed-tools-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .landing-panel {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  .landing-how,
  .landing-validity,
  .landing-faq {
    padding: 0.7rem;
  }

  .faq-item {
    padding: 0.38rem 0.5rem;
  }

  .faq-item summary {
    font-size: 0.86rem;
  }

  .faq-item p {
    font-size: 0.82rem;
    line-height: 1.4;
  }
}

#cardPreviewFrame {
  width: 100%;
  height: clamp(520px, 70vh, 920px);
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #d8e0ea;
  border-radius: 12px;
  background: #f4f6fa;
}

#cardPreviewScaleWrap {
  width: 1200px;
  height: 1500px;
  flex: 0 0 auto;
  margin: 0 auto;
}

#cardMount {
  width: 1200px;
  height: 1500px;
}

@media (max-width: 900px) {
  #cardPreviewFrame {
    min-height: 420px;
    height: clamp(420px, 62vh, 760px);
  }
}

.alignment-summary {
  width: min(960px, 100%);
  margin: 0 auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.alignment-summary h3 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.alignment-summary-list {
  margin: 0;
  padding-left: 1.15rem;
  color: #0f172a;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  line-height: 1.35;
}

.alignment-summary-list li {
  overflow-wrap: anywhere;
}

.alignment-summary-list a {
  color: var(--result-link-color);
  text-decoration: none;
}

.alignment-summary-list a:hover {
  text-decoration: underline;
}

.alignment-summary-note,
.alignment-summary-disclaimer {
  margin: 0;
  font-size: 0.84rem;
  color: #475569;
}

.alignment-summary-disclaimer {
  color: #334155;
}

.share-actions {
  width: min(960px, 100%);
  margin: 0 auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.share-actions h3 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.share-note {
  margin: 0;
  font-size: 0.85rem;
  color: #475569;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.share-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  min-height: 38px;
}

.copy-caption-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  min-height: 38px;
}

.copy-caption-btn:hover {
  background: #f8fafc;
}

.result-notice {
  margin: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.65rem;
}

.result-actions {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  min-width: 0;
}

.download-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  background: #0f766e;
  color: #fff;
  cursor: pointer;
}

.download-btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.debug-layout {
  outline: 2px dashed #e11d48;
  outline-offset: -2px;
}

.debug-layout .hero {
  outline: 2px dashed #0ea5e9;
  outline-offset: -2px;
}

.debug-layout .body {
  outline: 2px dashed #22c55e;
  outline-offset: -2px;
}

.debug-layout .footer {
  outline: 2px dashed #f59e0b;
  outline-offset: -2px;
}

@media (max-width: 480px) {
  .app-shell {
    padding: 0.75rem;
  }

  #screen-result {
    padding-right: 0;
  }

  .result-content {
    gap: 0.65rem;
  }

  .result-facts-cta,
  .alignment-summary,
  .share-actions,
  .result-preview-panel {
    padding: 0.75rem;
  }

  .result-facts-cta a {
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .alignment-summary-list {
    padding-left: 1rem;
    gap: 0.25rem;
    line-height: 1.4;
  }

  .alignment-summary-list li {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .share-links,
  .result-actions {
    gap: 0.45rem;
  }

  .share-links a,
  .copy-caption-btn,
  .result-actions button {
    min-height: 38px;
    line-height: 1.2;
  }

  .result-actions button {
    flex: 1 1 calc(50% - 0.45rem);
    min-width: 0;
  }
}

@media (max-width: 360px) {
  .share-links {
    flex-direction: column;
    align-items: stretch;
  }

  .share-links a,
  .copy-caption-btn {
    width: 100%;
    justify-content: center;
  }

  .result-actions button {
    flex-basis: 100%;
  }
}
