:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --line: #dfe4e2;
  --line-strong: #c9d2ce;
  --text: #111827;
  --muted: #667085;
  --green: #087d52;
  --green-dark: #05623f;
  --green-soft: #eaf7f1;
  --blue: #176fa3;
  --red: #c63c3c;
  --rail: #1f2523;
  --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
html.is-wechat-browser, html.is-wechat-browser body { overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(23, 111, 163, .24);
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 88px minmax(0, 1fr); }
@supports (min-height: 100dvh) {
  html.is-wechat-browser .app-shell { min-height: 100dvh; }
}
.side-rail {
  position: sticky; top: 0; height: 100vh; background: var(--rail); color: #fff;
  display: flex; flex-direction: column; align-items: center; padding: 18px 10px; gap: 10px;
}
.brand-mark { width: 52px; height: 52px; margin-bottom: 12px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.rail-button {
  width: 68px; min-height: 64px; border: 0; border-radius: var(--radius);
  background: transparent; color: #c9d0cd; display: grid; place-items: center; gap: 3px;
  font-size: 12px;
}
.rail-button span { font-size: 22px; line-height: 1; }
.rail-button:hover, .rail-button.is-active { background: #343c39; color: #fff; }
.side-rail small { margin-top: auto; color: #8e9995; font-size: 11px; }

.workspace { min-width: 0; }
.topbar {
  height: 78px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.view { display: none; padding: 22px 28px 40px; }
.view.is-active { display: block; }

.quiet-button, .primary-button, .load-more {
  min-height: 40px; border-radius: var(--radius); padding: 0 16px; border: 1px solid var(--line-strong);
}
.quiet-button { background: var(--surface); color: var(--text); }
.quiet-button:hover { border-color: var(--green); color: var(--green); }
.primary-button { background: var(--green); color: #fff; border-color: var(--green); font-weight: 700; }
.primary-button:hover { background: var(--green-dark); }

.search-toolbar {
  display: grid; grid-template-columns: minmax(240px, 1fr) 160px 190px auto;
  gap: 10px; max-width: 1200px; margin: 0 auto 16px;
}
.search-toolbar input, .search-toolbar select,
.editor-form input, .editor-form select, .editor-form textarea,
.account-form input, .account-form textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 11px 12px;
}
.search-toolbar input, .search-toolbar select { height: 46px; }
.search-toolbar .primary-button { height: 46px; }
.search-field { min-width: 0; }

.market-layout {
  max-width: 1200px; margin: 0 auto; display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(360px, 1fr);
  min-height: calc(100vh - 164px); border: 1px solid var(--line); background: var(--surface);
}
.feed-pane { border-right: 1px solid var(--line); min-width: 0; }
.pane-heading {
  height: 54px; padding: 0 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--line);
}
.pane-heading h3 { margin: 0; font-size: 16px; }
.pane-heading span { color: var(--muted); font-size: 13px; }
.feed-list { display: grid; }
.feed-card {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: var(--surface); padding: 15px 16px; text-align: left; color: var(--text);
}
.feed-card:hover, .feed-card.is-active { background: var(--green-soft); }
.feed-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.feed-card-heading { min-width: 0; display: flex; align-items: center; gap: 9px; }
.feed-card-market { min-width: 0; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.feed-card time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed-card-meta { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px 13px; color: var(--muted); font-size: 13px; }
.type-badge {
  flex: 0 0 auto; min-width: 42px; padding: 3px 7px; border-radius: 4px;
  background: var(--green); color: #fff; font-size: 12px; font-weight: 700; text-align: center;
}
.feed-fact { display: inline-flex; align-items: baseline; gap: 5px; }
.feed-fact-label { color: var(--muted); }
.feed-fact-value { color: #344054; font-size: 13px; line-height: 1.4; }
.contact-fact { margin-left: auto; }
.load-more { display: block; margin: 16px auto; background: var(--surface); }
.empty-state { padding: 48px 18px; color: var(--muted); text-align: center; }

.detail-pane { padding: 28px; background: var(--surface-soft); }
.empty-detail { max-width: 420px; margin: 16vh auto 0; text-align: center; color: var(--muted); }
.empty-detail strong { color: var(--text); font-size: 18px; }
.detail-content { max-width: 600px; margin: 0 auto; }
.detail-content .detail-type { color: var(--green); font-weight: 700; }
.detail-content h3 { margin: 10px 0 18px; font-size: 26px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.detail-grid div { padding: 16px 0; border-bottom: 1px solid var(--line); }
.detail-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.detail-grid strong { font-size: 15px; }
.mobile-feed-detail { display: none; }

.section-heading {
  max-width: 960px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: space-between;
}
.section-heading h2 { margin: 0; font-size: 24px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); }
.editor-form, .auth-layout, .account-form, .workbench-pane {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.editor-form { max-width: 960px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.editor-form label, .account-form label { display: grid; gap: 7px; color: #344054; font-size: 14px; font-weight: 600; }
.editor-form textarea, .account-form textarea { resize: vertical; min-height: 96px; }
.type-segments { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line-strong); }
.type-segments button {
  min-height: 42px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.type-segments button:last-child { border-right: 0; }
.type-segments button.is-active { background: var(--green-soft); color: var(--green); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; align-items: center; gap: 14px; }
.form-actions span { color: var(--green); }

.auth-layout { max-width: 440px; margin: 48px auto; padding: 28px; }
.auth-intro { margin-bottom: 22px; text-align: center; }
.auth-intro h3 { margin: 0; font-size: 22px; }
.auth-intro p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.account-form { padding: 20px; display: grid; gap: 15px; }
.auth-layout .account-form { padding: 0; border: 0; }
.account-form h3 { margin: 0 0 4px; }
.checkbox-row { grid-template-columns: auto 1fr; align-items: center; font-weight: 400 !important; }
.checkbox-row input { width: auto; }
.code-field { display: grid; gap: 7px; }
.code-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.code-entry .quiet-button { white-space: nowrap; }
.wechat-login-button {
  width: 100%; min-height: 68px; border: 0; border-radius: var(--radius); padding: 10px 16px;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: #07c160; color: #fff; text-align: left;
}
.wechat-login-button:hover:not(:disabled) { background: #06ad56; }
.wechat-login-button:disabled { opacity: 1; background: #edf1ef; color: #748079; border: 1px solid #d9e0dc; }
.wechat-mark {
  position: relative; width: 42px; height: 42px; border-radius: 50%; background: #fff; color: #07a84f;
}
.wechat-mark::before, .wechat-mark::after {
  content: ""; position: absolute; border: 2px solid currentColor; border-radius: 50%; background: #fff;
}
.wechat-mark::before { width: 20px; height: 15px; left: 8px; top: 9px; }
.wechat-mark::after { width: 16px; height: 12px; right: 7px; bottom: 8px; }
.wechat-login-button:disabled .wechat-mark { color: #8a9690; }
.wechat-login-copy { min-width: 0; }
.wechat-login-copy strong, .wechat-login-copy small { display: block; }
.wechat-login-copy strong { font-size: 17px; }
.wechat-login-copy small { margin-top: 3px; color: inherit; opacity: .78; font-size: 12px; }
.auth-chevron { font-size: 28px; line-height: 1; opacity: .72; }
.auth-terms { margin: 10px 0 0; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.5; }
.auth-methods { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-method-button {
  min-height: 40px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-soft); color: #475467;
}
.auth-method-button:hover:not(:disabled), .auth-method-button.is-active {
  border-color: #9bcdb8; background: var(--green-soft); color: var(--green);
}
.auth-method-button.is-active { font-weight: 700; }
.auth-form-panel { margin-top: 18px; padding-top: 18px !important; border-top: 1px solid var(--line) !important; }
.auth-form-panel .primary-button { width: 100%; }
.auth-capability-hint { margin-top: 12px; line-height: 1.5; text-align: center; }
.form-message { min-height: 20px; color: var(--red); margin: 12px 0 0; text-align: center; }
.account-grid { max-width: 960px; margin: 0 auto 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.avatar-row { display: flex; align-items: center; gap: 14px; }
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; background: #192233; color: #fff;
  display: grid; place-items: center; font-size: 24px; overflow: hidden;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-button { display: inline-flex !important; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.file-button input { display: none; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.workbench-pane { max-width: 960px; margin: 0 auto; }
.workbench-list { display: grid; }
.workbench-row {
  padding: 15px 16px; border-bottom: 1px solid var(--line); display: grid;
  grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center;
}
.workbench-row:last-child { border-bottom: 0; }
.workbench-row h4 { margin: 0 0 5px; font-size: 15px; }
.workbench-row p { margin: 0; color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); min-height: 34px; padding: 0 10px; }
.row-actions .danger { color: var(--red); }

.mobile-nav { display: none; }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 20; background: #18201d; color: #fff;
  border-radius: var(--radius); padding: 11px 14px; max-width: min(360px, calc(100vw - 32px));
  opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .side-rail { padding-inline: 6px; }
  .rail-button { width: 58px; }
  .search-toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .search-toolbar .primary-button { grid-column: 1 / -1; }
  .market-layout { grid-template-columns: minmax(310px, 44%) minmax(0, 1fr); }
  .view { padding-inline: 18px; }
}

@media (max-width: 680px) {
  .app-shell { display: block; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .side-rail { display: none; }
  .topbar { height: 68px; padding: 0 16px; }
  html.is-wechat-browser .topbar {
    min-height: calc(68px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
  .topbar h1 { font-size: 18px; }
  .view { padding: 14px 12px 28px; }
  .search-toolbar { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
  .search-toolbar .primary-button { grid-column: 1 / -1; }
  .market-layout { display: block; min-height: 0; border-radius: var(--radius); overflow: hidden; }
  .feed-pane { border-right: 0; }
  .detail-pane { display: none; }
  .feed-card { padding: 16px 14px; }
  .mobile-feed-detail {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
    padding: 14px; background: var(--green-soft); border-bottom: 1px solid var(--line);
  }
  .mobile-feed-detail div { min-width: 0; }
  .mobile-feed-detail span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
  .mobile-feed-detail strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
  .type-segments { grid-template-columns: repeat(3, 1fr); }
  .type-segments button:nth-child(3) { border-right: 0; }
  .type-segments button { border-bottom: 1px solid var(--line); }
  .type-segments button:nth-last-child(-n+2) { border-bottom: 0; }
  .form-grid, .account-grid { grid-template-columns: 1fr; }
  .editor-form { padding: 17px 14px; }
  .auth-layout { margin: 12px auto; padding: 22px 18px; }
  .code-entry { grid-template-columns: 1fr; }
  .code-entry .quiet-button { width: 100%; }
  .workbench-row { grid-template-columns: 1fr; }
  .mobile-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: grid;
    grid-template-columns: repeat(3, 1fr); background: rgba(255,255,255,.98);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav button { height: 64px; border: 0; background: transparent; color: var(--muted); font-weight: 700; }
  .mobile-nav button.is-active { color: var(--green); background: var(--green-soft); }
  .mobile-nav span { font-size: 23px; vertical-align: -2px; margin-right: 4px; }
  .toast { right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); }
}
