/* ========== 基础：暖米色护眼手账风 ========== */
:root {
  --bg: #FAF8F3;
  --card: #FFFFFF;
  --ink: #3A3530;
  --ink2: #5E574F;
  --muted: #9A9186;
  --line: #ECE6DA;
  --line2: #F3EEE5;
  --primary: #E8684A;
  --primary-soft: #FDEEE9;
  --flower: #E85A7A;
  --ok: #4CAF7A;
  --warn: #E9A23B;
  --danger: #D9534F;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(80, 60, 30, .05), 0 4px 14px rgba(80, 60, 30, .06);
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --kai: KaiTi, STKaiti, "Kaiti SC", "楷体", "华文楷体", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
small { font-size: 12px; color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }

/* ---------- 顶栏 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  height: calc(52px + var(--safe-t));
  padding: var(--safe-t) 10px 0 16px;
  background: rgba(250, 248, 243, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
}
.appbar h1 { font-size: 19px; font-weight: 700; flex: 1; letter-spacing: .5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btnBack { margin-left: -8px; }
.appbar-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink2); font-size: 22px;
}
.icon-btn:active { background: var(--line2); }
.icon-btn:disabled { opacity: .3; }
.icon-btn .txt { font-size: 15px; font-weight: 600; color: var(--primary); }

/* ---------- 主体 ---------- */
#view { padding: 4px 14px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
.page { display: flex; flex-direction: column; gap: 14px; animation: fadeIn .18s ease; }
.page.has-batch { padding-bottom: 64px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  max-width: 720px; margin: 0 auto;
}
.tabbar a, .tab-add {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted);
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.tab-add { color: var(--primary); font-weight: 600; }
.tab-add i {
  width: 52px; height: 52px; margin-top: -24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #F2845F, #E25A45);
  color: #fff; box-shadow: 0 6px 16px rgba(226, 90, 69, .38);
  border: 4px solid var(--bg);
}
.tab-add i svg { width: 26px; height: 26px; }
.tab-add:active i { transform: scale(.94); }
.tab-badge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(232, 104, 74, .25); }
.btn-ghost { background: var(--line2); color: var(--ink2); }
.btn-flower { background: linear-gradient(135deg, #F27A96, #E5577A); color: #fff; box-shadow: 0 3px 10px rgba(229, 87, 122, .25); }
.btn-danger { background: var(--danger); color: #fff; }
.btn.danger, .danger { color: var(--danger); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { height: 50px; font-size: 16px; border-radius: 14px; padding: 0 22px; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.link-btn { color: var(--primary); font-weight: 600; font-size: 14px; }
.mini-btn { font-size: 13px; padding: 2px 10px; border-radius: 20px; background: var(--line2); color: var(--ink2); font-weight: 500; }

/* ---------- 表单 ---------- */
.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  outline: none; font-size: 16px; /* 防止 iOS 自动放大 */
  transition: border-color .15s;
}
textarea.input { resize: vertical; line-height: 1.55; }
.input:focus { border-color: #F0A48F; box-shadow: 0 0 0 3px rgba(232, 104, 74, .1); }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .extra-box > label { font-size: 13px; font-weight: 600; color: var(--ink2); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.filters select, select.input {
  height: 40px; padding: 0 30px 0 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239A9186' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 12px center;
  -webkit-appearance: none; appearance: none; font-size: 14px; color: var(--ink2); min-width: 0;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); padding: 4px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.hint.center { text-align: center; }

/* ---------- 标签 chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 2px 14px; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 16px;
  background: #fff; border: 1.5px solid var(--line); color: var(--ink2); font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip b { color: var(--primary); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip.subj-chip.on { background: var(--cs); border-color: var(--c); color: var(--c); }
.chip-add { border-style: dashed; color: var(--muted); }
.chip-s {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; background: var(--line2); color: var(--ink2); white-space: nowrap;
}
.chip-s.subj { background: var(--cs, #eee); color: var(--c, #666); }
.chip-s.t-mistake { background: #FDECEC; color: #D9534F; }
.chip-s.t-key { background: #FFF5D9; color: #B7861B; }
.chip-s.m-new { background: #F6EFE6; color: #A0846A; }
.chip-s.m-rev { background: #EAF3FB; color: #3B82C4; }
.chip-s.m-ok { background: #E6F5EC; color: #2E9A5E; }
.chip-s.reason { background: #FFF1EC; color: #D2603F; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card-title { font-size: 16px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.sec-title { font-size: 16px; font-weight: 700; margin: 6px 2px 10px; display: flex; align-items: baseline; gap: 8px; }
.mini-title { font-size: 13.5px; color: var(--ink2); margin-top: 4px; display: flex; justify-content: space-between; align-items: center; }

.empty { text-align: center; color: var(--muted); padding: 34px 12px; font-size: 14px; line-height: 1.8; }
.empty-emoji { font-size: 42px; margin-bottom: 4px; }

/* ---------- 提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px); z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 86vw; padding: 10px 18px; border-radius: 22px;
  background: rgba(50, 44, 38, .92); color: #fff; font-size: 14px; text-align: center;
  transition: all .22s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#print-root { display: none; }
