:root {
  color-scheme: light;
  --ink: #1c1a16;
  --muted: #676158;
  --line: #d7d0c4;
  --panel: rgba(255, 252, 246, 0.92);
  --paper: #f7f0e3;
  --accent: #9f3e2f;
  --accent-dark: #742b22;
  --jade: #2e6f60;
  --gold: #c79035;
  --shadow: 0 24px 70px rgba(77, 54, 33, 0.16);
  --shadow-sm: 0 8px 24px rgba(77, 54, 33, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(159, 62, 47, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(46, 111, 96, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 18% 16%, rgba(199, 144, 53, 0.18), transparent 28%),
    linear-gradient(135deg, #fbf7ef 0%, #eee5d6 48%, #f5efe6 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ===== Top nav ===== */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(251, 247, 239, 0.78);
  border-bottom: 1px solid rgba(112, 93, 72, 0.14);
}
.top-nav-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.brand::before {
  content: "☯";
  color: var(--accent);
  margin-right: 8px;
  font-size: 1.1em;
}
.brand-sub {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 500;
  font-size: 0.66em;
  color: var(--muted);
  letter-spacing: 0.12em;
  vertical-align: 0.14em;
}
.brand-sub::before {
  content: "·";
  color: var(--accent);
  margin: 0 0.55em 0 0.6em;
  font-weight: 400;
  opacity: 0.85;
}
.nav-links {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}
.nav-links a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  transition: 160ms ease;
}
.nav-links a:hover { color: var(--ink); background: rgba(28, 26, 22, 0.05); }
.nav-links a.active {
  color: var(--accent);
  background: rgba(159, 62, 47, 0.08);
}
.nav-cta {
  margin-left: auto;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(159, 62, 47, 0.4);
  background: var(--panel);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 160ms ease;
}
.nav-cta:hover { background: var(--accent); color: #fffdf8; }

/* ===== Page shell ===== */
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.page-head {
  display: grid;
  gap: 10px;
  margin-bottom: 32px;
}
.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0;
}
.page-head h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 800;
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  line-height: 1.05;
}
.page-head .lead {
  margin: 4px 0 0;
  color: var(--muted);
  max-width: 640px;
  line-height: 1.7;
}

/* ===== Filters ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px 18px;
  border: 1px solid rgba(112, 93, 72, 0.16);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.filters-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-right: 4px;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(112, 93, 72, 0.2);
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
  transition: 140ms ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active {
  background: var(--ink);
  color: #fbf7ef;
  border-color: var(--ink);
}
.filter-divider {
  width: 1px;
  height: 20px;
  background: rgba(112, 93, 72, 0.2);
  margin: 0 4px;
}
.sort-select {
  padding: 6px 30px 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(112, 93, 72, 0.2);
  background: transparent;
  font-size: 0.88rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23676158' fill='none' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ===== Case grid ===== */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.case-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(112, 93, 72, 0.16);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: 180ms ease;
  cursor: pointer;
}
.case-card:hover {
  transform: translateY(-2px);
  border-color: rgba(159, 62, 47, 0.35);
  box-shadow: var(--shadow);
}

.case-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.category-tag {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(46, 111, 96, 0.1);
  color: var(--jade);
}
.category-tag.love { background: rgba(159, 62, 47, 0.1); color: var(--accent); }
.category-tag.career { background: rgba(46, 111, 96, 0.1); color: var(--jade); }
.category-tag.study { background: rgba(199, 144, 53, 0.15); color: #8f6821; }
.category-tag.money { background: rgba(199, 144, 53, 0.15); color: #8f6821; }
.category-tag.health { background: rgba(103, 97, 88, 0.14); color: var(--muted); }
.category-tag.other { background: rgba(103, 97, 88, 0.14); color: var(--muted); }

.verdict-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.verdict-pill.yes { background: rgba(46, 111, 96, 0.12); color: var(--jade); border-color: rgba(46, 111, 96, 0.3); }
.verdict-pill.partial { background: rgba(199, 144, 53, 0.15); color: #8f6821; border-color: rgba(199, 144, 53, 0.35); }
.verdict-pill.no { background: rgba(159, 62, 47, 0.1); color: var(--accent); border-color: rgba(159, 62, 47, 0.3); }
.verdict-pill.pending { background: rgba(103, 97, 88, 0.1); color: var(--muted); border-color: rgba(103, 97, 88, 0.25); }

.case-question {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.case-hex-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background:
    linear-gradient(90deg, rgba(28, 26, 22, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(28, 26, 22, 0.03) 1px, transparent 1px),
    rgba(255, 253, 247, 0.7);
  background-size: 18px 18px;
  border-radius: 6px;
  border: 1px solid rgba(112, 93, 72, 0.12);
}
.mini-hex {
  display: grid;
  gap: 4px;
  width: 62px;
}
.mini-hex .yao {
  height: 6px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.mini-hex .yao.yin { grid-template-columns: 1fr 1fr; }
.mini-hex .yao span {
  background: var(--ink);
  border-radius: 999px;
}
.mini-hex .yao.moving span {
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(159, 62, 47, 0.15);
}
.hex-arrow {
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 900;
}
.hex-labels {
  display: grid;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}
.hex-labels strong {
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.case-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}
.case-meta .dot { opacity: 0.4; }
.case-meta .stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ===== Empty CTA card ===== */
.empty-cta {
  grid-column: 1 / -1;
  display: none;
}

/* ===== Detail page ===== */
.detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
}
.detail-main { display: grid; gap: 22px; min-width: 0; }
.detail-side { display: grid; gap: 18px; align-content: start; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

.card {
  padding: 24px;
  border: 1px solid rgba(112, 93, 72, 0.16);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.card h3 {
  margin: 0 0 14px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

.detail-head {
  display: grid;
  gap: 14px;
}
.detail-head .row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.detail-question {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.3;
}
.detail-meta {
  display: flex;
  gap: 16px;
  font-size: 0.86rem;
  color: var(--muted);
  flex-wrap: wrap;
}

/* Big hexagram (reuse from main) */
.hexagram-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid rgba(112, 93, 72, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(28, 26, 22, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(28, 26, 22, 0.04) 1px, transparent 1px),
    rgba(255, 253, 247, 0.62);
  background-size: 24px 24px;
}
.hex-wrap { display: grid; justify-items: center; gap: 10px; }
.hex-wrap .label { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.1em; }
.hex-wrap .title {
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.15rem;
  font-weight: 700;
}
.hex-wrap .symbol {
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.6rem;
  color: var(--muted);
}
.big-hex {
  width: 140px;
  display: grid;
  gap: 8px;
}
.big-hex .yao {
  height: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.big-hex .yao.yin { grid-template-columns: 1fr 1fr; }
.big-hex .yao span {
  background: var(--ink);
  border-radius: 999px;
}
.big-hex .yao.moving span {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(159, 62, 47, 0.13);
}
.change-arrow {
  color: var(--gold);
  font-size: 2rem;
  font-weight: 900;
}
.reading-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 20px 0 0;
  padding: 0;
}
.reading-grid > div {
  padding: 12px;
  background: rgba(255, 253, 247, 0.6);
  border-radius: 6px;
  border: 1px solid rgba(112, 93, 72, 0.1);
}
.reading-grid dt {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.reading-grid dd {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-weight: 700;
  font-size: 1rem;
}

.ai-text {
  white-space: pre-wrap;
  line-height: 1.85;
  color: #2a2620;
  font-size: 0.98rem;
}
.ai-text strong { color: var(--accent-dark); }

/* Outcomes timeline */
.timeline { display: grid; gap: 16px; }
.timeline-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 14px;
}
.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
  margin-top: 6px;
  justify-self: center;
  position: relative;
}
.timeline-item:not(:last-child) .timeline-dot::after {
  content: "";
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: calc(100% + 16px);
  background: rgba(159, 62, 47, 0.2);
}
.timeline-body {
  display: grid;
  gap: 6px;
  padding-bottom: 4px;
}
.timeline-row {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.timeline-text {
  line-height: 1.7;
  color: var(--ink);
}

/* Comments */
.comment-list { display: grid; gap: 16px; }
.comment {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid rgba(112, 93, 72, 0.12);
  background: rgba(255, 253, 247, 0.5);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: #fbf7ef;
  display: grid;
  place-items: center;
  font-family: "Songti SC", "STSong", serif;
  font-weight: 800;
}
.comment-head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.comment-name { font-weight: 700; font-size: 0.92rem; }
.comment-time { font-size: 0.78rem; color: var(--muted); }
.comment-body { line-height: 1.7; font-size: 0.95rem; }
.comment-actions {
  margin-top: 6px;
  display: flex;
  gap: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}
.comment-actions button {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
}
.comment-actions button:hover { color: var(--accent); }

.reply-form {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}
.reply-form textarea {
  width: 100%;
  min-height: 90px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid rgba(112, 93, 72, 0.2);
  background: rgba(255, 253, 247, 0.8);
  resize: vertical;
  line-height: 1.6;
}
.reply-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(159, 62, 47, 0.12);
}
.reply-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reply-row input {
  flex: 0 0 180px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid rgba(112, 93, 72, 0.2);
  background: rgba(255, 253, 247, 0.8);
}
.reply-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(159, 62, 47, 0.12);
}
.primary-btn {
  padding: 9px 20px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fbf7ef;
  font-weight: 700;
  cursor: pointer;
  transition: 160ms ease;
}
.primary-btn:hover { background: var(--accent-dark); }
.ghost-btn {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(112, 93, 72, 0.25);
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  transition: 140ms ease;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.ml-auto { margin-left: auto; }

/* Side cards */
.side-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-cell {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.7);
  border: 1px solid rgba(112, 93, 72, 0.12);
}
.stat-cell .num {
  font-family: "Songti SC", "STSong", serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
}
.stat-cell .label { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.related-list { display: grid; gap: 10px; }
.related-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(112, 93, 72, 0.12);
  cursor: pointer;
  transition: 140ms ease;
}
.related-item:hover { border-color: var(--accent); background: rgba(255, 253, 247, 0.9); }
.related-item .q {
  font-family: "Songti SC", "STSong", serif;
  font-weight: 700;
  font-size: 0.98rem;
}
.related-item .m { font-size: 0.78rem; color: var(--muted); }

.tips {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--muted);
}
.tips li { margin-bottom: 6px; }

/* Notice banner styling */
.notice {
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(199, 144, 53, 0.1);
  border: 1px solid rgba(199, 144, 53, 0.3);
  color: #6d4f14;
  font-size: 0.86rem;
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 900px) {
  .detail-shell { grid-template-columns: 1fr; }
  .reading-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-cta { display: none; }
  .top-nav-inner { gap: 12px; }
}

/* ============================================================
   移动端优化 —— 手机也能完美显示
   ============================================================ */
html, body { overflow-x: hidden; }

/* 平板及以下：布局降列 */
@media (max-width: 900px) {
  .shell { padding: 24px 0 56px; }
  .top-nav-inner { height: 56px; gap: 10px; }
  .brand { font-size: 1.15rem; }
  .nav-links a { padding: 6px 10px; font-size: 0.9rem; }

  /* 详情页栅格降列（已在上方定义过 detail-shell = 1fr，此处补上间距） */
  .detail-shell { gap: 20px; }

  /* 详情页卦象 stage：两个大六爻 + 箭头一行放不下时改成竖排 */
  .hexagram-stage {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px;
  }
  .change-arrow {
    transform: rotate(90deg);
    justify-self: center;
    font-size: 1.6rem;
  }
  .big-hex { width: 120px; }

  /* 卡片内边距轻微收紧 */
  .card { padding: 20px; }
  .form-card, .result-card { padding: 22px; }
}

/* 常规手机竖屏（≤560px）：精细化 */
@media (max-width: 560px) {
  .shell { width: calc(100% - 24px); padding: 20px 0 48px; }

  /* 顶栏：只保留品牌 + 两个链接，隐藏 CTA */
  .top-nav-inner {
    width: calc(100% - 24px);
    height: 54px;
    gap: 8px;
  }
  .brand { font-size: 1.08rem; }
  .brand::before { margin-right: 5px; }
  .nav-links { gap: 2px; margin-left: 0; }
  .nav-links a { padding: 6px 8px; font-size: 0.86rem; }
  .nav-cta { display: none; }

  /* 页头标题字号收敛 */
  .page-head { margin-bottom: 22px; gap: 8px; }
  .page-head h1 { font-size: clamp(1.7rem, 6vw, 2.2rem); line-height: 1.15; }
  .page-head .lead { font-size: 0.95rem; }

  /* 筛选栏：改为可横向滚动的条，避免多行拥挤 */
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }
  .filters-label { flex-shrink: 0; }
  .chip { flex-shrink: 0; padding: 6px 12px; }
  .filter-divider { flex-shrink: 0; }
  .sort-select { flex-shrink: 0; }

  /* 卡片栅格：单列，卡片压缩 */
  .case-grid { grid-template-columns: 1fr; gap: 14px; }
  .case-card { padding: 16px; gap: 12px; }
  .case-question { font-size: 1.08rem; }

  /* 卡片里六爻行：迷你六爻缩小，卦名换行到下方 */
  .case-hex-row {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 10px;
  }
  .mini-hex { width: 52px; }
  .hex-labels {
    margin-left: 0;
    text-align: left;
    flex-basis: 100%;
    order: 3;
    border-top: 1px dashed rgba(112,93,72,0.18);
    padding-top: 8px;
  }
  .hex-labels strong { font-size: 0.95rem; }

  /* case-meta 换行更容易 */
  .case-meta { flex-wrap: wrap; row-gap: 4px; font-size: 0.78rem; }

  /* 详情页 head 收紧 */
  .detail-question { font-size: 1.45rem; }
  .detail-meta { font-size: 0.8rem; gap: 12px; }
  .reading-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
  }
  .reading-grid > div { padding: 10px; }

  /* AI 解读 */
  .ai-text { font-size: 0.94rem; line-height: 1.8; }

  /* 追更时间线 dot 竖线继续保留 */
  .timeline-item { grid-template-columns: 16px 1fr; gap: 10px; }

  /* 评论：头像小一号，操作栏字号 */
  .comment { padding: 12px; grid-template-columns: 32px 1fr; gap: 10px; }
  .avatar { width: 32px; height: 32px; font-size: 0.9rem; }
  .comment-actions { gap: 12px; }

  /* 回复表单：昵称与按钮竖排，别再挤在一行 */
  .reply-form textarea { min-height: 100px; padding: 11px 13px; }
  .reply-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .reply-row input {
    flex: 1 1 100%;
    min-height: 44px; /* 触控友好 */
  }
  .reply-row > span {
    flex: 1 1 auto;
    order: 3;
    font-size: 0.76rem;
  }
  .reply-row .primary-btn {
    margin-left: 0;
    min-height: 44px;
    padding: 10px 22px;
  }

  /* 右侧栏在移动端已被扁平化到主流下方 */
  .side-stats { grid-template-columns: 1fr 1fr; }

  /* 按钮触控目标 ≥44px */
  .primary-btn, .ghost-btn, .chip { min-height: 40px; }
  .primary-btn, .ghost-btn { padding: 10px 22px; }
  .chip { display: inline-flex; align-items: center; }

  /* 返回链接更贴上 */
  .back-link { margin-bottom: 4px; }

  /* h3 字号小一号 */
  .card h3 { font-size: 1.05rem; }
}

/* iPhone SE / 窄屏 (≤380px) */
@media (max-width: 380px) {
  .case-hex-row { padding: 10px; }
  .mini-hex { width: 46px; }
  .big-hex { width: 108px; }
  .detail-question { font-size: 1.3rem; }
  .page-head h1 { font-size: 1.75rem; }
  .brand { font-size: 1rem; }
  .nav-links a { padding: 6px 6px; font-size: 0.82rem; }
}

/* 窄屏时收起顶栏品牌旁的中文副标，避免挤压 nav-links */
@media (max-width: 560px) {
  .top-nav .brand-sub { display: none; }
}

/* iOS 刘海屏 safe-area */
@supports (padding: env(safe-area-inset-bottom)) {
  .shell { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
  .top-nav-inner { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* ============================================================
   Plaza search box + snippet highlighting
   ============================================================ */
.plaza-search {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 18px 0;
  flex-wrap: wrap;
}
.plaza-search-input {
  flex: 1 1 260px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(112,93,72,0.3);
  background: rgba(255,253,247,0.85);
  font-family: inherit;
  font-size: 0.92rem;
  color: #3a2f24;
  outline: none;
  transition: border-color 0.15s;
}
.plaza-search-input:focus { border-color: #9f3e2f; }
.plaza-search-btn {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  background: #9f3e2f;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.plaza-search-btn:hover { background: #7f3225; }
.plaza-search-clear {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 10px;
}
.plaza-search-clear:hover { color: #9f3e2f; }

/* Snippet highlight <mark> from FTS5 */
.case-card mark, .case-ai-snippet mark {
  background: rgba(199, 144, 53, 0.28);
  color: #6d4f14;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
.case-ai-snippet {
  margin: -4px 0 10px;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 640px) {
  .plaza-search { flex-wrap: wrap; }
  .plaza-search-input { flex: 1 1 100%; }
}

/* ============================================================
   Rich editor (EasyMDE) + Markdown rendered content
   ============================================================ */
.plain-input {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(112,93,72,0.3);
  background: rgba(255,253,247,0.85);
  font-family: inherit;
  font-size: 0.92rem;
  color: #3a2f24;
  outline: none;
  box-sizing: border-box;
}
.plain-input:focus { border-color: #9f3e2f; }

/* EasyMDE 主题微调：吃我们的暖色背景 */
.EasyMDEContainer .CodeMirror {
  background: rgba(255,253,247,0.85);
  border: 1px solid rgba(112,93,72,0.3);
  color: #3a2f24;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.EasyMDEContainer .editor-toolbar {
  border: 1px solid rgba(112,93,72,0.3);
  border-bottom: none;
  background: rgba(255,253,247,0.5);
  opacity: 1;
}
.EasyMDEContainer .editor-toolbar button {
  color: #6b5b48 !important;
}
.EasyMDEContainer .editor-toolbar button.active,
.EasyMDEContainer .editor-toolbar button:hover {
  background: rgba(159, 62, 47, 0.08);
  border-color: rgba(159, 62, 47, 0.2);
  color: #9f3e2f !important;
}
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: rgba(255,253,247,0.95);
  color: #3a2f24;
  padding: 12px 16px;
  line-height: 1.7;
}

/* Markdown-rendered comment/outcome bodies */
.md-content { line-height: 1.7; color: #3a2f24; word-break: break-word; }
.md-content p { margin: 0 0 8px; }
.md-content p:last-child { margin-bottom: 0; }
.md-content ul, .md-content ol { padding-left: 20px; margin: 6px 0 10px; }
.md-content ul li, .md-content ol li { margin: 2px 0; }
.md-content blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid rgba(112,93,72,0.3);
  background: rgba(255,253,247,0.55);
  color: #6b5b48;
}
.md-content code {
  background: rgba(112,93,72,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.md-content pre {
  background: rgba(58,47,36,0.06);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
}
.md-content pre code { background: transparent; padding: 0; }
.md-content a { color: #9f3e2f; text-decoration: underline; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
  margin: 12px 0 6px;
  font-family: 'Songti SC', 'STSong', serif;
  color: #3a2f24;
}
.md-content h1 { font-size: 1.25rem; }
.md-content h2 { font-size: 1.15rem; }
.md-content h3 { font-size: 1.05rem; }
.md-content strong { color: #3a2f24; }
.md-content hr { border: none; border-top: 1px dashed rgba(112,93,72,0.25); margin: 12px 0; }

@media (max-width: 640px) {
  .EasyMDEContainer .editor-toolbar {
    padding: 4px 6px;
  }
  .EasyMDEContainer .editor-toolbar button { padding: 4px 6px !important; }
}

/* ============================================================
   Like button with visual feedback
   ============================================================ */
.like-btn { display: inline-flex; align-items: center; gap: 6px; user-select: none; cursor: pointer; }
.like-btn .like-icon { font-size: 1.05em; line-height: 1; transition: transform 0.18s ease; }
.like-btn .like-count {
  display: inline-flex;
  min-width: 20px;
  justify-content: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(112,93,72,0.1);
  font-size: 0.82em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: background 0.18s, color 0.18s;
}
.like-btn:hover .like-icon { transform: scale(1.1); }
.like-btn.is-liked {
  color: #9f3e2f;
  border-color: rgba(159, 62, 47, 0.45);
  background: rgba(159, 62, 47, 0.08);
}
.like-btn.is-liked .like-icon { color: #9f3e2f; }
.like-btn.is-liked .like-count { background: rgba(159, 62, 47, 0.14); color: #9f3e2f; }
.like-btn:disabled { opacity: 0.75; cursor: default; }
.like-btn.bump .like-icon { animation: like-bump 0.4s ease; }
@keyframes like-bump {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  55% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
