/* 班级留言板 — white, editorial, quiet */

:root {
  --paper: #ffffff;
  --ink: #161412;
  --ink-soft: #6f6a64;
  --rule: #e6e2dc;
  --rule-strong: #ccc6be;
  --accent: #8a7a55;
  --ok: #3d4a3e;
  --warn: #7a4e42;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC",
    "Source Han Serif SC", "Songti", "Georgia", "Times New Roman", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC",
    "Source Han Sans SC", "Microsoft YaHei", "Heiti SC", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  background: #fff;
}

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1.75rem 1.35rem 3.5rem;
  padding-left: max(1.35rem, env(safe-area-inset-left));
  padding-right: max(1.35rem, env(safe-area-inset-right));
}

.masthead {
  padding-bottom: 1.35rem;
  margin-bottom: 2.1rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 500;
  letter-spacing: 0.22em;
}

.brand:hover,
.brand:focus-visible {
  color: var(--ink);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.6rem;
  margin-top: 0.85rem;
}

.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.4rem 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  letter-spacing: 0.08em;
  font-size: 0.92rem;
  border-bottom: 1px solid transparent;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.who {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.main h1 {
  margin: 0 0 0.7rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.7rem;
  letter-spacing: 0.1em;
  line-height: 1.4;
}

.intro p,
.letter p {
  color: var(--ink-soft);
  margin: 0 0 0.8rem;
}

.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.6rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.crumb a,
.text-link {
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-bottom: 1px solid transparent;
}

.crumb a:hover,
.crumb a:focus-visible,
.text-link:hover,
.text-link:focus-visible {
  border-bottom-color: var(--accent);
}

.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 1.4rem;
}

.flash {
  padding: 0.75rem 0;
  background: transparent;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.95rem;
}

.flash-ok {
  border-color: var(--rule);
  color: var(--ok);
}

.flash-error {
  color: var(--warn);
}

.search-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  margin-bottom: 0.45rem;
}

.search {
  width: 100%;
  height: 48px;
  padding: 0 0;
  margin-bottom: 1.6rem;
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.search:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.roster {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.roster-item {
  border-bottom: 1px solid var(--rule);
}

.roster-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 64px;
  padding: 0.7rem 0.15rem;
  color: inherit;
  text-decoration: none;
}

.roster-link:hover,
.roster-link:focus-visible {
  background: transparent;
}

.num {
  flex: 0 0 2.2rem;
  font-family: var(--sans);
  color: var(--ink-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.names {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

..cn {
  font-family: var(--serif);
  font-size: 1.12rem;
}

.en {
  color: var(--ink-soft);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.marks {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tag {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  padding: 0.12rem 0.32rem;
  border: 1px solid var(--rule-strong);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.92);
  font-weight: 400;
}

.tag-me {
  border-color: var(--ink);
  color: var(--ink);
}

.tag-done {
  border-color: var(--accent);
  color: var(--accent);
}

.empty-filter,
.empty-inbox {
  color: var(--ink-soft);
  margin-top: 1.4rem;
}

.letter {
  background: #fff;
  padding: 0.2rem 0 0.4rem;
  box-shadow: none;
  border: none;
}

.letter-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--ink-soft);
  text-transform: none;
}

.letter-name {
  margin: 0.2rem 0 0.2rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.letter-en {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.letter-note {
  font-size: 0.92rem;
  margin: 1.2rem 0 1.4rem;
}

.letter-form textarea {
  width: 100%;
  min-height: 220px;
  padding: 0.95rem 0;
  border: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.8;
  resize: vertical;
}

.letter-form textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.letter-form textarea[readonly] {
  background: #fff;
  color: var(--ink);
  cursor: default;
}

.letter-status {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: -0.4rem 0 1.1rem;
}

.form-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
}

.form-actions .btn,
.form-actions .btn-quiet {
  margin: 0;
}

.counter {
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.counter.is-over {
  color: var(--warn);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.55rem 1.5rem;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 0.22em;
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
}

.btn:hover,
.btn:focus-visible {
  background: #2c2a27;
  border-color: #2c2a27;
}

.btn:disabled {
  cursor: default;
  opacity: 0.72;
  pointer-events: none;
}

.btn:disabled:hover,
.btn:disabled:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
}

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
  min-height: 44px;
  margin: 0 0.35rem 0.5rem 0;
}

.btn-quiet:hover,
.btn-quiet:focus-visible {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.note {
  background: #fff;
  padding: 1.4rem 0 1.25rem;
  box-shadow: none;
  border: none;
  border-top: 1px solid var(--rule);
}

.note:last-child {
  border-bottom: 1px solid var(--rule);
}

.note-index {
  margin: 0 0 0.25rem;
  font-family: var(--sans);
  font-size: 20px;
  line-height: 1.4;
  color: var(--ink);
  font-weight: 400;
}

.note-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.9;
}

.note-date {
  margin: 0.85rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}

.colophon {
  margin-top: 3.2rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.colophon p {
  margin: 0 0 0.3rem;
}

.colophon a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.colophon a:hover,
.colophon a:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.hint {
  font-size: 0.78rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 1.4rem;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  box-shadow: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.admin-table th,
.admin-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  font-weight: 500;
  background: #fff;
  white-space: nowrap;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink);
}

.token-cell code,
.code-cell {
  font-size: 0.78rem;
  word-break: break-all;
  letter-spacing: 0.04em;
}

.code-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  word-break: normal;
}

.body-cell {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 28rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.error-card h1 {
  font-size: 1.5rem;
}

/* Entry cover */

.page-enter {
  width: min(440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: max(2.5rem, 10vh);
  padding-bottom: max(2.5rem, 8vh);
}

.enter {
  text-align: center;
}

.enter-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.85rem;
  letter-spacing: 0.32em;
  margin: 0;
  line-height: 1.45;
  text-indent: 0.32em;
}

.enter-title::after {
  content: "";
  display: block;
  width: 2.25rem;
  height: 1px;
  background: var(--accent);
  margin: 1.35rem auto 0;
}

.enter-lead {
  color: var(--ink-soft);
  margin: 1.35rem 0 2.4rem;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.enter-form {
  max-width: 17.5rem;
  margin: 0 auto;
  text-align: left;
}

.enter-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}

.enter-input {
  width: 100%;
  height: 52px;
  border: none;
  border-bottom: 1px solid var(--ink);
  background: transparent;
  font: inherit;
  font-size: 1.12rem;
  letter-spacing: 0.28em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  border-radius: 0;
  padding: 0.2rem 0;
}

.enter-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.enter-error {
  margin: 0.95rem 0 0;
  color: var(--warn);
  font-size: 0.88rem;
  text-align: center;
  letter-spacing: 0.04em;
}

.enter-btn {
  width: 100%;
  margin-top: 1.9rem;
  letter-spacing: 0.32em;
}

.colophon-enter {
  text-align: center;
  border-top: none;
  margin-top: 4.5rem;
  padding-top: 0;
}

@media (min-width: 640px) {
  .page {
    padding-top: 2.4rem;
  }
}

/* 猫咪之家 title — 演示佛系体 Slidefu, SIL OFL 1.1, subset of 猫/咪/之/家 */
@font-face {
  font-family: "Slidefu";
  src: url("fonts/Slidefu-title.ttf?v=1794748368") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "QingsongClaim";
  src: url("fonts/Qingsong-claim.woff2?v=1794756441") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.gallery-top {
  position: static;
  background: #fff;
  padding-top: max(0.45rem, env(safe-area-inset-top));
  margin: 0 0 0.35rem;
  overflow: visible;
}

h1.site-title, .main h1.site-title {
  margin: 0;
  padding: 0.1rem 0.4rem 0.2rem;
  text-align: center;
  font-family: "Slidefu", "PingFang SC", cursive;
  font-size: 200px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.14em;
  color: var(--ink);
  white-space: nowrap;
  position: relative;
  transform-origin: center center;
  transition: transform 0.15s ease;
}
h1.site-title:hover,
h1.site-title:focus-visible,
.main h1.site-title:hover,
.main h1.site-title:focus-visible {
  transform: scale(1.2);
  z-index: 21;
}

@media (max-width: 908px) {
  html,
  body {
    overflow-x: hidden;
  }

  .site-title-wrap {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    overflow: hidden;
  }

  h1.site-title,
  .main h1.site-title {
    font-size: 22vw;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
    max-width: none;
    overflow: hidden;
  }
}

.site-title-wrap {
  position: relative;
}

.title-danmaku {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.danmaku-item {
  position: absolute;
  left: 100%;
  top: 0;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink);
  text-shadow:
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    1px 1px 0 #fff,
    0 0 6px #fff;
  animation-name: danmaku-move;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}

@keyframes danmaku-move {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-100% - var(--danmaku-span, 100vw))); }
}

@media (max-width: 720px) {
  .danmaku-item {
    font-size: 16px;
  }
}

/* Portrait gallery */

.page-wide {
  /* 8-column photos are 1.2× the original ~117px size */
  width: min(1308px, 100%);
}

.page-gallery {
  padding-top: 0;
  padding-bottom: 3.5rem;
  overflow: visible;
}

.gallery-login {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  background: #fff;
  padding: 0.45rem 0.4rem 0.8rem;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.gallery-login-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.85rem;
  flex: 0 1 auto;
  max-width: 36rem;
  margin-left: auto;
}

.gallery-login-form .enter-label {
  flex: 0 0 100%;
  margin-bottom: 0;
  text-align: right;
  font-size: 13px;
}

.gallery-login-form .enter-input {
  width: 13.5rem;
  flex: 1 1 11rem;
  max-width: 16rem;
  height: 44px;
  letter-spacing: 0.2em;
  font-size: 18px;
}

.gallery-login-form .enter-input::placeholder {
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--ink-soft);
  opacity: 0.85;
}

.gallery-login-form .enter-btn {
  width: auto;
  min-width: 5.5rem;
  margin-top: 0;
  min-height: 44px;
  padding: 0 1.25rem;
  letter-spacing: 0.28em;
}

.claim-code {
  flex: 0 0 auto;
  margin: 0 auto 0 0.15rem;
  padding: 0.1rem 0.15rem;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: "QingsongClaim", "PingFang SC", cursive;
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transform-origin: center center;
  transition: transform 0.15s ease;
}
.claim-code:hover,
.claim-code:focus-visible {
  color: var(--ink);
  outline: none;
  transform: scale(1.3);
  z-index: 2;
}

.paw-btn {
  position: relative;
  top: -20px;
  flex: 0 0 auto;
  width: 76.8px;
  height: 76.8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  transform-origin: center center;
  transition: transform 0.15s ease, color 0.15s ease;
}
.paw-btn img, .paw-btn svg {
  width: 76.8px;
  height: 76.8px;
  display: block;
  fill: currentColor;
  object-fit: contain;
  pointer-events: none;
}
.paw-btn:hover,
.paw-btn:focus-visible {
  color: #ff4d6d;
  outline: none;
  transform: scale(1.3);
  z-index: 2;
}
.paw-btn:active {
  transform: scale(0.96);
}

.claim-dialog {
  width: min(24rem, calc(100vw - 2.4rem));
}
.claim-dialog #claim-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
}
.claim-name-input {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 44px;
  margin: 0 0 0.7rem;
  font-size: 18px;
  letter-spacing: 0.04em;
}
.claim-dialog .enter-error {
  margin: 0 0 0.7rem;
  font-size: 15px;
}
.claim-dialog-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.35rem;
}
.claim-dialog-actions .btn {
  flex: 1 1 0;
  width: auto;
  min-width: 6.5rem;
  min-height: 44px;
  margin: 0;
  padding: 0 1.1rem;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  letter-spacing: 0.18em;
}
.claim-code-result {
  margin: 0 0 1.1rem;
  text-align: center;
  font-family: var(--sans);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--ink);
}
.admin-notice {
  margin: 0.7rem 0 0;
  color: var(--ok);
}
.claim-status-cell {
  white-space: nowrap;
}
.regen-form {
  margin: 0.35rem 0 0;
}
.regen-btn {
  min-height: 32px;
  padding: 0 0.7rem;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.gallery-login-form .enter-error,
.gallery-login-form .gallery-login-hint {
  flex-basis: 100%;
  margin: 0.15rem 0 0;
  font-size: 16px;
}

.gallery-login-hint[hidden] {
  display: none;
}

.login-dialog {
  width: min(20rem, calc(100vw - 2.4rem));
  padding: 1.6rem 1.4rem 1.35rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(22, 20, 18, 0.12);
}

.login-dialog::backdrop {
  background: rgba(22, 20, 18, 0.28);
}

.login-dialog p {
  margin: 0 0 1.15rem;
  text-align: center;
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  line-height: 1.6;
}

.login-dialog form {
  margin: 0;
  display: flex;
  justify-content: center;
}

.login-dialog .enter-btn {
  width: auto;
  min-width: 5.5rem;
  margin-top: 0;
  min-height: 40px;
  padding: 0 1.25rem;
  letter-spacing: 0.28em;
}

.gallery-logged {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  flex: 0 1 auto;
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 16px;
  letter-spacing: 0.16em;
}

.gallery-logout {
  display: inline;
  margin: 0;
}

.logout-btn {
  border: none;
  background: none;
  padding: 0.2rem 0;
  margin: 0;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.16em;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

.logout-btn:hover,
.logout-btn:focus-visible {
  border-bottom-color: var(--ink);
}

.page-gallery .main {
  margin: 0;
}

.cat-grid {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.4rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.35rem 0.85rem;
  overflow: visible;
}

.cat-card {
  margin: 0;
  position: relative;
  z-index: 0;
}

.cat-card:hover,
.cat-card:focus-within {
  z-index: 3;
}

.cat-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: inherit;
  text-decoration: none;
  padding: 0;
  border-radius: 0;
  transform-origin: center center;
  transition: transform 0.22s ease;
}

.cat-link:hover,
.cat-link:focus-visible {
  transform: scale(1.4);
}

.cat-link:hover .cat-photo,
.cat-link:focus-visible .cat-photo {
  border-color: #fff;
}

.cat-link:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

.cat-photo {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid #fff;
  overflow: visible;
}

.cat-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cat-photo .tag {
  position: absolute;
  top: auto;
  bottom: 0.35rem;
  right: 0.35rem;
  background: rgba(255, 255, 255, 0.94);
}

.cat-photo .tag-me {
  top: 0.35rem;
  left: 0.35rem;
  right: auto;
  bottom: auto;
}

.cat-photo .msg-count {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  z-index: 2;
  box-sizing: border-box;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.38rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ff4d6d;
  color: #fff;
  border: 2px solid #fff;
  font-family: "Hiragino Maru Gothic ProN", "PingFang SC", var(--sans);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 2px 7px rgba(255, 77, 109, 0.4);
}

.cat-card.is-me .cat-photo .tag-me + .tag-done,
.cat-card.is-me.is-written .cat-photo .tag-done {
  bottom: 0.35rem;
  top: auto;
}

.cat-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  margin-top: 0.55rem;
  text-align: center;
  line-height: 1.3;
  min-height: 4.2em;
}

.cat-meta .num {
  flex: none;
  width: auto;
  text-align: center;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

.cat-meta .cn {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.cat-meta .en {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 400;
}

.cat-meta .written {
  margin-top: 0.08rem;
  font-family: "Hiragino Maru Gothic ProN", "PingFang SC", var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #ff4d6d;
}

.letter-head {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-bottom: 0.4rem;
}

.letter-cat {
  width: 96px;
  height: 96px;
  object-fit: cover;
  background: #fff;
  border: 1px solid #fff;
  flex: 0 0 96px;
}

.inbox-head {
  display: flex;
  align-items: flex-start;
  gap: 1.15rem;
  margin-bottom: 1.6rem;
}

.inbox-head .letter-cat {
  margin-top: 0.2rem;
}

.credits-table a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
}

.credits-table a:hover,
.credits-table a:focus-visible {
  border-bottom-color: var(--accent);
}

@media (min-width: 520px) {
  .cat-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem 1.05rem;
  }
}

@media (min-width: 760px) {
  .cat-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  .cat-meta .cn {
    font-size: 15px;
  }
}

@media (min-width: 1000px) {
  .cat-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 1.65rem 1.15rem;
  }
}

/* Compose page: vertical letter, 144px cat, 0.6× typography of prior 2× */

html:has(.page-letter),
html:has(.page-letter) body {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.page.page-letter {
  width: min(720px, 100%);
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.35rem 1.15rem;
  padding-left: max(1.35rem, env(safe-area-inset-left));
  padding-right: max(1.35rem, env(safe-area-inset-right));
  padding-bottom: max(1.15rem, env(safe-area-inset-bottom));
}

.page.page-wide.page-letter,
.page.page-wide.page-inbox {
  width: min(1308px, 100%);
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: max(3.5rem, env(safe-area-inset-bottom));
}

.page.page-wide.page-letter {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
}

.page-letter .gallery-top {
  flex: 0 0 auto;
}

.page-wide.page-letter .main,
.page-wide.page-inbox .main {
  width: min(720px, 100%);
  margin-left: auto;
  margin-right: auto;
  padding-left: max(1.35rem, env(safe-area-inset-left));
  padding-right: max(1.35rem, env(safe-area-inset-right));
}

.page-wide.page-letter .main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.page-inbox .inbox-actions {
  margin-top: 0.7rem;
}

.page-inbox .btn-quiet {
  min-height: 0;
  margin: 0;
  font-size: 18px;
  padding: 0.66rem 1.8rem;
  line-height: 1.2;
}

.page-letter .main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-letter .crumb {
  flex: 0 0 auto;
  margin: 0 0 0.5rem;
  font-size: 18px;
  line-height: 1.3;
}

.page-letter .crumb a {
  min-height: 0;
  padding: 0.15rem 0;
}

.page-letter .flashes {
  flex: 0 0 auto;
  margin: 0 0 0.45rem;
}

.page-letter .flash {
  padding: 0.35rem 0;
}

.page-letter .letter {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.page-letter .letter-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-bottom: 0.45rem;
}

.page-letter .letter-head > div {
  min-width: 0;
}

.page-letter .letter-cat {
  width: 144px;
  height: 144px;
  object-fit: cover;
  background: #fff;
  border: 1px solid #fff;
  flex: 0 0 144px;
  display: block;
}

.page-letter .letter-kicker {
  font-size: 15px;
  line-height: 1.3;
}

.page-letter .letter-name {
  margin: 0.15rem 0 0.15rem;
  font-size: 38px;
  line-height: 1.25;
}

.page-letter .letter-en {
  font-size: 18px;
  line-height: 1.3;
}

.page-letter .letter-note {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.45;
  margin: 0.25rem 0 0.35rem;
}

.page-letter .letter-status {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.45;
  margin: 0 0 0.45rem;
}

.page-letter .letter-form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-letter .letter-form textarea {
  flex: 1 1 0%;
  width: 100%;
  min-height: 4.5rem;
  height: auto;
  font-size: 30px;
  line-height: 1.8;
  overflow-y: auto;
  resize: none;
  padding: 0.42rem 0;
}

.page-letter .form-bar {
  flex: 0 0 auto;
  margin-top: 0.7rem;
  flex-wrap: nowrap;
  align-items: center;
}

.page-letter .counter {
  font-size: 15.7px;
}

.page-letter .btn {
  font-size: 18px;
  padding: 0.66rem 1.8rem;
  min-height: 0;
  line-height: 1.2;
}

.page-letter .btn-quiet {
  min-height: 0;
  margin: 0;
}

@media (max-width: 640px) {
  html:has(.page-letter),
  html:has(.page-letter) body {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .page.page-letter {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    max-height: none;
    overflow: visible;
    padding: 1rem 1.2rem 1.5rem;
    padding-left: max(1.2rem, env(safe-area-inset-left));
    padding-right: max(1.2rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .page.page-wide.page-letter,
  .page.page-wide.page-inbox {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .page.page-wide.page-letter {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding-bottom: max(0.8rem, env(safe-area-inset-bottom));
  }

  .page-letter .main,
  .page-letter .letter,
  .page-letter .letter-form {
    flex: none;
    min-height: 0;
  }

  .page-wide.page-letter .main,
  .page-wide.page-letter .letter,
  .page-wide.page-letter .letter-form {
    flex: 1 1 auto;
    min-height: 0;
  }

  .page-letter .letter,
  .page-letter .main {
    display: flex;
    flex-direction: column;
  }

  .page-letter .letter-cat {
    width: min(144px, 42vw);
    height: min(144px, 42vw);
    flex: 0 0 min(144px, 42vw);
  }

  .page-letter .letter-form textarea {
    min-height: 10rem;
    height: 12rem;
    flex: none;
    resize: none;
    overflow-y: auto;
  }

  .page-wide.page-letter .letter-form textarea {
    min-height: 4.5rem;
    height: auto;
    flex: 1 1 0%;
  }

  .page-letter .form-bar {
    flex-wrap: wrap;
  }

  .page-letter .crumb a {
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .page-letter .letter-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-letter .letter-cat {
    width: min(144px, 70vw);
    height: min(144px, 70vw);
    flex: 0 0 auto;
  }
}

/* Phones: let the board and compose page scroll instead of locking to one screen. */
@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    max-height: none;
  }

  html:has(.page-letter),
  html:has(.page-letter) body {
    height: auto;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page.page-gallery,
  .page.page-inbox,
  .page.page-letter,
  .page.page-wide.page-letter,
  .page.page-wide.page-inbox {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
  }

  .page-wide.page-letter .main,
  .page-letter .main,
  .page-letter .letter,
  .page-letter .letter-form {
    flex: 0 1 auto;
    min-height: 0;
    overflow: visible;
  }

  .page-wide.page-letter .letter-form textarea,
  .page-letter .letter-form textarea {
    flex: none;
    min-height: 10rem;
    height: 12rem;
    overflow-y: auto;
  }

}


.msg-handwriting {
  font-synthesis: none;
}

.page-inbox .letter-cat {
  width: 144px;
  height: 144px;
  object-fit: cover;
  background: #fff;
  border: 1px solid #fff;
  flex: 0 0 144px;
  display: block;
}


.bgm-toggle {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 50;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(22, 20, 18, 0.08);
}
.bgm-toggle:hover,
.bgm-toggle:focus-visible {
  border-color: var(--ink);
  outline: none;
}
.bgm-toggle.is-muted {
  color: var(--ink-soft);
  text-decoration: line-through;
}

.bgm-toggle.is-waiting {
  box-shadow: 0 0 0 4px rgba(138, 122, 85, 0.22);
  animation: bgm-pulse 1.4s ease-in-out infinite;
}
@keyframes bgm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138, 122, 85, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(138, 122, 85, 0.08); }
}


.bgm-player {
  flex: 0 1 22rem;
  min-width: 16rem;
  max-width: 26rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-right: auto;
}
.bgm-player .bgm-play,
.bgm-player .bgm-stop {
  flex: 0 0 auto;
  height: 36px;
  min-width: 3.4rem;
  padding: 0 0.7rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  line-height: 1;
}
.bgm-player .bgm-play:hover,
.bgm-player .bgm-stop:hover,
.bgm-player .bgm-play:focus-visible,
.bgm-player .bgm-stop:focus-visible {
  border-color: var(--ink);
  outline: none;
}
.bgm-player .bgm-seek {
  flex: 1 1 6rem;
  min-width: 4.5rem;
  height: 4px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--rule);
  border-radius: 999px;
  cursor: pointer;
}
.bgm-player .bgm-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  cursor: pointer;
}
.bgm-player .bgm-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
  cursor: pointer;
}
.bgm-player .bgm-seek::-moz-range-track {
  height: 4px;
  background: var(--rule);
  border: none;
  border-radius: 999px;
}
.bgm-player .bgm-time {
  flex: 0 0 auto;
  min-width: 5.6rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .bgm-player {
    flex-basis: 100%;
    max-width: none;
    margin-right: 0;
  }

  .claim-code {
    flex-basis: 100%;
    width: 100%;
    margin: 0;
    font-size: 28px;
    text-align: center;
  }

  .paw-btn {
    top: -14px;
  }
  .paw-btn,
  .paw-btn img, .paw-btn svg {
    width: 64px;
    height: 64px;
  }
}

.admin-auth {
  max-width: 26rem;
}

.admin-auth .enter-form,
.admin-change-password .enter-form,
.admin-recovery .enter-form {
  max-width: none;
  margin: 0;
  text-align: left;
}

.admin-password-input {
  text-transform: none;
  letter-spacing: 0.06em;
  text-align: left;
}

.admin-auth .enter-error,
.admin-auth .enter-notice,
.admin-change-password .enter-error,
.admin-recovery .enter-error {
  text-align: left;
}

.admin-auth .form-actions,
.admin-change-password .form-actions,
.admin-recovery .form-actions {
  margin-top: 1.2rem;
}

.admin-change-password,
.admin-recovery {
  margin: 2.4rem 0 0;
  max-width: 26rem;
}

.admin-change-password h2,
.admin-recovery h2 {
  margin: 0 0 0.7rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}

.admin-recovery-help {
  margin: 0 0 0.7rem;
}

.admin-forgot-link,
.admin-auth-alt {
  margin-top: 1rem;
}

.admin-actions .admin-logout {
  display: inline;
  margin: 0;
}
