:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #d8e0eb;
  --line-strong: #b6c3d4;
  --text: #172033;
  --muted: #5e6b7e;
  --blue: #1c6dd0;
  --blue-soft: #e8f1ff;
  --green: #1f7a55;
  --amber: #966700;
  --amber-soft: #fff3cf;
  --red: #b42318;
  --detail-pad: 16px;
  --row-min: 50px;
  --row-pad: 8px 12px;
  --title-size: 24px;
  --body-size: 14px;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: var(--body-size);
}

body[data-density="standard"] {
  --detail-pad: 20px;
  --row-min: 58px;
  --row-pad: 10px 14px;
  --title-size: 26px;
  --body-size: 15px;
}

body[data-density="roomy"] {
  --detail-pad: 24px;
  --row-min: 66px;
  --row-pad: 12px 16px;
  --title-size: 28px;
  --body-size: 16px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: grid;
  grid-template-columns: clamp(172px, 12vw, 200px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #f6f8fc;
  min-height: 100vh;
}

.brand {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 16px 14px 9px;
  border-bottom: 1px solid var(--line);
}

.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #9bb6d8;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  padding: 8px 10px 18px;
}

.nav-title {
  margin: 18px 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav a {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 0 20px 20px 0;
  padding: 6px 10px;
}

.nav a:hover,
.nav a.active {
  background: #d3e3fd;
  color: #041e49;
  font-weight: 800;
}

.nav-index,
.nav-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: #f6f8fc;
}

.crumb {
  color: var(--muted);
  font-size: 13px;
}

.top-title {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 850;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pill,
.density-button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  padding: 7px 11px;
}

.density-button {
  width: 48px;
  height: 30px;
  background: var(--blue-soft);
  color: #041e49;
  cursor: pointer;
}

.workspace {
  padding: 0 18px 18px 0;
}

.panel {
  border: 1px solid var(--line);
  border-top: 0;
  border-left: 0;
  border-radius: 0 0 8px 0;
  background: var(--panel);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel-title {
  font-weight: 850;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
}

.content {
  max-height: calc(100vh - 138px);
  overflow: auto;
  padding: var(--detail-pad);
}

.row-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  min-height: var(--row-min);
  padding: var(--row-pad);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.row:hover {
  background: #f8fbff;
}

.row:last-child {
  border-bottom: 0;
}

.dot {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--blue);
}

.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: #c48b05; }

.row-title {
  display: block;
  font-weight: 850;
}

.row-summary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: calc(var(--body-size) - 1px);
  line-height: 1.45;
}

.badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: var(--title-size);
  line-height: 1.15;
}

.lead {
  max-width: 860px;
  margin: 10px 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
  min-height: 58px;
}

.card-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-value {
  margin-top: 6px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.callout {
  border: 1px solid #f3c44f;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #5c4300;
  padding: 12px;
  line-height: 1.55;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  padding: 18px;
  line-height: 1.6;
}

.section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

.rules {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rules li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  line-height: 1.45;
}

.num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

pre {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  overflow: auto;
  line-height: 1.45;
}

code {
  border-radius: 5px;
  background: var(--blue-soft);
  color: #041e49;
  padding: 1px 5px;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 12px 12px;
  }

  .nav-title {
    display: none;
  }

  .nav a {
    min-width: 148px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions .pill {
    display: none;
  }

  .workspace {
    padding: 10px;
  }

  .panel {
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .content {
    max-height: none;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .brand {
    padding: 12px 14px 6px;
  }

  .top-title {
    font-size: 18px;
  }

  .row {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .badge {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
