:root {
  color-scheme: light;
  --ink: #1d2438;
  --muted: #5d6579;
  --line: #e1e4ef;
  --base: #f4f5fa;
  --paper: #fff;
  --accent: #4f43b7;
  --accent-soft: #eeecfc;
  --dark: #26233d;
  --green: #236344;
  --green-soft: #e5f4ec;
  --amber: #825511;
  --amber-soft: #fff2d5;
  --red: #9a3242;
  --red-soft: #fbecef;
  --head-height: 76px;
  font: 16px/1.5 "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--base);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button, input, textarea, select { color: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid #7767e5;
  outline-offset: 2px;
}
button:disabled { cursor: default; opacity: .5; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.sr-only, .skip:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip:focus { position: fixed; inset: 8px auto auto 8px; z-index: 8; padding: 10px 16px; background: white; color: var(--accent); }

.masthead {
  min-height: var(--head-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(16px, 2.2vw, 36px);
  background: var(--dark);
  color: #fff;
}
.identity, .tools { display: flex; align-items: center; gap: 12px; }
.identity img { border-radius: 11px; object-fit: contain; background: #fff; }
.identity strong { display: block; font-size: 19px; letter-spacing: .035em; }
.identity span { display: block; font-size: 12px; color: #d6d3ec; }
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}
button:hover:not(:disabled) { background: var(--accent-soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #4337a0; }
.tools button { color: white; background: transparent; border-color: #625e7c; white-space: nowrap; }
.tools button:hover:not(:disabled) { background: #3d3759; }
#storage-status { color: #d6d3ec; font-size: 13px; }
#storage-status.error { color: #ffd3d9; }

.workspace {
  max-width: 1780px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(180px, 224px) minmax(0, 1fr) minmax(268px, 316px);
  align-items: start;
  gap: 20px;
  padding: 22px clamp(16px, 2.2vw, 36px) 44px;
}
.sidebar, .inspector {
  position: sticky;
  top: 16px;
  max-height: calc(100dvh - 32px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: auto;
  scrollbar-width: thin;
}
.sidebar { padding: 12px 10px; }
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 10px;
  margin-bottom: 4px;
}
.sidebar-top h2 { font-size: 16px; }
.sidebar-top button { min-width: 44px; font-size: 18px; }
.subtle { border: 0; background: transparent; color: var(--accent); }
.nav-item, .nav-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
  border: 0;
  text-align: left;
}
.nav-group { color: var(--muted); font-size: 13px; }
.nav-group span:last-child { font-weight: 400; }
.nav-sub .nav-item { padding-left: 20px; font-weight: 500; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: #35278e; font-weight: 700; }
.nav-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nav-complete { color: var(--green); font-size: 12px; white-space: nowrap; }

main { min-width: 0; }
.section-header { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 18px; }
.section-header button { flex-shrink: 0; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
h1 { font-size: clamp(27px, 3vw, 40px); line-height: 1.2; letter-spacing: -.02em; }
.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 16px;
}
.metric { padding: 13px clamp(10px, 1.3vw, 20px); }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { display: block; font-size: 13px; color: var(--muted); }
.metric strong { display: block; font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric:nth-child(3) strong { color: var(--green); }
.metric:nth-child(4) strong { color: var(--accent); }

.ledger { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; overflow: clip; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 14px 8px; }
.search { position: relative; flex: 1 1 195px; min-width: 0; display: flex; }
.search-icon {
  position: absolute;
  top: 15px;
  left: 13px;
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}
.search-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 1.5px;
  background: var(--muted);
  transform: rotate(45deg);
  left: 8px;
  top: 9px;
}
input, select, textarea {
  max-width: 100%;
  min-height: 44px;
  border: 1px solid #cfd3e1;
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--paper);
}
.search input { width: 100%; padding-left: 34px; font-size: 14px; }
.filter select { font-size: 14px; }
.kinds { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 9px; }
.kinds button { border-color: transparent; }
.kinds button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.table-head, .result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 78px 74px;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
}
.table-head { color: var(--muted); background: #f6f6fb; font-size: 13px; border-block: 1px solid var(--line); }
.result {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.result[aria-pressed="true"] {
  background: #f1effc;
  box-shadow: inset 3px 0 var(--accent);
}
.result-title { min-width: 0; }
.result-title strong { display: block; font-size: 15px; font-weight: 650; }
.result-title small { display: block; color: var(--muted); font-size: 12px; }
.result-kind { color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 25px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #f0f1f6;
  color: #545d73;
  font-size: 12px;
  white-space: nowrap;
}
.badge.done, .badge.satisfied { background: var(--green-soft); color: var(--green); }
.badge.doing, .badge.revise, .badge.unavailable { background: var(--amber-soft); color: var(--amber); }
.badge.unsatisfied { background: var(--red-soft); color: var(--red); }
.badge.kind { background: var(--accent-soft); color: var(--accent); }
.empty { color: var(--muted); padding: 30px 16px; text-align: center; }
.pagination { min-height: 52px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 5px 14px; gap: 8px; color: var(--muted); font-size: 13px; }
.pagination div { display: flex; gap: 5px; }
.pagination button { padding: 6px 9px; }

.inspector { padding: 18px; }
.inspector h2 { font-size: 16px; margin: 0 0 16px; }
.inspector h3 { font-size: 24px; line-height: 1.24; margin: 8px 0 6px; overflow-wrap: anywhere; }
.inspector .detail { margin-top: 10px; font-size: 14px; overflow-wrap: anywhere; }
.record-path { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.source { font-size: 12px; overflow-wrap: anywhere; color: var(--muted); margin-top: 7px; }
.inspector form { margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.field, fieldset { display: grid; gap: 6px; margin: 0 0 14px; }
.field > span, legend { font-size: 14px; font-weight: 700; }
fieldset { padding: 1px 0 0; min-width: 0; border: 0; }
legend { padding: 0; margin-bottom: 5px; }
.ratings { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ratings button { padding-inline: 5px; }
.ratings button[aria-pressed="true"] { border-color: #7b6dca; background: var(--accent-soft); color: #392995; }
textarea { resize: vertical; width: 100%; min-height: 96px; line-height: 1.5; font-size: 14px; }
.saved-time { font-size: 12px; color: var(--muted); margin-top: -6px; }
.edit-record { margin-top: 10px; padding-inline: 0; }

dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  color: var(--ink);
}
dialog::backdrop { background: rgb(25 24 48 / 55%); }
dialog h2 { margin-bottom: 16px; font-size: 22px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; padding-top: 4px; }
.inline-error { color: var(--red); font-size: 14px; margin-bottom: 10px; }
.feedback { position: fixed; z-index: 4; right: 18px; bottom: 18px; max-width: min(480px, calc(100vw - 36px)); padding: 11px 16px; background: var(--dark); color: #fff; border-radius: 9px; font-size: 14px; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 175px minmax(0, 1fr) 260px; gap: 12px; }
}
@media (max-width: 1000px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 270px; }
  .sidebar { position: static; grid-column: 1 / -1; max-height: 245px; }
  .sidebar-top { margin: 0; }
  #page-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); align-items: start; gap: 0 8px; }
  .nav-sub { padding-bottom: 4px; }
  .inspector { top: 12px; }
}
@media (max-width: 700px) {
  .masthead { flex-wrap: wrap; gap: 6px; }
  .tools { flex-wrap: wrap; gap: 6px; }
  .workspace { display: block; padding: 12px 12px 25px; }
  .sidebar { max-height: 182px; margin-bottom: 18px; }
  .inspector { position: static; max-height: none; margin-top: 13px; scroll-margin-top: 12px; }
  .summary { margin-bottom: 12px; }
  .metric strong { font-size: 21px; }
  .metric span { font-size: 12px; }
  .table-head, .result { grid-template-columns: minmax(0, 1fr) 37px 59px 56px; padding-inline: 10px; gap: 4px; }
  .badge { padding-inline: 4px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 120ms ease, border-color 120ms ease; }
}
