/* ============ 设计变量 ============ */
:root {
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --surface-2: #faf6ec;
  --ink: #23211c;
  --ink-2: #5b554a;
  --muted: #8b8273;
  --line: #e4ddcd;
  --line-strong: #d2c9b5;
  --accent: #ad4628;
  --accent-dark: #8c3520;
  --accent-wash: #f6e5db;
  --sage: #5d735e;
  --sage-wash: #e9eee5;
  --danger: #a33a2c;
  --sidebar: #1c2620;
  --sidebar-ink: #f0ecdf;
  --sidebar-muted: #93a096;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(35, 33, 28, .05);
  --shadow-md: 0 10px 30px -12px rgba(35, 33, 28, .22);
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Noto Serif CJK SC", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 15% 0%, rgba(255, 253, 247, .9), transparent 55%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
h1, h2, h3, p { margin: 0; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============ 布局 ============ */
.app { min-height: 100vh; }
.main {
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(96px + env(safe-area-inset-bottom));
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}

/* ============ 品牌 ============ */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fdf3ea;
  font-family: var(--font-display);
  font-size: 22px;
  border-radius: 12px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: .06em; }
.brand-text span {
  font-size: 9px;
  letter-spacing: .22em;
  color: var(--muted);
  margin-top: 2px;
}
.brand-mini { display: flex; align-items: center; gap: 10px; }
.brand-mini .brand-mark { width: 36px; height: 36px; flex-basis: 36px; font-size: 19px; border-radius: 10px; }
.brand-mini .brand-text strong { font-size: 14px; }
.brand-mini .brand-text span { letter-spacing: .02em; color: var(--muted); font-size: 11px; margin-top: 1px; }

/* ============ 导航 ============ */
.sidebar { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 18px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  transition: background .18s ease, transform .18s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 253, 247, .94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav .nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 6px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--muted);
  border-radius: 12px;
}
.bottom-nav .nav-btn svg { width: 22px; height: 22px; }
.bottom-nav .nav-btn.active { color: var(--accent); }
.nav-dot {
  position: absolute;
  top: 7px;
  left: calc(50% + 6px);
  min-width: 7px;
  height: 7px;
  border-radius: 99px;
  background: transparent;
  transition: background .2s ease;
}
.nav-dot.has-count { background: var(--accent); }
.nav-dot.has-count::after { content: none; }

/* ============ 通用组件 ============ */
.view { display: none; }
.view.active { display: block; animation: view-in .34s cubic-bezier(.22, .8, .3, 1) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.view-head { margin-bottom: 20px; }
.view-head h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.15;
}
.view-head .sub {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  max-width: 40em;
}
.view-head.split { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.view-head.split .btn { flex: 0 0 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn:active { transform: scale(.975); }
.btn.primary { background: var(--accent); color: #fdf6ef; box-shadow: 0 6px 16px -8px rgba(173, 70, 40, .7); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { border-color: var(--line-strong); background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: #e3c9c1; }
.btn.danger:hover { background: #faeae5; }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 12.5px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.stat:nth-child(odd) { border-right: 1px solid var(--line); }
.stat:nth-last-child(-n+2) { border-bottom: 0; }
.stat .k { font-size: 11px; color: var(--muted); letter-spacing: .06em; }
.stat .v {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.2;
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat .v em { font-style: normal; font-size: 12px; color: var(--muted); font-family: var(--font-body); }
.stat .v.warn { color: var(--accent); }

.toolbar { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 12px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.search-box:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(173, 70, 40, .08); }
.search-box svg { width: 17px; height: 17px; flex: 0 0 17px; }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }
.toolbar-actions { display: flex; gap: 10px; }
.toolbar-actions .btn { flex: 1; }
.sort-select {
  height: 42px;
  padding: 0 32px 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b8273' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 13px center;
  -webkit-appearance: none;
  appearance: none;
  color: var(--ink-2);
  font-size: 12.5px;
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-filter {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  transition: all .16s ease;
}
.chip-filter:hover { border-color: var(--line-strong); }
.chip-filter.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip-filter .n { opacity: .55; margin-left: 4px; font-size: 11px; }

/* ============ 表单 ============ */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > span.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--ink-2);
}
.field > label i { color: var(--accent); font-style: normal; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field textarea { min-height: 72px; resize: vertical; line-height: 1.55; }
.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b8273' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(173, 70, 40, .1);
}
.field input::placeholder, .field textarea::placeholder { color: #a89f8e; }
.field.invalid input { border-color: var(--danger); background: #fdf1ed; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.level-pick { display: flex; gap: 6px; }
.level-pick button {
  flex: 1;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  transition: all .16s ease;
}
.level-pick button:hover { border-color: var(--line-strong); }
.level-pick button.active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}
.form-actions .btn { flex: 1; }
.form-actions .btn.primary { flex: 1.3; }

/* ============ 弹层 ============ */
.modal-overlay, .drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(28, 30, 25, .4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in .2s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-up .3s cubic-bezier(.22, .8, .3, 1) both;
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: .4; }
  to { transform: none; opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.modal-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.modal-head .icon-btn { width: 34px; height: 34px; flex: 0 0 34px; border-color: var(--line); }
.modal-head .icon-btn svg { width: 16px; height: 16px; }

/* 抽屉 */
.drawer-overlay { align-items: stretch; justify-content: flex-end; }
.drawer {
  width: 100%;
  max-width: 460px;
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: drawer-in .3s cubic-bezier(.22, .8, .3, 1) both;
  display: flex;
  flex-direction: column;
}
@keyframes drawer-in {
  from { transform: translateX(28px); opacity: .5; }
  to { transform: none; opacity: 1; }
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 300;
  max-width: calc(100vw - 40px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
