:root {
  --brand: #1f4e5f;
  --brand-dark: #173d4a;
  --brand-soft: #eaf2f4;
  --bg: #f3f6f7;
  --card: #ffffff;
  --ink: #1c2b33;
  --muted: #7c8b95;
  --tiny: #8a9aa5;
  --line: #e8eef0;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* 顶部导航 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 16px;
  background: var(--brand); color: #fff;
  box-shadow: 0 2px 12px rgba(23, 61, 74, .18);
}
.topbar-brand { font-weight: 700; letter-spacing: 2px; font-size: 17px; white-space: nowrap; }
.topbar-title {
  flex: 1; text-align: center; font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .92;
}
.topbar-spacer { width: 56px; }
.back-btn {
  width: 56px; padding: 4px 0; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 14px;
}
.back-btn:hover { background: rgba(255, 255, 255, .24); }

/* 页面容器 */
.page { max-width: 780px; margin: 0 auto; padding: 18px 16px 108px; }
.wrap { display: block; }

/* 底部标签栏 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(31, 78, 95, .06);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: 58px; color: var(--muted); font-size: 12px;
}
.tab.active { color: var(--brand); font-weight: 700; }
.tab-dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.tab.active .tab-dot { background: var(--brand); }

/* 启动提示（模块加载失败时可见） */
.boot-hint {
  max-width: 780px; margin: 18px auto 0; padding: 12px 16px;
  border-radius: 12px; background: #fff; color: var(--muted); font-size: 13px;
}
.boot-hint-error {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; line-height: 1.9;
}
.boot-hint code {
  background: rgba(31, 78, 95, .08); padding: 2px 6px; border-radius: 6px; font-size: 12px;
}

/* 卡片与文字 */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
  box-shadow: 0 2px 12px rgba(31, 78, 95, .06);
}
.card-tight { padding: 14px 16px; }
.h1 { font-size: 22px; font-weight: 700; letter-spacing: .5px; }
.h2 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--tiny); }
.brand { color: var(--brand); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.b { font-weight: 700; }
.row-center { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.between { display: flex; align-items: flex-end; gap: 12px; }
.between > * { flex: 1; min-width: 0; }
.gap { height: 14px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }

/* 标签 / 提示条 */
.tag {
  display: inline-block; font-size: 12px; padding: 2px 10px;
  border: 0; border-radius: 999px; background: var(--brand-soft);
  color: var(--brand); white-space: nowrap;
}
.tag-strong { background: #d7ece1; color: #166534; }
.tag-mid { background: #fef3c7; color: #92400e; }
.tag-weak { background: #f1f5f9; color: #64748b; }
.tag-warn { background: #fee2e2; color: var(--danger); }
.banner {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 13px;
}
.banner-info { background: #eef6f9; border-color: #cfe3ea; color: #28566a; }
.banner-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

/* 按钮 */
.btn {
  display: inline-block; padding: 9px 16px; border: 1px solid var(--brand);
  border-radius: 10px; background: var(--brand); color: #fff;
  font-size: 14px; line-height: 1.4; text-align: center;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: var(--brand-dark); box-shadow: 0 3px 10px rgba(31, 78, 95, .18); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-plain { background: #fff; color: var(--brand); border-color: #c9dbe1; }
.btn-plain:hover { background: var(--brand-soft); }
.btn-ghost { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.btn-ghost:hover { background: #dcebed; }
.btn-block { display: block; width: 100%; margin-top: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 0 1 auto; }

/* 选项与表单 */
.chip {
  display: inline-block; margin: 0 8px 8px 0; padding: 6px 13px;
  border: 1px solid #d9e4e8; border-radius: 999px;
  background: #fff; color: var(--ink); font-size: 13px;
}
.chip:hover { border-color: var(--brand); }
.chip-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.field { margin: 12px 0; }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, .picker, select.picker {
  width: 100%; padding: 9px 11px; border: 1px solid #d9e4e8; border-radius: 10px;
  background: #fff; color: var(--ink); font-size: 16px; outline: none;
}
.input:focus, .textarea:focus, .picker:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 78, 95, .08); }
.textarea { min-height: 84px; resize: vertical; }
.picker { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--brand) 50%), linear-gradient(135deg, var(--brand) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { width: 20px; height: 20px; accent-color: var(--brand); }

/* 图片 */
.cover { width: 100%; height: 150px; object-fit: cover; border-radius: 12px; margin-bottom: 8px; background: var(--brand-soft); }
.thumb { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; display: inline-block; margin: 8px 6px 0 0; vertical-align: top; }
.thumb-row { white-space: nowrap; overflow-x: auto; }
.inline-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; margin-top: 8px; }

/* 气泡、Markdown */
.bubble-user, .bubble-ai {
  max-width: 88%; margin: 8px 0; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.bubble-user { margin-left: auto; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.bubble-ai { background: #f1f5f6; border-bottom-left-radius: 4px; }
.md-h { font-weight: 700; font-size: 15px; margin: 10px 0 4px; }
.md-li { padding-left: 14px; position: relative; }
.md-li::before { content: '·'; position: absolute; left: 3px; color: var(--brand); }
.md-p { min-height: .8em; }
.md-hr { border-top: 1px solid var(--line); margin: 10px 0; }

/* 弹层 */
.mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(16, 35, 43, .48);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 18px; padding: 20px;
  box-shadow: 0 18px 50px rgba(16, 35, 43, .25);
}
.sheet-scroll { max-height: 52vh; overflow-y: auto; margin: 10px 0; }

/* toast / loading / 灯箱 */
#toast-layer {
  position: fixed; left: 50%; bottom: 84px; z-index: 80;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: 88vw; padding: 10px 16px; border-radius: 10px;
  background: rgba(23, 43, 51, .94); color: #fff; font-size: 13px;
  transition: opacity .2s ease, transform .2s ease; white-space: pre-wrap;
}
#toast-layer.toast-show { opacity: 1; transform: translate(-50%, 0); }
.loading-mask { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(16, 35, 43, .25); }
.loading-box { background: rgba(23, 43, 51, .94); color: #fff; padding: 14px 20px; border-radius: 12px; font-size: 14px; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(8, 18, 23, .92); display: flex; align-items: center; justify-content: center; }
.lightbox-img { max-width: 88vw; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.lightbox button { position: absolute; border: 0; background: rgba(255, 255, 255, .16); color: #fff; border-radius: 50%; width: 40px; height: 40px; font-size: 22px; }
.lightbox-close { top: 18px; right: 18px; }
.lightbox-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-tip { position: absolute; bottom: 20px; color: #cbd5d9; font-size: 12px; }

@media (min-width: 860px) {
  .page { padding: 24px 24px 120px; }
  .card { padding: 22px; }
  .h1 { font-size: 24px; }
}
@media (max-width: 380px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .page { padding: 14px 10px 104px; }
  .btn { padding: 8px 12px; font-size: 13px; }
}
