:root {
  --bg: #f7f5f0;
  --card-bg: #ffffff;
  --text: #3d3929;
  --text-secondary: #83807a;
  --text-tertiary: #b3aea3;
  --accent: #c15f3c;        /* 陶土橙：主强调色 / 卖书 */
  --accent-dark: #a84f30;
  --ink: #3d3a34;           /* 暖黑：买书 / 次强调 */
  --ink-light: #55524a;
  --status-active-bg: #e7ebe0;
  --status-active-fg: #5b7052;
  --status-maybe-bg: #f3e8d8;
  --status-maybe-fg: #96652f;
  --status-muted-bg: #efece4;
  --status-muted-fg: #83807a;
  --danger: #b3483c;
  --border: #e8e3d8;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei UI", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Top bar：三栏 grid，标题永远真正居中，不受两侧内容宽度影响 ---------- */
#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(52px + var(--safe-top));
  padding: var(--safe-top) 12px 0 12px;
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

#pageTitle {
  grid-column: 2;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

#backBtn { grid-column: 1; justify-self: start; }
#topbarSlot { grid-column: 3; justify-self: end; }

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.text-link-btn {
  border: none;
  background: none;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 0;
  white-space: nowrap;
}

/* ---------- Layout helpers ---------- */
#view {
  flex: 1;
  padding: 16px 16px calc(24px + var(--safe-bottom)) 16px;
}

.section-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 20px 4px 8px 4px;
  text-align: center;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(61, 57, 41, 0.06);
}

.list-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

.list-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.list-item-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
}

.list-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--status-active-bg);
  color: var(--status-active-fg);
  font-weight: 600;
  white-space: nowrap;
}
.badge.maybe { background: var(--status-maybe-bg); color: var(--status-maybe-fg); }
.badge.muted { background: var(--status-muted-bg); color: var(--status-muted-fg); }

.empty-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 40px 16px;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-sell { background: var(--accent); color: #fff; }
.btn-sell:active { opacity: 0.85; }
.btn-buy { background: var(--ink); color: #fff; }
.btn-buy:active { opacity: 0.85; }
.btn-secondary { background: #efeae0; color: var(--text); }
.btn-secondary:active { opacity: 0.75; }
.btn-small {
  width: auto;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 999px;
}
.btn-danger-outline {
  background: #fff;
  color: var(--danger);
  border: 1px solid #ecd6d1;
}

/* ---------- 首页大按钮 ---------- */
.home-hero {
  padding: 8px 4px 20px 4px;
  text-align: center;
}
.home-hero h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0 4px 0;
}
.home-hero .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.hero-card {
  border-radius: var(--radius);
  padding: 22px 14px;
  cursor: pointer;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 108px;
  text-align: center;
}
.hero-card:active { opacity: 0.88; }
.hero-card.sell { background: linear-gradient(160deg, #d1794f 0%, var(--accent) 100%); }
.hero-card.buy { background: linear-gradient(160deg, #55524a 0%, var(--ink) 100%); }
.hero-card .hero-label {
  font-size: 16px;
  font-weight: 700;
}
.hero-card .hero-arrow {
  font-size: 12px;
  opacity: 0.85;
}

.tip-list {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.9;
  text-align: center;
}
.tip-list .tip-title {
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-left: 2px;
}
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding-left: 2px;
}

.form-tip {
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  line-height: 1.7;
}
.form-tip li { margin: 0; }

.tip-box {
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ---------- Segmented control ---------- */
.segmented {
  display: flex;
  background: #efeae0;
  border-radius: 10px;
  padding: 2px;
  margin-bottom: 14px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 4px;
  font-size: 13px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.segmented button.active {
  background: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(61, 57, 41, 0.1);
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
}
.search-bar button {
  border: none;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 600;
}

.contact-highlight {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}
.contact-highlight .label { font-size: 13px; color: var(--text-secondary); }
.contact-highlight .value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}

/* ---------- 发布结果页 ---------- */
.result-hero {
  text-align: center;
  padding: 28px 16px 20px 16px;
}
.result-hero .check-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--status-active-bg);
  color: var(--status-active-fg);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
}
.result-hero h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 4px 0;
}
.result-hero p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(61, 57, 41, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  max-width: 80vw;
  text-align: center;
}
