:root {
  --paper: #eff3ec;
  --card: #ffffff;
  --ink: #1e3a2f;
  --ink-2: #5f6f66;
  --ink-3: #98a49d;
  --gold: #a98146;
  --gold-soft: rgba(169, 129, 70, 0.16);
  --line: rgba(30, 58, 47, 0.1);
  --line-2: rgba(30, 58, 47, 0.24);
  --radius: 18px;
  --radius-sm: 12px;
  --serif: "Songti SC", "SimSun", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px;
}

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 0 22px;
  position: relative;
  z-index: 1;
}

a {
  color: var(--gold);
  text-decoration: none;
}

h1 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 14px 0 8px;
}

h2 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  color: var(--ink-2);
}

.sub {
  color: var(--ink-2);
  font-size: 14px;
  margin: 0;
  letter-spacing: 0.02em;
}

.hint {
  color: var(--ink-3);
  font-size: 13px;
}

.card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px;
  margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(30, 58, 47, 0.05);
}

.card.white {
  background: rgba(255, 255, 255, 0.88);
}

.section {
  margin: 26px 0;
}

.rule-double {
  height: 6px;
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
  margin: 0 0 22px;
  opacity: 0.75;
}

.rule-double.thin {
  height: 4px;
  margin: 22px 0;
}

.hero {
  padding: 40px 0 2px;
  text-align: center;
}

.eyebrow {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.32em;
  color: var(--gold);
  text-transform: uppercase;
}

.hero h1 {
  font-size: 30px;
}

.hero .sub {
  letter-spacing: 0.1em;
}

.seal {
  display: inline-block;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 3px 12px;
  margin-top: 14px;
}

.num {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.plain {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 12px;
}

.stat {
  padding: 8px 10px;
  text-align: center;
}

.stat::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
  opacity: 0.6;
  margin: 8px auto 0;
}

.cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: flex-start;
}

.surname {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.1;
  text-align: center;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.surname:hover {
  background: rgba(255, 255, 255, 0.85);
}

.cloud-tip {
  position: fixed;
  z-index: 30;
  display: none;
  max-width: 220px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 13px;
  box-shadow: 0 12px 28px rgba(30, 58, 47, 0.16);
}

.cloud-tip .tip-h {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.12em;
  margin-bottom: 7px;
}

.cloud-tip .tip-n {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
}

.cloud-tip .tip-n span {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.surname i {
  display: block;
  font-style: normal;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--gold);
  margin-top: 3px;
}

.stat .num {
  font-size: 27px;
}

.stat .label {
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

input,
textarea,
select,
button {
  font-family: inherit;
  font-size: 16px;
}

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.9;
}

label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin: 0 0 6px;
  letter-spacing: 0.04em;
}

.field {
  margin-bottom: 12px;
}

button,
.btn {
  display: inline-block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fdfbf6;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 6px 16px rgba(30, 58, 47, 0.18);
}

button:active {
  opacity: 0.85;
  box-shadow: none;
}

button.ghost {
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  border: 1px solid var(--line-2);
  box-shadow: none;
}

button.small {
  width: auto;
  padding: 8px 18px;
  font-size: 13px;
  letter-spacing: 0.06em;
  border-radius: 999px;
}

button.danger {
  background: #8c2f2a;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

.bar {
  height: 5px;
  border-radius: 3px;
  background: rgba(30, 58, 47, 0.08);
  overflow: hidden;
  margin-top: 6px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
}

.navbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(239, 243, 236, 0.92);
  backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 20;
}

.navbar a {
  flex: 1;
  text-align: center;
  padding: 11px 0 13px;
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.14em;
}

.navbar a.on {
  color: var(--gold);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 0;
  font-family: var(--serif);
  letter-spacing: 0.1em;
  font-size: 13px;
}

.topbar .who {
  color: var(--ink-2);
}

.letter {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  border-radius: 16px;
  padding: 20px 22px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 2.05;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
  box-shadow: 0 8px 24px rgba(30, 58, 47, 0.07);
}

.letter.empty {
  font-family: var(--sans);
  color: var(--ink-3);
  font-size: 14px;
  text-align: center;
  padding: 44px 24px;
  border-top-color: var(--line);
  box-shadow: none;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-right: 6px;
}

.pill.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fdfbf6;
}

.pill.ok {
  border-color: var(--gold);
  color: var(--gold);
}

.pill.warn {
  border-color: #b4544e;
  color: #b4544e;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.gallery figure {
  margin: 0;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(30, 58, 47, 0.08);
  transition: transform 0.25s ease;
}

.gallery figure:active {
  transform: scale(0.98);
}

.gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  background: rgba(30, 58, 47, 0.05);
  cursor: pointer;
}

.gallery figcaption {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
  padding: 8px 2px 0;
  text-align: center;
}

.gallery figcaption .d {
  display: block;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  margin-top: 1px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 26, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.lightbox.on {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row.wrap-row {
  flex-wrap: wrap;
}

.student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.student-row:last-child {
  border-bottom: none;
}

.student-row .nm {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
}

.student-row .sid {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.search {
  margin-bottom: 14px;
}

.timeline {
  border-left: 1px solid var(--gold);
  padding-left: 22px;
  margin-left: 6px;
}

.timeline .item {
  position: relative;
  padding: 0 0 20px;
}

.timeline .item::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--gold);
}

.timeline .date {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.12em;
}

.timeline .ttl {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.timeline .dsc {
  font-size: 14px;
  color: var(--ink-2);
}

.msg {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.8;
}

.msg .meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 8px;
  letter-spacing: 0.04em;
}

.foot {
  text-align: center;
  color: var(--ink-3);
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.18em;
  padding: 32px 0 10px;
}

.err {
  color: #b4544e;
  font-size: 14px;
  min-height: 20px;
  margin-top: 10px;
}

.envelope {
  width: 250px;
  max-width: 84%;
  height: 155px;
  margin: 16px auto 4px;
  position: relative;
  perspective: 700px;
  cursor: pointer;
  outline: none;
}

.envelope:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.env-back,
.env-front,
.env-flap {
  position: absolute;
  border-radius: 6px;
}

.env-back {
  inset: 0;
  background: #fbf6ea;
  border: 1px solid var(--line-2);
}

.env-letter {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 10px;
  bottom: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold);
  border-radius: 4px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--serif);
  transition: transform 0.5s ease 0.18s;
}

.env-from {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}

.env-letter b {
  font-size: 15px;
  letter-spacing: 0.28em;
  color: var(--ink);
  font-weight: 600;
}

.env-seal2 {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 1px 6px;
  margin-top: 3px;
}

.env-front {
  inset: -1px;
  background: #f6efdd;
  border: 1px solid var(--line-2);
  clip-path: polygon(0 26%, 50% 68%, 100% 26%, 100% 100%, 0 100%);
  z-index: 2;
}

.env-flap {
  left: -1px;
  right: -1px;
  top: -1px;
  height: 64%;
  background: #efe5cc;
  border: 1px solid var(--line-2);
  border-radius: 6px 6px 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.45s ease, z-index 0s 0.2s;
  z-index: 3;
  backface-visibility: hidden;
}

.env-wax {
  position: absolute;
  left: 50%;
  top: calc(64% - 14px);
  width: 28px;
  height: 28px;
  margin-left: -14px;
  border-radius: 50%;
  background: var(--gold);
  color: #fdfbf4;
  font-family: var(--serif);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  transition: opacity 0.25s ease;
  box-shadow: 0 2px 6px rgba(30, 58, 47, 0.25);
}

.envelope.open .env-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.envelope.open .env-wax {
  opacity: 0;
}

.envelope.open .env-letter {
  transform: translateY(-30px);
}

@media (max-width: 380px) {
  h1,
  .hero h1 {
    font-size: 26px;
  }
  .num {
    font-size: 32px;
  }
}
