@font-face {
  font-family: "Taoyuan WenKai";
  src: url("/fonts/lxgw-wenkai-gb-lite-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Taoyuan Fangsong";
  src: url("/fonts/zhuque-fangsong-gb-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Taoyuan Source Han Serif";
  src: url("/fonts/source-han-serif-cn-gb-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-system-serif: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  --font-reading: var(--font-system-serif);
  --font-display: var(--font-system-serif);
}

:root[data-reading-typeface="wenkai"] {
  --font-reading: "Taoyuan WenKai", "Kaiti SC", KaiTi, var(--font-system-serif);
  --font-display: "Taoyuan WenKai", "Kaiti SC", KaiTi, var(--font-system-serif);
}

:root[data-reading-typeface="fangsong"] {
  --font-reading: "Taoyuan Fangsong", FangSong, STFangsong, var(--font-system-serif);
  --font-display: "Taoyuan Fangsong", FangSong, STFangsong, var(--font-system-serif);
}

:root[data-reading-typeface="sourceHan"] {
  --font-reading: "Taoyuan Source Han Serif", "Noto Serif CJK SC", var(--font-system-serif);
  --font-display: "Taoyuan Source Han Serif", "Noto Serif CJK SC", var(--font-system-serif);
}

.typefacePicker {
  position: relative;
  flex: 0 0 auto;
  font-family: var(--font-ui);
}

.siteHeader > .typefacePicker {
  margin-left: auto;
}

.typefaceTrigger {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(151, 131, 98, 0.26);
  border-radius: 11px;
  color: var(--pine, #31584d);
  background: rgba(255, 253, 248, 0.78);
  font-family: var(--font-system-serif);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.typefaceTrigger:hover,
.typefaceTrigger[aria-expanded="true"] {
  border-color: rgba(49, 88, 77, 0.4);
  background: var(--pine-soft, #dfe9e3);
}

.typefacePanel {
  position: absolute;
  z-index: 120;
  top: calc(100% + 10px);
  right: 0;
  width: min(370px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid rgba(151, 131, 98, 0.28);
  border-radius: 18px;
  color: var(--ink, #272822);
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 24px 62px rgba(54, 45, 31, 0.2);
  backdrop-filter: blur(18px);
}

.typefacePanel[hidden] {
  display: none;
}

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

.typefacePanelHeader strong {
  display: block;
  color: var(--ink, #272822);
  font-size: 16px;
}

.typefacePanelHeader p {
  margin: 4px 0 0;
  color: var(--ink-soft, #625f56);
  font-size: 11px;
  line-height: 1.55;
}

.typefacePanelClose {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft, #625f56);
  background: transparent;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.typefacePanelClose:hover {
  background: rgba(49, 88, 77, 0.07);
}

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

.typefaceChoice {
  position: relative;
  min-width: 0;
  min-height: 112px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  border: 1px solid rgba(151, 131, 98, 0.23);
  border-radius: 13px;
  color: var(--ink, #272822);
  background: rgba(245, 241, 232, 0.66);
  text-align: left;
  cursor: pointer;
}

.typefaceChoice:hover {
  border-color: rgba(49, 88, 77, 0.36);
  background: rgba(255, 255, 255, 0.88);
}

.typefaceChoice[aria-pressed="true"] {
  border-color: var(--cinnabar, #a44735);
  background: rgba(255, 253, 248, 0.98);
  box-shadow: inset 0 0 0 1px rgba(164, 71, 53, 0.12);
}

.typefaceSample {
  margin-bottom: 12px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}

.typefaceChoice[data-typeface-value="system"] .typefaceSample {
  font-family: var(--font-system-serif);
}

.typefaceChoice[data-typeface-value="wenkai"] .typefaceSample {
  font-family: "Taoyuan WenKai", var(--font-system-serif);
}

.typefaceChoice[data-typeface-value="fangsong"] .typefaceSample {
  font-family: "Taoyuan Fangsong", var(--font-system-serif);
}

.typefaceChoice[data-typeface-value="sourceHan"] .typefaceSample {
  font-family: "Taoyuan Source Han Serif", var(--font-system-serif);
}

.typefaceChoice strong {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 750;
}

.typefaceChoice small {
  margin-top: 3px;
  color: var(--ink-soft, #625f56);
  font-family: var(--font-ui);
  font-size: 10px;
  line-height: 1.4;
}

.typefaceCheck {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  display: none;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--cinnabar, #a44735);
  font-family: var(--font-ui);
  font-size: 11px;
}

.typefaceChoice[aria-pressed="true"] .typefaceCheck {
  display: grid;
}

.typefaceStatus {
  min-height: 17px;
  margin: 11px 2px 0;
  color: var(--ink-soft, #625f56);
  font-family: var(--font-ui);
  font-size: 10px;
  line-height: 1.5;
}

.typefaceStatus[data-kind="error"] {
  color: var(--cinnabar, #a44735);
}

@media (max-width: 700px) {
  .typefacePanel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    bottom: auto;
    left: auto;
    width: min(370px, calc(100vw - 20px));
    max-height: min(calc(100vh - 84px), 620px);
    max-height: min(calc(100dvh - 84px), 620px);
    overflow: auto;
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(54, 45, 31, 0.25);
  }

  .typefaceTrigger {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 380px) {
  .typefacePanel {
    padding: 15px;
  }

  .typefaceGrid {
    gap: 8px;
  }

  .typefaceChoice {
    min-height: 104px;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typefacePanel,
  .typefaceChoice,
  .typefaceTrigger {
    transition: none !important;
  }
}
