:root {
  --paper: #ece2cc;
  --paper-soft: #f4ecda;
  --paper-deep: #e3d7bd;
  --ink: #2c2620;
  --ink-soft: #6b5e4c;
  --cinnabar: #a63a2e;
  --cinnabar-dark: #8c2f26;
  --bronze: #96713a;
  --line: #cbb994;
  --seal: #a63a2e;
  --shadow: 0 12px 32px rgba(74, 56, 36, 0.12);
  --radius: 6px;
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.25;
  background-image: radial-gradient(rgba(116, 96, 66, 0.22) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

img {
  max-width: 100%;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(236, 226, 204, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  background: var(--seal);
  color: #f6ead2;
  font-family: var(--font-serif);
  font-size: 22px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(246, 234, 210, 0.55);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 1px;
}

.brand-text small {
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.nav a {
  padding: 6px 2px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.nav a:hover,
.nav a.is-active {
  color: var(--cinnabar);
  border-color: var(--cinnabar);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  border-radius: 999px;
  min-width: 0;
  max-width: 180px;
}

.user-chip.is-on {
  display: inline-flex;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: var(--cinnabar);
  color: #f8eddc;
  font-family: var(--font-serif);
  font-size: 14px;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-chip span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--ink);
  border-radius: var(--radius);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--bronze);
}

.btn-primary {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  color: #fbf3e5;
}

.btn-primary:hover {
  background: var(--cinnabar-dark);
  border-color: var(--cinnabar-dark);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.page-head {
  padding: 34px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--bronze);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 600;
  letter-spacing: 1px;
}

.page-desc {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.main {
  position: relative;
  z-index: 1;
  padding-bottom: 56px;
}

.forum-panel {
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 249, 236, 0.6), rgba(255, 249, 236, 0));
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 320px;
  min-width: 0;
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf5e8;
  outline: none;
}

.search-box input:focus {
  border-color: var(--bronze);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px 20px;
}

.post-item {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8f1e2;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.post-item:hover {
  border-color: var(--bronze);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(74, 56, 36, 0.08);
}

.post-item .avatar {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  font-size: 16px;
}

.post-main {
  flex: 1;
  min-width: 0;
}

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

.post-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.pin-tag {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.5;
}

.pending-tag {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 1px solid var(--bronze);
  color: var(--bronze);
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.5;
}

.post-excerpt {
  margin: 4px 0 8px;
  color: var(--ink-soft);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 12px;
}

.post-meta strong {
  color: var(--ink);
  font-weight: 500;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 4px 20px 20px;
  flex-wrap: wrap;
}

.pagination button {
  min-width: 38px;
}

.pagination .page-info {
  color: var(--ink-soft);
  font-size: 13px;
  padding: 0 8px;
}

.empty-state {
  padding: 52px 20px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink);
}

/* 帖子详情 */
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-article {
  padding: 24px 24px 20px;
}

.detail-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.detail-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.detail-author .avatar {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.detail-author-info {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.detail-author-info strong {
  font-weight: 600;
}

.detail-author-info em {
  font-style: normal;
  color: var(--ink-soft);
  font-size: 12px;
}

.detail-content {
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  font-size: 15px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-stats {
  display: flex;
  gap: 16px;
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  flex-wrap: wrap;
}

.reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.reply-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
}

.reply-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 24px 16px;
}

.reply-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8f1e2;
}

.reply-item .avatar {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.reply-main {
  flex: 1;
  min-width: 0;
}

.reply-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.reply-meta strong {
  color: var(--ink);
  font-weight: 500;
}

.reply-content {
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reply-editor {
  padding: 0 24px 24px;
}

.reply-editor textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf5e8;
  resize: vertical;
  outline: none;
}

.reply-editor textarea:focus {
  border-color: var(--bronze);
}

.reply-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.editor-hint {
  color: var(--ink-soft);
  font-size: 12px;
}

.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  background: rgba(228, 216, 193, 0.5);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 22px 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.footer-brand .brand-seal {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
  font-size: 16px;
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(44, 38, 32, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-mask[hidden] {
  display: none;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(33, 27, 21, 0.28);
}

.modal-wide {
  width: min(680px, 100%);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
}

.modal-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  flex-wrap: wrap;
  background: var(--paper-soft);
  border-top: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tabs button {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--radius);
}

.tabs button.is-active {
  border-color: var(--line);
  background: #fbf5e8;
  color: var(--cinnabar);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbf5e8;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--bronze);
}

.field textarea {
  min-height: 140px;
  resize: vertical;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

.field-row .btn {
  flex: 0 0 auto;
}

/* 图形验证码：输入框 + 可点击刷新的图片 */
.captcha-row {
  align-items: stretch;
}

.captcha-row input {
  flex: 1 1 auto;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.captcha-btn {
  flex: 0 0 120px;
  width: 120px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7efdf;
  display: grid;
  place-items: center;
  cursor: pointer;
}

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

.captcha-btn.is-loading img,
.captcha-btn.is-error img {
  display: none;
}

.captcha-btn.is-loading::after {
  content: "加载中…";
  font-size: 12px;
  color: var(--ink-soft);
}

.captcha-btn.is-error::after {
  content: "点击重试";
  font-size: 12px;
  color: var(--cinnabar);
}

.captcha-note {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 420px) {
  .captcha-btn {
    flex-basis: 104px;
    width: 104px;
  }
}

.form-message {
  min-height: 20px;
  color: var(--cinnabar);
  font-size: 13px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.profile-avatar-row .avatar {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
  font-size: 24px;
}

.profile-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-avatar-actions small {
  color: var(--ink-soft);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 99;
  max-width: calc(100vw - 40px);
  padding: 10px 18px;
  border-radius: 4px;
  background: rgba(44, 38, 32, 0.94);
  color: #f7ecd9;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: calc(100% - 24px);
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
  }

  .nav {
    order: 3;
    width: 100%;
    gap: 16px;
  }

  .user-area {
    margin-left: auto;
  }

  .page-head {
    padding: 24px 0 14px;
  }

  .toolbar {
    padding: 14px 14px;
  }

  .post-list {
    padding: 14px;
  }

  .post-item {
    padding: 14px;
  }

  .detail-article,
  .reply-list,
  .reply-editor,
  .reply-head {
    padding-left: 16px;
    padding-right: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-foot {
    padding: 12px 16px 16px;
  }
}

/* 矮屏（如 320×568）压缩弹窗纵向间距，保证底部按钮与全部字段同屏可见 */
@media (max-height: 620px) {
  .modal-head {
    padding: 10px 14px;
  }

  .modal-head h3 {
    font-size: 17px;
  }

  .modal-body {
    padding: 10px 14px;
  }

  .tabs {
    padding: 0 0 8px;
    margin-bottom: 10px;
  }

  .tabs button {
    min-height: 30px;
    padding: 4px 10px;
  }

  .field {
    gap: 4px;
    margin-bottom: 6px;
  }

  .field label {
    font-size: 12.5px;
  }

  .captcha-note {
    font-size: 11.5px;
  }

  .form-message {
    min-height: 16px;
    font-size: 12.5px;
  }

  .modal-foot {
    padding: 8px 14px 10px;
  }
}
