:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #26232b;
  background: #f5f1eb;
  --purple: #5d4a78;
  --purple-soft: #f1ebf8;
  --border: #ddd6df;
  --portrait-bg: #eeeeee;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { color: inherit; }

.app {
  width: min(1500px, calc(100% - 32px));
  margin: 34px auto 80px;
}
.site-header { max-width: 760px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .56;
}
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1; }
.intro { font-size: 1rem; line-height: 1.6; }
.muted { font-weight: 500; opacity: .58; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 124px;
  margin: 24px 0 12px;
  border: 2px dashed #aaa1ad;
  border-radius: 18px;
  background: rgba(255,255,255,.6);
  cursor: pointer;
  transition: .15s ease;
}
.dropzone:hover, .dropzone.dragging { transform: translateY(-1px); background: #fff; border-color: var(--purple); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { font-size: 1.08rem; }
.dropzone span { opacity: .62; }
.status { min-height: 1.5em; margin: 10px 2px 18px; opacity: .68; }

.pet-overview {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 28px;
}
.portrait-frame {
  display: grid;
  place-items: center;
  min-height: 104px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--portrait-bg);
}
.portrait-frame img {
  width: 96px;
  height: auto;
  max-height: 88px;
  image-rendering: pixelated;
  object-fit: contain;
}
.portrait-missing { padding: 14px; text-align: center; font-size: .75rem; opacity: .5; }
.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--border);
}
.summary > div { padding: 15px 17px; background: rgba(255,255,255,.95); }
.summary strong { display: block; margin-top: 4px; }
.label { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .55; }

.pedigree-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}
.pedigree-heading h2 { margin: 0 0 4px; }
.pedigree-heading p { margin: 0; font-size: .88rem; opacity: .6; }
.pedigree-heading .pedigree-trim-note { margin-top: 5px; color: #584369; opacity: .9; font-size: .8rem; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.secondary-button, .icon-button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 11px;
  cursor: pointer;
}
.secondary-button { padding: 9px 12px; font-weight: 650; }
.secondary-button:hover { border-color: #b9acbf; background: #fcfbfd; }
.secondary-button:disabled { opacity: .45; cursor: default; }
.icon-button { width: 36px; height: 36px; font-size: 1.4rem; line-height: 1; }
.generation-control {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: white;
  font-size: .84rem;
  white-space: nowrap;
}
.generation-control select { border: 0; border-bottom: 1px solid #aaa1ad; background: transparent; font-weight: 750; cursor: pointer; }

.pedigree-scroll {
  overflow: auto;
  max-height: 72vh;
  padding: 5px 5px 24px;
  scrollbar-gutter: stable;
}
.pedigree { position: relative; min-width: 100%; }
.node-layer, .connectors { position: absolute; inset: 0 auto auto 0; }
.node-layer { z-index: 2; }
.connectors { z-index: 1; overflow: visible; pointer-events: none; }
.connector-path { fill: none; stroke: #b8afb9; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.pet-card {
  position: absolute;
  width: 210px;
  height: 68px;
  padding: 9px 11px;
  overflow: hidden;
  border: 1px solid #d8d1d9;
  border-radius: 11px;
  background: white;
  box-shadow: 0 3px 12px rgba(60,45,65,.05);
}

.pet-card.female {
  border: 3px solid #e6a8b7;
}
.pet-card.male {
  border: 3px solid #9db8df;
}

.pedigree-deep .pet-card { width: 176px; height: 60px; padding: 7px 9px; }
.pet-card-name, .pet-card-breed, .pet-card-breeder { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.15;}
.pet-card-name { font-size: .87rem;
  line-height: 1.15;}
.pet-card-breed { margin-top: 2px; font-size: .74rem; opacity: .72;
  line-height: 1.15;}
.pet-card-breeder { margin-top: 2px; font-size: .66rem; opacity: .52; }
.pedigree-deep .pet-card-name { font-size: .79rem; }
.pedigree-deep .pet-card-breed { font-size: .68rem; }
.pedigree-deep .pet-card-breeder { font-size: .61rem; }

.lines-dialog {
  width: min(440px, calc(100% - 28px));
  max-height: min(680px, calc(100vh - 50px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #d4ccd7;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(40,30,45,.22);
}
.lines-dialog::backdrop { background: rgba(39, 31, 43, .28); backdrop-filter: blur(2px); }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 14px; padding: 20px 20px 14px; border-bottom: 1px solid #eee9ef; }
.dialog-header h2 { margin: 0; }
.trim-warning {
  display: grid;
  gap: 5px;
  margin: 15px 18px 6px;
  padding: 12px 13px;
  border: 1px solid #cdbde0;
  border-radius: 11px;
  background: var(--purple-soft);
  color: #49385f;
  font-size: .86rem;
  line-height: 1.45;
}
.lines-list { max-height: 390px; overflow-y: auto; padding: 8px 20px 12px; }
.line-row { padding: 10px 2px; border-bottom: 1px solid #eee9ef; font-weight: 650; }
.line-row:last-child { border-bottom: 0; }
.empty-lines { opacity: .62; line-height: 1.5; }
.dialog-footer { display: flex; justify-content: end; padding: 13px 18px 18px; border-top: 1px solid #eee9ef; }

@media (max-width: 800px) {
  .app { width: min(100% - 20px, 1500px); margin-top: 22px; }
  .pet-overview { grid-template-columns: 96px 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .pedigree-toolbar { align-items: start; flex-direction: column; }
  .toolbar-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .pet-overview { grid-template-columns: 1fr; }
  .portrait-frame { min-height: 96px; }
  .summary { grid-template-columns: 1fr 1fr; }
}

[hidden] { display: none !important; }

.lines-summary {
  margin: 14px 20px 2px;
  color: #746b78;
  font-size: .82rem;
  line-height: 1.4;
}

.view-control select { min-width: 82px; }

.load-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 12px;
}
.load-tools .dropzone {
  flex: 1 1 100%;
  margin: 0;
}
.folder-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.folder-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.library-status { font-size: .78rem; opacity: .62; }
.pet-card.has-portrait {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: 8px;
  align-content: center;
}
.pet-card.has-portrait .ancestor-portrait {
  grid-row: 1 / 4;
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 7px;
  background: var(--portrait-bg);
}
.pet-card.has-portrait .ancestor-portrait.default-portrait {
  image-rendering: auto;
}
.pedigree-deep .pet-card.has-portrait {
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 7px;
}
.pedigree-deep .pet-card.has-portrait .ancestor-portrait {
  width: 40px;
  height: 40px;
}

.export-button { border-color: #b9acbf; }
.export-button:hover { border-color: var(--purple); }
.export-dialog { width: min(460px, calc(100vw - 28px)); }
.export-options { padding: 8px 18px 18px; }
.export-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.export-option input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--purple); }
.export-option strong, .export-option small { display: block; }
.export-option small { margin-top: 3px; font-size: .76rem; line-height: 1.35; opacity: .58; }
.export-fixed-note {
  margin-top: 14px;
  padding: 11px 12px;
  border-radius: 10px;
  background: #f4eff8;
  font-size: .78rem;
  color: #55405f;
}

.proper-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  max-width: none;
}
.brand-block { max-width: 820px; }
.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.title-row > div { min-width: 0; }
.site-nav {
  display: flex;
  gap: 8px;
  padding-top: 8px;
}
.privacy-banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 22px 0 18px;
  padding: 12px 14px;
  border: 1px solid #d9d0df;
  border-radius: 13px;
  background: rgba(255,255,255,.72);
  font-size: .84rem;
  line-height: 1.45;
}
.privacy-banner strong,
.privacy-banner span { display: block; }
.privacy-banner span { margin-top: 2px; opacity: .68; }
.privacy-icon { font-size: 1.05rem; line-height: 1.4; }
.folder-note {
  flex: 1 1 100%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(255,255,255,.48);
  font-size: .74rem;
  line-height: 1.45;
  opacity: .67;
}
.site-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid rgba(120,108,124,.22);
  color: #655e68;
  font-size: .74rem;
}
.site-footer strong,
.site-footer span { display: block; }
.site-footer span { margin-top: 3px; opacity: .7; }
.site-footer p { margin: 0; opacity: .7; }

.about-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: min(820px, calc(100vh - 36px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #d4ccd7;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(40,30,45,.24);
}
.about-dialog[open] {
  display: flex;
  flex-direction: column;
}
.about-dialog::backdrop {
  background: rgba(39,31,43,.3);
  backdrop-filter: blur(2px);
}
.about-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 22px 22px;
}
.about-content section {
  padding: 17px 0;
  border-bottom: 1px solid #ece7ed;
}
.about-content section:last-child { border-bottom: 0; }
.about-content h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.about-content p {
  margin: 7px 0 0;
  font-size: .86rem;
  line-height: 1.58;
  color: #4e4851;
}
.about-lead p { font-size: .92rem; }
.help-steps,
.help-list {
  margin: 8px 0 0;
  padding-left: 1.25rem;
  color: #4e4851;
  font-size: .84rem;
  line-height: 1.55;
}
.help-steps li,
.help-list li { margin: 7px 0; }
.about-callout {
  margin: 12px 0;
  padding: 15px 16px !important;
  border: 1px solid #ddd3e5 !important;
  border-radius: 12px;
}
.privacy-callout { background: #f7f4fa; }
.about-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: .74rem;
  color: #6b626f;
}
.about-footer span { opacity: .72; }

@media (max-width: 760px) {
  .proper-header { flex-direction: column; }
  .site-nav { padding-top: 0; }
  .title-row { align-items: flex-start; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

.discord-contact {
  white-space: nowrap;
  color: #c0392b;
  font-weight: 700;
}

.js-note {
  text-align: center;
  font-size: 0.74rem;
  color: #6b626f;
}

.updates {
  border: 1px solid #000000;
  background-color: #FEFEFE;
  padding: 10px;
  font-size: .8rem;
}

.site-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

.echo-callout {
  text-align: center;
  background: var(--purple-soft);
  border-color: #cdbde0 !important;
}

.echo-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #fff;
  color: var(--purple);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.pet-text-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 24px));
  padding: 7px 9px;
  border: 1px solid #cfc5d3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(40,30,45,.18);
  color: #342f38;
  font-size: .78rem;
  line-height: 1.35;
  white-space: normal;
  pointer-events: none;
}

.link-button {
  padding-top: 10px;
  text-align: center;
}
