:root {
  color-scheme: light;
  --paper: #fffaf0;
  --paper-strong: #ffffff;
  --ink: #263238;
  --muted: #687477;
  --line: #d9ccb6;
  --sun: #f4d36f;
  --sun-dark: #b98222;
  --mint: #9ad8bc;
  --sky: #9ec5e8;
  --rose: #e99595;
  --plum: #6d5a7c;
  --leaf: #517c60;
  --shadow: 0 18px 45px rgba(57, 47, 31, 0.14);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(51, 106, 147, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #f2eadc;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.95), rgba(250, 244, 232, 0.96)),
    repeating-linear-gradient(90deg, rgba(158, 197, 232, 0.14) 0 1px, transparent 1px 42px);
}

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

button {
  cursor: pointer;
}

a {
  color: #265f8f;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 1rem;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.75rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.header-note,
.section-note,
.eyebrow {
  color: var(--muted);
}

.header-note {
  max-width: 18rem;
  margin: 0 0 0.35rem;
  text-align: right;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 2rem;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.88fr) minmax(320px, 1.12fr);
  gap: 1rem;
  min-height: 520px;
}

.pet-panel,
.prompt-panel,
.entry-section,
.gallery-section,
.data-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: var(--shadow);
}

.pet-panel {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-self: start;
  overflow: hidden;
}

.room {
  position: relative;
  min-height: 340px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(244, 211, 111, 0.25), transparent 56%),
    linear-gradient(90deg, rgba(154, 216, 188, 0.38), rgba(158, 197, 232, 0.34));
}

.room::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(109, 90, 124, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109, 90, 124, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, #000 0 68%, transparent 100%);
}

.floor-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 4px;
  background: rgba(99, 79, 57, 0.22);
}

.wall-frames {
  position: absolute;
  left: 1.25rem;
  right: 1.25rem;
  top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.55rem;
  min-height: 84px;
}

.wall-frame {
  aspect-ratio: 1;
  padding: 0.32rem;
  border: 5px solid #8d6e4f;
  border-radius: 5px;
  background: #fffefa;
  box-shadow: 0 8px 14px rgba(57, 47, 31, 0.18);
  transform: rotate(var(--tilt, -1deg));
}

.wall-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 3px;
  background: #fffefa;
}

.empty-frame {
  display: grid;
  place-items: center;
  padding: 0.5rem;
  border: 2px dashed rgba(82, 72, 60, 0.28);
  border-radius: 5px;
  color: rgba(82, 72, 60, 0.68);
  font-size: 0.8rem;
  text-align: center;
  background: rgba(255, 250, 240, 0.5);
}


.pip {
  position: absolute;
  left: 50%;
  bottom: 42px;
  width: 176px;
  height: 170px;
  transform: translateX(-50%);
  filter: drop-shadow(0 10px 12px rgba(74, 57, 50, 0.08));
}

.pip-body {
  --ghost-fill: #f9f7ff;
  position: absolute;
  inset: 0 16px 18px;
  border: 4px solid #4a3932;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.95) 0 10%, transparent 11%),
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.86) 0 15%, transparent 16%),
    linear-gradient(180deg, #ffffff 0%, #f4efff 62%, #eadffb 100%);
  clip-path: polygon(13% 10%, 24% 4%, 38% 1%, 50% 4%, 62% 1%, 77% 4%, 88% 10%, 96% 24%, 100% 43%, 99% 66%, 94% 84%, 84% 95%, 72% 86%, 60% 96%, 48% 87%, 36% 96%, 24% 85%, 12% 95%, 4% 82%, 0 63%, 0 42%, 4% 22%);
  border-radius: 42% 42% 28% 28% / 36% 36% 18% 18%;
  box-shadow: inset -10px -14px 0 rgba(169, 151, 214, 0.16);
}

.pip-body::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 20px;
  width: 42px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(1px);
}

.pip-face {
  position: absolute;
  left: 50%;
  top: 44px;
  width: 84px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-items: center;
  row-gap: 14px;
  transform: translateX(-50%);
}

.pip-eye {
  width: 12px;
  height: 16px;
  border-radius: 999px;
  background: #332c29;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.26);
  transition: transform 180ms ease, height 180ms ease, width 180ms ease;
}

.pip-mouth {
  grid-column: 1 / span 2;
  justify-self: center;
  width: 30px;
  height: 14px;
  border-bottom: 4px solid #4a3932;
  border-radius: 0 0 28px 28px;
  transition: all 180ms ease;
}

.pip-blush {
  position: absolute;
  top: 86px;
  width: 20px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 183, 201, 0.5);
  opacity: 0.6;
  transition: opacity 180ms ease, transform 180ms ease;
}

.pip-blush-left {
  left: 36px;
}

.pip-blush-right {
  right: 36px;
}

.pip-shadow {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 0;
  height: 18px;
  border-radius: 50%;
  background: rgba(67, 53, 38, 0.14);
}

.pip[data-expression="happy"] .pip-body {
  transform: translateY(-2px);
}

.pip[data-expression="happy"] .pip-mouth {
  width: 34px;
  height: 16px;
  border-bottom-width: 4px;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
}

.pip[data-expression="happy"] .pip-eye {
  transform: translateY(1px) scaleY(0.92);
}

.pip[data-expression="happy"] .pip-blush {
  opacity: 0.88;
  transform: scale(1.05);
}

.pip[data-expression="neutral"] .pip-mouth {
  width: 24px;
  height: 0;
  border-bottom: 0;
  border-top: 4px solid #4a3932;
  border-radius: 999px;
  margin-top: 5px;
}

.pip[data-expression="sad"] .pip-body {
  transform: translateY(3px);
}

.pip[data-expression="sad"] .pip-mouth {
  width: 30px;
  height: 12px;
  border-bottom: 0;
  border-top: 4px solid #4a3932;
  border-radius: 28px 28px 0 0;
  margin-top: 3px;
}

.pip[data-expression="sad"] .pip-eye:first-child {
  transform: rotate(8deg) translateY(1px);
}

.pip[data-expression="sad"] .pip-eye:last-child {
  transform: rotate(-8deg) translateY(1px);
}

.pip[data-expression="sad"] .pip-blush {
  opacity: 0.3;
}

.pet-status,
.gift-shelf,
.prompt-panel,
.entry-section,
.gallery-section,
.data-section {
  padding: 1rem;
}

.pet-status {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1rem;
  align-items: center;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}

.pet-status h2,
.gift-shelf h2,
.prompt-panel h2,
.entry-section h2,
.gallery-section h2,
.data-section h2 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.meter {
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(68, 58, 45, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.meter span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--sun), var(--mint));
  transition: width 220ms ease;
}

.meter-wrap p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gift-shelf {
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(82, 72, 60, 0.18);
  border-radius: 999px;
  color: #4c433d;
  background: rgba(255, 255, 255, 0.64);
  font-size: 0.86rem;
  font-weight: 700;
}

.gift-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 42px;
}

.gift {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(82, 72, 60, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.66);
  font-weight: 700;
}

.gift::before {
  content: "";
  width: 0.78rem;
  height: 0.78rem;
  border: 2px solid currentColor;
  border-radius: 3px;
  background: var(--gift-color, var(--sun));
}

.prompt-panel {
  display: flex;
  flex-direction: column;
}

.pet-message {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border-left: 4px solid var(--sun-dark);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(244, 211, 111, 0.22);
  color: #5a472d;
}

.prompt-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: -0.15rem 0 1rem;
}

.prompt-control {
  display: grid;
  gap: 0.35rem;
}

.prompt-control span {
  margin-bottom: 0;
}

.prompt-text {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.references-block {
  margin-top: auto;
  padding-top: 1.5rem;
}

.references-block h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

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

.reference-card {
  display: grid;
  gap: 0.25rem;
  min-height: 84px;
  padding: 0.7rem;
  border: 1px solid rgba(82, 72, 60, 0.17);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.reference-card:hover {
  transform: translateY(-2px);
  border-color: rgba(38, 95, 143, 0.35);
  background: #ffffff;
}

.reference-card strong {
  line-height: 1.15;
}

.reference-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.entry-section,
.gallery-section,
.data-section {
  background: rgba(255, 255, 255, 0.66);
}

.entry-form {
  display: grid;
  grid-template-columns: minmax(240px, 0.78fr) minmax(260px, 1fr);
  gap: 1rem;
}

.upload-zone {
  display: grid;
  gap: 0.75rem;
}

.file-drop {
  display: grid;
  gap: 0.3rem;
  padding: 1rem;
  border: 2px dashed rgba(38, 95, 143, 0.34);
  border-radius: var(--radius);
  background: rgba(158, 197, 232, 0.16);
}

.file-drop-title {
  font-weight: 850;
}

.file-drop-note {
  color: var(--muted);
  font-size: 0.9rem;
}

#imageInput,
#importInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.image-preview {
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid rgba(82, 72, 60, 0.18);
  border-radius: var(--radius);
  color: var(--muted);
  background:
    linear-gradient(45deg, rgba(104, 116, 119, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(104, 116, 119, 0.06) 25%, transparent 25%),
    #fffefa;
  background-size: 22px 22px;
}

.image-preview img {
  width: 100%;
  height: 100%;
  max-height: 340px;
  object-fit: contain;
  background: #fffefa;
}

.image-missing {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  background: #fffefa;
}

.field-grid {
  display: grid;
  gap: 0.8rem;
}

label span,
.search-label span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 800;
}

textarea,
input[type="text"],
input[type="search"],
select {
  width: 100%;
  border: 1px solid rgba(82, 72, 60, 0.2);
  border-radius: var(--radius);
  padding: 0.75rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
}

select {
  min-height: 2.75rem;
}

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

.form-actions,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.button,
.icon-button {
  border: 1px solid rgba(54, 44, 36, 0.18);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffefa;
  font-weight: 850;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease;
}

.button {
  min-height: 2.75rem;
  padding: 0.64rem 0.9rem;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button.primary {
  border-color: rgba(78, 93, 70, 0.22);
  background: var(--mint);
}

.button.secondary {
  background: #fff3bf;
}

.button.quiet {
  background: rgba(255, 255, 255, 0.56);
}

.button.danger {
  border-color: rgba(138, 72, 72, 0.25);
  background: #ffd4ca;
}

.search-label {
  width: min(100%, 300px);
}

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

.gallery-card {
  display: grid;
  grid-template-rows: 210px auto;
  overflow: hidden;
  border: 1px solid rgba(82, 72, 60, 0.18);
  border-radius: var(--radius);
  background: #fffefa;
  text-align: left;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #efe7d9;
}

.gallery-copy {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem;
}

.gallery-copy h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.gallery-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 2rem;
  border: 1px dashed rgba(82, 72, 60, 0.22);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.48);
}

.data-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.data-section .section-note {
  max-width: 48rem;
  margin: 0.45rem 0 0;
}

.entry-dialog {
  width: min(920px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.entry-dialog::backdrop {
  background: rgba(39, 34, 29, 0.42);
}

.entry-dialog article {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(260px, 1fr);
  gap: 1rem;
  padding: 1rem;
}

.icon-button {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  z-index: 2;
}

.dialog-image {
  display: grid;
  place-items: center;
  min-height: 360px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #efe7d9;
}

.dialog-image img {
  width: 100%;
  height: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.dialog-copy {
  align-self: center;
  padding-right: 2.5rem;
}

.dialog-copy h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.dialog-copy p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  max-width: min(92vw, 520px);
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(82, 72, 60, 0.18);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffefa;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 1rem);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 880px) {
  .site-header,
  .data-section {
    align-items: start;
    flex-direction: column;
  }

  .header-note {
    max-width: none;
    text-align: left;
  }

  .studio-grid,
  .entry-form,
  .entry-dialog article {
    grid-template-columns: 1fr;
  }

  .prompt-panel {
    min-height: 480px;
  }

  .gallery-grid,
  .reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-copy {
    padding-right: 0;
  }
}

@media (max-width: 560px) {
  .site-header,
  .app-shell {
    width: min(100% - 1rem, 1180px);
  }

  .section-heading,
  .pet-status {
    align-items: start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .prompt-controls {
    grid-template-columns: 1fr;
  }

  .reference-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-card {
    grid-template-rows: 230px auto;
  }

  .prompt-text {
    font-size: 2rem;
  }
}
