:root {
  color-scheme: light;
  --paper: #f5f3ee;
  --surface: #eeece4;
  --soft-surface: #efede6;
  --ink: #242c27;
  --muted: #545f56;
  --line: #c9cdc2;
  --accent: #345247;
  --accent-ink: #fffefa;
  --focus: #396450;
  --nav-active: #345247;
  --control: transparent;
  --control-hover: #e4e9e0;
  --control-border: #a0aa9f;
  --rail-surface: rgb(245 243 238 / .95);
  --rail-border: var(--line);
  --dialog: #f9f7f1;
  --placeholder: var(--muted);
  --glass-shadow: 0 14px 40px rgb(33 46 36 / .13);
  --glass-shadow-hover: var(--glass-shadow);

  --serif: 'EB Garamond', 'Songti SC', SimSun, Georgia, serif;
  --hand: 'Ma Shan Zheng', KaiTi, STKaiti, serif;
  --sans: Inter, 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --display-size: clamp(2.5rem, 1.75rem + 3.8vw, 6rem);
  --heading-size: clamp(1.6rem, 1.35rem + 1.25vw, 2.65rem);
  --leading: 1.72;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-6: 48px;
  --space-8: 64px;
  --space-12: 96px;
  --gutter: clamp(20px, 5vw, 76px);
  --frame: 88rem;
  --radius-control: 5px;
  --radius-card: 8px;
  --radius-panel: 10px;
  --motion-fast: 180ms ease;
  --motion: 360ms cubic-bezier(.22, 1, .36, 1);
}

html:lang(zh-Hant) {
  --serif: 'EB Garamond', 'Songti TC', PMingLiU, 'Noto Serif TC', serif;
  --hand: 'Ma Shan Zheng', 'Kaiti TC', BiauKai, KaiTi, STKaiti, serif;
  --sans: Inter, 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', system-ui, sans-serif;
}

:root[data-theme='night'] {
  color-scheme: dark;
  --paper: #101924;
  --surface: #1a2735;
  --soft-surface: #162330;
  --ink: #edf0ed;
  --muted: #a8babf;
  --line: #394b56;
  --accent: #dfb878;
  --accent-ink: #101924;
  --focus: #a9d5cb;
  --nav-active: #bbe1d5;
  --control-hover: #273b48;
  --control-border: #627681;
  --rail-surface: rgb(16 25 36 / .95);
  --dialog: #1a2937;
  --glass-shadow: 0 14px 40px rgb(3 7 12 / .45);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); scroll-padding-top: 92px; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/var(--leading) var(--sans);
  overflow-wrap: anywhere;
}
a { color: inherit; text-underline-offset: .22em; text-decoration-thickness: 1px; }
a[href], a[href] * { cursor: pointer; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
h1, h2, h3 { margin-block-start: 0; }
h1 { margin-bottom: var(--space-2); font: 500 var(--display-size)/1.04 var(--serif); letter-spacing: -.035em; }
h2 { font: 500 var(--heading-size)/1.15 var(--serif); letter-spacing: -.02em; }
h3 { line-height: 1.35; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; }
button, .btn, input:not([type='range'], [type='checkbox'], [type='radio']), select, textarea {
  color: var(--ink);
  border: 1px solid var(--control-border);
  background: var(--control);
  border-radius: var(--radius-control);
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: 9px 16px;
  cursor: pointer;
  line-height: 1.35;
  text-decoration: none;
}
button:not(:disabled):hover, .btn:hover { background-color: var(--control-hover); }
button:disabled { cursor: default; opacity: .56; }
button[aria-pressed='true'] { background: var(--control-hover); border-color: var(--focus); }
.btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { color: var(--ink); background: var(--control-hover); border-color: var(--focus); }
input, select { min-height: 44px; max-width: 100%; padding: 8px 12px; }
input[type='range'] { padding: 0; accent-color: var(--focus); }
input[type='file'], textarea { min-width: 0; max-width: 100%; }
select option { color: var(--ink); background: var(--dialog); }
::placeholder { color: var(--placeholder); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
summary { min-height: 44px; cursor: pointer; }

.site-chrome {
  position: sticky;
  z-index: 40;
  top: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  transition: background-color var(--motion-fast);
}
.site-chrome.is-scrolled { background: var(--rail-surface); }
.site-scroll-marker { position: absolute; top: 0; width: 1px; height: 1px; }
@supports (backdrop-filter: blur(12px)) {
  .site-chrome.is-scrolled { backdrop-filter: blur(12px); }
}
.site-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: 'brand links actions';
  align-items: center;
  gap: clamp(12px, 2vw, 36px);
  width: min(calc(100% - 2 * var(--gutter)), var(--frame));
  min-height: 76px;
  margin-inline: auto;
}
.namebar { grid-area: brand; }
.name {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
}
.brand-circle {
  display: inline-block;
  flex: 0 0 28px;
  width: 28px;
  aspect-ratio: 1;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--nav-active);
}
@supports (mask-image: url('./favicon.svg')) {
  .brand-circle { border: 0; background: currentColor; mask: url('./favicon.svg') center / contain no-repeat; }
}
.name span:not(.brand-circle) { display: block; }
.name .en { font: 600 1.18rem/1.05 var(--serif); white-space: nowrap; }
.name .cn { margin-top: 3px; color: var(--muted); font-size: .69rem; line-height: 1.35; }
.site-controls { grid-area: actions; position: relative; display: flex; align-items: center; gap: 8px; }
.sidenav { grid-area: links; min-width: 0; }
.nav ul { display: flex; justify-content: center; align-items: center; gap: clamp(0px, 1vw, 18px); list-style: none; margin: 0; padding: 0; }
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 7px clamp(5px, .55vw, 12px);
  color: var(--muted);
  font-size: .875rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--motion-fast);
}
.nav a::after { position: absolute; inset: auto 8px 3px; content: ''; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform var(--motion); }
.nav a:is(:hover, :focus-visible, [aria-current]) { color: var(--nav-active); }
.nav a:is(:hover, :focus-visible, [aria-current])::after { transform: scaleX(1); }
.nav .en { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html:lang(en) :is(.nav .en, .name .cn, [data-i18n-secondary]) { display: none; }
.nav-toggle { display: none; }

.content, .site-footer, .home-main {
  width: min(calc(100% - 2 * var(--gutter)), var(--frame));
  margin-inline: auto;
}
.content { min-width: 0; padding-block: clamp(42px, 6vw, 96px) clamp(48px, 7vw, 104px); }
.page-header { padding-bottom: clamp(24px, 4vw, 52px); border-bottom: 1px solid var(--line); }
.page-header h1 i { display: inline-block; color: var(--muted); font-size: .72em; font-weight: 400; }
.eyebrow { margin-bottom: var(--space-2); color: var(--muted); font: 600 .75rem/1.5 var(--sans); letter-spacing: .15em; text-transform: uppercase; }
.tip, .muted, .meta { color: var(--muted); font-size: .875rem; }
.page-intro { max-width: 58ch; color: var(--muted); }
.empty-state { margin: var(--space-3) 0; padding: var(--space-3) 0; border-block: 1px solid var(--line); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) 0 var(--space-4);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .875rem;
}
body:has(> .site-footer) { display: flex; flex-direction: column; }
body > .site-footer { margin-top: auto; }
.site-footer .name { min-height: 24px; }
.site-footer .brand-circle { flex-basis: 17px; width: 17px; }
.site-version { margin: 0; font-variant-numeric: tabular-nums; }
.site-language { display: none; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-inline-start: auto; }
.locale-ready .site-language { display: inline-flex; }
.site-language select { padding-block: 4px; }
.error-page > .site-footer { justify-content: flex-end; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); }
.site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
.inline-footer { margin-top: var(--space-8); }
.skip-link { position: fixed; z-index: 1000; top: -100px; left: 16px; padding: 10px 16px; background: var(--dialog); }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.not-found { max-width: 51rem; min-height: 74svh; display: grid; align-content: center; justify-items: start; }
.not-found h1 { max-width: 16em; font-size: clamp(2.75rem, 7vw, 5.25rem); }
.error-mark { width: clamp(64px, 8vw, 112px); aspect-ratio: 1; margin-bottom: var(--space-4); border: 1px solid var(--control-border); border-radius: 50%; }

.theme-settings { margin: 0; }
.theme-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  white-space: nowrap;
  font-size: .8125rem;
  transition: background-color var(--motion-fast);
}
.theme-summary::-webkit-details-marker { display: none; }
.theme-summary::before { content: '☼'; line-height: 1; }
:root[data-theme='night'] .theme-summary::before { content: '☾'; }
.theme-summary:hover, .theme-settings[open] .theme-summary { background: var(--control-hover); }
html:lang(en) .theme-summary { font-size: .76rem; }
.theme-options {
  position: absolute;
  inset: calc(100% + 10px) 0 auto auto;
  z-index: 3;
  width: min(304px, calc(100vw - 2 * var(--gutter)));
  max-height: min(65dvh, 430px);
  overflow: auto;
  padding: var(--space-2);
  background: var(--dialog);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow: var(--glass-shadow);
  font-size: .875rem;
}
.theme-options p { margin: 10px 0; color: var(--muted); }
.theme-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.theme-choices label { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius-control); cursor: pointer; white-space: nowrap; }
.theme-choices label:has(:checked) { border-color: var(--focus); background: var(--control-hover); }
.theme-choices input { min-height: auto; margin: 0; accent-color: var(--focus); }
.theme-location-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-options .theme-location-note, .theme-options .theme-feedback { margin-bottom: 0; }

@keyframes page-enter { from { opacity: .72; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  :where(.page-header, .gallery-heading, .music-heading, .shop-heading, .blog-heading, .home-hero) { animation: page-enter var(--motion) both; }
}
@media (min-width: 1024px) and (max-width: 1240px) {
  .site-bar { gap: 14px; }
  .nav ul { gap: 5px; }
  .nav a { padding-inline: 5px; }
}
@media (max-width: 1023px) {
  .site-bar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'brand actions' 'links links'; gap: 0 12px; min-height: 68px; }
  .site-controls, .namebar { padding-block: 11px; }
  .nav-toggle { display: inline-flex; padding-inline: 10px; }
  .sidenav { max-height: min(65dvh, 420px); overflow: auto; border-top: 1px solid var(--line); padding-block: 8px 14px; }
  .js .sidenav:not(.is-open) { display: none; }
  .nav ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
  .nav a { min-height: 54px; padding-inline: 8px; white-space: normal; border-bottom: 1px solid var(--line); }
  .nav a::after { inset: auto 8px 0; }
  .label { display: flex; flex-direction: column; }
  .nav .en { position: static; width: auto; height: auto; overflow: visible; clip-path: none; color: var(--muted); font: 1rem/1.15 var(--serif); white-space: normal; }
}
@media (max-width: 400px) {
  .name .cn { display: none; }
  .brand-circle { flex-basis: 19px; width: 19px; }
  .name { gap: 6px; }
  .name .en { font-size: 1.06rem; }
}
@media (max-width: 350px) {
  .site-bar { gap: 0 6px; }
  .site-controls { gap: 4px; }
  .name .en { font-size: .94rem; }
  .nav-toggle, .theme-summary { padding-inline: 7px; }
  html:lang(en) .theme-summary { font-size: .69rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
