:root {
  color-scheme: dark;
  --bg: #121212;
  --text: rgb(212 212 216);
  --muted: rgb(161 161 170);
  --card: #1d1d1d;
  --border: #33302a;
  --page-width: 640px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  overflow-y: auto;
  scrollbar-gutter: stable;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 19px;
  line-height: 1.75;
}

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

:is(.post-content, .thought-preview, .thought-content) a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: #fff;
}

.site-header,
.site-main,
.site-footer {
  width: min(100% - 32px, var(--page-width));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0;
  font-family: "Page Title Latin", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "Songti TC", "LiSong Pro", "Noto Serif CJK TC", "Source Han Serif TC", serif;
  font-weight: 400;
  font-synthesis: none;
}

.site-title {
  font-size: 1.1rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
}

.nav-short {
  display: none;
}

@media (max-width: 640px) {
  .site-header,
  .site-nav {
    flex-wrap: nowrap;
    gap: 12px;
  }

  .site-title,
  .site-nav > a {
    position: relative;
    white-space: nowrap;
  }

  .nav-full {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .nav-short {
    display: inline;
  }
}

.lang-switch {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.lang-switch:hover {
  border-color: var(--text);
  color: #fff;
  text-decoration: none;
}

.site-main {
  padding: 48px 0 64px;
}

.heat {
  min-height: 117px;
  margin-bottom: 36px;
}

.heat-scroll {
  overflow: hidden;
}

.heat-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  height: 16px;
  margin: 0 0 6px 22px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 16px;
}

.heat-months span {
  overflow: visible;
  white-space: nowrap;
}

.heat-body {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.heat-days {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  width: 16px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 11px;
}

.heat-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
}

.heat-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #3a3a3a;
}

.heat-cell.is-future {
  opacity: 0.2;
}

.heat-cell[data-level="1"] {
  background: #196c2e;
}

.heat-cell[data-level="2"] {
  background: #2ea043;
}

.heat-cell[data-level="3"] {
  background: #56d364;
}

time,
.updated-at,
.thought-date {
  color: rgb(161 161 170);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

h2,
h3,
.page-title {
  line-height: 1.2;
}

/* Latin in .page-title: a bold sans installed in the regular-weight slot.
   CJK falls through unicode-range to Songti at font-weight 400. */
@font-face {
  font-family: "Page Title Latin";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"), local("Arial Bold"), local("Arial-BoldMT"), local("Segoe UI Bold"), local("SegoeUI-Bold");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2197, U+2212, U+2215, U+FEFF, U+FFFD;
}

a[target="_blank"] {
  text-decoration: underline;
  text-underline-offset: 2px;
}

a[target="_blank"]::after {
  content: "↗";
  margin-left: 0.12em;
  font-family: "Page Title Latin", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72em;
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  vertical-align: super;
  text-decoration: none;
}

.page-title {
  margin: 0 0 16px;
  font-family: "Page Title Latin", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", "Songti TC", "LiSong Pro", "Noto Serif CJK TC", "Source Han Serif TC", serif;
  font-size: clamp(1.25rem, 2.2vw, 1.45rem);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: -0.06em;
}

.page-header {
  margin-bottom: 36px;
}

.post-list,
.thought-list {
  display: grid;
  gap: 18px;
}

#home-feed .is-older {
  display: none;
}

#home-feed:target .is-older {
  display: block;
}

#home-feed:not(:target) .thought-preview:not(.is-expanded),
#home-feed:not(:target) .post-card > p:not(.entry-kind):not(.is-expanded) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

#home-feed:not(:target) .thought-preview.is-clamped,
#home-feed:not(:target) .post-card > p.is-clamped {
  cursor: pointer;
}

#home-feed:not(:target) .thought-preview:not(.is-expanded) *:not(table):not(thead):not(tbody):not(tr):not(th):not(td) {
  display: inline;
}

#home-feed:not(:target) .thought-preview:not(.is-expanded) > * + *::before {
  content: " ";
}

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(0 0 0 / 86%);
  cursor: zoom-out;
}

.img-lightbox[hidden] {
  display: none;
}

.img-lightbox img {
  max-width: min(100%, 960px);
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 12px;
  cursor: zoom-out;
}

.list-more {
  margin: 22px 0 0;
}

.list-more a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

#home-feed:target + .list-more {
  display: none;
}

.post-card,
.thought-card {
  min-width: 0;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.entry-kind {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post-card h2,
.post-card h3 {
  margin: 0 0 8px;
}

.post-card p {
  margin-bottom: 0;
}

:is(.thought-content, .thought-preview) p {
  margin-top: 0;
}

:is(.thought-content, .thought-preview) p:last-child {
  margin-bottom: 0;
}

.thought-date {
  display: inline-block;
  margin-top: 14px;
  text-decoration: none;
}

strong,
b {
  color: #fff;
  font-weight: 700;
}

:is(.post-content, .thought-content, .thought-preview) :is(code, pre, blockquote) {
  color: inherit;
  font-family: inherit;
  font-style: italic;
  font-weight: 400;
}

:is(.post-content, .thought-content, .thought-preview) :not(pre) > code {
  font-size: 1em;
}

:is(.post-content, .thought-content, .thought-preview) pre {
  max-width: 100%;
  margin: 0 0 0.85em;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

:is(.post-content, .thought-content, .thought-preview) :is(ol, ul) {
  margin: 0.35em 0 0.85em;
  padding-left: 1.4em;
}

:is(.post-content, .thought-content, .thought-preview) pre code {
  font-size: inherit;
}

:is(.post-content, .thought-content) img {
  display: block;
  max-width: 100%;
  margin-top: 1rem;
  border-radius: 12px;
}

.thought-preview img {
  display: block;
  width: auto;
  max-width: 64px;
  height: auto;
  margin-top: 1rem;
  border-radius: 12px;
  cursor: zoom-in;
}

:is(.post-content, .thought-content, .thought-preview) table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
}

:is(.post-content, .thought-content, .thought-preview) :is(th, td) {
  box-sizing: content-box;
  min-width: 4em;
  text-align: left;
  vertical-align: top;
  padding: 10px 20px 10px 0;
}

:is(.post-content, .thought-content, .thought-preview) :is(th, td):last-child {
  padding-right: 0;
}

:is(.post-content, .thought-content, .thought-preview) th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

:is(.post-content, .thought-content, .thought-preview) td {
  border-top: 1px solid var(--border);
}

.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a,
.site-footer a:hover {
  text-decoration: none;
}

.contact-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.contact-fab[hidden] {
  display: none;
}

.contact-fab-link {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
  text-decoration: none;
}

.contact-fab-link:hover {
  color: #fff;
}

.contact-fab-close {
  appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.contact-fab-close:hover {
  color: #fff;
}
