:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-weak: #ccfbf1;
  --blue: #2563eb;
  --blue-weak: #dbeafe;
  --red: #dc2626;
  --red-weak: #fee2e2;
  --amber: #b45309;
  --amber-weak: #fef3c7;
  --text: #111827;
  --muted: #6b7280;
  --hint: #9ca3af;
  --line: #e8eaed;
  --bg: #f4f5f7;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 520px; margin: 0 auto; min-height: 100%; padding-bottom: 88px; }
.hidden { display: none !important; }

/* 顶部栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 2px;
  padding: 12px 12px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 4px rgba(13, 148, 136, .25);
}
.topbar h1 { flex: 1; font-size: 18px; font-weight: 600; text-align: center; letter-spacing: .5px; }
.icon-btn { background: none; border: none; color: #fff; font-size: 28px; line-height: 1; width: 40px; height: 40px; cursor: pointer; border-radius: 10px; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.badge-btn { background: none; border: none; color: #fff; font-size: 20px; position: relative; width: 40px; height: 40px; cursor: pointer; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.badge-btn:active { background: rgba(255,255,255,.15); }
.badge-btn .bell { font-size: 22px; }
.badge-btn .count {
  position: absolute; top: -2px; right: -2px;
  background: #e11d48; color: #fff; font-size: 11px; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 600;
}

/* 待归档横幅 */
.due-banner {
  margin: 12px 12px 0; padding: 14px 16px;
  background: var(--amber-weak); border: 1px solid #fcd34d; border-radius: var(--radius);
  font-size: 14px; color: var(--amber); cursor: pointer;
  box-shadow: var(--shadow);
}
.due-banner b { display: block; font-size: 15px; margin-bottom: 3px; }
.due-banner .overdue { color: var(--red); font-weight: 600; }

/* 筛选栏 */
.filter-bar { padding: 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.filter-bar input[type=search] {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; margin-bottom: 10px; background: #f9fafb; transition: border .15s, box-shadow .15s;
}
.filter-bar input[type=search]:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); background: #fff; }
.filter-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--muted); font-size: 13px; }
.filter-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; background: #fff; }
.filter-row input:focus { outline: none; border-color: var(--primary); }
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chip {
  flex: 1; padding: 8px 0; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--muted); font-size: 13.5px; cursor: pointer; transition: all .15s;
}
.chip:active { transform: scale(.97); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 500; }
.chips-time .chip.active { background: var(--blue); border-color: var(--blue); }

/* 列表 */
.list { list-style: none; padding: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; border: 1px solid var(--line); cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.card:active { transform: scale(.985); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.card .row1 { display: flex; align-items: center; gap: 8px; }
.card .name { font-size: 17px; font-weight: 600; }
.card .meta { font-size: 13px; color: var(--muted); margin-left: auto; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
.tag.critical { background: var(--red-weak); color: var(--red); }
.tag.difficult { background: var(--amber-weak); color: var(--amber); }
.card .row2 { font-size: 14px; color: var(--muted); margin-top: 5px; }
.card .row3 { display: flex; align-items: center; margin-top: 8px; gap: 8px; }
.st { font-size: 12px; padding: 3px 10px; border-radius: 10px; background: #f3f4f6; color: var(--muted); font-weight: 500; }
.st.in { background: var(--blue-weak); color: var(--blue); }
.st.arch { background: var(--primary-weak); color: var(--primary-dark); }
.st.due { background: var(--amber-weak); color: var(--amber); }
.st.overdue { background: var(--red-weak); color: var(--red); }
.deadline { font-size: 12px; color: var(--muted); margin-left: auto; }
.deadline.soon { color: var(--amber); font-weight: 600; }
.deadline.past { color: var(--red); font-weight: 600; }
.empty { text-align: center; color: var(--hint); padding: 60px 20px; font-size: 14px; }

/* 详情页 */
.detail-head { background: var(--card); padding: 20px 16px; border-bottom: 1px solid var(--line); }
.detail-head .name { font-size: 23px; font-weight: 700; letter-spacing: .3px; }
.detail-head .tags { margin: 8px 0 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.detail-head .info { font-size: 13.5px; color: var(--muted); }
.detail-head .actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; cursor: pointer; color: var(--text); transition: all .12s; font-weight: 500;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* 折叠区块 */
.section { background: var(--card); margin: 12px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow); }
.section-head { display: flex; align-items: center; padding: 15px 16px; cursor: pointer; font-size: 16px; font-weight: 600; }
.section-head .arrow { margin-left: auto; color: var(--hint); transition: transform .2s; font-size: 20px; }
.section.open .arrow { transform: rotate(90deg); }
.section-head .add { margin-left: 6px; color: var(--primary); font-size: 22px; font-weight: 400; }
.section-body { display: none; padding: 0 16px 14px; }
.section.open .section-body { display: block; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* 键值对 */
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 10px; font-size: 14px; }
.kv .k { color: var(--muted); }

/* 条目 */
.med-ocr-row { border-top: 1px solid var(--line); padding: 10px 0; }
.med-ocr-row:first-of-type { border-top: none; }
.med-ocr-row .row { display: flex; gap: 8px; margin-top: 8px; }
.med-ocr-row .field { flex: 1; min-width: 0; margin-bottom: 0; }
.med-ocr-row .field label { font-size: 12px; margin-bottom: 3px; }
.med-ocr-row .check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.med-ocr-row .check input { width: 17px; height: 17px; }
.item { border-top: 1px solid var(--line); padding: 12px 0; font-size: 14px; display: flex; align-items: flex-start; gap: 8px; }
.item:first-child { border-top: none; }
.item .main { flex: 1; min-width: 0; }
.item .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.item .del { color: var(--hint); font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1.3; }
.item .del:active { color: var(--red); }
.item .edit { color: var(--primary); cursor: pointer; font-size: 13px; white-space: nowrap; padding: 0 4px; }
.item .done-toggle { color: var(--primary); cursor: pointer; font-size: 13px; white-space: nowrap; padding: 0 4px; }
.flag-abnormal { color: var(--red); font-weight: 600; }
.flag-high { color: var(--red); }
.flag-low { color: var(--blue); }

/* 表单 */
.form { background: var(--card); margin: 12px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.form .field { margin-bottom: 14px; }
.form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.form input, .form select, .form textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; font-size: 15px; background: #fff;
  transition: border .15s, box-shadow .15s;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.form textarea { min-height: 72px; resize: vertical; }
.form .row { display: flex; gap: 10px; }
.form .row .field { flex: 1; min-width: 0; }
.form .check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.form .check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form .btns { display: flex; gap: 10px; margin-top: 18px; }
.form .btns .btn { flex: 1; padding: 12px; font-size: 15px; }

/* 浮动按钮 */
.fab {
  position: fixed; right: 20px; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 30;
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 30px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(13, 148, 136, .4); transition: transform .12s;
}
.fab:active { transform: scale(.92); }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 40; display: flex; align-items: flex-end; backdrop-filter: blur(2px); }
.modal {
  background: #fff; width: 100%; max-width: 520px; margin: 0 auto;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto; animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 16px; font-weight: 600; }

/* 加载动画 */
.spinner {
  width: 42px; height: 42px; margin: 0 auto;
  border: 3px solid #e5e7eb; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 521px) {
  .mask { align-items: center; padding: 24px; }
  .modal { border-radius: 20px; }
}
