:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-soft: #eeeeee;
  --ink: #111111;
  --muted: #666666;
  --line: #d8d8d8;
  --accent: #111111;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: block;
  margin-bottom: 18px;
}

.site-title {
  margin: 0;
  color: var(--accent);
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-style: italic;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab,
.plain-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.tab {
  padding: 0 14px;
}

.tab.is-active {
  border-color: rgba(17, 17, 17, 0.45);
  background: var(--accent);
  color: #ffffff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.selectors {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) 92px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafafa;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(17, 17, 17, 0.18);
  border-color: var(--accent);
}

.plain-button:hover,
.tab:hover {
  border-color: rgba(17, 17, 17, 0.5);
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}

.directory-panel,
.reader-panel,
.history-table-wrap,
.history-summary article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.directory-panel {
  position: sticky;
  top: 16px;
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading span,
.directory-section span,
.item-card p {
  color: var(--muted);
}

.directory-list {
  display: grid;
  gap: 10px;
}

.directory-section {
  display: grid;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.directory-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.directory-section button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.directory-section button:hover {
  color: var(--accent);
}

.directory-items {
  display: grid;
  gap: 4px;
  padding-left: 10px;
}

.directory-items button {
  color: var(--muted);
  font-size: 0.9rem;
}

.reader-panel {
  min-height: 540px;
  padding: 18px;
}

.reader-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.reader-title p {
  margin-bottom: 0;
  color: var(--muted);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.item-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  text-align: left;
  cursor: pointer;
}

.item-card:hover {
  border-color: rgba(17, 17, 17, 0.5);
}

.item-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.35;
}

.item-card p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.note-content p,
.note-content ul,
.note-content ol {
  margin: 0 0 0.9rem;
}

.note-content ul,
.note-content ol {
  padding-left: 1.35rem;
}

.note-content li + li {
  margin-top: 0.25rem;
}

.note-content h1 {
  margin: 0 0 1rem;
  font-size: 2rem;
  line-height: 1.15;
}

.note-content h2 {
  margin: 1.4rem 0 0.7rem;
  font-size: 1.25rem;
  line-height: 1.3;
}

.note-content h3,
.note-content h4,
.note-content h5 {
  margin: 1.2rem 0 0.45rem;
}

.note-content hr {
  height: 1px;
  margin: 1.35rem 0;
  border: 0;
  background: var(--line);
}

.note-content blockquote {
  margin: 1rem 0 1.2rem;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface-soft);
  color: var(--ink);
}

.note-content blockquote p:last-child {
  margin-bottom: 0;
}

.note-content img,
.note-content video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
}

.note-content figure {
  margin: 14px 0;
}

.note-content figcaption {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.note-content a,
.text-link {
  color: var(--accent);
  font-weight: 750;
}

.markdown-table {
  margin: 0.8rem 0 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.markdown-table table {
  min-width: 680px;
}

.markdown-table th,
.markdown-table td {
  padding: 10px 12px;
}

.markdown-table th {
  white-space: nowrap;
}

.markdown-meta {
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.markdown-meta strong {
  color: var(--ink);
}

.plan-document {
  margin-top: 0;
  padding: 24px;
}

.plan-document .note-content {
  color: #222222;
}

.plan-document .note-content table {
  min-width: 640px;
}

.calendar-heading {
  align-items: flex-start;
}

.calendar-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.calendar-years {
  display: grid;
  gap: 16px;
}

.contribution-panel {
  overflow: hidden;
}

.contribution-scroll {
  --calendar-cell-size: 14px;
  --calendar-cell-gap: 4px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}

.contribution-months {
  display: grid;
  gap: var(--calendar-cell-gap);
  margin-left: 42px;
  margin-bottom: 6px;
  min-width: max-content;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.contribution-months span {
  min-width: var(--calendar-cell-size);
  height: 18px;
  overflow: visible;
  white-space: nowrap;
}

.contribution-body {
  display: flex;
  gap: 8px;
  min-width: max-content;
}

.contribution-weekdays {
  flex: 0 0 34px;
  display: grid;
  grid-template-rows: repeat(7, var(--calendar-cell-size));
  gap: var(--calendar-cell-gap);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: var(--calendar-cell-size);
  text-align: right;
}

.contribution-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--calendar-cell-size));
  gap: var(--calendar-cell-gap);
  min-width: max-content;
}

.contribution-cell {
  width: var(--calendar-cell-size);
  height: var(--calendar-cell-size);
  display: block;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 3px;
  background: #e9e9e9;
}

.contribution-cell[tabindex="0"] {
  cursor: default;
}

.contribution-cell[tabindex="0"]:focus-visible {
  outline: 3px solid rgba(17, 17, 17, 0.2);
  outline-offset: 2px;
}

.contribution-cell.level-1 {
  background: #dcdcdc;
}

.contribution-cell.level-2 {
  background: #b9b9b9;
}

.contribution-cell.level-3 {
  background: #777777;
}

.contribution-cell.level-4 {
  background: #222222;
}

.contribution-cell.is-outside-year {
  border-color: transparent;
  background: transparent;
}

.history-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.history-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
}

.range-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.history-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(150px, 0.9fr) minmax(220px, 1.35fr) 42px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(17, 17, 17, 0.45);
  background: #eeeeee;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-heading span {
  color: var(--muted);
}

.weight-trends-section {
  margin-bottom: 14px;
}

.weight-trend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.weight-trend-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.weight-trend-heading,
.weight-trend-dates {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.weight-trend-heading h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weight-trend-dates {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.weight-trend-chart {
  width: 100%;
  height: 122px;
  margin-top: 10px;
  overflow: visible;
}

.weight-axis {
  stroke: #dddddd;
  stroke-width: 1;
}

.weight-axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.weight-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.weight-points circle {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

.weight-trend-dates {
  margin-top: 2px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}


.table-panel {
  padding: 0;
}

.table-panel .panel-heading {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap,
.history-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8f8f8;
  color: var(--muted);
  font-size: 0.82rem;
}


.cell-muted {
  color: var(--muted);
}

.empty-state {
  padding: 28px 16px 32px;
  color: var(--muted);
  text-align: center;
}

.empty {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .selectors,
  .history-toolbar,
  .library-layout,
  .weight-trend-grid {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    align-items: stretch;
  }

  .icon-button {
    width: 100%;
  }

  .directory-panel {
    position: static;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1220px);
    padding-top: 18px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .tab {
    padding: 0 8px;
  }

  .plan-document {
    padding: 16px;
  }

  .plan-document .note-content table {
    min-width: 560px;
  }

  .history-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .range-badge {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }

  .calendar-heading {
    align-items: flex-start;
    flex-direction: column;
  }

}
