:root {
  --ink: #172126;
  --muted: #596a72;
  --paper: #f8fbfa;
  --panel: #ffffff;
  --line: #dce7e4;
  --teal: #097d78;
  --green: #18a058;
  --coral: #db6b50;
  --gold: #c48a22;
  --blue: #2c72b8;
  --shadow: 0 18px 50px rgba(23, 33, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgba(9, 125, 120, 0.12), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 62%);
}

a {
  color: inherit;
}

.home-shell,
.pet-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 28px 18px 96px;
}

.hero {
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  text-align: center;
}

.brand-logo {
  width: clamp(124px, 38vw, 190px);
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 22px rgba(23, 33, 38, 0.12));
}

.logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.hero-copy {
  max-width: 650px;
}

h1 {
  margin: 0;
  font-size: clamp(2.55rem, 12vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p,
.pet-intro p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 4vw, 1.35rem);
}

.action-grid {
  width: min(100%, 650px);
  display: grid;
  gap: 12px;
}

.action-button,
.primary-button,
.secondary-button,
.back-link {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.action-button {
  padding: 16px 18px;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(23, 33, 38, 0.13);
}

.action-button:hover,
.primary-button:hover,
.secondary-button:hover,
.back-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(23, 33, 38, 0.14);
}

.action-button.pet {
  background: var(--teal);
}

.action-button.keys {
  background: var(--gold);
}

.action-button.wallet {
  background: var(--blue);
}

.action-button.item {
  background: var(--coral);
}

.action-button.scan,
.action-grid .action-button.scan,
.action-grid .action-button.scan-button {
  border-color: #d9a900;
  color: #000000 !important;
  background: #ffd447 !important;
}

.action-button.scan .button-icon,
.action-grid .action-button.scan .button-icon,
.action-grid .action-button.scan-button .button-icon {
  color: #000000;
  background: rgba(0, 0, 0, 0.08);
}

.admin-login-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 800;
  text-decoration: none;
}

.admin-login-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(23, 33, 38, 0.1);
}

.button-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 1.05rem;
  line-height: 1;
}

.dashboard-grid {
  width: min(100%, 980px);
  display: grid;
  gap: 16px;
  text-align: left;
}

.login-panel {
  width: min(100%, 430px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  text-align: left;
}

.login-panel h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

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

.login-form,
.settings-form,
.edit-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.login-form label,
.settings-form label,
.edit-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.login-form input,
.settings-form input,
.settings-form textarea,
.edit-form input,
.edit-form select,
.edit-form textarea {
  min-height: 48px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  text-transform: none;
}

.settings-form textarea,
.edit-form textarea {
  resize: vertical;
}

.contact-readonly {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.contact-photo-preview {
  min-height: 150px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(9, 125, 120, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: #f7fbfa;
  font-weight: 800;
  text-align: center;
}

.contact-photo-preview img {
  width: 128px;
  height: 128px;
  display: block;
  border-radius: 8px;
  object-fit: cover;
}

.contact-meta {
  width: 100%;
}

.settings-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.edit-form {
  display: block;
}

.form-section {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfa;
}

.form-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.span-all,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.dashboard-panel {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 16px;
}

.admin-toolbar {
  width: min(100%, 980px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
  text-align: left;
}

.logout-button {
  color: #9a2f1c;
  border-color: rgba(219, 107, 80, 0.42);
}

.settings-panel,
.dashboard-heading {
  width: min(100%, 980px);
}

.settings-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  text-align: left;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.compact-button {
  width: auto;
  min-width: 150px;
  flex: 0 0 auto;
}

.dashboard-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card-photo {
  width: 44px !important;
  height: 44px !important;
  max-width: 44px;
  max-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  display: block;
  flex: 0 0 44px;
}

.card-photo.sprite-thumb {
  padding: 5px;
  object-fit: contain;
}

.card-heading h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.type-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #0c6d3d;
  background: rgba(24, 160, 88, 0.12);
  font-size: 0.82rem;
  font-weight: 850;
}

.qr-preview {
  width: 100%;
  min-height: 178px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px dashed rgba(9, 125, 120, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: #f7fbfa;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
}

.qr-preview-link {
  width: 150px !important;
  height: 150px !important;
  max-width: 150px;
  max-height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.qr-preview-image,
.qr-preview img {
  width: 150px !important;
  height: 150px !important;
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
  display: block;
}

.qr-preview-fallback {
  display: none;
}

.qr-preview.is-broken .qr-preview-link {
  display: none;
}

.qr-preview.is-broken .qr-preview-fallback {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.profile-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-meta div {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(220, 231, 228, 0.9);
}

.profile-meta div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.profile-meta dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.profile-meta dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-weight: 750;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.profile-meta a {
  color: var(--teal);
}

.dashboard-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.danger-button {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 16px;
  border: 1px solid rgba(219, 107, 80, 0.48);
  border-radius: 8px;
  color: #9a2f1c;
  background: rgba(219, 107, 80, 0.1);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(23, 33, 38, 0.14);
}

.secondary-button:disabled,
.primary-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.dashboard-message {
  width: min(100%, 980px);
  margin-top: -6px;
  text-align: center;
}

.empty-state {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  text-align: center;
}

.category-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.category-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.category-grid h3 {
  margin: 0;
  font-size: 1rem;
}

.category-grid p {
  margin: 6px 0;
  color: var(--muted);
}

.category-grid span {
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 800;
}

footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 16px;
  border-top: 1px solid rgba(220, 231, 228, 0.8);
  color: var(--muted);
  background: rgba(248, 251, 250, 0.92);
  text-align: center;
  font-size: 0.88rem;
  backdrop-filter: blur(14px);
}

.pet-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.mini-logo {
  width: 52px;
  height: 52px;
}

.back-link {
  min-height: 42px;
  padding: 9px 14px;
  color: var(--teal);
  background: #ffffff;
  font-size: 0.95rem;
}

.pet-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pet-photo {
  width: 100%;
  min-height: 320px;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  padding: 28px;
  color: rgba(23, 33, 38, 0.66);
  background:
    linear-gradient(135deg, rgba(9, 125, 120, 0.2), rgba(219, 107, 80, 0.18)),
    linear-gradient(180deg, #ffffff, #eef6f3);
}

.pet-photo span {
  width: min(100%, 360px);
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(9, 125, 120, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  font-size: 1.05rem;
  font-weight: 800;
}

.pet-content {
  padding: 24px;
}

.pet-intro h1 {
  font-size: clamp(2.4rem, 16vw, 5rem);
}

.pet-actions {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.primary-button,
.secondary-button {
  width: 100%;
  padding: 15px 16px;
  cursor: pointer;
  font: inherit;
}

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

.secondary-button {
  color: var(--teal);
  background: #ffffff;
}

.settings-panel > .section-heading,
.dashboard-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: 10px;
}

.section-heading .compact-button,
.dashboard-heading .compact-button,
.compact-button {
  width: auto;
  min-width: 0;
  min-height: 42px;
  padding: 9px 16px;
  justify-self: start;
}

.contact-card .settings-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.9fr);
  align-items: stretch;
  gap: 10px;
  text-align: left;
}

.contact-card .settings-form .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contact-card .settings-form label {
  display: grid;
  gap: 6px;
  align-content: start;
}

.contact-card .settings-form .span-all {
  grid-column: 1 / -1;
}

.contact-card .settings-form input,
.contact-card .settings-form textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.contact-card .settings-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 0;
}

.contact-card .settings-actions .primary-button,
.contact-card .settings-actions .secondary-button {
  width: 100%;
  min-height: 0;
}

.contact-card .settings-actions .primary-button {
  min-height: 224px;
}

.contact-card .settings-actions .secondary-button {
  min-height: 224px;
}

.status-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.edit-dialog {
  width: min(94vw, 720px);
  max-height: min(88vh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.edit-dialog::backdrop {
  background: rgba(23, 33, 38, 0.38);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.sprite-preview {
  width: 100%;
  min-height: 96px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(9, 125, 120, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
  font-weight: 800;
  text-align: center;
}

.sprite-preview img {
  width: 72px !important;
  height: 72px !important;
  max-width: 72px;
  max-height: 72px;
  display: block;
  object-fit: contain;
}

.pet-photo img {
  width: 100%;
  height: 100%;
  max-height: 560px;
  object-fit: cover;
  border-radius: 8px;
}

.pet-photo img.public-sprite {
  width: min(46%, 190px);
  height: auto;
  max-height: 220px;
  object-fit: contain;
}

.public-page {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 32px 18px 96px;
}

.public-health {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfa;
}

.public-health h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.info-panel {
  min-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.info-panel h1 {
  font-size: clamp(2.2rem, 10vw, 4.6rem);
}

.info-panel p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.instruction-list {
  width: min(100%, 640px);
  display: grid;
  gap: 10px;
  margin: 6px 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.instruction-list li {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 18px rgba(23, 33, 38, 0.08);
}

.page-actions {
  width: min(100%, 640px);
  display: grid;
  gap: 10px;
}

@media (min-width: 720px) {
  .home-shell,
  .pet-shell {
    padding-right: 30px;
    padding-left: 30px;
  }

  .action-grid,
  .pet-actions,
  .dashboard-actions,
  .settings-form,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-form label:nth-last-of-type(-n + 2),
  .settings-form button,
  .form-actions {
    grid-column: 1 / -1;
  }

  .contact-readonly {
    grid-template-columns: 180px minmax(0, 1fr);
    align-items: start;
  }

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

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

  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .pet-card {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
    align-items: stretch;
  }

  .pet-photo {
    min-height: 560px;
  }

  .pet-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 42px;
  }
}

@media (max-width: 360px) {
  .action-button,
  .primary-button,
  .secondary-button {
    font-size: 0.94rem;
  }
}

@media (max-width: 719px) {
  .dashboard-panel {
    gap: 18px;
  }

  .section-heading,
  .dashboard-heading {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .section-heading > div,
  .dashboard-heading > div {
    min-width: 0;
  }

  .compact-button,
  .section-heading .compact-button,
  .dashboard-heading .compact-button {
    width: 100%;
    min-width: 0;
  }

  .settings-panel {
    padding: 16px;
  }

  .contact-card .settings-form,
  .contact-card .settings-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-card .settings-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-card .settings-actions .primary-button,
  .contact-card .settings-actions .secondary-button {
    min-height: 52px;
  }

  .admin-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-toolbar .logout-button {
    width: 100%;
  }

  .edit-dialog {
    width: min(96vw, 520px);
    max-height: 92vh;
    padding: 16px;
  }

  .edit-dialog .section-heading {
    position: relative;
    padding-right: 48px;
  }

  .edit-dialog .icon-button {
    position: absolute;
    top: 0;
    right: 0;
  }

  .edit-dialog .section-heading h2 {
    font-size: 1.35rem;
  }

  .edit-dialog .section-heading p {
    font-size: 0.95rem;
  }

  .form-section {
    padding: 14px;
  }

  .form-grid,
  .settings-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .edit-form label,
  .settings-form label,
  .edit-dialog .form-grid > label {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .edit-form input,
  .edit-form select,
  .edit-form textarea,
  .settings-form input,
  .settings-form textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .edit-form input[type="file"],
  .settings-form input[type="file"] {
    min-height: auto;
    padding: 12px;
  }

  .span-all,
  .form-actions,
  .settings-actions {
    grid-column: 1 / -1;
  }

  .form-actions,
  .settings-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-actions .primary-button,
  .settings-actions .primary-button,
  .settings-actions .secondary-button {
    width: 100%;
  }
}
