:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2129;
  --sub: #6b7280;
  --line: #e8eaef;
  --brand: #07c160;
  --brand-dark: #06a050;
  --brand-soft: #e7f8ef;
  --need: #ff8a00;
  --need-soft: #fff3e3;
  --offer: #1677ff;
  --offer-soft: #e8f1ff;
  --danger: #f5455c;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55;
}
#app { max-width: 560px; margin: 0 auto; padding: 0 0 calc(72px + var(--safe-bottom)); min-height: 100vh; }
.hidden { display: none !important; }
a { color: var(--offer); text-decoration: none; }

header.top {
  position: sticky; top: 0; z-index: 10; background: rgba(244,245,247,.92); backdrop-filter: blur(10px);
  padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px;
}
header.top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .back { font-size: 22px; color: var(--text); padding: 0 6px 0 0; }
.room-pill { font-size: 12px; color: var(--sub); background: #fff; border-radius: 99px; padding: 3px 10px; border: 1px solid var(--line); }

.section { padding: 0 16px; margin: 12px 0; }
.section-title { font-size: 13px; color: var(--sub); margin: 18px 16px 8px; display: flex; justify-content: space-between; align-items: center; }
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.panel + .panel { margin-top: 10px; }
.muted { color: var(--sub); font-size: 13px; }
.small { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { height: 10px; }

.hero {
  margin: 8px 16px 0; border-radius: var(--radius); padding: 18px;
  background: linear-gradient(135deg, #07c160 0%, #10b981 60%, #34d399 100%); color: #fff;
}
.hero h2 { margin: 0 0 6px; font-size: 18px; }
.hero p { margin: 0; opacity: .95; font-size: 14px; }
.hero .steps { display: flex; gap: 8px; margin-top: 12px; }
.hero .step { flex: 1; background: rgba(255,255,255,.18); border-radius: 10px; padding: 8px; font-size: 12px; text-align: center; }

.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 11px 16px; font-size: 15px; font-weight: 500;
  background: var(--brand); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { background: var(--brand-dark); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:active { background: #f2f3f5; }
.btn.soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #ffd5db; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; }
input[type=text], input:not([type]), textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit;
  background: #fff; color: var(--text); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 72px; }
.seg { display: flex; background: #eef0f3; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 0; border-radius: 8px; font-size: 14px; color: var(--sub); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.rcard { background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px; margin-bottom: 10px; border-left: 4px solid var(--offer); }
.rcard.need { border-left-color: var(--need); }
.rcard.dim { opacity: .6; }
.rcard .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rcard .title { font-weight: 600; font-size: 16px; flex: 1; }
.rcard .detail { color: #3d4450; font-size: 14px; margin: 4px 0 8px; white-space: pre-wrap; word-break: break-word; }
.rcard .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--sub); }
.rcard .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--offer-soft); color: var(--offer); white-space: nowrap; }
.badge.need { background: var(--need-soft); color: var(--need); }
.badge.gray { background: #f0f1f4; color: var(--sub); }
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: #ffecef; color: var(--danger); }
.tag { font-size: 12px; color: var(--sub); background: #f3f4f6; padding: 1px 7px; border-radius: 6px; }
.contact { margin-top: 8px; background: var(--brand-soft); color: var(--brand-dark); padding: 8px 10px; border-radius: 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.contact b { user-select: all; }
.notice { background: #fffbe6; border: 1px solid #ffe58f; color: #8a6d00; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }

.chat { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 8px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg.assistant { background: #f2f3f5; align-self: flex-start; border-top-left-radius: 4px; }
.msg.user { background: var(--brand); color: #fff; align-self: flex-end; border-top-right-radius: 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 8px; }
.chat-input textarea { min-height: 42px; height: 42px; padding: 9px 12px; }
.typing { color: var(--sub); font-size: 13px; padding-left: 4px; }

.rec { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.rec .score { font-size: 12px; font-weight: 600; color: var(--brand-dark); background: var(--brand-soft); padding: 2px 8px; border-radius: 99px; }
.rec .reason { background: #f7f8fa; border-radius: 10px; padding: 10px; margin: 10px 0; font-size: 14px; }
.rec .reason::before { content: "🤖 "; }
.rec .pair { font-size: 13px; color: var(--sub); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-bottom);
}
.tabbar .inner { display: flex; width: 100%; max-width: 560px; }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 7px; color: var(--sub); font-size: 11px; position: relative; }
.tabbar a .ic { display: block; font-size: 20px; line-height: 1.2; }
.tabbar a.on { color: var(--brand-dark); font-weight: 600; }
.dot { position: absolute; top: 4px; left: 50%; margin-left: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; font-weight: 600; }

.toast { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 80vw; text-align: center; }
.toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); max-height: 88vh; overflow-y: auto; animation: up .2s ease-out; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }

.empty { text-align: center; color: var(--sub); padding: 36px 16px; font-size: 14px; }
.empty .big { font-size: 36px; margin-bottom: 6px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #f7f8fa; border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.copybox { background: #f7f8fa; border-radius: 10px; padding: 12px; white-space: pre-wrap; font-size: 14px; word-break: break-all; user-select: all; }
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.mode-tip { font-size: 12px; color: var(--sub); text-align: center; margin: 16px 0; }
