:root {
  --cinnabar-bright: color-mix(in srgb, var(--cinnabar) 68%, white);
  --cinnabar-deep: color-mix(in srgb, var(--cinnabar) 70%, black);
  --root: var(--cinnabar);
  --notes: #5a7a8c;
  --article: #6b8f71;
  --req: #8a7355;
  --line: color-mix(in srgb, var(--ink) 14%, transparent);
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root:not([data-theme]) {
  --ink: #17130f;
  --paper: #f0e9dd;
  --paper-deep: #e4dac9;
  --sheet: #fbf7f0;
  --muted: #6d655a;
  --cinnabar: #c46b52;
  --text: #2a241e;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(880px 400px at 10% -8%, color-mix(in srgb, var(--cinnabar) 13%, transparent), transparent 55%),
    radial-gradient(700px 360px at 92% 8%, color-mix(in srgb, var(--cinnabar) 10%, transparent), transparent 50%),
    linear-gradient(168deg, var(--sheet), var(--paper));
  line-height: 1.5;
}

.atmosphere {
  position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 42%, color-mix(in srgb, var(--sheet) 28%, transparent) 42.5% 43%, transparent 43.5%);
  opacity: .55;
}

.page {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.1rem 2.2rem;
}

.head { margin-bottom: 1.05rem; }
.head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .4rem 1rem;
}
.back { margin: 0 0 .35rem; font-size: .86rem; }
.back a { color: var(--cinnabar-deep); text-decoration: none; font-weight: 600; }
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.8vw, 1.9rem);
  color: var(--ink);
  letter-spacing: .04em;
}
.sub { margin: .2rem 0 0; color: var(--muted); font-size: .86rem; }
.meta { margin: 0; color: var(--muted); font-size: .78rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
  margin-bottom: .65rem;
}
.cards--secondary { margin-bottom: 1rem; }
.cards--secondary .card {
  background: color-mix(in srgb, var(--sheet) 62%, transparent);
}
@media (min-width: 720px) {
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.card {
  background: color-mix(in srgb, var(--sheet) 84%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .8rem .85rem .75rem;
  animation: rise .45s ease both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.card .label { font-size: .78rem; color: var(--muted); }
.card .value {
  margin-top: .15rem;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.card .hint { margin-top: .2rem; font-size: .72rem; color: var(--muted); }
.card--root .value { color: var(--root); }
.card--notes .value { color: var(--notes); }
.card--article .value { color: var(--article); }
.card--req .value { color: var(--req); }

.panel {
  background: color-mix(in srgb, var(--sheet) 84%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .95rem 1rem 1.05rem;
  margin-bottom: .8rem;
}
.panel--muted { background: color-mix(in srgb, var(--sheet) 62%, transparent); }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .35rem .8rem;
  margin-bottom: .75rem;
}
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--ink);
}
.panel-hint {
  margin: 0;
  font-size: .76rem;
  color: var(--muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: .76rem;
  color: var(--muted);
}
.lg::before {
  content: "";
  display: inline-block;
  width: .55rem; height: .55rem;
  border-radius: 2px;
  margin-right: .3rem;
  vertical-align: 0;
}
.lg-root::before { background: var(--root); }
.lg-notes::before { background: var(--notes); }
.lg-article::before { background: var(--article); }
.lg-req::before { background: var(--req); }

/* Articles */
.articles { display: grid; gap: .45rem; }
.article {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: .55rem;
  align-items: start;
  padding: .35rem 0 .45rem;
  border-bottom: 1px solid var(--line);
  animation: rise .4s ease both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.article:last-child { border-bottom: 0; padding-bottom: .1rem; }
.rank {
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cinnabar-deep);
  background: color-mix(in srgb, var(--cinnabar) 12%, transparent);
}
.article:nth-child(-n+3) .rank {
  color: #fff;
  background: var(--cinnabar);
}
.article-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .65rem;
  margin-top: .18rem;
  font-size: .74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.folder {
  color: var(--notes);
  font-weight: 500;
}
.article-bar {
  margin-top: .35rem;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  overflow: hidden;
}
.article-bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cinnabar), var(--cinnabar-bright));
  transform-origin: left;
  animation: grow .55s ease both;
  animation-delay: calc(var(--i, 0) * 28ms + .1s);
}

/* Daily / hourly columns */
.cols, .hours {
  display: grid;
  gap: .2rem;
  align-items: end;
  min-height: 160px;
}
.cols {
  grid-template-columns: repeat(14, minmax(0, 1fr));
  height: 180px;
}
.hours {
  grid-template-columns: repeat(24, minmax(0, 1fr));
  height: 140px;
}
.col, .hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
  animation: rise .4s ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.col-bars, .hour-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.col-bar {
  width: 26%;
  max-width: 9px;
  min-height: 0;
  border-radius: 3px 3px 1px 1px;
  transition: height .25s ease;
}
.sub code {
  font-size: .78em;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  padding: .05rem .28rem;
  border-radius: 3px;
}
.col-bar--root { background: var(--root); }
.col-bar--notes { background: var(--notes); }
.col-bar--article { background: var(--article); }
.col-bar--req { background: var(--req); opacity: .85; }
.col-label, .hour-label {
  margin-top: .35rem;
  font-size: .62rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hour--quiet { opacity: .35; }

@media (max-width: 640px) {
  .cols { height: 150px; }
  .hours { height: 120px; overflow-x: auto; grid-template-columns: repeat(24, 1.4rem); }
  .col-label { font-size: .55rem; transform: rotate(-45deg); transform-origin: top center; margin-top: .55rem; }
  .hour-label { font-size: .55rem; }
}

.split {
  display: grid;
  gap: .8rem;
}
@media (min-width: 720px) {
  .split { grid-template-columns: 1fr 1fr; }
  .split--3 { grid-template-columns: 1fr 1fr 1fr; }
}

.table-wrap {
  margin-top: .85rem;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  padding-top: .55rem;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: .38rem .4rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: .72rem;
}
.data-table td.mono { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; }
.data-table td.muted { color: var(--muted); }
.data-table td.is-warn { color: var(--cinnabar-deep); font-weight: 600; }
.data-table .empty-cell { color: var(--muted); text-align: center; }
.data-table--compact td:first-child { width: 2.5rem; }

.page { max-width: 1040px; }

.table { font-size: .82rem; }
.tr {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: .15rem .5rem;
  padding: .42rem 0;
  border-bottom: 1px solid var(--line);
  animation: rise .35s ease both;
  animation-delay: calc(var(--i, 0) * 25ms);
}
.tr:last-child { border-bottom: 0; }
.tr .ip {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  word-break: break-all;
  font-size: .8rem;
}
.tr .hits {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.tr-bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  overflow: hidden;
}
.tr-bar > i {
  display: block;
  height: 100%;
  background: var(--root);
  border-radius: inherit;
}
#notes-ips .tr-bar > i { background: var(--notes); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .28rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cinnabar) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--cinnabar) 18%, transparent);
  font-size: .78rem;
  animation: rise .35s ease both;
  animation-delay: calc(var(--i, 0) * 30ms);
}
.chip b { font-weight: 600; color: var(--ink); }
.chip em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }

.foot-note {
  margin: .45rem 0 0;
  font-size: .74rem;
  color: var(--muted);
  line-height: 1.5;
}

.empty { color: var(--muted); font-size: .86rem; padding: .35rem 0; margin: 0; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .card, .article, .col, .hour, .tr, .chip, .article-bar > i {
    animation: none !important;
  }
}
