:root {
  --wechat-green: #07c160;
  --wechat-green-dark: #06a850;
  --bg: #ededed;
  --card: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --bubble-user: #95ec69;
  --r1: #07c160; /* General Guidance */
  --r2: #10aeff; /* Check Source Document */
  --r3: #fa8c16; /* Expert Support Recommended */
  --r4: #ff6b35; /* More Facts Needed */
  --r5: #e54d42; /* Inform Global Governance */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: #c9cdd4; color: var(--ink);
}

.phone {
  max-width: 440px; margin: 0 auto; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg); position: relative; overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,.18);
}

/* App bar */
.appbar {
  background: linear-gradient(135deg, var(--wechat-green), var(--wechat-green-dark));
  color: #fff; padding: 14px 16px 10px; flex: 0 0 auto;
}
.appbar-title { display: flex; flex-direction: column; line-height: 1.25; }
.brand-zh { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.brand-en { font-size: 11px; opacity: .9; }
.appbar-controls { display: flex; gap: 8px; margin-top: 10px; }
.pill-select {
  flex: 1; border: none; border-radius: 16px; padding: 6px 10px;
  font-size: 12px; background: rgba(255,255,255,.92); color: var(--ink);
  appearance: none; outline: none; max-width: 50%;
}
.user-meta { font-size: 11px; opacity: .92; margin-top: 7px; min-height: 14px; }

/* Content */
.content { flex: 1 1 auto; overflow-y: auto; position: relative; }
.view { display: none; min-height: 100%; }
.view.active { display: block; }

/* Chat */
.messages { padding: 14px 12px 18px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; }
.row.user { justify-content: flex-end; }
.row.bot { justify-content: flex-start; }

.bubble-user {
  background: var(--bubble-user); color: #111; padding: 9px 12px;
  border-radius: 14px 4px 14px 14px; max-width: 80%; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word;
}

.answer-card {
  background: var(--card); border-radius: 4px 14px 14px 14px;
  max-width: 92%; width: 92%; padding: 0; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.card-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafafa;
}
.risk-badge {
  font-size: 11px; font-weight: 700; color: #fff; padding: 3px 8px;
  border-radius: 10px; white-space: nowrap;
}
.chip {
  font-size: 10.5px; padding: 2px 7px; border-radius: 9px;
  background: #eef2f5; color: var(--ink-soft); border: 1px solid var(--line);
}
.chip.mode { text-transform: capitalize; }
.card-body { padding: 11px 13px; font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

.block { margin: 11px 13px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.block-title { font-weight: 700; font-size: 12px; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.block.clarify { background: #fff7e6; border: 1px solid #ffe1a8; }
.block.expert { background: #e8f6ff; border: 1px solid #bfe6ff; }
.block.clarify ul { margin: 4px 0 0; padding-left: 18px; }
.block.clarify li { margin: 3px 0; }

.sources { margin: 11px 13px; }
.sources summary {
  cursor: pointer; font-size: 12px; font-weight: 700; color: var(--ink-soft);
  list-style: none; user-select: none;
}
.sources summary::-webkit-details-marker { display: none; }
.source-item {
  display: flex; gap: 8px; align-items: baseline; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 12.5px;
}
.tier-dot {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; color: #fff;
  width: 18px; height: 18px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; background: var(--ink-soft);
}
.source-title { font-weight: 600; }
.source-sec { color: var(--ink-soft); }

.card-foot {
  padding: 9px 13px; border-top: 1px solid var(--line); background: #fbfbfb;
  font-size: 11px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px;
}
.foot-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.gen-tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: #eef2f5; }
.gen-ai { background: #e6f7ee; color: #06a850; }
.gen-fallback { background: #f3f0ff; color: #7a5af8; }
.disclaimer { line-height: 1.45; }

.typing { font-size: 13px; color: var(--ink-soft); padding: 4px 6px; }

/* Cards (docs / terms) */
.cards { padding: 14px 12px 18px; display: flex; flex-direction: column; gap: 11px; }
.info-card {
  background: var(--card); border-radius: 12px; padding: 12px 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.info-card h3 { margin: 0 0 4px; font-size: 14.5px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 10.5px; padding: 2px 8px; border-radius: 9px; background: #eef2f5; color: var(--ink-soft); }
.badge.tier { color: #fff; }
.term-langs { margin-top: 7px; font-size: 13px; line-height: 1.7; }
.term-langs b { color: var(--wechat-green-dark); }
.term-def { margin-top: 6px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.section-label { font-size: 11px; color: var(--ink-soft); margin: 6px 4px 0; font-weight: 700; letter-spacing: .4px; }

/* Composer */
.composer {
  flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 10px;
  background: #f7f7f7; border-top: 1px solid var(--line); align-items: flex-end;
}
.composer.hidden { display: none; }
#questionInput {
  flex: 1; border: 1px solid var(--line); border-radius: 18px; padding: 9px 13px;
  font-size: 14.5px; resize: none; max-height: 110px; outline: none; font-family: inherit;
  background: #fff;
}
#questionInput:focus { border-color: var(--wechat-green); }
.send-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border: none; border-radius: 50%;
  background: var(--wechat-green); color: #fff; font-size: 16px; cursor: pointer;
}
.send-btn:disabled { background: #b5d9c4; }

/* Tab bar */
.tabbar {
  flex: 0 0 auto; display: flex; background: #f7f7f7; border-top: 1px solid var(--line);
}
.tab {
  flex: 1; border: none; background: none; padding: 7px 0 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink-soft);
}
.tab .ic { font-size: 19px; filter: grayscale(1); opacity: .65; }
.tab .lbl { font-size: 10.5px; }
.tab.active { color: var(--wechat-green); }
.tab.active .ic { filter: none; opacity: 1; }

/* History & escalations */
.info-card.clickable { cursor: pointer; }
.card-head-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.hist-q { font-size: 14px; line-height: 1.5; word-break: break-word; }
.hist-meta { font-size: 11px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }
.hist-detail { margin-top: 9px; border-top: 1px dashed var(--line); padding-top: 9px; }
.hist-detail-body { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.hist-sources { margin-top: 9px; }
.hist-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; color: var(--wechat-green-dark);
  border-radius: 14px; padding: 5px 13px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.mini-btn:active { background: #f0f0f0; }
.mini-btn:disabled { opacity: .5; }
.mini-btn.danger { color: var(--r5); border-color: #f3c2bd; }
.status-pill {
  font-size: 10.5px; padding: 2px 9px; border-radius: 9px; font-weight: 700;
  color: #fff; background: var(--ink-soft); white-space: nowrap;
}
.st-suggested { background: var(--r3); }
.st-acknowledged { background: var(--r2); }
.st-resolved { background: var(--wechat-green); }
.st-dismissed { background: var(--ink-soft); }
.st-invited { background: var(--r3); }
.st-active { background: var(--wechat-green); }
.st-revoked { background: var(--ink-soft); }

/* Access / invitations */
.access-form { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.access-field { display: flex; flex-direction: column; gap: 3px; }
.access-label { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.access-select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font-size: 14px; background: #fff; outline: none; font-family: inherit;
}
.access-select:focus { border-color: var(--wechat-green); }
.access-code-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.access-code-label { font-size: 11px; color: var(--ink-soft); }
.access-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: #f3f0ff; color: #5b3df8; padding: 2px 8px; border-radius: 8px; user-select: all;
}

/* Insights (manager stats dashboard) */
.stat-headline { text-align: center; }
.stat-big { font-size: 34px; font-weight: 800; color: var(--wechat-green); line-height: 1.1; }
.stat-cap { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.stat-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.stat-label {
  flex: 0 0 38%; font-size: 12.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize;
}
.stat-bar { flex: 1; height: 14px; background: #eef2f5; border-radius: 7px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--wechat-green); border-radius: 7px; min-width: 2px; transition: width .3s ease; }
.stat-num { flex: 0 0 26px; font-size: 12.5px; color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }

.welcome { color: var(--ink-soft); font-size: 13px; text-align: center; padding: 6px 18px; line-height: 1.6; }
.examples { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.example-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
  font-size: 13px; text-align: left; cursor: pointer; color: var(--ink); line-height: 1.4;
}
.example-chip:active { background: #f0f0f0; }

/* Logout button in the app bar */
.pill-btn {
  flex: 0 0 auto; border: none; border-radius: 16px; padding: 6px 12px;
  font-size: 13px; background: rgba(255,255,255,.92); color: var(--ink);
  cursor: pointer; line-height: 1;
}

/* Notes / Expert guidance on escalations */
.note-thread { margin-top: 11px; border-top: 1px dashed var(--line); padding-top: 9px; }
.note-item {
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; margin-top: 7px;
}
.note-item.note-asker { background: #e8f6ff; border-color: #bfe6ff; }
.note-meta { font-size: 10.5px; color: var(--ink-soft); margin-bottom: 4px; }
.note-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.note-form { margin-top: 10px; }
.note-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 13px; resize: vertical; outline: none; font-family: inherit; background: #fff;
}
.note-input:focus { border-color: var(--wechat-green); }
.note-ctrls { display: flex; gap: 8px; margin-top: 7px; align-items: center; }
.note-vis {
  border: 1px solid var(--line); border-radius: 12px; padding: 5px 10px;
  font-size: 12px; background: #fff; outline: none; font-family: inherit;
}

/* Audit trail */
.audit-detail {
  margin-top: 7px; font-size: 11px; color: var(--ink-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; word-break: break-all; line-height: 1.45;
}

/* Login screen */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, var(--wechat-green), var(--wechat-green-dark));
}
.login-screen.hidden { display: none; }
.login-card {
  background: var(--card); border-radius: 18px; padding: 26px 22px;
  width: 100%; max-width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  text-align: center;
}
.login-brand { display: flex; flex-direction: column; gap: 3px; margin-bottom: 4px; }
.login-brand .brand-zh { color: var(--ink); font-size: 22px; }
.login-brand .brand-en { color: var(--ink-soft); font-size: 12px; opacity: 1; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 10px 0 18px; }
.login-methods { display: flex; flex-direction: column; gap: 10px; }
.login-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; cursor: pointer;
  font-family: inherit; width: 100%;
}
.login-btn.primary { background: var(--wechat-green); border-color: var(--wechat-green); color: #fff; font-weight: 600; }
.login-btn:active { opacity: .85; }
.login-btn:disabled { opacity: .5; }
.login-form { display: flex; gap: 8px; }
.login-input {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-size: 14px; outline: none; font-family: inherit; background: #fff;
}
.login-input:focus { border-color: var(--wechat-green); }
.login-form .login-btn { width: auto; flex: 0 0 auto; }
.login-error { color: var(--r5); font-size: 12.5px; margin-top: 14px; line-height: 1.5; min-height: 16px; }
