@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+Thai:wght@400;500;600;700&display=swap');

:root {
  --hogwarts-bg: #15191d;
  --hogwarts-navy: #222529;
  --hogwarts-card: #34312e;
  --hogwarts-card-light: #403a34;
  --hogwarts-input: #222529;
  --hogwarts-walnut: #665347;
  --hogwarts-gold: #b79a6c;
  --hogwarts-text: #ede4d6;
  --hogwarts-muted: #beb1a2;
  --hogwarts-border: #6c6053;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--hogwarts-bg);
  color: var(--hogwarts-text);
  font-family: Georgia, serif;
}

.container {
  max-width: 900px;
  margin: auto;
  padding: 100px 24px;
  text-align: center;
}

.symbol {
  font-size: 50px;
  color: var(--hogwarts-gold);
}

h1 {
  font-size: clamp(32px, 6vw, 60px);
  color: var(--hogwarts-text);
  margin-bottom: 12px;
}

.subtitle {
  font-style: italic;
  color: var(--hogwarts-muted);
}

.buttons {
  margin-top: 40px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
}

button {
  padding: 14px 26px;
  background: var(--hogwarts-walnut);
  color: white;
  border: 1px solid var(--hogwarts-gold);
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  background: #806a51;
}

section {
  margin-top: 90px;
  padding: 30px;
  border-top: 1px solid var(--hogwarts-border);
}

section p {
  line-height: 1.8;
}

/* Authentication Panel */

.auth-panel {
  max-width: 440px;
  margin: 45px auto 0;
  padding: 30px;
  border: 1px solid var(--hogwarts-border);
  border-radius: 10px;
  background: var(--hogwarts-card);
}

.auth-panel[hidden] {
  display: none;
}

.auth-panel h2 {
  color: var(--hogwarts-text);
}

.auth-panel p {
  line-height: 1.6;
}

.auth-panel input {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 15px 0;
  border: 1px solid var(--hogwarts-border);
  border-radius: 6px;
  background: var(--hogwarts-input);
  color: white;
  font-size: 15px;
}

.auth-panel input:focus {
  outline: 2px solid var(--hogwarts-gold);
}

#authMessage {
  color: var(--hogwarts-text);
  overflow-wrap: anywhere;
}


/* ==================================
   Character Registration
================================== */

.character-page {
  padding-top: 55px;
}

.character-form {
  max-width: 650px;
  margin: 45px auto;
  padding: 35px;
  background: var(--hogwarts-card);
  border: 1px solid var(--hogwarts-border);
  border-radius: 12px;
  text-align: left;
}

.character-form h2 {
  color: var(--hogwarts-text);
  font-size: 23px;
  margin: 10px 0 24px;
}

.character-form label:not(.upload-box) {
  display: block;
  margin: 20px 0 8px;
  color: var(--hogwarts-text);
}

.character-form input:not(.file-input),
.character-form select,
.character-form textarea {
  width: 100%;
  padding: 13px;
  background: var(--hogwarts-input);
  border: 1px solid var(--hogwarts-border);
  border-radius: 6px;
  color: var(--hogwarts-text);
  font-size: 15px;
  font-family: inherit;
}

.character-form textarea {
  resize: vertical;
}

.form-section {
  margin-top: 45px;
  padding-top: 25px;
  border-top: 1px solid var(--hogwarts-border);
}

.section-description {
  color: var(--hogwarts-muted);
  line-height: 1.6;
  font-size: 14px;
}

.portrait-upload {
  display: flex;
  justify-content: center;
  margin: 25px 0;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed var(--hogwarts-gold);
  border-radius: 8px;
  background: var(--hogwarts-input);
  color: var(--hogwarts-gold);
  text-align: center;
}

.upload-box span {
  font-size: 35px;
}

.upload-box small {
  display: block;
  font-size: 12px;
  margin-top: 5px;
}

.portrait-box {
  width: 180px;
  height: 240px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-top: 25px;
}

.memory-box {
  width: 100%;
  aspect-ratio: 4 / 5;
}

.upload-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.save-button {
  display: block;
  width: 100%;
  margin-top: 35px;
}

#characterMessage {
  color: var(--hogwarts-text);
  text-align: center;
}

.back-link {
  margin-top: 30px;
}

.back-link a {
  color: var(--hogwarts-gold);
  text-decoration: none;
}

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

@media (max-width: 600px) {
  .character-form {
    padding: 20px;
  }

  .memory-grid {
    gap: 8px;
  }
}

/* ==================================
   Student Profile Preview
================================== */

.preview-button {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 30px;
  background: transparent;
  border: 1px solid var(--hogwarts-gold);
  border-radius: 7px;
  color: var(--hogwarts-text);
  font-size: 16px;
  cursor: pointer;
}

.preview-button:hover {
  background: var(--hogwarts-card-light);
}

.profile-preview[hidden],
.preview-portrait-frame img[hidden],
#previewPortraitEmpty[hidden] {
  display: none;
}

.profile-preview {
  max-width: 650px;
  margin: 35px auto;
}

.profile-preview-card {
  padding: 28px;
  background: var(--hogwarts-card);
  border: 1px solid var(--hogwarts-gold);
  border-radius: 12px;
  text-align: left;
}

.profile-preview-heading {
  text-align: center;
  margin-bottom: 25px;
}

.preview-star {
  color: var(--hogwarts-gold);
  font-size: 28px;
}

.profile-preview-heading p {
  color: var(--hogwarts-gold);
  font-size: 12px;
  letter-spacing: 2px;
}

.profile-preview-heading h2 {
  color: var(--hogwarts-text);
  font-size: 28px;
}

.profile-preview-details {
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

.preview-portrait-frame {
  width: 155px;
  aspect-ratio: 3 / 4;
  flex-shrink: 0;
  background: var(--hogwarts-input);
  border: 1px solid var(--hogwarts-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#previewPortraitEmpty {
  font-size: 45px;
  color: var(--hogwarts-gold);
}

.preview-student-details {
  min-width: 0;
  overflow-wrap: anywhere;
}

.preview-student-details h3 {
  color: var(--hogwarts-text);
  font-size: 23px;
  margin: 0 0 15px;
}

.preview-student-details p {
  color: var(--hogwarts-muted);
  margin: 8px 0;
  line-height: 1.5;
}

.preview-farewell {
  border-top: 1px solid var(--hogwarts-border);
  margin-top: 25px;
  padding-top: 20px;
}

.preview-farewell h3 {
  color: var(--hogwarts-text);
}

.preview-farewell p {
  color: var(--hogwarts-muted);
  font-style: italic;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-note {
  color: var(--hogwarts-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 15px;
}

@media (max-width: 480px) {
  .profile-preview-details {
    flex-direction: column;
    align-items: center;
  }

  .preview-student-details {
    width: 100%;
  }
}


/* ==================================
   Magical Memories - Profile Preview
================================== */

.preview-memories {
  border-top: 1px solid var(--hogwarts-border);
  margin-top: 25px;
  padding-top: 20px;
}

.preview-memories h3 {
  color: var(--hogwarts-text);
  margin-bottom: 20px;
}

.preview-memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.preview-memory-frame {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  aspect-ratio: 4 / 5;

  background: var(--hogwarts-input);
  border: 1px dashed var(--hogwarts-border);
  border-radius: 8px;
  overflow: hidden;
}

.preview-memory-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-memory-frame img[hidden],
.preview-memory-frame span[hidden] {
  display: none;
}

.preview-memory-frame span {
  color: var(--hogwarts-muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 480px) {
  .preview-memory-grid {
    gap: 8px;
  }
}

/* Upload file size information */

.upload-hint {
  color: #b8a78a;
  font-size: 12px;
  line-height: 1.7;
  margin: 8px 0 18px;
}

/* Magical Memories Lightbox */

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(5, 9, 20, 0.94);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 50px 20px;
  box-sizing: border-box;
}

.image-lightbox img {
  max-width: 95%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid #c6a56a;
  border-radius: 8px;
  box-shadow: 0 0 35px rgba(198, 165, 106, 0.18);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 25px;
  background: transparent;
  border: none;
  color: var(--hogwarts-text);
  font-size: 42px;
  cursor: pointer;
  line-height: 1;
}

.lightbox-close:hover {
  color: white;
}

.preview-memory-frame img {
  cursor: zoom-in;
}


/* ==================================
   My Characters Page
================================== */

.my-characters-page {
  min-height: 100vh;
  padding: 60px 20px;
  background: var(--hogwarts-bg);
  color: var(--hogwarts-text);
}

.my-characters-container {
  max-width: 720px;
  margin: 0 auto;
}

.my-characters-heading {
  text-align: center;
  margin-bottom: 35px;
}

.my-characters-star {
  font-size: 36px;
  margin-bottom: 15px;
}

.my-characters-heading > p:first-of-type {
  letter-spacing: 3px;
  font-size: 12px;
}

.my-characters-heading h1 {
  font-size: 48px;
  margin: 15px 0;
}

.my-characters-subtitle {
  font-style: italic;
  color: var(--hogwarts-muted);
}

.new-character-button {
  display: block;
  text-align: center;
  padding: 16px;
  background: var(--hogwarts-walnut);
  border: 1px solid var(--hogwarts-gold);
  border-radius: 6px;
  color: white;
  text-decoration: none;
  margin-bottom: 40px;
}

.my-characters-container h2 {
  margin-bottom: 20px;
}

.characters-list {
  display: grid;
  gap: 18px;
}

.my-character-card {
  display: flex;
  gap: 20px;
  padding: 20px;
  background: var(--hogwarts-card);
  border: 1px solid var(--hogwarts-border);
  border-radius: 10px;
}

.my-character-portrait {
  width: 100px;
  height: 130px;
  flex-shrink: 0;
  background: var(--hogwarts-input);
  border: 1px solid var(--hogwarts-border);
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 32px;
}

.my-character-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.my-character-details h3 {
  margin: 0 0 12px;
  font-size: 24px;
}

.my-character-details p {
  margin: 8px 0;
  color: var(--hogwarts-muted);
}

.my-character-details a {
  display: inline-block;
  margin-top: 12px;
  color: var(--hogwarts-text);
}

.my-characters-back {
  display: block;
  margin-top: 40px;
  text-align: center;
  color: var(--hogwarts-text);
}

@media (max-width: 480px) {
  .my-characters-heading h1 {
    font-size: 36px;
  }

  .my-character-card {
    padding: 14px;
    gap: 14px;
  }

  .my-character-portrait {
    width: 80px;
    height: 110px;
  }
}

/* Logout button - top right */

.logout-top-right {
  position: fixed !important;
  top: 20px;
  right: 24px !important;
  left: auto !important;
  z-index: 1000;

  width: auto;
  margin: 0;

  padding: 10px 20px;
  background: var(--hogwarts-card);
  color: #e8d7b0;
  border: 1px solid var(--hogwarts-gold);
  border-radius: 8px;
  cursor: pointer;
}

.logout-top-right:hover {
  background: var(--hogwarts-walnut);
}

[hidden] {
  display: none !important;
}

/* ==================================
   Global Thai Font
   ================================== */

body,
button,
input,
textarea,
select {
  font-family: Georgia, "Noto Serif Thai", serif;
}


/* ==================================
   Registry Profile Pop-up
================================== */

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

.registry-profile-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;

  display: flex;
  justify-content: center;
  align-items: center;

  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 20px;

  box-sizing: border-box;
  overflow-y: auto;

  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
}

.registry-profile-modal .profile-preview-card {
  position: relative;

  width: 100%;
  max-width: 550px;
  max-height: 90vh;

  overflow-y: auto;
  box-sizing: border-box;

  margin: auto;
  padding: 28px;

  background: var(--hogwarts-card);
  border: 1px solid var(--hogwarts-gold);
  border-radius: 12px;

  animation: profilePopIn 0.25s ease;
}

.profile-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;

  background: transparent;
  border: none;

  color: var(--hogwarts-text);
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
}

.profile-modal-close:hover {
  color: white;
  transform: scale(1.1);
}

.registry-card {
  cursor: pointer;
}

.registry-card:focus-visible {
  outline: 2px solid #d5b77c;
  outline-offset: 4px;
}

@keyframes profilePopIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 480px) {
  .registry-profile-modal {
    padding: 10px;
  }

  .registry-profile-modal .profile-preview-card {
    padding: 22px 16px;
  }
}


/* ==================================
   Character Preview - Student Details
================================== */

.character-page .preview-name-group {
  margin-bottom: 18px;
}

.character-page .preview-name-group h3 {
  color: var(--hogwarts-text);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 5px;
  overflow-wrap: break-word;
}

.character-page .preview-uid {
  display: block;
  color: #aaa6b3;
  font-size: 12px;
  letter-spacing: 0.3px;
  margin-bottom: 15px;
  overflow-wrap: anywhere;
}

.character-page .preview-student-details p {
  margin: 11px 0;
  color: var(--hogwarts-muted);
  font-size: 16px;
  line-height: 1.5;
}

.character-page .preview-student-details strong {
  color: var(--hogwarts-text);
}


/* ==================================
   FIX - Character Profile Preview
================================== */

.character-page .profile-preview-details {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 22px;
  width: 100%;
}

.character-page .preview-portrait-frame {
  flex: 0 0 155px;
}

.character-page .preview-student-details {
  flex: 1;
  min-width: 0;
  width: auto;
  overflow-wrap: break-word;
}


/* ให้ Farewell และ Memories อยู่ด้านล่าง */
.character-page .preview-farewell,
.character-page .preview-memories {
  width: 100%;
  box-sizing: border-box;
  clear: both;
}

@media (max-width: 480px) {
  .character-page .profile-preview-details {
    flex-direction: column;
    align-items: center;
  }

  .character-page .preview-student-details {
    width: 100%;
  }
}

/* ==================================
   Hogwarts House Colors
   Shared palette: Preview + My Characters
   ================================== */

/* These values are intentionally shared across both views. */
.profile-preview[data-house="Gryffindor"],
.my-character-card[data-house="Gryffindor"] {
  --house-bg: #3b202a;
  --house-border: #a65a62;
}

.profile-preview[data-house="Ravenclaw"],
.my-character-card[data-house="Ravenclaw"] {
  --house-bg: #1a304c;
  --house-border: #688fbf;
}

.profile-preview[data-house="Hufflepuff"],
.my-character-card[data-house="Hufflepuff"] {
  --house-bg: #403522;
  --house-border: #c5a35b;
}

.profile-preview[data-house="Slytherin"],
.my-character-card[data-house="Slytherin"] {
  --house-bg: #1c352f;
  --house-border: #6a9b83;
}

/* Character Registration preview and Registry popup. */
.profile-preview[data-house] .profile-preview-card,
.registry-profile-modal[data-house] .profile-preview-card {
  background: var(--house-bg, var(--hogwarts-card));
  border-color: var(--house-border, var(--hogwarts-gold));
}

/* My Characters: the actual card class used in style.css. */
.my-character-card[data-house] {
  background: var(--house-bg, var(--hogwarts-card));
  border-color: var(--house-border, var(--hogwarts-border));
}



/* ==============================================
   ROYAL HOGWARTS ARCHIVE — unified visual theme
   Shared by all pages; house colors remain intact.
============================================== */
html, body {
  background: var(--hogwarts-bg);
  color: var(--hogwarts-text);
}

.container, .character-page, .my-characters-page, .registry-page {
  background-color: var(--hogwarts-bg);
  color: var(--hogwarts-text);
}

h1, h2, h3 { color: var(--hogwarts-text); }
.subtitle, .section-description, .my-characters-subtitle {
  color: var(--hogwarts-muted);
}
.symbol, .my-characters-star, .preview-star { color: var(--hogwarts-gold); }

/* Elegant panels and form fields */
.auth-panel, .character-form {
  background: var(--hogwarts-card);
  border-color: var(--hogwarts-border);
}
.auth-panel input,
.character-form input:not(.file-input),
.character-form select,
.character-form textarea,
.registry-search {
  background: var(--hogwarts-input);
  color: var(--hogwarts-text);
  border-color: var(--hogwarts-border);
}
input::placeholder, textarea::placeholder { color: var(--hogwarts-muted); opacity: 1; }
.auth-panel input:focus,
.character-form input:focus,
.character-form select:focus,
.character-form textarea:focus,
.registry-search:focus {
  outline-color: var(--hogwarts-gold);
  border-color: var(--hogwarts-gold);
}
.character-form select option {
  background: var(--hogwarts-input);
  color: var(--hogwarts-text);
}
.character-form h2, .character-form label:not(.upload-box),
.preview-farewell h3, .preview-memories h3,
.preview-student-details strong { color: var(--hogwarts-text); }

.upload-box, .preview-portrait-frame, .preview-memory-frame {
  background: var(--hogwarts-input);
  border-color: var(--hogwarts-border);
}
.form-section, .preview-farewell, .preview-memories {
  border-top-color: var(--hogwarts-border);
}

/* Buttons and links */
button, .new-character-button {
  background: var(--hogwarts-walnut);
  border-color: var(--hogwarts-gold);
  color: var(--hogwarts-text);
}
button:hover, .new-character-button:hover { background: #806a51; }
.preview-button {
  background: transparent;
  color: var(--hogwarts-text);
  border-color: var(--hogwarts-gold);
}
.preview-button:hover { background: var(--hogwarts-card-light); }
a, .back-link a, .my-characters-back,
.my-character-details a, .my-characters-page a { color: var(--hogwarts-gold); }
.logout-top-right { background: var(--hogwarts-card); color: var(--hogwarts-text); }
.logout-top-right:hover { background: var(--hogwarts-card-light); }

/* Profile preview defaults; selected house overrides below */
.profile-preview-card,
.registry-profile-modal .profile-preview-card {
  background: var(--hogwarts-card);
  border-color: var(--hogwarts-gold);
}
.profile-preview-heading h2,
.preview-student-details h3,
.character-page .preview-name-group h3 { color: var(--hogwarts-text); }
.preview-student-details p, .preview-farewell p,
.preview-note, .preview-memory-frame span,
.preview-uid, .character-page .preview-uid {
  color: var(--hogwarts-muted);
}
.profile-preview-heading p { color: var(--hogwarts-gold); }

/* House colors have priority only when a recognized house is selected. */
.profile-preview[data-house="Gryffindor"] .profile-preview-card,
.profile-preview[data-house="Ravenclaw"] .profile-preview-card,
.profile-preview[data-house="Hufflepuff"] .profile-preview-card,
.profile-preview[data-house="Slytherin"] .profile-preview-card {
  background: var(--house-bg);
  border-color: var(--house-border);
}
.my-character-card {
  background: var(--hogwarts-card);
  border-color: var(--hogwarts-border);
}
.my-character-card[data-house="Gryffindor"],
.my-character-card[data-house="Ravenclaw"],
.my-character-card[data-house="Hufflepuff"],
.my-character-card[data-house="Slytherin"] {
  background: var(--house-bg);
  border-color: var(--house-border);
}
.my-character-details p, .my-characters-page p { color: var(--hogwarts-muted); }
.my-characters-page .my-character-card h3 { color: var(--hogwarts-text); }

/* Shared Registry elements; registry.css may load after this file. */
.registry-heading p, #registryMessage { color: var(--hogwarts-muted); }
.house-tab:not(.active) {
  background: var(--hogwarts-card);
  border-color: var(--hogwarts-border);
  color: var(--hogwarts-text);
}
.registry-card:not([data-house="Gryffindor"]):not([data-house="Ravenclaw"]):not([data-house="Hufflepuff"]):not([data-house="Slytherin"]) {
  background: var(--hogwarts-card);
  border-color: var(--hogwarts-border);
}

/* Preserve transparent close controls and full-screen overlays. */
.lightbox-close, .profile-modal-close { background: transparent; }
.image-lightbox { background: rgba(9, 11, 14, .94); }
.registry-profile-modal { background: rgba(0, 0, 0, .82); }


/* ปรับปุ่ม Register ให้เหมือนปุ่มหน้าแรก */
.new-character-button,
.new-character-button:link,
.new-character-button:visited {
  background-color: #665347 !important;
  color: #f5ede1 !important;
  border: 1px solid #a88d69 !important;

  font-family: "Cormorant Garamond", "Noto Serif Thai", Georgia, serif !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

.new-character-button:hover {
  background-color: #786253 !important;
  color: #ffffff !important;
}


/* ==============================================
   Hogwarts Memorial Archive — Responsive Footer
   ============================================== */
.archive-footer {
  width: 100%;
  padding: 44px 20px 32px;
  background: #1a1c1e;
  border-top: 1px solid var(--hogwarts-walnut);
  text-align: center;
}
.archive-footer-inner {
  max-width: 760px;
  margin: 0 auto;
}
.archive-footer-symbol {
  color: var(--hogwarts-gold);
  font-size: 27px;
  line-height: 1;
  margin-bottom: 12px;
}
.archive-footer h2 {
  color: var(--hogwarts-text);
  font-size: clamp(22px, 4vw, 29px);
  line-height: 1.3;
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}
.archive-footer-motto {
  color: #c9b8a2;
  font-style: italic;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}
.archive-footer-divider {
  width: min(100%, 430px);
  border-top: 1px solid var(--hogwarts-walnut);
  margin: 24px auto 20px;
}
.archive-footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 28px;
  color: #e2d0b5;
  font-size: 14px;
  margin-bottom: 23px;
}
/* Labels become links after the information pages/contact are ready. */
.archive-footer-disclaimer {
  color: #a89a89;
  font-size: 12px;
  line-height: 1.65;
  margin: 5px 0;
}
.archive-footer-credit {
  color: var(--hogwarts-gold);
  font-size: 14px;
  margin: 20px 0 10px;
}
.archive-footer-copyright {
  color: #91877b;
  font-size: 11px;
  margin: 0;
}
@media (max-width: 600px) {
  .archive-footer { padding: 34px 18px 26px; }
  .archive-footer-nav { gap: 12px 20px; }
  .archive-footer-motto { font-size: 14px; }
}


/* =====================================
   Unified Numbers - Hogwarts Archive
   ===================================== */

.my-characters-page,
.character-page,
.registry-page {
  font-variant-numeric: lining-nums tabular-nums;
}

/* ตัวเลขในช่องกรอกข้อมูล */
.character-form input,
.character-form select,
.character-form textarea {
  font-family: Georgia, "Noto Serif Thai", serif;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ชื่อและ UID ในหน้ารวมตัวละคร */
.my-character-details h3,
.my-character-details p,
.registry-card h3,
.registry-card p {
  font-variant-numeric: lining-nums tabular-nums;
}

/* Make homepage Thai text non-italic */
.home-layout .home-frame .archive-subtitle,
.home-layout .home-closing p {
  font-style: normal !important;
}
/* Open Letters: matches the homepage action cards without changing existing buttons */
.home-actions .home-open-letters {
  box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; text-decoration: none; text-align: center; cursor: pointer;
  background: #665347; border: 1px solid #b79a6c; border-radius: 6px; color: #ede4d6;
  padding: 14px 18px; min-width: 0; flex: 1 1 155px;
  font-family: Georgia, "Noto Serif Thai", serif;
}
.home-actions .home-open-letters:hover { background: #806a51; color: #fff; }
.home-actions .home-open-letters:focus-visible { outline: 2px solid #e5c99b; outline-offset: 3px; }
.home-actions .home-open-letters .home-action-icon { width: 22px; height: 22px; flex: none; }
.home-actions .home-open-letters .action-title,
.home-actions .home-open-letters .action-sub { display: block; }
/* Four visible actions after login: tidy two-by-two arrangement. */
.home-actions:has(#myLettersBtn:not([hidden])) { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.home-actions:has(#myLettersBtn:not([hidden])) > button,
.home-actions:has(#myLettersBtn:not([hidden])) > .home-open-letters { width: 100%; min-width: 0; height: 100%; }
@media (max-width: 420px) {
  .home-actions:has(#myLettersBtn:not([hidden])) { gap: 9px; }
  .home-actions .home-open-letters { padding: 12px 8px; }
}

/* Fix: all homepage action tiles use exactly the same grid cell dimensions. */
.home-layout .home-actions:has(#myLettersBtn:not([hidden])) {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch; gap: 10px 12px;
}
.home-layout .home-actions:has(#myLettersBtn:not([hidden])) > button:not([hidden]),
.home-layout .home-actions:has(#myLettersBtn:not([hidden])) > .home-open-letters {
  width: 100%; max-width: none; min-width: 0; min-height: 98px; height: 100%;
  margin: 0; padding: 12px 10px; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: none;
}
.home-layout .home-actions .home-open-letters {
  font-family: 'Cormorant Garamond', 'Noto Serif Thai', Georgia, serif;
  font-size: 18px; font-weight: normal;
}
.home-layout .home-actions .home-open-letters .action-sub { margin-top: 3px; }
@media(max-width:600px) {
  .home-layout .home-actions:has(#myLettersBtn:not([hidden])) {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
  }
}


/* ==============================================
   Elegant Gold — Registry student profile popup
   Scoped to the popup; preserves house backgrounds,
   dimensions, content, and all JavaScript behavior.
   ============================================== */
.registry-profile-modal .profile-preview-card {
  border: 1px solid #c7a56b;
  box-shadow:
    inset 0 0 0 5px var(--house-bg, var(--hogwarts-card)),
    inset 0 0 0 6px rgba(199, 165, 107, .44),
    0 18px 55px rgba(0, 0, 0, .32);
}

/* Delicate antique-gold trim on the character portrait. */
.registry-profile-modal .preview-portrait-frame {
  border: 1px solid #c7a56b;
  box-shadow: 0 0 0 2px rgba(199, 165, 107, .10);
}

/* Match the memory photographs to the portrait frame. */
.registry-profile-modal .preview-memory-frame {
  border: 1px solid rgba(199, 165, 107, .75);
  box-shadow: 0 0 0 2px rgba(199, 165, 107, .07);
}

/* Keep the original section spacing; add a tiny gold star
   centered over each existing divider. */
.registry-profile-modal .preview-farewell,
.registry-profile-modal .preview-memories {
  position: relative;
  border-top: 1px solid rgba(199, 165, 107, .68);
}
.registry-profile-modal .preview-farewell::before,
.registry-profile-modal .preview-memories::before {
  content: '✦';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 9px;
  background: var(--house-bg, var(--hogwarts-card));
  color: #d9b477;
  font-size: 14px;
  line-height: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .registry-profile-modal .profile-preview-card {
    animation: none;
  }
}

/* ==============================================
   Elegant Gold v2 — soft house gradient + fine paper grain
   Popup only. No external image assets required.
   ============================================== */
.registry-profile-modal .profile-preview-card {
  /* Tiny irregular flecks and a faint woven-paper grain,
     layered over a softly lit house-color gradient. */
  background-color: var(--house-bg, var(--hogwarts-card));
  background-image:
    radial-gradient(circle at 14% 19%, rgba(242,221,181,.045) 0 .65px, transparent 1px),
    radial-gradient(circle at 77% 63%, rgba(242,221,181,.035) 0 .6px, transparent 1px),
    repeating-linear-gradient(103deg, rgba(255,240,210,.012) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 20% 0%, rgba(255,235,195,.085), transparent 62%),
    linear-gradient(155deg, rgba(255,255,255,.025), transparent 45%, rgba(0,0,0,.14));
  background-size: 31px 37px, 43px 47px, auto, auto, auto;
}


/* FIX v3: house-specific background rules previously reset background-image.
   Match the house selector and keep the gradient / fine grain visible. */
.registry-profile-modal[data-house] .profile-preview-card,
.registry-profile-modal .profile-preview[data-house] .profile-preview-card,
.registry-profile-modal .profile-preview-card {
  background-color: var(--house-bg, var(--hogwarts-card));
  background-image:
    radial-gradient(circle at 17% 23%, rgba(255,236,196,.09) 0 0.75px, transparent 1.2px),
    radial-gradient(circle at 73% 67%, rgba(255,236,196,.07) 0 0.7px, transparent 1.2px),
    repeating-linear-gradient(108deg, rgba(255,245,220,.022) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 15% 0%, rgba(255,235,198,.14), transparent 65%),
    linear-gradient(160deg, rgba(255,255,255,.035), transparent 48%, rgba(0,0,0,.19)) !important;
  background-size: 29px 37px, 41px 47px, auto, auto, auto;
}


/* ============================================================
   Character Registration Preview — match Elegant Gold registry
   Keeps existing --house-bg and --house-border values untouched.
   Only the registration preview is affected.
   ============================================================ */
.character-page .profile-preview[data-house] .profile-preview-card,
.character-page .profile-preview .profile-preview-card {
  position: relative;
  background-color: var(--house-bg, var(--hogwarts-card));
  background-image:
    radial-gradient(circle at 17% 23%, rgba(255,236,196,.09) 0 .75px, transparent 1.2px),
    radial-gradient(circle at 73% 67%, rgba(255,236,196,.07) 0 .7px, transparent 1.2px),
    repeating-linear-gradient(108deg, rgba(255,245,220,.022) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 15% 0%, rgba(255,235,198,.14), transparent 65%),
    linear-gradient(160deg, rgba(255,255,255,.035), transparent 48%, rgba(0,0,0,.19)) !important;
  background-size: 29px 37px, 41px 47px, auto, auto, auto;
  border: 1px solid #c7a56b;
  box-shadow:
    inset 0 0 0 5px var(--house-bg, var(--hogwarts-card)),
    inset 0 0 0 6px rgba(199,165,107,.44),
    0 18px 55px rgba(0,0,0,.32);
}
.character-page .profile-preview .preview-portrait-frame {
  border: 1px solid #c7a56b;
  box-shadow: 0 0 0 2px rgba(199,165,107,.10);
}
.character-page .profile-preview .preview-memory-frame {
  border: 1px solid rgba(199,165,107,.75);
  box-shadow: 0 0 0 2px rgba(199,165,107,.07);
}
.character-page .profile-preview .preview-farewell,
.character-page .profile-preview .preview-memories {
  position: relative;
  border-top: 1px solid rgba(199,165,107,.68);
}
.character-page .profile-preview .preview-farewell::before,
.character-page .profile-preview .preview-memories::before {
  content: '✦';
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 9px;
  background: var(--house-bg, var(--hogwarts-card));
  color: #d9b477;
  font-size: 14px;
  line-height: 20px;
}
.character-page .profile-preview .preview-archive-footer {
  border-top: 1px solid rgba(199,165,107,.68);
  margin-top: 28px;
  padding: 18px 0 2px;
  text-align: center;
  color: var(--hogwarts-muted);
  font-size: 11px;
  line-height: 1.8;
}
.character-page .profile-preview .preview-archive-footer p { margin: 3px 0; }
.character-page .profile-preview .preview-archive-footer .preview-credit {
  color: var(--hogwarts-gold);
  font-size: 12px;
  margin-top: 12px;
}

/* ============================================================
   My Characters — Elegant Gold paper gradient + texture
   Same five-layer treatment as the Registry profile popup.
   Keep each Hogwarts house's existing background and border.
   ============================================================ */
.my-characters-page .my-character-card[data-house] {
  background-color: var(--house-bg, var(--hogwarts-card));
  background-image:
    radial-gradient(circle at 17% 23%, rgba(255,236,196,.09) 0 .75px, transparent 1.2px),
    radial-gradient(circle at 73% 67%, rgba(255,236,196,.07) 0 .7px, transparent 1.2px),
    repeating-linear-gradient(108deg, rgba(255,245,220,.022) 0 1px, transparent 1px 5px),
    radial-gradient(ellipse at 15% 0%, rgba(255,235,198,.14), transparent 65%),
    linear-gradient(160deg, rgba(255,255,255,.035), transparent 48%, rgba(0,0,0,.19));
  background-size: 29px 37px, 41px 47px, auto, auto, auto;
  border-color: var(--house-border, var(--hogwarts-border));
}

/* Prevent the native iOS date control from overflowing the character form. */
.character-form #firstDay {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
.character-form #firstDay::-webkit-date-and-time-value {
  min-width: 0;
  text-align: center;
}
