:root {
  color-scheme: light;
  --paper: #f3f0e9;
  --paper-deep: #e8e2d7;
  --ink: #24231f;
  --ink-soft: #6e6a61;
  --line: #d7d0c4;
  --line-strong: #bbb1a2;
  --seal: #ad3b32;
  --seal-dark: #8e2d27;
  --gold: #8c651f;
  --green: #477453;
  --white: #fbfaf7;
  --focus: #315f86;
  font-family: "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: url("../assets/paper-texture.png");
  background-repeat: repeat;
  line-height: 1.6;
}

button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }

button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: var(--white);
  background: var(--ink);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

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

.site-header {
  border-bottom: 1px solid rgba(92, 83, 70, .22);
  background: rgba(243, 240, 233, .9);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 48px));
  min-height: 88px;
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}
.seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--white);
  background: var(--seal);
  border: 2px solid var(--seal-dark);
  border-radius: 4px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 24px;
  line-height: 1;
}
.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-family: "Noto Serif SC", "Songti SC", serif; font-size: 21px; font-weight: 700; }
.brand-copy span { margin-top: 4px; color: var(--ink-soft); font-size: 12px; letter-spacing: 0; }
.visitor-area { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.visitor-label { color: var(--ink-soft); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-button {
  padding: 4px 0;
  color: var(--seal-dark);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  font-size: 13px;
}

.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.composer-section { padding: 76px 0 64px; border-bottom: 1px solid var(--line); }
.section-kicker {
  color: var(--seal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}
h1, h2 { margin: 6px 0 0; font-family: "Noto Serif SC", "Songti SC", serif; font-weight: 700; line-height: 1.2; }
h1 { font-size: 52px; }
.composer-heading { font-size: 42px; }
h2 { font-size: 30px; }
.section-intro { max-width: 540px; margin: 16px 0 30px; color: var(--ink-soft); font-size: 15px; }
.composer {
  max-width: 800px;
  padding: 5px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  box-shadow: 8px 8px 0 rgba(91, 75, 54, .06);
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 18px 20px;
  color: var(--ink);
  resize: vertical;
  background: transparent;
  border: 0;
  outline: 0;
  line-height: 1.7;
}
.composer textarea::placeholder { color: #9b958a; }
.composer textarea:focus { box-shadow: inset 0 0 0 2px rgba(49, 95, 134, .2); }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px 12px 20px; border-top: 1px solid var(--line); }
.character-count { color: var(--ink-soft); font-size: 12px; }
.character-count.is-near-limit { color: var(--seal-dark); font-weight: 700; }
.primary-button, .quiet-button, .load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 4px;
  font-weight: 700;
  transition: background-color .15s ease, transform .15s ease;
}
.primary-button { color: var(--white); background: var(--seal); border: 1px solid var(--seal-dark); }
.primary-button:hover { background: var(--seal-dark); transform: translateY(-1px); }
.primary-button svg, .load-more svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.quiet-button { color: var(--ink); background: transparent; border: 1px solid var(--line-strong); }
.quiet-button:hover, .load-more:hover { background: var(--paper-deep); }
.form-feedback { min-height: 1.4em; margin: 4px 20px 8px; color: var(--ink-soft); font-size: 13px; }
.form-feedback.is-error, .dialog-error { color: var(--seal-dark); }
.form-feedback.is-success { color: var(--green); }

.messages-section { padding: 62px 0 90px; }
.list-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.list-total { color: var(--ink-soft); font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 12px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
}
.filter-button span { min-width: 1.3em; color: inherit; font-variant-numeric: tabular-nums; }
.filter-button:hover { color: var(--ink); border-color: var(--line); }
.filter-button.is-active { color: var(--ink); background: var(--white); border-color: var(--line-strong); box-shadow: 2px 2px 0 rgba(91, 75, 54, .05); }
.list-status { min-height: 28px; color: var(--ink-soft); font-size: 13px; }
.message-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.message-card {
  display: flex;
  flex-direction: column;
  min-height: 210px;
  padding: 20px;
  overflow-wrap: anywhere;
  background: rgba(251, 250, 247, .86);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: 4px;
}
.message-card.status-in_progress { border-top-color: var(--gold); }
.message-card.status-completed { border-top-color: var(--green); }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.nickname { overflow: hidden; color: var(--ink); font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 5px; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.status::before { display: inline-block; width: 9px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; content: ""; }
.status-in_progress { color: var(--gold); }
.status-in_progress::before { border-radius: 9px 9px 0 0; background: currentColor; }
.status-completed { color: var(--green); }
.status-completed::before { border: 0; content: "✓"; width: auto; height: auto; font-size: 14px; font-weight: 700; line-height: 1; }
.message-body { flex: 1; margin: 0; white-space: pre-wrap; line-height: 1.8; }
.message-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 22px; color: var(--ink-soft); font-size: 11px; }
.retention-note { color: var(--green); }
.load-more { display: flex; margin: 30px auto 0; color: var(--ink); background: transparent; border: 1px solid var(--line-strong); }
.load-more[hidden] { display: none; }
.empty-state, .error-state { grid-column: 1 / -1; padding: 52px 20px; text-align: center; border: 1px dashed var(--line-strong); }
.empty-state strong, .error-state strong { display: block; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 20px; }
.empty-state p, .error-state p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.error-state button { margin-top: 20px; }

.site-footer { padding: 24px; color: var(--ink-soft); border-top: 1px solid var(--line); text-align: center; font-size: 12px; }
.site-footer p { margin: 0; }
.nickname-dialog { width: min(440px, calc(100% - 32px)); padding: 0; color: var(--ink); background: transparent; border: 0; }
.nickname-dialog::backdrop { background: rgba(28, 26, 22, .46); }
.dialog-card { position: relative; padding: 32px; background: var(--white); border: 1px solid var(--line-strong); box-shadow: 12px 12px 0 rgba(42, 35, 26, .13); }
.dialog-card h2 { padding-right: 32px; font-size: 28px; }
.dialog-copy { margin: 15px 0 24px; color: var(--ink-soft); font-size: 13px; }
.dialog-card label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.dialog-card input { width: 100%; padding: 11px 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 3px; outline: 0; }
.dialog-card input:focus { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(49, 95, 134, .18); }
.dialog-error { min-height: 1.4em; margin: 7px 0 0; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; color: var(--ink-soft); background: transparent; border: 1px solid transparent; border-radius: 4px; }
.icon-button:hover { color: var(--ink); background: var(--paper-deep); border-color: var(--line); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.dialog-close { position: absolute; top: 16px; right: 16px; }
.admin-shell { padding-bottom: 90px; }
.admin-heading { padding: 64px 0 42px; border-bottom: 1px solid var(--line); }
.admin-heading .section-intro { margin-bottom: 0; }
.admin-list-section { padding-top: 54px; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.admin-feedback { min-height: 1.6em; margin: 0 0 4px; color: var(--ink-soft); font-size: 13px; }
.admin-feedback.is-error { color: var(--seal-dark); }
.admin-feedback.is-success { color: var(--green); }
.admin-message-grid .message-card { min-height: 250px; }
.admin-message-meta { margin-bottom: 14px; }
.admin-message-footer { margin-top: 16px; }
.admin-card-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.admin-status-control { margin: 0; }
.status-select { min-height: 34px; padding: 5px 28px 5px 9px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 3px; font-size: 12px; }
.status-select:disabled { cursor: wait; }
.danger-icon-button { color: var(--seal-dark); }
.danger-icon-button:hover { color: var(--white); background: var(--seal); border-color: var(--seal-dark); }
.danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; color: var(--white); background: var(--seal-dark); border: 1px solid var(--seal-dark); border-radius: 4px; font-weight: 700; }
.danger-button:hover { background: #72221e; }
.danger-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.confirm-dialog { width: min(500px, calc(100% - 32px)); padding: 0; color: var(--ink); background: transparent; border: 0; }
.confirm-dialog::backdrop { background: rgba(28, 26, 22, .46); }
.delete-summary { max-height: 220px; overflow: auto; margin-top: 18px; padding: 14px; background: var(--paper); border-left: 3px solid var(--seal); overflow-wrap: anywhere; }
.delete-summary strong { display: block; margin-bottom: 7px; }
.delete-summary p { margin: 0; white-space: pre-wrap; }


@media (max-width: 900px) {
  .message-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .composer-section { padding-top: 58px; }
}

@media (max-width: 600px) {
  .header-inner, .page-shell { width: min(100% - 32px, 1180px); }
  .header-inner { min-height: 76px; }
  .visitor-label { display: none; }
  .composer-section { padding: 48px 0 46px; }
  h1 { font-size: 36px; }
  .composer-heading { font-size: 32px; }
  h2 { font-size: 27px; }
  .section-intro { margin-bottom: 24px; font-size: 14px; }
  .composer textarea { min-height: 132px; padding: 15px; }
  .composer-footer { align-items: flex-end; padding-left: 15px; }
  .message-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .message-card { min-height: 0; }
  .messages-section { padding-top: 46px; }
  .list-heading { align-items: start; flex-direction: column; gap: 8px; margin-bottom: 20px; }
  .filters { gap: 4px; }
  .filter-button { padding-inline: 8px; }
  .dialog-card { padding: 28px 22px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
