/* YiLian — neutral, dense, quiet. Colour only carries meaning. 4px spacing grid. */
:root {
  --canvas: #FAFAF9;
  --surface: #FFFFFF;
  --subtle: #F5F5F4;
  --hover: #EEEEEC;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --ink: #1C1917;
  --ink-muted: #57534E;
  --ink-faint: #A8A29E;
  --on-ink: #FAFAF9;

  --supply: #15803D;
  --supply-bg: #F0FDF4;
  --demand: #1D4ED8;
  --demand-bg: #EFF6FF;
  --pin: #A16207;
  --pin-bg: #FEFCE8;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --ok: #15803D;
  --verified: #0E7490;
  --mine: #1C1917;
  --on-mine: #FAFAF9;

  --r-control: 8px;
  --r-card: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0C0A09;
    --surface: #1C1917;
    --subtle: #292524;
    --hover: #2F2B29;
    --border: #292524;
    --border-strong: #44403C;
    --ink: #FAFAF9;
    --ink-muted: #A8A29E;
    --ink-faint: #78716C;
    --on-ink: #0C0A09;
    --supply: #4ADE80;
    --supply-bg: rgba(74, 222, 128, .12);
    --demand: #60A5FA;
    --demand-bg: rgba(96, 165, 250, .12);
    --pin: #FACC15;
    --pin-bg: rgba(250, 204, 21, .12);
    --danger: #F87171;
    --danger-bg: rgba(248, 113, 113, .12);
    --ok: #4ADE80;
    --verified: #22D3EE;
    --mine: #FAFAF9;
    --on-mine: #0C0A09;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.6 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-muted); }
.small { font-size: 12px; }
.block { display: block; }
.center { text-align: center; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.narrow { max-width: 720px; margin: 0 auto; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { display: flex; align-items: center; gap: 24px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { position: relative; padding: 8px 12px; border-radius: var(--r-control); color: var(--ink-muted); white-space: nowrap; }
.nav a:hover { background: var(--subtle); color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); font-weight: 600; background: var(--subtle); }
.badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 4px; margin-left: 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-family: var(--mono); vertical-align: 1px; }
.topbar-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.lang { color: var(--ink-muted); font-size: 13px; }
.me { display: flex; align-items: center; gap: 8px; }
.me:hover { text-decoration: none; }
.me-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; margin: 4px -16px 0; padding: 0 12px 8px; }
  .nav::-webkit-scrollbar { display: none; }
  .me-name { display: none; }
}

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border: 1px solid var(--ink); border-radius: var(--r-control); background: var(--ink); color: var(--on-ink);
  font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; opacity: .88; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--subtle); opacity: 1; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { height: 28px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:disabled { color: var(--ink-faint); cursor: not-allowed; text-decoration: none; }
.link.muted { color: var(--ink-muted); text-decoration: none; }
.link.danger { color: var(--danger); }
.inline { display: inline; }

input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-control);
  background: var(--surface); outline: none; }
textarea { height: auto; padding: 8px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--hover); }
input:disabled { background: var(--subtle); color: var(--ink-muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--ink); width: 16px; height: 16px; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap; }

/* ---- cards & generic ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.page-title { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 600; margin: 24px 0 12px; }
.card-title { font-size: 16px; font-weight: 600; }
.empty { padding: 48px 24px; text-align: center; color: var(--ink-muted); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty.small { padding: 24px 16px; }
.flash { margin-top: 16px; padding: 12px 16px; border-radius: var(--r-control); background: var(--supply-bg); color: var(--supply); font-weight: 500; }
.verify-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 16px; padding: 10px 16px; border-radius: var(--r-control);
  background: var(--pin-bg); color: var(--pin); font-size: 13px; }
.verify-bar .link { color: inherit; }
.fx-form input[type=email] { font-family: var(--font); font-size: 14px; font-weight: 400; }
.alert { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--r-control); background: var(--danger-bg); color: var(--danger); }
.crumbs { display: flex; gap: 8px; color: var(--ink-muted); margin-bottom: 16px; font-size: 13px; }
.body-text { white-space: pre-wrap; word-break: break-word; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 9999px; background: var(--subtle);
  color: var(--ink-muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-plain { background: transparent; border: 1px solid var(--border); }
.kind-supply { background: var(--supply-bg); color: var(--supply); }
.kind-demand { background: var(--demand-bg); color: var(--demand); }
.tag-pin { background: var(--pin-bg); color: var(--pin); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-ok { background: var(--supply-bg); color: var(--ok); }
.tag-muted { background: var(--subtle); color: var(--ink-faint); }
.tag-ad { background: var(--subtle); color: var(--ink-faint); border: 1px dashed var(--border-strong); }
.vbadge { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px;
  border-radius: 50%; background: var(--verified); color: var(--surface); font-size: 10px; font-weight: 700; vertical-align: 1px; }
.vbadge-full { display: inline-block; color: var(--verified); font-size: 12px; font-weight: 600; margin-left: 4px; }
.online { color: var(--ok); }
.online::before { content: "●"; margin-right: 4px; font-size: 9px; vertical-align: 1px; }
.pay { display: inline-block; margin-right: 8px; }

.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--subtle); color: var(--ink); font-weight: 600; border: 1px solid var(--border); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }

.price { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-lg { font-size: 28px; line-height: 36px; letter-spacing: -.02em; }

/* ---- market ---- */
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }
@media (max-width: 960px) {
  .layout-side { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.side-card h4 { font-size: 14px; font-weight: 600; }
.notice ul { margin: 0; padding-left: 18px; color: var(--ink-muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.side-ad { position: relative; }
.side-ad:hover { text-decoration: none; border-color: var(--border-strong); }
.side-ad img { border-radius: var(--r-control); margin-bottom: 4px; }
.mini { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.mini span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats th { text-align: left; font-weight: 500; color: var(--ink-faint); font-size: 12px; padding: 4px 0; }
.stats td { padding: 6px 0; border-top: 1px solid var(--border); }
.stats .num { padding-left: 8px; }

.market-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--subtle); border-radius: 10px; }
.seg a { padding: 4px 16px; border-radius: var(--r-control); color: var(--ink-muted); font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; min-width: 128px; }
.filters input[type=search] { flex: 1; min-width: 180px; width: auto; }
@media (max-width: 760px) {
  .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .filters input[type=search] { flex-basis: 100%; }
}

.feed { display: flex; flex-direction: column; gap: 8px; }
.post-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); transition: border-color .15s; }
.post-card:hover { border-color: var(--border-strong); text-decoration: none; }
.post-card.pinned { border-color: var(--pin); }
.post-link { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.post-link:hover { text-decoration: none; }
.post-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.post-title { font-size: 15px; font-weight: 600; line-height: 22px; overflow-wrap: anywhere; }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--ink-muted); font-size: 12px; }
.post-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: none; max-width: 40%; }
.post-side .price { font-size: 18px; }
.author { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sponsored { border-style: dashed; }
.sponsored-img { width: 96px; height: 64px; object-fit: cover; border-radius: var(--r-control); flex: none; }
@media (max-width: 560px) {
  .post-link { flex-direction: column; gap: 12px; }
  .post-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; max-width: none; text-align: left; }
  .post-side .price { order: 3; margin-left: auto; }
}
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 24px; }

/* banner carousel */
.carousel { position: relative; height: 120px; margin-bottom: 24px; border-radius: var(--r-card); overflow: hidden; background: var(--ink); }
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity .5s; pointer-events: none; color: var(--on-ink); }
.slide.on { opacity: 1; pointer-events: auto; }
.slide:hover { text-decoration: none; }
.slide img { width: 100%; height: 100%; object-fit: cover; }
.slide-text { height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 32px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(74, 222, 128, .28), transparent 55%), var(--ink); }
.slide-text strong { font-size: 22px; line-height: 30px; letter-spacing: -.01em; }
.slide-text span { opacity: .75; }
.ad-mark { position: absolute; top: 8px; right: 8px; padding: 0 6px; border-radius: 4px; font-size: 10px; line-height: 16px;
  background: rgba(0, 0, 0, .35); color: #fff; }
.side-ad .ad-mark, .chat-ad .ad-mark { position: static; background: var(--subtle); color: var(--ink-faint); align-self: flex-start; }
.dots { position: absolute; bottom: 12px; left: 32px; display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; background: rgba(255, 255, 255, .35); cursor: pointer; }
.dot.on { background: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .carousel, :root:not([data-theme="light"]) .slide-text { background-color: #1C1917; }
  :root:not([data-theme="light"]) .slide { color: #FAFAF9; }
}
@media (max-width: 560px) {
  .carousel { height: 112px; }
  .slide-text { padding: 0 20px; }
  .slide-text strong { font-size: 17px; line-height: 24px; }
  .slide-text span { font-size: 12px; }
  .dots { left: 20px; bottom: 8px; }
}

/* ---- detail ---- */
.detail { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.detail-title { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.detail-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 24px; }
.specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; border-top: 1px solid var(--border); }
.specs div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.specs dt { color: var(--ink-muted); white-space: nowrap; }
.specs dd { margin: 0; text-align: right; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 560px) { .specs { grid-template-columns: minmax(0, 1fr); } .detail { padding: 16px; } }
.detail-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.author-card { gap: 12px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who:hover { text-decoration: none; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.report { font-size: 13px; color: var(--ink-muted); }
.report summary { cursor: pointer; list-style: none; display: inline-block; }
.report summary::-webkit-details-marker { display: none; }
.report summary:hover { color: var(--danger); }
.report[open] summary { color: var(--danger); margin-bottom: 8px; }
.report-form { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--canvas); max-width: 420px; }
.report-form label { display: flex; flex-direction: column; gap: 4px; }
.report-form .btn { align-self: flex-start; }

/* ---- forms ---- */
.form { padding: 24px; display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label, .field > legend { font-weight: 500; padding: 0; }
.hint { color: var(--ink-muted); font-size: 12px; }
.ferr { color: var(--danger); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } .form { padding: 16px; } }
.input-suffix, .input-prefix { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--r-control); background: var(--surface); }
.input-suffix:focus-within, .input-prefix:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--hover); }
.input-suffix input, .input-prefix input { border: 0 !important; box-shadow: none !important; background: transparent !important; }
.input-suffix span, .input-prefix span { padding: 0 12px; color: var(--ink-muted); font-family: var(--mono); white-space: nowrap; }
.input-prefix span { padding-right: 0; }
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kind-opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; }
.kind-opt input { margin-top: 3px; }
.kind-opt span { display: flex; flex-direction: column; }
.kind-opt small { color: var(--ink-muted); }
.kind-opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sub-label { font-weight: 400; color: var(--ink-muted); font-size: 13px; }
.fx-form .fx-row { display: flex; gap: 8px; align-items: center; }
.fx-form input { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 4px 12px; border-radius: 9999px; border: 1px solid var(--border-strong); color: var(--ink-muted); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--hover); }
.form-actions { display: flex; gap: 8px; }
.auth { max-width: 400px; margin: 24px auto 0; display: flex; flex-direction: column; gap: 12px; }
.auth .form { margin: 8px 0 0; }
.cf-turnstile { min-height: 65px; }
.danger-zone { margin-top: 8px; }
.prose { padding: 32px; }
.prose ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-muted); }
.prose p { margin: 16px 0 12px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--ink-faint); font-size: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.row-title { display: block; margin-top: 4px; font-weight: 500; min-width: 200px; }
.row-actions { white-space: nowrap; display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.search-inline { display: flex; gap: 8px; }
.search-inline input { min-width: 220px; }
.search-inline select { width: auto; }

/* ---- profile ---- */
.profile-head { display: flex; gap: 16px; padding: 24px; align-items: flex-start; }
.profile-head > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ---- admin ---- */
.subnav { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.subnav a { padding: 8px 12px; color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-top: 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi-label { color: var(--ink-muted); font-size: 12px; }
.kpi-value { font-family: var(--mono); font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.02em; }
.kpi-alert .kpi-value { color: var(--danger); }
.report-list { display: flex; flex-direction: column; gap: 12px; }
.report-item { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.report-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report-target { font-weight: 500; overflow-wrap: anywhere; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-actions input { flex: 1; min-width: 200px; height: 28px !important; }
.ad-preview { max-height: 120px; border-radius: var(--r-control); border: 1px solid var(--border); }

/* ---- chat ---- */
.chat-ad { display: flex; align-items: center; gap: 8px; padding: 8px 16px; margin-bottom: 12px; border-radius: var(--r-control);
  background: var(--pin-bg); color: var(--pin); font-size: 13px; }
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 56px - 24px - 48px); min-height: 480px; overflow: hidden; }
.conv-list { border-right: 1px solid var(--border); overflow-y: auto; }
.pane-title { font-size: 16px; font-weight: 600; padding: 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.conv { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: relative; }
.conv:hover { background: var(--subtle); text-decoration: none; }
.conv.on { background: var(--subtle); }
.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-top { display: flex; align-items: center; gap: 4px; }
.conv-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { margin-left: auto; white-space: nowrap; padding-left: 8px; }
.conv-preview { color: var(--ink-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-section { padding: 12px 16px 4px; font-size: 12px; font-weight: 500; color: var(--ink-faint); border-bottom: 1px solid var(--border); }
.conv-pinned { background: var(--canvas); }
.avatar-official { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.avatar-room { background: var(--demand-bg); color: var(--demand); border-color: transparent; }
.tag-official { height: 18px; padding: 0 6px; margin-left: 4px; font-size: 11px; background: var(--ink); color: var(--on-ink); }
.staff-desk .pane-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.seg-sm a { padding: 2px 10px; font-size: 12px; }
.dot-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; visibility: hidden; }
.conv.unread .dot-unread { visibility: visible; }
.conv.unread .conv-preview { color: var(--ink); font-weight: 500; }

.thread-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread-empty { margin: auto; }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.thread-head .who { flex: 1; gap: 8px; }
.thread-tools { display: flex; align-items: center; gap: 12px; position: relative; }
.thread-tools .report-form { position: absolute; right: 0; top: 28px; z-index: 5; width: 300px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); background: var(--surface); }
.back { display: none; font-size: 18px; padding: 0 4px; }
.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.safety-note { align-self: center; max-width: 520px; padding: 8px 12px; border-radius: var(--r-control); background: var(--subtle);
  color: var(--ink-muted); font-size: 12px; text-align: center; }
.load-more { align-self: center; font-size: 13px; }
#msgs { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 75%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 14px; border-top-left-radius: 4px; background: var(--subtle); display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.msg.mine .bubble { background: var(--mine); color: var(--on-mine); border-top-left-radius: 14px; border-top-right-radius: 4px; }
.msg-name { display: flex; align-items: center; gap: 2px; padding: 0 4px; font-size: 12px; color: var(--ink-muted); }
.msg-name a { color: inherit; }
.msg.greeting { max-width: 75%; }
.msg-tools { display: flex; gap: 8px; padding: 0 4px; visibility: hidden; }
.msg:hover .msg-tools { visibility: visible; }
@media (hover: none) { .msg-tools { visibility: visible; } }
.msg-del { font-size: 11px; color: var(--ink-faint); text-decoration: none; }
.msg-del:hover { color: var(--danger); }
.mute-pop { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--surface); box-shadow: 0 4px 16px rgba(0, 0, 0, .08); }
.mute-pop select, .mute-pop input { width: auto !important; height: 28px !important; font-size: 12px; }
.mute-pop input { flex: 1; min-width: 140px; }
.mute-note { padding: 8px 12px; border-radius: var(--r-control); background: var(--danger-bg); color: var(--danger); font-size: 13px; }
.mute-note a { text-decoration: underline; text-underline-offset: 3px; }
.mute-info { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.mute-menu { display: inline-block; position: relative; }
.mute-menu summary { list-style: none; display: inline; }
.mute-menu summary::-webkit-details-marker { display: none; }
.mute-form { position: absolute; right: 0; top: 24px; z-index: 5; display: flex; flex-direction: column; gap: 8px; width: 220px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-control); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.mute-form .btn { align-self: flex-start; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-img { max-width: 240px; max-height: 240px; border-radius: 8px; }
.msg-time, .receipt { font-size: 11px; color: var(--ink-faint); padding: 0 4px; }
.msg-post { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: 10px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); min-width: 220px; }
.msg-post:hover { text-decoration: none; border-color: var(--border-strong); }
.msg-post .tag { align-self: flex-start; }
.msg-post-title { font-weight: 600; }
.msg-post-meta { font-size: 12px; color: var(--ink-muted); font-family: var(--mono); }

.composer { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 36px; max-height: 160px; resize: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border-radius: var(--r-control);
  border: 1px solid var(--border-strong); color: var(--ink-muted); cursor: pointer; }
.icon-btn:hover { background: var(--subtle); color: var(--ink); }
.attach { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-control); background: var(--subtle); }
.attach span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 760px) {
  .main:has(.chat) { padding-top: 0; padding-bottom: 0; }
  .main:has(.chat) .chat-ad { margin: 8px 0; }
  .main:has(.chat.has-thread) .chat-ad { display: none; }
  .thread-tools > a { display: none; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 104px); border-radius: 0; border-left: 0; border-right: 0; margin: 0 -16px; }
  .chat.has-thread .conv-list { display: none; }
  .chat:not(.has-thread) .thread-pane { display: none; }
  .conv-list { border-right: 0; }
  .back { display: inline; }
  .msg { max-width: 85%; }
  .main:has(.chat) + .footer { display: none; }
}

/* ---- footer ---- */
.footer { border-top: 1px solid var(--border); color: var(--ink-faint); font-size: 12px; }
.footer-in { padding-top: 24px; padding-bottom: 24px; display: flex; flex-direction: column; gap: 4px; }
.footer a { color: var(--ink-muted); }
