/* ==========================================================================
   妖精的女儿 · 管理端
   与公开页共用纸面 / 金框 / 浮雕语言
   ========================================================================== */

.admin-body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 8% 4%, rgba(235, 201, 201, 0.28), transparent 26%),
    radial-gradient(circle at 94% 6%, rgba(201, 182, 217, 0.22), transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(169, 190, 214, 0.16), transparent 32%),
    repeating-linear-gradient(0deg, rgba(184, 137, 59, 0.028) 0 1px, transparent 1px 28px);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
}

/* --------------------------------------------------------------------------
   顶栏
   -------------------------------------------------------------------------- */

.admin-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background: rgba(251, 243, 228, 0.98);
  border-bottom: 2px solid var(--gold);
  box-shadow:
    inset 0 1px 0 #FFFDF7,
    0 8px 22px rgba(74, 30, 47, 0.09);
  backdrop-filter: blur(8px);
}

.admin-header__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 13px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 22px;
  flex-wrap: wrap;
}

.admin-header__brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.admin-header__emblem {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 2px rgba(74, 30, 47, 0.16));
}

.admin-header__emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}

.admin-header__words {
  min-width: 0;
}

.admin-header__title {
  color: var(--wine);
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.admin-header__sub {
  margin: 1px 0 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.admin-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 4px 15px;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: var(--card-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.badge.is-warning {
  border-color: #B25A6A;
  background: #FBE9EA;
  color: #7A2333;
}

.badge.is-ok {
  border-color: #6E8B5B;
  background: #EAF3E4;
  color: #2F5D3A;
}

/* --------------------------------------------------------------------------
   主体与面板
   -------------------------------------------------------------------------- */

.admin-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 26px 64px;
}

.panel {
  position: relative;
  margin-bottom: 28px;
  padding: 28px 30px 30px;
  border: 2px solid var(--gold);
  border-radius: 16px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 5px var(--card-2),
    inset 0 0 0 6px rgba(184, 137, 59, 0.30),
    0 16px 36px rgba(74, 30, 47, 0.11);
}

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed rgba(184, 137, 59, 0.55);
}

.panel__head-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.panel__badge {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #FFFDF7 0 12%, #F6E8D3 54%, #EBC9C9 100%);
  color: var(--wine);
  box-shadow:
    inset 0 0 0 3px #FFFDF7,
    inset 0 0 0 4px rgba(184, 137, 59, 0.30),
    0 3px 0 rgba(184, 137, 59, 0.24);
}

.panel__badge svg {
  width: 30px;
  height: 30px;
}

.panel__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.panel__hint {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
}

.panel__meta {
  flex: 0 0 auto;
  padding-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.field {
  display: block;
  min-width: 0;
}

.field__label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.field__label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
}

.field__label-row .field__label {
  margin-bottom: 0;
}

.field__hint {
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
}

.field--compact .field__label {
  margin-bottom: 5px;
  font-size: 13.5px;
  font-weight: 700;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 2px solid #C9A15B;
  border-radius: 10px;
  background: var(--card-2);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.65;
  box-shadow: inset 0 1px 3px rgba(74, 30, 47, 0.07);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background-color 0.18s var(--ease);
}

.input::placeholder {
  color: #7A666D;
  opacity: 1;
}

.input:hover {
  border-color: var(--gold);
  background: #FFFEFA;
}

.input:focus {
  outline: none;
  border-color: var(--wine);
  background: #FFFEFA;
  box-shadow:
    0 0 0 4px rgba(243, 217, 154, 0.85),
    inset 0 1px 3px rgba(74, 30, 47, 0.07);
}

.input:disabled {
  background: #F0E6D6;
  color: #6B5A61;
  border-color: #CDBFA7;
  cursor: not-allowed;
}

.textarea {
  min-height: 150px;
  padding-top: 12px;
  line-height: 1.8;
  resize: vertical;
}

.link-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) auto;
  gap: 8px;
  align-items: center;
}

.link-row .input {
  min-height: 48px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px dashed rgba(184, 137, 59, 0.55);
}

#save-info {
  min-height: 52px;
  min-width: 200px;
}

.form-status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.form-status:empty {
  display: none;
}

.form-status.is-ok {
  color: #2F5D3A;
}

.form-status.is-error {
  color: #7A2333;
}

/* --------------------------------------------------------------------------
   上传
   -------------------------------------------------------------------------- */

.upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: stretch;
}

.upload__drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 172px;
  padding: 22px;
  border: 2px dashed var(--gold);
  border-radius: 14px;
  background: var(--card-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.upload__drop:hover {
  border-color: var(--wine);
  background: #FFF6E4;
  box-shadow: inset 0 0 0 3px rgba(243, 217, 154, 0.45);
}

.upload__drop:focus-within {
  outline: 3px solid var(--wine);
  outline-offset: 3px;
}

.upload__drop.is-dragover {
  border-color: var(--wine);
  border-style: solid;
  background: var(--gold-hi);
  box-shadow: inset 0 0 0 3px #FFFDF7;
}

.upload__drop.has-file {
  border-style: solid;
  border-color: var(--wine);
  background: #FFF4E2;
}

.upload__icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  color: var(--gold-deep);
}

.upload__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.upload__title {
  max-width: 100%;
  color: var(--wine);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.upload__hint {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.upload__preview {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 120px;
  margin-top: 8px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: var(--paper-deep);
  box-shadow: 0 3px 8px rgba(74, 30, 47, 0.14);
}

.upload__side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

.upload__side .field {
  margin: 0;
}

.upload__side .btn {
  width: 100%;
  min-height: 50px;
}

.upload__progress {
  position: relative;
  height: 14px;
  margin-top: 14px;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: var(--paper-deep);
  overflow: hidden;
}

.upload__progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--wine), var(--wine-hover) 55%, var(--gold-light));
  transition: width 0.2s var(--ease);
}

/* --------------------------------------------------------------------------
   宣传图图卡
   -------------------------------------------------------------------------- */

.gallery-admin {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.g-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  padding: 12px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--card-2);
  box-shadow:
    inset 0 0 0 3px #FFFDF7,
    0 4px 12px rgba(74, 30, 47, 0.07);
}

.g-card__thumb {
  align-self: start;
  border: 1px solid rgba(184, 137, 59, 0.65);
  border-radius: 8px;
  background: var(--paper-deep);
  overflow: hidden;
}

.g-card__thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.g-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.g-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.g-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.g-card__actions .btn {
  min-height: 48px;
  padding: 8px 15px;
  font-size: 15px;
}

.g-card__status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.g-card__status:empty {
  display: none;
}

.g-card__status.is-ok {
  color: #2F5D3A;
}

.g-card__status.is-error {
  color: #7A2333;
}

/* --------------------------------------------------------------------------
   提示与只读
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  max-width: calc(100vw - 32px);
  padding: 14px 24px;
  transform: translateX(-50%);
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--wine);
  color: #FFF7E8;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.30);
}

.toast.is-ok {
  background: #2F5D3A;
  border-color: var(--gold-hi);
}

.toast.is-error {
  background: #7A2333;
  border-color: var(--gold-hi);
}

.admin-body.is-readonly .upload__drop {
  cursor: not-allowed;
  opacity: 0.72;
}

.admin-body.is-readonly .panel__badge {
  filter: grayscale(0.35);
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */

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

  .upload__side {
    gap: 10px;
  }

  .g-card {
    grid-template-columns: 150px minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .admin-header__inner {
    padding: 11px 16px;
  }

  .admin-main {
    padding: 22px 14px 52px;
  }

  .panel {
    padding: 22px 18px 24px;
  }

  .panel__head {
    flex-direction: column;
    gap: 10px;
  }

  .panel__meta {
    padding-top: 0;
  }

  .panel__title {
    font-size: 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .link-row {
    grid-template-columns: 1fr;
    padding-bottom: 10px;
    border-bottom: 1px dashed rgba(184, 137, 59, 0.45);
  }

  .link-row .btn {
    width: 100%;
  }

  .g-card {
    grid-template-columns: 1fr;
  }

  .g-card__thumb img {
    aspect-ratio: 16 / 9;
  }

  .upload__drop {
    min-height: 156px;
  }
}

@media (max-width: 560px) {
  .admin-header__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .admin-header__actions {
    justify-content: space-between;
  }

  .admin-header__title {
    font-size: 24px;
  }

  .badge {
    min-height: 36px;
    font-size: 13.5px;
  }

  .panel__head-main {
    align-items: flex-start;
    gap: 11px;
  }

  .panel__badge {
    width: 46px;
    height: 46px;
  }

  .panel__badge svg {
    width: 26px;
    height: 26px;
  }

  .field__label {
    font-size: 15px;
  }

  .field__label-row {
    align-items: flex-start;
  }

  .field__label-row .btn {
    width: 100%;
  }

  .form-actions .btn {
    width: 100%;
  }

  .form-status {
    width: 100%;
  }

  #save-info {
    min-width: 0;
  }

  .upload__side .btn,
  .link-row .btn {
    min-height: 48px;
  }

  .toast {
    width: calc(100vw - 28px);
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --------------------------------------------------------------------------
   可读性硬性修正 · 正文 16px；标签 15px 加粗深色
   -------------------------------------------------------------------------- */
.admin-header__sub,
.panel__hint,
.panel__meta,
.form-status,
.upload__hint,
.upload__title,
.g-card__meta,
.g-card__status,
.g-card__actions .btn {
  font-size: 16px;
}

.badge,
.field__label,
.field--compact .field__label,
.field__hint {
  font-size: 15px;
}


/* --------------------------------------------------------------------------
   编辑登录门（未登录时不渲染编辑表单）
   -------------------------------------------------------------------------- */

.auth-gate {
  max-width: 560px;
  margin: 0 auto;
  padding: 44px 26px 72px;
}

.auth-gate__card {
  margin-bottom: 0;
}

.auth-gate .form-actions {
  margin-top: 0;
}

.auth-gate .form-actions .btn {
  min-height: 52px;
  min-width: 180px;
}

.admin-body.is-locked .admin-main {
  display: none;
}

/* hidden 属性优先于 .btn 的 display，未登录时不显示“退出登录” */
.admin-header__actions [hidden],
.auth-gate[hidden],
.admin-main[hidden] {
  display: none !important;
}

#login-password {
  letter-spacing: 0.14em;
}

@media (max-width: 720px) {
  .auth-gate {
    padding: 26px 14px 56px;
  }

  .auth-gate .form-actions .btn {
    width: 100%;
  }
}

.panel__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.character-form-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.character-upload {
  min-height: 320px;
  padding: 14px;
}

.character-preview {
  display: block;
  width: 100%;
  max-height: 225px;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  border: 1px solid rgba(184, 137, 59, 0.45);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 35%, #F3E8F4, #D8C5DE);
}

.character-fields {
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.character-fields .form-grid {
  gap: 14px;
}

#cancel-character[hidden] {
  display: none !important;
}

.characters-admin {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 25px;
  padding-top: 24px;
  border-top: 1px dashed rgba(184, 137, 59, 0.55);
}

.character-admin-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(184, 137, 59, 0.65);
  border-radius: 14px;
  background: var(--card-2);
}

.character-admin-card__image {
  display: grid;
  place-items: center;
  height: 205px;
  background: radial-gradient(circle at 50% 35%, #F3E8F4, #D8C5DE);
}

.character-admin-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.character-admin-card__body {
  padding: 17px;
}

.character-admin-card__heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.character-admin-card__heading h3 {
  color: var(--wine);
  font-family: var(--font-display);
  font-size: 23px;
  overflow-wrap: anywhere;
}

.character-admin-card__gender {
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--wine);
  background: #F0E1EC;
  font-size: 13px;
}

.character-admin-card__description {
  margin: 12px 0 15px;
  color: var(--ink-soft);
  font-size: 15px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.character-admin-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.messages-admin {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 18px;
}

#messages-admin-status {
  margin-bottom: 14px;
}

.message-admin-card {
  padding: 18px 20px;
  border: 1px solid rgba(184, 137, 59, 0.55);
  border-radius: 12px;
  background: var(--card-2);
}

.message-admin-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.message-admin-card__author {
  color: var(--wine);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.message-admin-card__time {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.message-admin-card__content {
  margin: 11px 0 14px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .character-form-grid {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px;
  }
}

@media (max-width: 720px) {
  .panel__actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .character-form-grid,
  .characters-admin {
    grid-template-columns: 1fr;
  }

  .character-upload {
    width: min(100%, 250px);
    min-height: 300px;
    margin-inline: auto;
  }

  .message-admin-card__head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}
