:root {
  color-scheme: light;
  --ink: #19212a;
  --muted: #66717e;
  --line: #d9e0e6;
  --paper: #ffffff;
  --bg: #f4f6f1;
  --green: #18805c;
  --red: #c84b45;
  --blue: #2f6fb4;
  --amber: #c68521;
  --shadow: 0 18px 45px rgba(25, 33, 42, 0.08);
}
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 111, 180, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(24, 128, 92, 0.08) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

html {
  scroll-behavior: smooth;
}

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

.forum-page {
  min-height: 100vh;
  overflow-x: hidden;
}

.forum-shell {
  width: min(940px, calc(100% - 48px));
  margin: 0 auto;
  padding: clamp(70px, 10vw, 130px) 0 80px;
}

.forum-hero {
  max-width: 820px;
}

.forum-hero h1 {
  max-width: 800px;
  font-size: clamp(3.5rem, 10vw, 7.5rem);
  line-height: 0.95;
}

.forum-description {
  max-width: 600px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.7;
}

.forum-sections {
  display: grid;
  gap: 12px;
  margin-top: clamp(60px, 9vw, 110px);
  grid-template-columns: repeat(3, 1fr);
}

.forum-section-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  scroll-margin-top: 24px;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.forum-section-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow:
    0 22px 50px rgba(25, 33, 42, 0.12);
}

.forum-section-number {
  align-self: start;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 800;
}

.forum-section-card h2 {
  font-size: clamp(1.1rem, 3vw, 1.45rem);
}

.forum-section-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.forum-card-arrow {
  color: var(--muted);
  font-size: 2rem;
  transition: transform 160ms ease;
}

.forum-section-card:hover .forum-card-arrow {
  transform: translateX(4px);
}

/* ================================
   Right drawer
   ================================ */

.forum-drawer {
  position: fixed;
  z-index: 100;
  top: 0;
  right: 0;
  width: min(360px, calc(100vw - 28px));
  height: 100vh;
  height: 100dvh;
  border-left: 1px solid var(--line);
  background:
    linear-gradient(
      180deg,
      rgba(47, 111, 180, 0.06),
      transparent 35%
    ),
    rgba(255, 255, 255, 0.98);
  box-shadow:
    -18px 0 45px rgba(25, 33, 42, 0.1);

  /*
   * 默认只留下 26px 宽的区域。
   * 鼠标放到它上面时，整个侧栏会滑出来。
   */
  transform: translateX(calc(100% - 26px));
  transition: transform 260ms ease;
}

/*
 * 鼠标悬停、键盘聚焦或者点击打开时，
 * 都显示完整侧栏。
 */
.forum-drawer:hover,
.forum-drawer:focus-within,
.forum-drawer.is-open {
  transform: translateX(0);
}

.forum-drawer-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 26px;
  height: 100%;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  transform: translateY(-50%);
}

.forum-drawer-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 18px;
  height: 64px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px 0 0 8px;
  background: var(--paper);
  box-shadow:
    -8px 0 20px rgba(25, 33, 42, 0.08);
  font-size: 1.5rem;
  transform: translate(-100%, -50%);
}

.forum-drawer-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 34px 26px 26px 50px;
  overflow-y: auto;
}

.forum-user {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.forum-user-label,
.forum-navigation-title {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.forum-user strong {
  display: block;
  margin-top: 8px;
  font-size: 1.1rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.forum-start-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-top: 24px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 0 17px;
  font-weight: 800;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.forum-start-button:hover {
  background: var(--blue);
  transform: translateY(-1px);
}

.forum-start-button span:last-child {
  font-size: 1.35rem;
}

.forum-drawer-navigation {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.forum-navigation-title {
  margin-bottom: 6px;
}

.forum-drawer-navigation a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  transition:
    color 160ms ease,
    padding 160ms ease;
}

.forum-drawer-navigation a:hover {
  color: var(--blue);
  padding-left: 6px;
}

.forum-drawer-navigation a span:last-child {
  color: var(--muted);
  font-size: 0.75rem;
}

.forum-home-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 0 14px;
  font-weight: 700;
}

.forum-home-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* 清晰的键盘焦点样式 */
.forum-drawer a:focus-visible,
.forum-drawer button:focus-visible {
  outline: 3px solid rgba(47, 111, 180, 0.3);
  outline-offset: 3px;
}

/* ================================
   Responsive
   ================================ */

@media (max-width: 620px) {
  .forum-shell {
    width: min(100% - 32px, 540px);
    padding-top: 60px;
  }

  .forum-hero h1 {
    font-size: clamp(3.1rem, 18vw, 5rem);
  }

  .forum-section-card {
    grid-template-columns: 38px 1fr;
    min-height: 104px;
    padding: 18px;
  }

  .forum-card-arrow {
    display: none;
  }

  .forum-drawer {
    width: min(330px, calc(100vw - 18px));
  }

  /*
   * 手机没有可靠的 hover，
   * 默认仅显示把手，通过点击打开。
   */
  .forum-drawer:not(.is-open) {
    transform: translateX(calc(100% - 20px));
  }

  .forum-drawer-handle {
    width: 20px;
  }

  .forum-drawer-content {
    padding:
      max(24px, env(safe-area-inset-top))
      20px
      max(20px, env(safe-area-inset-bottom))
      40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .forum-drawer,
  .forum-section-card,
  .forum-card-arrow,
  .forum-start-button {
    transition: none;
  }
}


#physics {
  scroll-margin-top: 24px;
}

/* ================================
   论坛主体
   ================================ */

.forum-zone {
  display: grid;
  gap: 18px;
  width: min(940px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

/* 每个学科区域 */
.forum-subject {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 24px;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

/* 鼠标放到学科区域上时 */
.forum-subject:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow:
    0 22px 50px rgba(25, 33, 42, 0.12);
}

/* 学科区域的头部 */
.forum-subject-header {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
  padding: 26px 28px;
  border-bottom: 1px solid var(--line);
}


/* 学科名称 */
.forum-subject-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.1;
}

/* “欢迎来到物理区” */
.forum-subject-header p {
  margin:8px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* 学科区域的下半部分 */
.forum-subject-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
}

/* 学科介绍 */
.forum-subject-content > p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

/* 键盘操作时的焦点 */
.forum-subject-link:focus-visible {
  outline: 3px solid rgba(47, 111, 180, 0.3);
  outline-offset: 3px;
}

@media (max-width: 620px) {
  .forum-zone {
    width: min(100% - 32px, 540px);
    padding: 28px 0 60px;
  }

  .forum-subject-header {
    grid-template-columns: 38px 1fr;
    gap: 12px;
    padding: 22px 18px;
  }

  .forum-subject-content {
    display: grid;
    gap: 18px;
    padding: 20px 18px;
  }

  .forum-subject-link {
    width: 100%;
  }
}

/* ================================
   新讨论页面
   ================================ */

.discussion-editor-page {
  min-height: 100vh;
}

.discussion-editor-shell {
  width: min(820px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(50px, 8vw, 90px) 0 80px;
}

.discussion-editor-header {
  margin-bottom: 36px;
}

.discussion-editor-header h1 {
  font-size: clamp(2.8rem, 8vw, 5rem);
}

.discussion-editor-header > p:last-child {
  max-width: 620px;
  margin: 20px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.discussion-form {
  display: grid;
  gap: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 34px);
}

.discussion-field {
  display: grid;
  gap: 9px;
}

.discussion-field > span,
.discussion-tags-field legend {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.discussion-field small {
  color: var(--muted);
  font-size: 0.82rem;
}

.discussion-field input,
.discussion-field select,
.discussion-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding: 12px 14px;
}

.discussion-field input,
.discussion-field select {
  min-height: 48px;
}

.discussion-field textarea {
  min-height: 260px;
  line-height: 1.7;
  resize: vertical;
  font: inherit;
}

.discussion-field input:focus,
.discussion-field select:focus,
.discussion-field textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(47, 111, 180, 0.15);
}

.discussion-tags-field {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.discussion-tags-field:disabled {
  opacity: 0.65;
}

.discussion-tags-field legend {
  padding: 0 7px;
}

#tagsHelp {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.discussion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.discussion-tag-option {
  cursor: pointer;
}

.discussion-tag-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.discussion-tag-option span {
  display: inline-grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  padding: 0 14px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.discussion-tag-option input:checked + span {
  border-color: var(--blue);
  background: #e8f1fb;
  color: #164d86;
}

.discussion-tag-option input:focus-visible + span {
  outline: 3px solid rgba(47, 111, 180, 0.25);
  outline-offset: 2px;
}

.discussion-message {
  min-height: 24px;
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
}

.discussion-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.discussion-cancel-button,
.discussion-submit-button {
  display: inline-grid;
  min-height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 17px;
  font-weight: 800;
}

.discussion-cancel-button {
  background: var(--paper);
  color: var(--ink);
}

.discussion-submit-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.discussion-submit-button:hover {
  border-color: var(--blue);
  background: var(--blue);
}

.discussion-submit-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

@media (max-width: 560px) {
  .discussion-editor-shell {
    width: min(100% - 24px, 520px);
    padding-top: 32px;
  }

  .discussion-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .discussion-cancel-button,
  .discussion-submit-button {
    width: 100%;
  }
}

/* ================================
   论坛帖子列表
   ================================ */

.forum-post-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  margin-bottom: 8px;

  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  align-content: start;
  gap: 0;
  border-top: 1px solid var(--line);

  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color:
    var(--muted)
    transparent;
}

.forum-post-list::-webkit-scrollbar {
  width: 8px;
}

.forum-post-list::-webkit-scrollbar-track {
  background: transparent;
}

.forum-post-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background:
    rgba(102, 113, 126, 0.45);
  background-clip: padding-box;
}

.forum-post-list::-webkit-scrollbar-thumb:hover {
  background:
    rgba(47, 111, 180, 0.7);
  background-clip: padding-box;
}

@media (max-width: 620px) {
  .forum-post-list {
    height: 420px;
  }

  .back-to-top {
    right: 30px;
    bottom: 22px;
    width: 42px;
    height: 42px;
  }
}

.forum-post-card {
  display: grid;
  gap: 14px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.forum-post-card:focus-visible {
  outline: 3px solid rgba(47, 111, 180, 0.3);
  outline-offset: -3px;
}

.forum-post-card:last-child {
  border-bottom: 0;
}

.forum-post-card:hover {
  background: rgba(232, 241, 251, 0.65);
  transform: translateX(3px);
}

.forum-post-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.forum-post-heading h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.forum-post-time {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.forum-post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.forum-post-tags span {
  display: inline-grid;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #e8f1fb;
  color: #164d86;
  padding: 0 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.forum-post-preview {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.forum-post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.82rem;
}

.forum-post-open {
  color: var(--blue);
  font-weight: 800;
}

.forum-post-open:hover {
  text-decoration: underline;
}

.forum-post-empty,
.forum-post-loading {
  margin: 0;
  padding: 34px 28px;
  color: var(--muted);
  text-align: center;
}


@media (max-width: 620px) {
  .forum-post-card {
    padding: 20px 18px;
  }

  .forum-post-heading {
    display: grid;
    gap: 8px;
  }

  .forum-post-footer {
    align-items: start;
  }
}

<!--Discussion Page-->

.discussion-page-shell {
  width: min(860px, calc(100% - 64px));
  margin: 0 auto;
  padding: 50px 0 80px;
}

@media (max-width: 560px) {
  .discussion-page-shell {
    width: calc(100% - 24px);
    padding: 28px 0 48px;
  }
}

.discussion-back-link {
  display: inline-flex;
  margin-bottom: 24px;
  color: var(--blue);
  font-weight: 800;
}

.discussion-status {
  color: var(--muted);
}

.discussion-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}


.discussion-detail-header {
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.discussion-detail-header h1 {
  overflow-wrap: anywhere;
}

.discussion-detail-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.85rem;
}

.discussion-detail-header .forum-post-tags {
  margin-top: 18px;
}

.discussion-detail-content {
  min-height: 220px;
  padding: 28px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.discussion-detail-content p {
  margin: 0.65em 0;
}

.discussion-detail-content li {
  margin: 0.25em 0;
}

.discussion-detail-content ul,
.discussion-detail-content ol {
  margin: 0.7em 0;
  padding-left: 1.6em;
}

.markdown-preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.markdown-preview-panel > h2 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 241, 0.7);
  padding: 14px 18px;
  font-size: 0.9rem;
}

.markdown-body {
  min-height: 160px;
  padding: 22px;
  color: var(--ink);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.5em 0 0.65em;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: 2rem;
}

.markdown-body h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 1.5rem;
}

.markdown-body h3 {
  font-size: 1.2rem;
}

.markdown-body p {
  margin: 1em 0;
}

.markdown-body a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body blockquote {
  margin: 18px 0;
  border-left: 4px solid var(--blue);
  background: #e8f1fb;
  padding: 12px 18px;
  color: var(--muted);
}

.markdown-body code {
  border-radius: 5px;
  background: #eef1f3;
  padding: 2px 6px;
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.9em;
}

.markdown-body pre {
  overflow-x: auto;
  border-radius: 8px;
  background: var(--ink);
  padding: 18px;
  color: #fff;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg);
}

.markdown-preview-empty {
  margin: 0;
  color: var(--muted);
}

.input-error-message {
  color: var(--red) !important;
  font-weight: 700;
}

/* ================================
   帖子作者操作按钮
   ================================ */

.discussion-owner-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(
      90deg,
      rgba(47, 111, 180, 0.03),
      rgba(24, 128, 92, 0.03)
    ),
    rgba(255, 255, 255, 0.72);
  padding: 18px 28px;
}

/*
 * 防止 display:flex 覆盖 HTML 的 hidden 属性。
 */
.discussion-owner-actions[hidden] {
  display: none;
}

.discussion-owner-actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

/* 编辑按钮 */
#editPostButton {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

#editPostButton:hover {
  border-color: var(--blue);
  background: var(--blue);
  transform: translateY(-1px);
  box-shadow:
    0 8px 18px rgba(47, 111, 180, 0.2);
}

/* 删除按钮 */
#deletePostButton {
  border-color: rgba(200, 75, 69, 0.45);
  background: rgba(200, 75, 69, 0.07);
  color: var(--red);
}

#deletePostButton:hover {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow:
    0 8px 18px rgba(200, 75, 69, 0.2);
}

.discussion-owner-actions button:focus-visible {
  outline: 3px solid rgba(47, 111, 180, 0.22);
  outline-offset: 2px;
}

.discussion-owner-actions button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

@media (max-width: 560px) {
  .discussion-owner-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 16px 18px;
  }

  .discussion-owner-actions[hidden] {
    display: none;
  }

  .discussion-owner-actions button {
    width: 100%;
  }
}

/* ================================
   帖子回复区域
   ================================ */

.discussion-replies {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.discussion-replies-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 22px 28px;
}

.discussion-replies-header .eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.discussion-replies-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

#replyCount {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.reply-list {
  display: grid;
}

.reply-card {
  padding: 22px 28px;
}

.reply-card + .reply-card {
  border-top: 1px solid var(--line);
}

.reply-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.reply-card-header strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.reply-card-header time {
  color: var(--muted);
  font-size: 0.8rem;
}

.reply-card-content {
  margin: 14px 0 0;
  color: var(--ink);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.reply-status {
  margin: 0;
  padding: 26px 28px;
  color: var(--muted);
}

.reply-error {
  color: var(--red);
}

.reply-form {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  background:
    rgba(244, 246, 241, 0.45);
  padding: 24px 28px;
}

.reply-form label {
  font-size: 0.92rem;
  font-weight: 800;
}

.reply-form textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
}

.reply-form textarea:focus {
  border-color: var(--blue);
  outline:
    3px solid
    rgba(47, 111, 180, 0.15);
}

.reply-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reply-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-size: 0.86rem;
}

.reply-submit-button {
  min-height: 44px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  padding: 0 17px;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.reply-submit-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue);
  transform: translateY(-1px);
}

.reply-submit-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 560px) {
  .discussion-replies-header,
  .reply-card,
  .reply-form {
    padding-left: 18px;
    padding-right: 18px;
  }

  .reply-form-footer {
    display: grid;
  }

  .reply-submit-button {
    width: 100%;
  }
}

/* ================================
   回复标题右侧操作区
   ================================ */

.reply-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#replyCount {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.open-reply-button {
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  padding: 0 17px;
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.open-reply-button:hover {
  border-color: var(--blue);
  background: var(--blue);
  transform: translateY(-1px);
  box-shadow:
    0 8px 18px
    rgba(47, 111, 180, 0.2);
}

.open-reply-button:focus-visible {
  outline:
    3px solid
    rgba(47, 111, 180, 0.22);
  outline-offset: 2px;
}


/* ================================
   回复抽屉背景
   ================================ */
.reply-composer[hidden],
.reply-composer-backdrop[hidden] {
  display: none;
}

.reply-composer-backdrop {
  position: fixed;
  z-index: 299;
  inset: 0;
  background:
    rgba(25, 33, 42, 0.32);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 220ms ease,
    visibility 220ms ease;
}

.reply-composer-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}


/* ================================
   底部回复抽屉
   ================================ */

.reply-composer {
  position: fixed;
  z-index: 300;
  right: 0;
  bottom: 0;
  left: 0;

  width:
    min(820px, calc(100% - 32px));

  max-height:
    min(680px, 88dvh);

  margin: 0 auto;

  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;

  background:
    rgba(255, 255, 255, 0.99);

  box-shadow:
    0 -18px 45px
    rgba(25, 33, 42, 0.12);

  overflow-y: auto;

  transform: translateY(110%);
  visibility: hidden;
  pointer-events: none;

  transition:
    transform 260ms ease,
    visibility 260ms ease;
}

.reply-composer.is-open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.reply-composer-handle {
  width: 46px;
  height: 5px;
  margin: 10px auto 0;
  border-radius: 999px;
  background:
    rgba(102, 113, 126, 0.38);
}

.reply-composer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
}

.reply-composer-header .eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.reply-composer-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.close-reply-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background 150ms ease;
}

.close-reply-button:hover {
  border-color: var(--red);
  background:
    rgba(200, 75, 69, 0.07);
  color: var(--red);
}


/* ================================
   抽屉中的回复表单
   ================================ */

.reply-composer .reply-form {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  background:
    rgba(244, 246, 241, 0.45);
  padding: 24px 28px;
}

.reply-composer .reply-form label {
  font-size: 0.92rem;
  font-weight: 800;
}

.reply-composer .reply-form textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 13px 14px;
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
}

.reply-composer
.reply-form textarea:focus {
  border-color: var(--blue);
  outline:
    3px solid
    rgba(47, 111, 180, 0.15);
}

.reply-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.reply-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-size: 0.86rem;
}

.reply-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reply-cancel-button,
.reply-submit-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 17px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.reply-cancel-button {
  background: var(--paper);
  color: var(--ink);
}

.reply-cancel-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.reply-submit-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.reply-submit-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue);
}

.reply-submit-button:disabled {
  cursor: wait;
  opacity: 0.58;
}


/*
 * 打开回复抽屉时阻止页面背景滚动。
 */
body.reply-composer-open {
  overflow: hidden;
}


/* ================================
   移动端
   ================================ */

@media (max-width: 560px) {
  .discussion-replies-header {
    align-items: center;
  }

  .reply-header-actions {
    gap: 8px;
  }

  #replyCount {
    display: none;
  }

  .open-reply-button {
    min-height: 40px;
    padding: 0 14px;
  }

  .reply-composer {
    width: 100%;
    max-height: 92dvh;
    border-right: 0;
    border-left: 0;
  }

  .reply-composer-header {
    padding:
      16px
      18px;
  }

  .reply-composer .reply-form {
    padding:
      20px
      18px
      24px;
  }

  .reply-form-footer {
    display: grid;
  }

  .reply-form-actions {
    display: grid;
    grid-template-columns:
      1fr 1fr;
  }

  .reply-cancel-button,
  .reply-submit-button {
    width: 100%;
  }
}

/* ================================
   回复 Markdown 预览
   ================================ */

.reply-preview-panel {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

.reply-preview-panel > h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background:
    rgba(244, 246, 241, 0.72);
  padding: 11px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.reply-markdown-preview {
  min-height: 110px;
  max-height: 240px;
  overflow-y: auto;
  padding: 16px;
  color: var(--ink);
  line-height: 1.6;
}


/*
 * 已发表回复中的 Markdown。
 */
.reply-card-content.markdown-body {
  min-height: 0;
  margin: 14px 0 0;
  padding: 0;
  line-height: 1.6;
  white-space: normal;
}

.reply-card-content.markdown-body p {
  margin: 0.65em 0;
}

.reply-card-content.markdown-body
> :first-child {
  margin-top: 0;
}

.reply-card-content.markdown-body
> :last-child {
  margin-bottom: 0;
}


/*
 * 回复中的标题不需要和帖子标题一样大。
 */
.reply-card-content.markdown-body h1 {
  font-size: 1.5rem;
}

.reply-card-content.markdown-body h2 {
  font-size: 1.25rem;
}

.reply-card-content.markdown-body h3 {
  font-size: 1.08rem;
}


/*
 * 回复预览中的标题也适当缩小。
 */
.reply-markdown-preview h1 {
  font-size: 1.5rem;
}

.reply-markdown-preview h2 {
  font-size: 1.25rem;
}

.reply-markdown-preview h3 {
  font-size: 1.08rem;
}

@media (max-width: 560px) {
  .reply-markdown-preview {
    max-height: 190px;
    padding: 14px;
  }
}

/* 回复右侧时间和操作按钮 */
.reply-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reply-delete-button {
  min-height: 30px;
  border:
    1px solid
    rgba(200, 75, 69, 0.35);
  border-radius: 6px;
  background:
    rgba(200, 75, 69, 0.06);
  padding: 0 10px;
  color: var(--red);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.reply-delete-button:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.reply-delete-button:focus-visible {
  outline:
    3px solid
    rgba(200, 75, 69, 0.18);
  outline-offset: 2px;
}

.reply-delete-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

@media (max-width: 560px) {
  .reply-card-header {
    align-items: flex-start;
  }

  .reply-card-actions {
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
  }
}

.forum-post-pin {
  display: inline-block;
  margin-left: 6px;
  color: #c62828;
  font-size: 0.85em;
  vertical-align: 0.08em;
}

.admin-wrench {
  display: inline-block;
  margin-left: 4px;
  color: #c62828;
  font-size: 0.82em;
  font-weight: 800;
  vertical-align: 0.08em;
} 


.forum-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 8px;
}

/*
 * 覆盖原来 strong 上面的 margin，
 * 因为现在间距由 forum-user-row 控制。
 */
.forum-user-row strong {
  min-width: 0;
  margin-top: 0;
}

.forum-admin-button {
  flex: 0 0 auto;
  border: 1px solid rgba(190, 40, 40, 0.3);
  border-radius: 6px;
  background: rgba(190, 40, 40, 0.07);
  padding: 7px 9px;
  color: #b3261e;
  font-size: 0.76rem;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;

  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.forum-admin-button:hover {
  border-color: #b3261e;
  background: rgba(190, 40, 40, 0.13);
  color: #8f1d17;
  transform: translateY(-1px);
}

/*
 * 确保 hidden 属性一定能隐藏按钮。
 */
.forum-admin-button[hidden] {
  display: none;
} 
