:root {
  --theme-color: #1d7a68;
  --content-max-width: 920px;
  --line-soft: #dfe4da;
  --surface: #ffffff;
  --surface-soft: #eef6f3;
  --ink: #20241f;
  --muted: #6b7268;
}

body {
  color: var(--ink);
  background: #f7f8f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-name-link {
  color: #1d7a68;
  font-size: 1.18rem;
  font-weight: 800;
}

.sidebar {
  border-right: 1px solid var(--line-soft);
  background: #fff;
}

.sidebar ul {
  padding-left: 18px;
}

.sidebar ul li {
  margin: 2px 0;
}

.sidebar ul li p {
  margin: 0;
}

.sidebar ul li a {
  color: #39413b;
  line-height: 1.55;
  text-decoration: none;
}

.sidebar > ul > li > a {
  color: #1d342f;
  font-weight: 700;
}

.sidebar ul li ul li > a {
  color: #1d564c;
  font-weight: 650;
}

.sidebar ul li ul li ul li > a {
  color: #39413b;
  font-weight: 500;
}

.sidebar ul li.active > a {
  color: #1d7a68;
  border-right: 0 !important;
  font-weight: 700;
}

.sidebar li.nav-date > a {
  display: none;
}

.sidebar .toc-date-row {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

.sidebar .toc-toggle {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: #7d8982;
  background: transparent;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.sidebar .toc-toggle:hover,
.sidebar .toc-toggle:focus-visible {
  color: #1d7a68;
  background: #eef6f3;
  outline: none;
}

.sidebar li.nav-date.nav-open > .toc-date-row .toc-toggle,
.sidebar li.nav-date.nav-open > p > .toc-date-row .toc-toggle {
  transform: rotate(90deg);
}

.sidebar .toc-date-link {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding-right: 6px;
}

.sidebar .toc-problem-link,
.sidebar .toc-subject-link {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
}

.sidebar li.nav-date:not(.nav-open) > ul {
  display: none;
}

.sidebar li.nav-current > a {
  color: #1d7a68;
  font-weight: 700;
}

.section-anchor {
  display: block;
  position: relative;
  top: -18px;
  height: 0;
  overflow: hidden;
}

.content {
  padding-top: 12px;
}

.mobile-bottom-nav {
  display: none;
}

.study-drawer-button,
.study-drawer,
.study-drawer-backdrop {
  display: none;
}

.markdown-section {
  max-width: var(--content-max-width);
  padding: 28px 28px 56px;
  line-height: 1.72;
  font-size: 16px;
}

.markdown-section h1,
.markdown-section h2,
.markdown-section h3,
.markdown-section h4 {
  color: #17211d;
  letter-spacing: 0;
}

.markdown-section h1 {
  font-size: 1.86rem;
  margin-bottom: 0.72rem;
}

.markdown-section h2 {
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0.36rem;
  font-size: 1.45rem;
  margin-top: 1.45rem;
}

.markdown-section h3 {
  margin-top: 1.55rem;
  font-size: 1.18rem;
}

.markdown-section h2[id^="-"],
.markdown-section h2[id^="_"] {
  color: #1d564c;
}

.markdown-section h2 {
  scroll-margin-top: 18px;
}

.markdown-section h3 {
  scroll-margin-top: 18px;
}

.markdown-section h3[id*="错题"],
.markdown-section h3:has(a[href*="错题"]) {
  border-left: 4px solid #1d7a68;
  padding-left: 10px;
  color: #1d342f;
}

.markdown-section a {
  color: #1d7a68;
}

.markdown-section p a:has(img),
.markdown-section a:has(img),
.image-link {
  display: block;
  border-bottom: 0;
}

.markdown-section blockquote {
  border-left: 4px solid #1d7a68;
  color: #39413b;
  background: #e8f4f1;
}

.markdown-section code {
  border-radius: 4px;
  color: #20362f;
  background: #eef2ec;
  overflow-wrap: anywhere;
}

.markdown-section pre {
  border-radius: 8px;
  background: #eef2ec;
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.markdown-section table {
  display: block;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.markdown-section img,
.image-link img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto 18px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
}

.markdown-section a img,
.image-link img {
  cursor: zoom-in;
}

.markdown-section ul,
.markdown-section ol {
  padding-left: 1.35rem;
}

.markdown-section li {
  margin: 0.28rem 0;
}

.markdown-section li input[type="checkbox"] {
  width: 1.05em;
  height: 1.05em;
  margin: 0 0.42em 0.16em -1.15em;
  vertical-align: middle;
  accent-color: #1d7a68;
}

.markdown-section li:has(input[type="checkbox"]) {
  list-style: none;
  margin: 0.12rem 0 0.12rem 0.12rem;
  padding: 0.04rem 0.16rem;
  border-radius: 6px;
}

.markdown-section li:has(input[type="checkbox"]:checked) {
  color: #5f6963;
  background: transparent;
}

.publish-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
  color: #4e5b55;
  font-size: 0.82rem;
}

.publish-meta span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px 8px;
  background: #f2f6f3;
  line-height: 1.45;
}

.markdown-section .publish-meta + h1,
.markdown-section .publish-meta + h2,
.markdown-section .publish-meta + .section-anchor + h1,
.markdown-section .publish-meta + .section-anchor + h2 {
  margin-top: 8px !important;
}

.markdown-section .publish-meta ~ .section-anchor:first-of-type + h1,
.markdown-section .publish-meta ~ .section-anchor:first-of-type + h2 {
  margin-top: 8px !important;
}

.markdown-section .publish-meta + .today-summary {
  margin-top: 8px;
}

.markdown-section .today-summary + h1,
.markdown-section .today-summary + h2,
.markdown-section .today-summary + .section-anchor + h1,
.markdown-section .today-summary + .section-anchor + h2 {
  margin-top: 14px !important;
}

.markdown-section .publish-meta + .section-anchor {
  margin: 0;
  padding: 0;
}

.doc-nav {
  display: flex;
  gap: 8px;
  margin: -4px 0 10px;
  padding-bottom: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.doc-nav-link {
  flex: 0 0 auto;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 5px 11px;
  color: #1d564c;
  background: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.doc-nav-link.active {
  border-color: #1d7a68;
  color: #fff;
  background: #1d7a68;
}

.markdown-section th {
  background: #f2f5ef;
}

.markdown-section tr {
  border-top: 1px solid var(--line-soft);
}

.markdown-section td,
.markdown-section th {
  border: 1px solid var(--line-soft);
  padding: 8px 10px;
}

.search {
  border-bottom: 1px solid var(--line-soft);
}

.search input {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 10px;
}

.search .matching-post {
  padding: 8px 2px;
}

.search .matching-post h2 {
  line-height: 1.35;
}

.search .matching-post p {
  line-height: 1.5;
}

.study-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 24px;
}

.study-card {
  display: block;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}

.study-card:hover {
  border-color: #1d7a68;
}

.study-card strong {
  display: block;
  margin-bottom: 0;
  color: #1d7a68;
  font-size: 1rem;
}

.home-updated {
  margin-top: -8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

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

.summary-chip {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.summary-chip span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.summary-chip strong {
  display: block;
  color: #20362f;
  font-size: 1rem;
}

@media (max-width: 768px) {
  body {
    background: #fbfcf8;
  }

  .content {
    padding-top: 8px;
  }

  .markdown-section {
    padding: 16px 14px 92px;
    font-size: 16px;
    line-height: 1.76;
  }

  .markdown-section h1 {
    font-size: 1.48rem;
    line-height: 1.25;
    margin: 0 0 0.42rem !important;
  }

  .markdown-section h2 {
    font-size: 1.22rem;
    margin-top: 1rem;
  }

  .markdown-section .publish-meta + h1,
  .markdown-section .publish-meta + h2,
  .markdown-section .publish-meta + .section-anchor + h1,
  .markdown-section .publish-meta + .section-anchor + h2,
  .markdown-section .publish-meta ~ .section-anchor:first-of-type + h1,
  .markdown-section .publish-meta ~ .section-anchor:first-of-type + h2 {
    margin-top: 0.38rem !important;
  }

  .markdown-section .publish-meta + .today-summary {
    margin-top: 8px;
  }

  .markdown-section .today-summary + h1,
  .markdown-section .today-summary + h2,
  .markdown-section .today-summary + .section-anchor + h1,
  .markdown-section .today-summary + .section-anchor + h2 {
    margin-top: 0.65rem !important;
  }

  .markdown-section .publish-meta + .section-anchor {
    margin: 0;
    padding: 0;
  }

  .markdown-section h3 {
    font-size: 1.06rem;
    margin-top: 1.25rem;
  }

  .markdown-section img,
  .image-link img {
    width: 100%;
    border-radius: 6px;
    margin: 10px auto 16px;
  }

  .markdown-section table {
    font-size: 0.92rem;
  }

  .markdown-section pre {
    font-size: 0.88rem;
  }

  .markdown-section ul,
  .markdown-section ol {
    padding-left: 1.18rem;
  }

  .sidebar,
  .sidebar-toggle {
    display: none !important;
  }

  .content,
  body.close .content {
    left: 0 !important;
    transform: none !important;
  }

  .study-drawer-button {
    position: fixed;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 80;
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border: 1px solid rgba(29, 122, 104, 0.16);
    border-radius: 14px;
    color: #1d7a68;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 5px 16px rgba(24, 47, 40, 0.1);
    backdrop-filter: blur(8px);
  }

  .study-drawer-button span {
    width: 17px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .study-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 68;
    display: block;
    background: rgba(20, 28, 24, 0.26);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease;
  }

  .study-drawer-backdrop[hidden] {
    display: none;
  }

  .study-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 75;
    display: flex;
    width: min(82vw, 320px);
    max-width: 320px;
    flex-direction: column;
    border-right: 1px solid var(--line-soft);
    background: #fff;
    box-shadow: 10px 0 28px rgba(24, 47, 40, 0.12);
    transform: translateX(-102%);
    transition: transform 0.18s ease;
  }

  body.study-drawer-open .study-drawer {
    transform: translateX(0);
  }

  body.study-drawer-open .study-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .study-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 18px 12px;
    color: #20362f;
  }

  .study-drawer-header strong {
    font-size: 1.12rem;
    font-weight: 800;
  }

  .study-drawer-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    color: #52605a;
    background: #f2f6f3;
    font-size: 1.25rem;
    line-height: 1;
  }

  .study-drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 18px 86px;
    -webkit-overflow-scrolling: touch;
  }

  .study-drawer-subject {
    margin: 10px 0 14px;
  }

  .study-drawer-subject-link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    color: #1d342f;
    font-weight: 760;
    text-decoration: none;
  }

  .study-drawer-subject.is-current > .study-drawer-subject-link {
    color: #1d7a68;
  }

  .study-drawer-date {
    margin: 2px 0 4px;
  }

  .study-drawer-date-toggle {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    border: 0;
    border-radius: 8px;
    padding: 2px 8px 2px 0;
    color: #1d564c;
    background: transparent;
    font: inherit;
    font-weight: 760;
  }

  .study-drawer-chevron {
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #7d8982;
    transition: transform 0.12s ease, background-color 0.12s ease;
  }

  .study-drawer-date-toggle:active .study-drawer-chevron {
    background: #eef6f3;
  }

  .study-drawer-date.is-open .study-drawer-chevron {
    color: #1d7a68;
    transform: rotate(90deg);
  }

  .study-drawer-problems {
    display: grid;
    gap: 2px;
    margin: 0 0 8px 34px;
  }

  .study-drawer-problems[hidden] {
    display: none !important;
  }

  .study-drawer-problem-link {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    color: #39413b;
    font-weight: 520;
    text-decoration: none;
  }

  .study-drawer-problem-link.is-current {
    color: #1d7a68;
    font-weight: 760;
  }

  .sidebar ul {
    padding-left: 14px;
  }

  .sidebar ul li {
    margin: 1px 0;
  }

  .sidebar ul li a {
    line-height: 1.45;
  }

  .sidebar .toc-date-row {
    min-height: 32px;
  }

  .sidebar .toc-toggle {
    width: 34px;
    height: 32px;
    flex-basis: 34px;
    border-radius: 9px;
  }

  .sidebar .toc-date-link {
    min-height: 32px;
  }

  .sidebar .toc-problem-link,
  .sidebar .toc-subject-link {
    min-height: 30px;
  }

  .study-card-grid {
    grid-template-columns: 1fr;
    gap: 7px;
    margin: 12px 0 20px;
  }

  .today-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin: 10px 0 14px;
  }

  .summary-chip {
    padding: 8px 10px;
  }

  .study-card {
    padding: 9px 11px;
  }

  .study-card strong {
    margin-bottom: 2px;
  }

  .doc-nav {
    display: none;
  }

  .publish-meta {
    gap: 4px;
    margin: 0 0 6px;
    font-size: 0.78rem;
  }

  .publish-meta span {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 0;
    border-radius: 6px;
    padding: 3px 6px;
    overflow-wrap: anywhere;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 12px;
    bottom: max(9px, env(safe-area-inset-bottom));
    left: 74px;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    border: 1px solid rgba(29, 122, 104, 0.16);
    border-radius: 14px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 5px 16px rgba(24, 47, 40, 0.1);
    backdrop-filter: blur(8px);
  }

  .mobile-bottom-nav-link {
    position: relative;
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    padding: 3px 2px 5px;
    color: #1d564c;
    font-size: 0.82rem;
    font-weight: 750;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
  }

  .mobile-bottom-nav-link.active {
    color: #1d7a68;
    background: #f6fbf8;
  }

  .mobile-bottom-nav-link.active::after {
    position: absolute;
    right: 30%;
    bottom: 2px;
    left: 30%;
    height: 2px;
    border-radius: 999px;
    background: #1d7a68;
    content: "";
  }
}
