:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: #422a33;
  background: #fdf5f3;
  --ink: #422a33;
  --muted: #745862;
  --rose: #9e3658;
  --line: #e9ced3;
  --paper: #fffcfa;
  --display: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.55; }
[hidden] { display: none !important; }
a { color: var(--rose); text-underline-offset: .24em; }
button, input, textarea { font: inherit; }
button, a, input, textarea { touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid #ae5172;
  outline-offset: 3px;
}
h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
h1 { font: 700 clamp(2.1rem, 5vw, 3.3rem)/1.15 var(--display); letter-spacing: .05em; }
h2 { font-size: 1.25rem; line-height: 1.4; letter-spacing: .015em; }
img { display: block; max-width: 100%; height: auto; }

.gate-page {
  background-color: #fff3ef;
  background-image: radial-gradient(ellipse at 15% 12%, #f8dce7 0%, transparent 44%),
    radial-gradient(ellipse at 93% 91%, #f7e1ed 0%, transparent 44%),
    linear-gradient(#c8879326 1px, transparent 1px), linear-gradient(90deg, #c8879326 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}
.gate {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.gate-card {
  position: relative;
  width: min(100%, 26rem);
  padding: 1.8rem clamp(1.3rem, 6vw, 2.6rem) 2.4rem;
  border: 1px solid #e8b9c8;
  border-radius: 2rem;
  background: var(--paper);
  box-shadow: 0 24px 70px #92405a20, 0 3px 0 #f6dce3;
  text-align: center;
}
.gate-card::before {
  content: "";
  position: absolute;
  inset: .5rem;
  border: 1px dashed #ebced6;
  border-radius: 1.6rem;
  pointer-events: none;
}
.gate-art { display: grid; place-items: center; margin-bottom: .7rem; }
.gate-art .envelope { width: min(100%, 18.5rem); filter: drop-shadow(0 4px 4px #965d4619); }
.gate-card h1 { font-size: clamp(1.8rem, 6vw, 2.55rem); }
.gate-hint { color: var(--muted); margin: .65rem 0 1.65rem; }
.gate-form { display: grid; text-align: left; gap: .55rem; }
label { font-weight: 650; font-size: .92rem; }
small { color: var(--muted); font-weight: 400; font-size: .82rem; }
input, textarea {
  display: block;
  width: 100%;
  padding: .64rem .78rem;
  border: 1px solid #dcb9c5;
  border-radius: .75rem;
  color: var(--ink);
  background: #fffdfc;
}
::placeholder { color: #856c75; }
textarea { resize: vertical; min-height: 5rem; }
.password-field { display: grid; position: relative; }
.password-field input { min-height: 3.05rem; padding-right: 4.1rem; }
.toggle-password {
  position: absolute;
  right: .42rem;
  top: .32rem;
  bottom: .32rem;
  padding: 0 .65rem;
  border: 0;
  background: #f6e3e9;
  color: #82314d;
  border-radius: .55rem;
  font-size: .875rem;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 2.9rem;
  padding: .6rem 1rem;
  border: 0;
  border-radius: .75rem;
  font-weight: 700;
  line-height: 1.4;
}
.primary-button { background: var(--rose); color: #fff9fa; box-shadow: 0 3px 0 #772642; }
.primary-button:hover { background: #872d4b; }
.primary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #772642; }
.gate-form .button { margin-top: .38rem; }
.back { display: inline-block; margin-top: 1.15rem; }
.form-error, .message-success { border-radius: .65rem; padding: .55rem .7rem; font-size: .9rem; }
.form-error { color: #8d2941; background: #ffe8eb; }
.message-success { color: #285b46; background: #e4f1e7; }

.diary-page {
  background-color: #fff8f5;
  background-image: radial-gradient(#d8a1ad55 1px, transparent 1px);
  background-size: 19px 19px;
}
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  width: min(100% - 2rem, 72rem);
  margin: 0 auto;
  padding: 1.2rem .2rem;
}
.brand { color: var(--ink); text-decoration: none; font-weight: 750; white-space: nowrap; }
.brand span { color: var(--rose); font-size: 1.2rem; vertical-align: -.04em; }
.site-header nav { display: flex; align-items: center; gap: 1rem; font-size: .91rem; }
.text-button { background: none; border: 0; color: var(--muted); padding: .25rem 0; }
.text-button:hover, .brand:hover { text-decoration: underline; }
.main-wrap { width: min(100% - 2rem, 72rem); margin: .25rem auto 4rem; }
.welcome {
  isolation: isolate;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 13.1rem;
  padding: 2rem clamp(1.35rem, 6.5vw, 4rem);
  overflow: hidden;
  border: 1px solid #e6bac5;
  border-radius: 1.7rem;
  background: linear-gradient(110deg, #fff6f1 10%, #fbe2e8 100%);
  box-shadow: 0 5px 0 #f4dce2;
}
.welcome::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: .55rem;
  border: 1px dashed #d9a7b4;
  border-radius: 1.25rem;
  z-index: -1;
}
.welcome time { display: block; margin-bottom: .65rem; color: #87465d; font-weight: 650; font-size: .9rem; }
.welcome-art {
  position: absolute;
  right: 2%;
  z-index: -1;
  width: min(39%, 24rem);
  transform: rotate(8deg);
  filter: drop-shadow(0 6px 8px #97526223);
}
.tiles, .editor-grid { display: grid; gap: 1rem; margin-top: 1.4rem; }
.tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
.editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile {
  --tile-line: #e9c3ca;
  --tile-top: #fff4f7;
  --accent: #983852;
  --chip: #fae0e9;
  min-width: 0;
  padding: clamp(1rem, 2.3vw, 1.65rem);
  border: 1px solid var(--tile-line);
  border-top-width: 3px;
  border-radius: 1.3rem;
  background: linear-gradient(160deg, var(--tile-top), var(--paper) 65%);
  box-shadow: 0 8px 18px #65454b0c;
}
.tile-tasks { --tile-line: #dccbe9; --tile-top: #f9f2fe; --accent: #674683; --chip: #eddef7; }
.tile-message { --tile-line: #c4dfd3; --tile-top: #f1faf5; --accent: #356554; --chip: #dbefe4; }
.tile-icon {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: .7rem;
  border-radius: .85rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
  background: var(--chip);
}
.entry-text, .empty { margin-top: .65rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty, .updated, .received-letter time { color: var(--muted); }
.updated, .received-letter time { margin-top: .9rem; font-size: .82rem; }
.progress-wrap { margin: .95rem 0 .25rem; }
.progress-label { display: flex; justify-content: space-between; gap: .7rem; color: var(--accent); }
progress { display: block; width: 100%; height: .82rem; margin-top: .35rem; accent-color: #8c64a8; }
.letter-form, .editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; margin-top: .9rem; }
.letter-form input, .letter-form textarea { border-color: #bcd6ca; }
.letter-form label:not(:first-child), .editor label:not(:first-child) { margin-top: .35rem; }
.letter-form .button, .editor .button { margin-top: .45rem; justify-self: start; }
.tile-message .primary-button { background: #39705a; box-shadow: 0 3px 0 #24513e; }
.tile-message .primary-button:hover { background: #2e604b; }
.tile-message .primary-button:active { box-shadow: 0 1px 0 #24513e; }
.admin-wrap { margin-top: 1rem; }
.percent-field { display: flex; align-items: center; gap: .5rem; }
.percent-field input { width: 6.2rem; }
.inbox { margin-top: 1rem; }
.received-letters { display: grid; gap: .65rem; padding: 0; list-style: none; }
.received-letter { padding: .8rem .9rem; border: 1px solid #d3e5db; border-radius: .8rem; background: #fffdfc; }
.received-letter > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .8rem; }
.received-letter time { margin: 0; }
.pagination { display: flex; align-items: center; gap: .8rem; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles .tile-message { grid-column: 1 / -1; }
}
@media (max-width: 585px) {
  .tiles, .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .welcome { min-height: 8.75rem; }
  .welcome h1 { font-size: clamp(1.5rem, 6.8vw, 2.45rem); }
  .welcome-art { right: -8%; width: 54%; }
  .site-header nav { gap: .65rem; }
}
