/* ============================================================
   蓝天社区 · 前端设计系统
   配色：白底 + 橙色主色 + 蓝色次色（截图同款），支持深色模式
   ============================================================ */

:root {
  --brand: #ff7a00;
  --brand-2: #ffa03a;
  --brand-soft: rgba(255, 122, 0, .12);
  --blue: #2f7df6;
  --blue-soft: rgba(47, 125, 246, .12);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, .14);
  --purple: #8b5cf6;
  --danger: #ef4444;

  --bg: #f2f4f8;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f7f8fb;
  --text: #17181c;
  --muted: #8a8f9c;
  --line: rgba(23, 24, 28, .08);
  --line-strong: rgba(23, 24, 28, .14);

  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .04);
  --shadow: 0 6px 20px rgba(20, 24, 40, .07);
  --shadow-lg: 0 16px 40px rgba(20, 24, 40, .14);

  --radius: 16px;
  --radius-lg: 22px;

  color-scheme: light;
}

html.dark {
  --bg: #0b1018;
  --bg-elev: #101826;
  --card: #141c2c;
  --card-2: #0f1622;
  --text: #eef1f6;
  --muted: #8b93a5;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);

  --brand-soft: rgba(255, 138, 31, .16);
  --blue-soft: rgba(77, 146, 255, .16);
  --green-soft: rgba(52, 213, 122, .16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { display: block; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 21px; font-weight: 800; letter-spacing: .5px; }
.brand .accent {
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  transition: transform .12s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- 主视图 ---------- */
#view { flex: 1; padding: 12px 14px 110px; animation: fade .24s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 8px);
  width: min(528px, calc(100% - 20px));
  display: flex; align-items: stretch; z-index: 60;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(20px) saturate(170%);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
}
#tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 7px 0; font-size: 11px; color: var(--muted); border-radius: 18px; cursor: pointer; position: relative;
  transition: color .15s;
}
#tabbar .tab svg { width: 22px; height: 22px; }
#tabbar .tab.active { color: var(--brand); font-weight: 600; }
#tabbar .tab .badge {
  position: absolute; top: 1px; right: calc(50% - 22px);
  background: var(--danger); color: #fff; font-size: 10px;
  min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; padding: 0 4px; text-align: center;
}
#tabbar .tab .publish {
  width: 50px; height: 50px; margin-top: -22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: grid; place-items: center;
  box-shadow: 0 10px 22px rgba(255, 122, 0, .42);
  border: 4px solid var(--bg);
}
#tabbar .tab .publish svg { width: 24px; height: 24px; color: #fff; }

.hidden { display: none !important; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card.tap { cursor: pointer; transition: transform .12s ease; }
.card.tap:active { transform: scale(.985); }

.row { display: flex; gap: 10px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt { margin-top: 10px; } .mb { margin-bottom: 10px; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.lg { width: 62px; height: 62px; font-size: 24px; }

.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; line-height: 16px; font-weight: 600;
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.orange { background: var(--brand-soft); color: var(--brand); }
.tag.purple { background: rgba(139, 92, 246, .14); color: var(--purple); }

.vip-tag {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 6px; font-size: 10px; font-weight: 700;
  background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff; margin-left: 4px;
}

/* ---------- 分段 / 标签 ---------- */
.seg {
  display: flex; gap: 4px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: 13px; padding: 4px; margin-bottom: 12px;
}
.seg > span, .seg > button {
  flex: 1; padding: 9px 0; border: none; background: transparent; color: var(--muted);
  border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
  transition: all .18s;
}
.seg > span.on, .seg > button.on {
  background: var(--card); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.seg.tabs-underline { background: transparent; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; }
.seg.tabs-underline > span { border-radius: 0; position: relative; padding: 10px 0; font-size: 15px; }
.seg.tabs-underline > span.on { box-shadow: none; color: var(--brand); }
.seg.tabs-underline > span.on::after {
  content: ''; position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 2px; background: var(--brand);
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.chips .chip.on { color: #fff; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-color: transparent; }

/* ---------- 首页：公告 ---------- */
.notice-list { display: flex; flex-direction: column; }
.notice-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 2px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px;
}
.notice-item:last-child { border-bottom: none; }
.notice-item .ico { width: 24px; height: 24px; flex: 0 0 auto; }
.notice-item .chev { color: var(--muted); flex: 0 0 auto; }

/* ---------- 首页：广告 banner ---------- */
.ad-banner {
  position: relative; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 12px;
  padding: 20px 18px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6 55%, #22d3ee);
  box-shadow: 0 12px 30px rgba(59, 130, 246, .35);
}
.ad-banner .title { font-size: 19px; font-weight: 800; }
.ad-banner .sub { font-size: 12px; opacity: .85; margin-top: 4px; }
.ad-banner .deco { position: absolute; right: -20px; top: -20px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.14); }
.ad-banner .deco.b { right: 60px; top: 40px; width: 60px; height: 60px; }

/* ---------- 首页：快捷入口 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 7px; cursor: pointer; padding: 12px 0;
}
.quick .qc {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  color: #fff; box-shadow: var(--shadow);
}
.quick .qc svg { width: 25px; height: 25px; }
.quick span { font-size: 12px; color: var(--text); }

/* ---------- 应用卡片 ---------- */
.app-card { display: flex; gap: 12px; align-items: center; }
.app-cover {
  width: 54px; height: 54px; border-radius: 14px; object-fit: cover; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; font-size: 26px; color: #fff;
}
.app-info { flex: 1; min-width: 0; }
.app-info .nm { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.app-info .ds { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.app-info .meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 11px; color: var(--muted); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); border: none; color: #fff; box-shadow: 0 8px 18px rgba(255,122,0,.32); }
.btn.blue { background: linear-gradient(90deg, #2563eb, #3b82f6); border: none; color: #fff; box-shadow: 0 8px 18px rgba(47,125,246,.3); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3); color: var(--danger); }

/* ---------- 帖子流 ---------- */
.post-head { display: flex; gap: 10px; align-items: center; }
.post-user { flex: 1; min-width: 0; }
.post-user .nm { font-size: 14px; font-weight: 700; }
.post-user .tm { font-size: 11px; color: var(--muted); margin-top: 2px; }
.post-title { font-size: 16px; font-weight: 700; margin: 9px 0 4px; }
.post-text { white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 15px; color: var(--text); }
.post-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 9px 0; }
.post-media img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--card-2); }
.post-media.full { grid-template-columns: repeat(3, 1fr); }
.post-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.post-topics .chip { color: var(--blue); font-size: 12px; padding: 3px 8px; }
.post-foot { display: flex; align-items: center; gap: 20px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.post-foot .act { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; }
.post-foot .act svg { width: 16px; height: 16px; }
.post-foot .act.liked { color: var(--brand); }

/* ---------- 评论 ---------- */
.cmt { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cmt:last-child { border-bottom: none; }
.cmt .body { flex: 1; min-width: 0; }
.cmt .nm { font-size: 13px; font-weight: 700; }
.cmt .tx { font-size: 14px; line-height: 1.5; margin-top: 3px; word-break: break-word; }
.cmt .tm { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font-size: 15px; outline: none; font-family: inherit;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.input:focus, textarea:focus { border-color: var(--brand); }

.img-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick-item { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px dashed var(--line-strong); background: var(--card-2); }
.pick-item img { width: 100%; height: 100%; object-fit: cover; }
.pick-item.add { display: grid; place-items: center; font-size: 28px; color: var(--muted); cursor: pointer; }
.pick-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; cursor: pointer; }

/* ---------- 列表 ---------- */
.li { display: flex; gap: 12px; align-items: center; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: none; }
.li .li-t { flex: 1; min-width: 0; }
.li .li-s { color: var(--muted); font-size: 13px; }

/* ---------- 我的 ---------- */
.me-head { display: flex; gap: 14px; align-items: center; padding: 18px 16px; }
.me-head .nm { font-size: 18px; font-weight: 800; }
.me-head .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { text-align: center; padding: 14px 8px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.stat .n { font-size: 20px; font-weight: 800; color: var(--brand); }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 3px; }

.menu-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu-list .li { padding: 14px 16px; cursor: pointer; }
.menu-list .li .ico { width: 22px; height: 22px; flex: 0 0 auto; }

/* ---------- 消息 ---------- */
.conv-item { display: flex; gap: 12px; align-items: center; }
.conv-item .nm { font-size: 15px; font-weight: 700; }
.conv-item .last { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge-inline { background: var(--danger); color: #fff; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 5px; text-align: center; }

.chat-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg-row { display: flex; flex-direction: column; max-width: 78%; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row .bubble { padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; word-break: break-word; background: var(--card); border: 1px solid var(--line); }
.msg-row.mine .bubble { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.msg-row .tm { font-size: 10px; color: var(--muted); margin-top: 3px; padding: 0 4px; }

.chat-input { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(560px, 100%); display: flex; gap: 8px; padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px); background: var(--bg); border-top: 1px solid var(--line); z-index: 40; }

/* ---------- 弹层 / Toast ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  width: min(560px, 100%); background: var(--card); border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 84vh; overflow: auto;
  animation: up .24s ease;
}
@keyframes up { from { transform: translateY(40px); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head b { font-size: 17px; }
.sheet-close { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; cursor: pointer; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 130px; transform: translateX(-50%) translateY(20px); z-index: 200; pointer-events: none; opacity: 0; transition: .25s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .msg { padding: 11px 20px; border-radius: 14px; background: rgba(0,0,0,.82); color: #fff; font-size: 14px; max-width: 80vw; }

/* ---------- 其他 ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .e-ico { font-size: 48px; margin-bottom: 10px; }
.loading { text-align: center; padding: 40px; color: var(--muted); }
.spin { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.img-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 300; display: grid; place-items: center; cursor: zoom-out; }
.img-viewer img { max-width: 100%; max-height: 100%; }

.gift-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gift { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 4px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); cursor: pointer; }
.gift .g-ico { font-size: 34px; }
.gift .g-nm { font-size: 12px; }
.gift .g-pr { font-size: 11px; color: var(--brand); font-weight: 600; }
.gift.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: none; }
.rank-n { width: 26px; text-align: center; font-weight: 800; font-size: 15px; color: var(--muted); }
.rank-n.top { color: var(--brand); font-size: 17px; }

.chev { color: var(--muted); display: inline-flex; }
.chev svg { width: 18px; height: 18px; }

.opt { padding: 15px 16px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); margin-bottom: 10px; cursor: pointer; font-size: 15px; }
.opt:active { transform: scale(.98); }

.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--line-strong); cursor: pointer; transition: .2s; flex: 0 0 auto; }
.switch.on { background: var(--brand); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on::after { left: 23px; }

.banner-img { border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.banner-img img { width: 100%; }

.link-url { color: var(--blue); word-break: break-all; font-size: 13px; }
.disclaimer { font-size: 11px; color: var(--muted); margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--card-2); }

.sec-title { font-size: 16px; font-weight: 800; margin: 4px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.sec-title .more { font-size: 12px; color: var(--muted); font-weight: 400; }
