:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #6b7079;
  --line: #e4e0da;
  --accent: #c8102e;
  --accent-soft: #fbe9ec;
  --accent-2: #0a7ea4;
  --ok: #2f7d32;
  --hero: linear-gradient(135deg, #8e0c22 0%, #c8102e 55%, #e0582b 100%);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
}
:root[data-theme="dark"] {
  --bg: #15171a;
  --panel: #1e2125;
  --text: #e6e6e6;
  --muted: #9aa0a8;
  --line: #2e3238;
  --accent: #ff5a6e;
  --accent-soft: #3a1f25;
  --accent-2: #4fc3e8;
  --ok: #7bc47f;
  --hero: linear-gradient(135deg, #3b0a14 0%, #6b1022 60%, #7a3218 100%);
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.inline { display: inline; }
[lang="zh"] { font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "SimSun", sans-serif; }

/* top bar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-in { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); }
.mainnav { display: flex; gap: 16px; flex: 1; }
.mainnav a { color: var(--text); font-weight: 500; }
.userbox { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.langs a { color: var(--muted); font-size: .8rem; padding: 2px 4px; border-radius: 4px; }
.langs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.me { font-weight: 600; }
.menu-btn, .theme-btn, .linkbtn {
  background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0;
}
.linkbtn { color: var(--accent-2); }
.linkbtn.danger, a.danger { color: var(--accent); }
.theme-btn { font-size: 1.1rem; color: var(--muted); }
.menu-btn { display: none; font-size: 1.4rem; margin-left: auto; }

/* hero with dictionary search */
.hero { background: var(--hero); color: #fff; padding: 26px 0 30px; margin-bottom: 20px; }
.tagline { margin: 0 0 12px; opacity: .9; text-align: center; }
.dictsearch { display: flex; gap: 8px; max-width: 680px; margin: 0 auto; }
.dictsearch input {
  flex: 1; min-width: 0; font-size: 1.15rem; padding: 12px 16px; border-radius: var(--radius);
  border: 0; outline: none; background: #fff; color: #1f2328;
}
.plain-search { margin: 0 0 20px; max-width: none; }
.plain-search input { border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.hero .btn { background: #ffd54a; color: #3a2a00; }

/* buttons & forms */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.form label { display: block; font-weight: 600; margin: 14px 0 6px; }
.form input, .form select, .form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
.form textarea { resize: vertical; }
.form .btn { margin-top: 16px; margin-right: 10px; }
.hz-input { font-size: 1.4rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.narrow { max-width: 620px; margin: 0 auto; }
.auth { max-width: 400px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.error { background: var(--accent-soft); color: var(--accent); }
.flash.ok { background: rgba(47, 125, 50, .12); color: var(--ok); }
.notice { background: var(--panel); padding: 14px; border-radius: var(--radius); text-align: center; border: 1px dashed var(--line); }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.sidebar h3 { margin: 0 0 10px; font-size: .95rem; }
.searches { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 12px; }
.searches li { display: flex; justify-content: space-between; gap: 6px; font-size: .9rem; break-inside: avoid; }
.searches span { color: var(--muted); font-size: .75rem; }
.plain { list-style: none; padding: 0; margin: 0 0 12px; }
.plain li { padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.stats dd { margin: 0; font-weight: 600; text-align: right; }
.inline-stats { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 10px 0 14px; }
.inline-stats dt { color: var(--muted); }
.inline-stats dd { margin-right: 14px; }

/* forum list */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.minisearch { margin-left: auto; }
.minisearch input { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chips a { padding: 3px 11px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: .85rem; }
.chips a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips a:hover { text-decoration: none; border-color: var(--accent); }

.topics, .results, .history { list-style: none; margin: 0; padding: 0; }
.topic-row {
  display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
}
.topic-main { flex: 1; min-width: 0; }
.topic-title { font-weight: 600; font-size: 1.02rem; color: var(--text); }
.topic-meta { display: flex; gap: 10px; align-items: center; font-size: .82rem; margin-top: 2px; }
.tag { background: var(--accent-soft); color: var(--accent); padding: 0 8px; border-radius: 99px; }
.last { margin: 6px 0 0; color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.topic-nums { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: .8rem; min-width: 52px; }
.count { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-weight: 700; font-size: .9rem; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.results li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.results p { margin: 4px 0; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.pager a { padding: 4px 10px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); }
.pager a.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* topic page */
.crumbs { font-size: .85rem; color: var(--muted); }
.topic-h { margin-bottom: 2px; }
.modbar { display: flex; gap: 8px; margin: 10px 0; }
.post { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.post-author { width: 150px; flex-shrink: 0; padding: 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; word-break: break-word; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.avatar.big { width: 80px; height: 80px; font-size: 2rem; flex-shrink: 0; }
.badge { background: var(--accent-2); color: #fff; font-size: .7rem; padding: 1px 7px; border-radius: 99px; vertical-align: middle; }
.badge.danger { background: var(--accent); }
.post-body { flex: 1; min-width: 0; padding: 12px 16px; display: flex; flex-direction: column; }
.post-text { flex: 1; overflow-wrap: anywhere; }
.post-actions { display: flex; gap: 14px; align-items: center; font-size: .85rem; margin-top: 10px; flex-wrap: wrap; }
blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 6px 6px 0; }
blockquote cite { display: block; font-style: normal; font-weight: 600; font-size: .85em; color: var(--muted); }

/* dictionary */
.sec { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 20px 0 10px; }
.word { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
.word .hz { font-size: 1.6rem; color: var(--text); margin-right: 10px; }
.word.big .hz { font-size: 2.6rem; }
.word .py, td.py { color: var(--accent); font-size: 1.05rem; }
.meanings { margin: 8px 0 0; padding-left: 22px; }
.wordgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.wordgrid .word { margin: 0; }
.orig { margin-top: 10px; padding: 10px 12px; background: var(--bg); border-radius: 8px; font-size: .92rem; }
.orig.collapsed { display: none; }
.draft { margin-top: 10px; padding: 10px 12px; border: 1px dashed var(--accent-2); border-radius: 8px; font-size: .95rem; }
.orig-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.orig .m { margin: 2px 0; }
.orig .m2 { padding-left: 1.2em; }
.orig .m3 { padding-left: 2.4em; }
.orig .m4 { padding-left: 3.6em; }
.orig .ab, .orig .c { color: var(--ok); font-style: italic; }
.orig .ex { color: var(--muted); }
.orig i { color: var(--muted); }
.muted-badge { background: var(--line); color: var(--muted); }
.leaders { margin: 0; padding-left: 20px; }
.leaders li { padding: 3px 0; }
.leaders b { float: right; }
.credit { color: var(--muted); font-size: .8rem; margin-top: 24px; }
.history li { border-bottom: 1px solid var(--line); padding: 10px 0; }
.diff del { display: block; color: var(--accent); white-space: pre-line; }
.diff ins { display: block; color: var(--ok); text-decoration: none; white-space: pre-line; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hz-cell { font-size: 1.4rem; color: var(--text); }

.profile { display: flex; gap: 20px; align-items: flex-start; }
.footer { margin-top: 40px; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* phones */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  .topbar-in { flex-wrap: wrap; height: auto; min-height: 56px; gap: 10px; }
  .mainnav, .userbox { display: none; width: 100%; }
  .nav-open .mainnav, .nav-open .userbox { display: flex; flex-wrap: wrap; padding-bottom: 10px; }
  .minisearch { margin-left: 0; width: 100%; }
  .minisearch input { width: 100%; }
  .post { flex-direction: column; }
  .post-author { width: auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 14px; }
  .avatar { width: 30px; height: 30px; font-size: .9rem; }
  .dictsearch input { font-size: 1rem; }
  .profile { flex-direction: column; }
}
