:root {
  --fg: #1f2328;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --bg: #f6f7f9;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #047857;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; height: 54px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; color: var(--fg);
  text-decoration: none; white-space: nowrap;
}
.brand-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative;
  padding: 15px 12px; font-size: 14px; color: var(--muted);
  text-decoration: none; white-space: nowrap; border-radius: 8px 8px 0 0;
  transition: color .15s;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--accent); font-weight: 600; }
.tabs a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}
.tabs a .soon { font-size: 10.5px; color: var(--faint); margin-left: 4px; }

/* ---------- 布局 ---------- */
main { max-width: 720px; margin: 0 auto; padding: 26px 20px 90px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card-head .spacer { flex: 1; }
h3 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.pill {
  font-size: 12px; color: #1d4ed8; background: var(--accent-soft);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.pill.warn { color: #b45309; background: #fffbeb; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 24px; }
.q-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.q-title .opt { font-weight: 400; color: var(--faint); font-size: 12.5px; margin-left: 6px; }
.q-hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
textarea, input[type="text"], select {
  width: 100%; font: inherit; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 74px; resize: vertical; }
textarea:focus, input[type="text"]:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
::placeholder { color: #b8bec9; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 13.5px;
  color: var(--muted); user-select: none; transition: all .12s;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover { border-color: #d1d5db; }
.seg label:has(input:checked) {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 10px; padding: 10px 18px; border: 1px solid transparent;
  transition: opacity .15s, background .15s;
}
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #1d4ed8; }
button.ghost { background: #fff; border-color: var(--line); color: var(--muted); }
button.ghost:hover:not(:disabled) { border-color: #d1d5db; color: var(--fg); }
button.link {
  background: none; border: 0; padding: 0; font-weight: 500;
  font-size: 12.5px; color: var(--accent);
}
button.link.danger { color: var(--danger); }
.msg { font-size: 13px; color: var(--ok); }
.msg.err { color: var(--danger); }

/* ---------- 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 20px; font-weight: 700; line-height: 1.3; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- 列表 ---------- */
.rec { border-top: 1px solid var(--line); padding: 14px 0; }
.rec:first-child { border-top: 0; }
.rec-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.rec-head b { font-size: 14px; }
.rec-head time { color: var(--faint); font-size: 12px; margin-left: auto; }
.rec p { margin: 7px 0 0; color: #4b5563; font-size: 13.5px; }
.rec .meta { color: var(--faint); font-size: 12.5px; margin-top: 5px; }
.rec-actions { display: flex; gap: 14px; margin-top: 9px; }
/* 折叠态的操作按钮：右对齐；点击时由 JS 阻止 summary 展开 */
.rec-head .rec-actions {
  margin-left: auto; margin-top: 0;
  display: flex; gap: 12px; align-items: center;
}
.rec-head .rec-actions button { font-size: 12.5px; }
details.rec .rec-head time { margin-left: 10px; }

/* 可展开的记录（点击标题区域展开详情，无弹窗） */
details.rec { padding: 0; }
details.rec summary {
  list-style: none; cursor: pointer; outline: none;
  padding: 15px 0 13px;
  -webkit-tap-highlight-color: transparent;
}
details.rec:first-child summary { padding-top: 4px; }
details.rec summary::-webkit-details-marker { display: none; }
details.rec summary:hover .rec-brief { color: var(--fg); }
details.rec summary:focus-visible { box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); border-radius: 8px; }

.rec-brief {
  margin: 6px 0 0; color: #4b5563; font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden; transition: color .12s;
}
.chev {
  width: 7px; height: 7px; flex: none; align-self: center; margin-left: 4px;
  border-right: 1.6px solid var(--faint);
  border-bottom: 1.6px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform .18s ease;
}
details.rec[open] .chev { transform: rotate(45deg); }

.rec-body { padding: 2px 0 15px; }
.kv-list { margin: 0; display: grid; gap: 9px; }
.kv { display: grid; grid-template-columns: 106px 1fr; gap: 12px; font-size: 13.5px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; color: #374151; white-space: pre-wrap; word-break: break-word; }

.tag {
  font-size: 11.5px; border-radius: 6px; padding: 1px 7px;
  background: #f3f4f6; color: var(--muted);
}
.tag.draft { background: #fffbeb; color: #b45309; }
.tag.done { background: #ecfdf5; color: var(--ok); }
.tag.traded { background: #fef2f2; color: var(--danger); }
.tag.dropped { background: #ecfdf5; color: var(--ok); }
.empty { color: var(--muted); font-size: 13.5px; margin: 6px 0; }

/* ---------- 占位 ---------- */
.placeholder {
  text-align: center; padding: 46px 20px; color: var(--muted); font-size: 13.5px;
}
.placeholder b { display: block; color: var(--fg); font-size: 15px; margin-bottom: 8px; }

@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { gap: 14px; padding: 0 14px; }
  main { padding: 18px 14px 80px; }
  .card { padding: 18px; }
  .kv { grid-template-columns: 84px 1fr; gap: 9px; }
}
