/* Timemark public article reader */
:root {
  color-scheme: light;
}

@media (min-width: 1081px) {
  html:has(.post-page),
  body:has(.post-page) {
    overflow-x: visible !important;
  }
}

.post-page {
  background:
    linear-gradient(180deg, #ffffff, rgba(248, 250, 248, 0.98) 560px),
    #f7f8f5 !important;
  max-width: none !important;
  width: 100% !important;
}

.post-page .site-header {
  max-width: none !important;
  width: 100vw !important;
}

.post-page .post {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  max-width: min(1360px, calc(100vw - 64px)) !important;
  overflow: visible !important;
  padding: clamp(8px, 2vw, 20px) 0 0 !important;
  width: min(1360px, calc(100vw - 64px)) !important;
}

.post-page .post-head {
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 820px !important;
}

.post-reading-layout {
  align-items: start;
  display: grid;
  gap: clamp(36px, 4vw, 56px);
  grid-template-columns: minmax(0, 840px);
  justify-content: center;
  margin: clamp(24px, 4vw, 44px) auto 0;
  max-width: 1360px;
}

.post-reading-layout.has-toc {
  grid-template-columns: minmax(0, 840px) minmax(280px, 320px);
  justify-content: center;
}

.post-reading-main {
  min-width: 0;
}

.post-reading-main .content,
.post-page .content {
  color: #263545 !important;
  font-size: clamp(18px, 1.25vw, 20px) !important;
  line-height: 1.9 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

.post-page .post-cover-frame,
.post-page .reading-toolbar {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
}

.post-reading-sidebar {
  align-self: stretch;
  min-width: 0;
}

.post-toc-backdrop,
.post-toc-fab {
  display: none;
}

.post-reading-sidebar .post-toc {
  background: rgba(255, 255, 255, 0.88) !important;
  border: 1px solid #dce7e2 !important;
  border-radius: 14px !important;
  box-shadow: 0 18px 46px rgba(18, 26, 36, 0.08) !important;
  display: block !important;
  margin: 0 !important;
  max-height: calc(100vh - 130px);
  max-width: none !important;
  overflow: auto;
  padding: 0 !important;
  position: sticky;
  top: 96px;
  width: 100%;
}

.post-toc-head {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid #e4ebe8;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px 18px;
}

.post-toc-title {
  align-items: center;
  color: #172233;
  display: inline-flex;
  font-size: 16px;
  gap: 10px;
  min-width: 0;
}

.post-toc-title strong {
  color: inherit !important;
  font-size: inherit !important;
  line-height: 1.2;
}

.post-toc-icon {
  color: #4f6df5;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.post-toc-progress {
  color: #718096;
  font-size: 14px;
  font-weight: 820;
}

.post-toc-list {
  display: grid;
  gap: 4px;
  padding: 14px 12px 18px;
}

.post-toc-list a,
.post-reading-sidebar .post-toc a {
  border: 0 !important;
  border-radius: 10px;
  color: #526173 !important;
  display: block;
  font-size: 14px !important;
  font-weight: 650;
  line-height: 1.42;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 9px 10px !important;
  position: relative;
  text-overflow: clip;
  white-space: normal !important;
}

.post-toc-list a.toc-level-3 {
  color: #667585 !important;
  font-size: 13px !important;
  padding-left: 24px !important;
}

.post-toc-list a:hover {
  background: #f4f7fb;
  color: #2f4ff1 !important;
}

.post-toc-list a.active {
  background: #eef1ff;
  color: #3657f4 !important;
  font-weight: 840;
}

.post-toc-list a.active::before {
  background: #4f6df5;
  border-radius: 99px;
  content: "";
  height: 22px;
  left: -12px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
}

.post-page .content h2,
.post-page .content h3 {
  scroll-margin-top: 96px;
}

.post-page .content code {
  background: #eef4f1 !important;
  border: 1px solid #dfe8e4;
  border-radius: 5px;
  color: #9f1239 !important;
  font-size: 0.9em;
  padding: 0.12em 0.34em;
}

.post-page .content .code-block {
  background: #f8fafc !important;
  border: 1px solid #d8e2e7 !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 34px rgba(18, 26, 36, 0.08) !important;
  color: #263545 !important;
  overflow: hidden;
}

.post-page .content .code-block-head {
  background: #f2f6f7 !important;
  border-bottom: 1px solid #d8e2e7 !important;
  color: #334155 !important;
}

.post-page .content .code-block-head span {
  color: #334155 !important;
}

.post-page .content .copy-code-button {
  background: #ffffff !important;
  border: 1px solid #ccd8df !important;
  color: #334155 !important;
}

.post-page .content .copy-code-button:hover {
  background: #eef4f1 !important;
  color: #0f766e !important;
}

.post-page .content pre,
.post-page .content .code-block pre {
  background: #f8fafc !important;
  border: 0 !important;
  color: #263545 !important;
  margin: 0 !important;
}

.post-page .content pre code,
.post-page .content .code-block pre code {
  background: transparent !important;
  border: 0 !important;
  color: inherit !important;
  padding: 0 !important;
}

@media (prefers-color-scheme: dark) {
  body,
  .post-page {
    background:
      linear-gradient(180deg, #ffffff, rgba(248, 250, 248, 0.98) 560px),
      #f7f8f5 !important;
    color: #17202a !important;
  }

  .post-page .site-header,
  .post-reading-sidebar .post-toc,
  .post-page .comments,
  .post-page .post-nav a,
  .post-page .related-posts .post-card,
  .post-page .comment,
  .post-page .comment-form,
  .post-page .comment-empty {
    background-color: #ffffff !important;
    border-color: #dfe8e4 !important;
    color: #17202a !important;
  }

  .post-page .post h1,
  .post-page .content h2,
  .post-page .content h3,
  .post-toc-title,
  .post-toc-title strong,
  .post-page .post-nav strong,
  .post-page .comment-form-head strong,
  .post-page .comment-empty strong {
    color: #111923 !important;
  }
}

@media (min-width: 1280px) {
  .post-page .post {
    max-width: calc(100vw - 96px) !important;
    width: calc(100vw - 96px) !important;
  }

  .post-reading-layout,
  .post-reading-layout.has-toc {
    --reader-gap: clamp(56px, 4vw, 76px);
    --reader-toc-width: 320px;
    --reader-main-width: min(1280px, calc(100vw - 96px - var(--reader-toc-width) - var(--reader-gap)));

    gap: var(--reader-gap);
    grid-template-columns: minmax(0, var(--reader-main-width)) var(--reader-toc-width);
    justify-content: center;
    margin-left: 0;
    margin-right: 0;
    max-width: none;
    width: 100%;
  }

  .post-reading-sidebar .post-toc {
    max-height: calc(100vh - 128px);
    position: sticky;
    right: auto;
    top: 108px;
    width: 100%;
    z-index: 8;
  }
}

@media (min-width: 1680px) {
  .post-page .post {
    max-width: calc(100vw - 144px) !important;
    width: calc(100vw - 144px) !important;
  }

  .post-reading-layout,
  .post-reading-layout.has-toc {
    --reader-gap: clamp(64px, 4vw, 84px);
    --reader-toc-width: 340px;
    --reader-main-width: min(1320px, calc(100vw - 144px - var(--reader-toc-width) - var(--reader-gap)));

    grid-template-columns: minmax(0, var(--reader-main-width)) var(--reader-toc-width);
  }

  .post-reading-sidebar .post-toc {
    right: auto;
    width: 100%;
  }
}

@media (max-width: 1080px) {
  .post-reading-layout,
  .post-reading-layout.has-toc {
    grid-template-columns: minmax(0, 760px);
  }

  .post-reading-sidebar {
    order: -1;
  }

  .post-reading-sidebar .post-toc {
    max-height: none;
    position: static;
  }

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

@media (max-width: 720px) {
  .post-page {
    padding-bottom: 82px;
    padding-top: 16px !important;
  }

  .post-page .site-header,
  .post-page .post {
    width: min(100%, calc(100vw - 28px)) !important;
  }

  .post-page .site-header {
    margin-bottom: 14px !important;
    width: 100vw !important;
  }

  .post-page .post {
    padding-top: 2px !important;
  }

  .post-page .post-head {
    margin-bottom: 16px !important;
    padding-bottom: 14px !important;
  }

  .post-page .post h1 {
    font-size: clamp(28px, 7.4vw, 32px) !important;
    line-height: 1.12 !important;
    margin: 8px 0 12px !important;
  }

  .post-page .post-summary {
    font-size: 16px !important;
    line-height: 1.58 !important;
    margin-top: 12px !important;
  }

  .post-page .post-reading-strip {
    align-items: center !important;
    flex-direction: row !important;
    display: flex !important;
    font-size: 13px !important;
    gap: 7px 12px !important;
    justify-content: flex-start !important;
    margin-top: 14px !important;
    padding: 9px 0 !important;
  }

  .post-page .post-reading-strip a {
    width: auto !important;
  }

  .post-page .reading-toolbar {
    display: none !important;
  }

  .post-reading-layout,
  .post-reading-layout.has-toc {
    gap: 0;
    margin-top: 16px;
  }

  .post-page .content {
    margin-top: 0 !important;
  }

  .post-page .content > :first-child {
    margin-top: 0 !important;
  }

  .post-page .content > h2:first-of-type {
    margin-top: 0 !important;
  }

  .post-reading-sidebar {
    min-height: 0;
    order: 0;
  }

  .post-reading-sidebar .post-toc {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 18px 18px 16px 16px !important;
    bottom: max(12px, env(safe-area-inset-bottom));
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2) !important;
    left: 12px;
    max-height: min(72vh, 560px);
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    position: fixed;
    right: 12px;
    top: auto;
    transform: translateY(calc(100% + 28px));
    transition: transform 0.24s ease, opacity 0.2s ease;
    width: auto;
    z-index: 80;
  }

  .post-reading-sidebar.open .post-toc {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .post-toc-backdrop {
    background: rgba(15, 23, 42, 0.22);
    border: 0;
    display: block;
    inset: 0;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity 0.2s ease;
    z-index: 70;
  }

  .post-reading-sidebar.open .post-toc-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .post-toc-fab {
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(207, 217, 223, 0.96);
    border-radius: 999px;
    bottom: max(14px, env(safe-area-inset-bottom));
    box-shadow: 0 14px 34px rgba(18, 26, 36, 0.18);
    color: #1f2937;
    display: flex;
    font: inherit;
    gap: 12px;
    justify-content: space-between;
    min-height: 48px;
    padding: 0 16px;
    position: fixed;
    right: 16px;
    width: 138px;
    z-index: 65;
  }

  .post-toc-fab span {
    align-items: center;
    display: inline-flex;
    font-size: 15px;
    font-weight: 780;
    gap: 8px;
  }

  .post-toc-fab strong {
    background: #eef2ff;
    border-radius: 999px;
    color: #3657f4;
    font-size: 13px;
    font-weight: 840;
    line-height: 1;
    padding: 7px 9px;
  }

  .post-toc-head {
    border-bottom-color: #e6ece9;
    padding: 16px 16px 14px;
  }

  .post-toc-list {
    grid-template-columns: 1fr;
    max-height: min(52vh, 420px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 10px 10px 14px;
  }

  .post-reading-main .content,
  .post-page .content {
    font-size: 17px !important;
    line-height: 1.84 !important;
  }

  html.toc-open {
    overflow: hidden;
  }
}
