:root {
  --accent: #e8552d;
  --accent-soft: #fdeee9;
  --star: #f5a623;
  --bg: #f4f4f2;
  --card: #fff;
  --line: #ececea;
  --text: #222;
  --muted: #8a8a86;
  --ok: #2f9e5b;
  --info: #2f7fd1;
  --tab: 54px;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
#app { max-width: 640px; min-height: 100vh; margin: 0 auto; background: var(--bg); position: relative; }

h1, h2, h3, p { margin: 0; }
h3 { font-size: 15px; margin-bottom: 8px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .4; cursor: default; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big { font-size: 18px; font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; padding: 8px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; height: 46px; padding: 0 8px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; text-align: center; font-size: 16px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 6px; }
.topbar .back, .topbar .back-sp { width: 40px; height: 40px; font-size: 30px; line-height: 38px; text-align: center; flex: none; }
.topbar-right { min-width: 40px; flex: none; display: flex; justify-content: flex-end; }

/* 页面容器 */
.page { padding: 10px 10px 24px; }
.page.has-tabs { padding-bottom: calc(var(--tab) + var(--safe) + 16px); }
.page.has-bar { padding-bottom: calc(70px + var(--safe)); }
.page.has-tabs.has-bar { padding-bottom: calc(var(--tab) + var(--safe) + 76px); }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; z-index: 30;
  display: flex; height: calc(var(--tab) + var(--safe)); padding-bottom: var(--safe);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; color: var(--muted); font-size: 15px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.badge {
  position: absolute; top: 8px; left: calc(50% + 16px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; font-style: normal; line-height: 18px; text-align: center;
}

/* 底部操作栏 */
.bottom-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; z-index: 25;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px calc(10px + var(--safe));
  background: var(--card); border-top: 1px solid var(--line);
}
.page.has-tabs + .bottom-bar { bottom: calc(var(--tab) + var(--safe)); padding-bottom: 10px; }
.bar-count { flex: 1; text-align: right; color: var(--muted); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 18px; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap;
}
.btn.small { min-height: 30px; padding: 0 12px; font-size: 13px; }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.danger, .danger { color: #c9372c; }
.btn.disabled { opacity: .4; pointer-events: none; }
.link { color: var(--accent); font-size: 13px; padding: 4px 8px 4px 0; }
.icon-btn { padding: 4px 12px; border-radius: 14px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.icon-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-sq { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }

/* 卡片与表单 */
.card { background: var(--card); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.card.flush { padding: 0; overflow: hidden; }
.field { display: block; margin-bottom: 10px; }
.field input, .field select, .field textarea,
.card > select, .card > textarea, .card > input[type=datetime-local], .card textarea, .card select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; outline: none;
}
.card input[type=datetime-local] { margin-top: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; display: block; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 60px 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty.small { padding: 24px 16px; }
.form-page .btn.block { margin-top: 4px; }

/* 登录 */
.auth { padding: 90px 28px 28px; }
.auth h1 { font-size: 26px; margin-bottom: 4px; }
.auth .sub { color: var(--muted); margin-bottom: 28px; }
.auth input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; outline: none; }
.auth .link { display: block; margin: 16px auto 0; }

/* 提示与弹窗 */
#toast {
  position: fixed; left: 50%; top: 40%; z-index: 100; transform: translateX(-50%);
  max-width: 80%; padding: 10px 16px; border-radius: 6px; background: rgba(30, 30, 30, .88); color: #fff;
  opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center;
}
#toast.show { opacity: 1; }
.mask { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog { width: 100%; max-width: 300px; background: #fff; border-radius: 10px; padding: 20px 18px 14px; }
.dialog p { margin-bottom: 18px; }
.dialog-btns { display: flex; gap: 10px; }
.dialog-btns .btn { flex: 1; }
.viewer { position: fixed; inset: 0; z-index: 95; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
