/* 曾侯乙编钟 · 漆黑钟架上的青铜，只有被敲响的钟会亮。
   正鼓用金色，侧鼓用铜绿色，全页一致。 */
:root {
	--bg: #120c08;
	--ink: #f1e6d2;
	--ink2: #c9b99b;
	--ink3: #a39278;
	--line: rgba(241, 230, 210, .14);
	--gold: #ecc46f;
	--teal: #7fcdb6;
	--serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
	--sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
	color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
	margin: 0; min-height: 100%; color: var(--ink); font: 14px/1.6 var(--sans);
	background: radial-gradient(120% 80% at 55% 36%, #2a1d13 0%, #17100b 46%, var(--bg) 100%) no-repeat, var(--bg);
	-webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
kbd { display: inline-block; min-width: 18px; padding: 0 4px; font: 600 11px/17px var(--sans); text-align: center; color: var(--ink); border: 1px solid rgba(241, 230, 210, .3); border-radius: 3px; }

/* ---------- 桌面：左侧竖排标题，上方一排按钮，中间钟架，下方是所选的钟 ---------- */
.app {
	position: relative; height: 100vh; height: 100svh; min-height: 540px; overflow: hidden;
	display: grid;
	grid-template-columns: 92px minmax(0, 1fr);
	grid-template-rows: 44px minmax(0, 1fr) auto;
	grid-template-areas: "head tools" "head stage" "detail detail";
	padding: 6px 20px 12px 14px;
}
.head { grid-area: head; display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 10px; padding: 50px 0 0 6px; }
.title {
	margin: 0; writing-mode: vertical-rl; font: 700 38px/1 var(--serif); letter-spacing: .32em; color: #f6e7c4;
	text-shadow: 0 0 24px rgba(236, 196, 111, .22);
}
.lede { margin: 0; writing-mode: vertical-rl; font: 13px/1.9 var(--serif); letter-spacing: .14em; color: var(--ink2); }
.lede span { display: block; }

.tools { grid-area: tools; display: flex; justify-content: center; align-items: center; gap: 8px; }
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 16px; cursor: pointer;
	font-size: 14px; letter-spacing: .06em; white-space: nowrap; color: var(--ink); background: rgba(34, 24, 16, .85);
	border: 1px solid rgba(241, 230, 210, .2); border-radius: 8px; transition: background .15s, border-color .15s;
	-webkit-tap-highlight-color: transparent;
}
.btn:hover { background: rgba(52, 37, 24, .9); border-color: rgba(241, 230, 210, .34); }
.btn--main { color: #1b130c; background: linear-gradient(180deg, #f1cf85, #d3a252); border-color: transparent; font-weight: 600; }
.btn--main:hover { background: linear-gradient(180deg, #f6d995, #dcad5e); }
.btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.btn--main[aria-pressed="true"] { color: #1b130c; border-color: transparent; }
.btn .ic--play { width: 0; height: 0; border-left: 9px solid currentColor; border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; }
.btn .ic--stop { width: 9px; height: 9px; background: currentColor; }

.stage { grid-area: stage; position: relative; min-height: 0; display: flex; flex-direction: column; }
.rackwrap { position: relative; flex: 1 1 auto; min-height: 0; }
.rack { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; cursor: pointer; outline: none; }
.rack:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 6px; }
.rack-note { margin: 2px 0 0; font-size: 12px; color: var(--ink3); text-align: right; }
.tip {
	position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; white-space: nowrap;
	padding: 3px 9px; border-radius: 4px; font-size: 12.5px; line-height: 1.5; color: var(--ink);
	background: rgba(14, 9, 6, .92); border: 1px solid var(--line);
	transform: translate(-50%, calc(-100% - 8px)); opacity: 0; transition: opacity .12s;
}
.tip.on { opacity: 1; }
.tip b { font-weight: 700; }
.tip .m { color: var(--gold); }
.tip .s { color: var(--teal); }

.detail {
	grid-area: detail; display: grid; align-items: start;
	grid-template-columns: 200px minmax(250px, 1fr) minmax(190px, 230px) 330px;
	column-gap: 24px; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--line);
}
.big { display: grid; justify-items: center; }
.big svg { display: block; width: 100%; height: 196px; overflow: visible; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.big__name { margin: 0; font: 600 15px/1.4 var(--serif); letter-spacing: .08em; text-align: center; }
.hot circle.r { fill: none; stroke-width: 1.6; }
.hot--m circle.r { stroke: var(--gold); }
.hot--s circle.r { stroke: var(--teal); }
.hot--m circle.c { fill: var(--gold); }
.hot--s circle.c { fill: var(--teal); }
.parts text { font: 600 14px var(--serif); fill: var(--ink); }
.parts line { stroke: rgba(241, 230, 210, .5); stroke-width: .8; }

.notes { min-width: 0; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.tile {
	display: grid; justify-items: start; padding: 8px 14px 9px; text-align: left; cursor: pointer; min-width: 0;
	background: rgba(20, 14, 10, .7); border: 1px solid var(--line); border-radius: 10px;
	transition: border-color .15s, background .15s; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tile:hover { background: rgba(38, 27, 18, .8); }
.tile__k { font-size: 13px; letter-spacing: .1em; }
.tile__n { font: 600 34px/1.05 var(--serif); letter-spacing: .02em; }
.tile__n sub, .key sub { font: 600 .5em var(--sans); vertical-align: baseline; position: relative; top: .1em; margin-left: 1px; }
.tile--main .tile__k, .tile--main .tile__n { color: var(--gold); }
.tile--side .tile__k, .tile--side .tile__n { color: var(--teal); }
.tile--main.lit { border-color: var(--gold); background: rgba(236, 196, 111, .14); }
.tile--side.lit { border-color: var(--teal); background: rgba(127, 205, 182, .13); }
.tile[disabled] { cursor: default; opacity: .45; }
.ivl { display: grid; justify-items: center; font: 600 15px/1.3 var(--serif); white-space: nowrap; }
.ivl::before { content: ""; width: 54px; height: 1px; margin-bottom: 5px; background: linear-gradient(90deg, var(--gold), var(--teal)); }
.notes__cap { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--ink2); }
.pcs { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; margin-top: 10px; }
.pcs i {
	display: grid; place-items: center; height: 24px; border-radius: 4px; font: 600 11px/1 var(--sans); font-style: normal;
	color: var(--ink3); background: rgba(241, 230, 210, .05); border: 1px solid rgba(241, 230, 210, .08); transition: background .3s, color .3s;
}
.pcs i.on { color: #1a120b; background: linear-gradient(180deg, #f3d48d, #c99a48); border-color: transparent; }
.pcs i.on.s { background: linear-gradient(180deg, #a7e3d1, #5fae98); }
.pcs__cap { margin: 5px 0 0; font-size: 12.5px; color: var(--ink2); }
.pcs__cap b { color: var(--ink); font-weight: 600; }

.mode { margin: 0; min-width: 0; }
.mode svg { display: block; width: 100%; height: 124px; overflow: visible; }
.mode text { font-family: var(--sans); }
.mode figcaption { margin-top: 2px; font-size: 12px; line-height: 1.55; color: var(--ink2); }

.aside { min-width: 0; }
.fact { margin: 0; font: 13.5px/1.8 var(--serif); color: var(--ink2); }
.fact q { quotes: "「" "」"; color: var(--ink); }
.hint { margin: 8px 0 0; font-size: 12px; line-height: 1.75; color: var(--ink3); }

.strip { display: none; }

@media (prefers-reduced-motion: no-preference) {
	.big:not(.struck) .hot circle.r { animation: hotpulse 1.9s ease-in-out infinite; }
	@keyframes hotpulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
}

/* 矮一些的桌面 */
@media (min-width: 761px) and (max-height: 720px) {
	.big svg { height: 168px; }
	.mode svg { height: 104px; }
	.tile__n { font-size: 30px; }
	.hint { display: none; }
}
/* 中等宽度：不放截面图 */
@media (min-width: 761px) and (max-width: 1120px) {
	.detail { grid-template-columns: 172px minmax(240px, 1fr) minmax(200px, 300px); }
	.mode { display: none; }
	.btn { padding: 0 12px; }
}

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
	.app {
		height: auto; min-height: 100svh; overflow: visible; align-content: start;
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: none;
		grid-template-areas: "head" "stage" "strip" "tools" "detail";
		padding: 8px 12px 20px;
	}
	.head { flex-direction: column; align-items: center; justify-content: flex-start; gap: 0; padding: 0; }
	.title { writing-mode: horizontal-tb; font-size: 22px; line-height: 34px; letter-spacing: .2em; margin-left: .2em; }
	.lede { writing-mode: horizontal-tb; margin-top: 10px; font-size: 12px; letter-spacing: .04em; line-height: 1.4; text-align: center; }
	.lede span { display: inline; }
	.lede span + span::before { content: "，"; }
	.stage { margin-top: 6px; }
	.rackwrap { flex: none; aspect-ratio: 1000 / 336; }
	.rack-note { text-align: left; font-size: 11px; }
	.strip { grid-area: strip; display: grid; grid-template-columns: 30px minmax(0, 1fr) 30px; gap: 4px; margin-top: 8px; }
	.strip__nav { padding: 0; font-size: 18px; color: var(--ink); background: rgba(34, 24, 16, .85); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
	.keys { display: flex; gap: 3px; min-width: 0; }
	.key { flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 1fr 1fr; gap: 3px; border-radius: 7px; }
	.key.on { outline: 1px solid rgba(241, 230, 210, .55); outline-offset: 1px; }
	.key button {
		min-width: 0; min-height: 40px; padding: 0; border: 0; border-radius: 6px; cursor: pointer; overflow: hidden; white-space: nowrap;
		font: 600 11px/1.1 var(--sans); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
	}
	.key .k-s { color: #0f2a23; background: linear-gradient(180deg, #a3dccb, #6cb7a1); }
	.key .k-m { color: #2a1c0c; background: linear-gradient(180deg, #f2d38f, #cf9f4f); }
	.key .k-s[disabled] { opacity: .2; }
	.key button.lit { filter: brightness(1.25); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
	.detail { grid-template-columns: 116px minmax(0, 1fr); column-gap: 12px; row-gap: 10px; margin-top: 10px; }
	.big svg { height: 156px; }
	.big__name { font-size: 13.5px; }
	.tile { padding: 6px 9px 7px; }
	.tile__k { font-size: 12px; }
	.tile__n { font-size: 25px; }
	.ivl { font-size: 13px; }
	.ivl::before { width: 28px; }
	.notes__cap { font-size: 11.5px; margin-top: 6px; }
	.pcs { gap: 2px; margin-top: 7px; }
	.pcs i { height: 20px; font-size: 9.5px; }
	.pcs__cap { font-size: 11.5px; }
	.mode { display: none; }
	.aside { grid-column: 1 / -1; }
	.fact { font-size: 13px; line-height: 1.75; }
	.hint { display: none; }
	.tools { margin-top: 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
	.btn { min-height: 42px; padding: 0 4px; font-size: 13px; letter-spacing: .02em; }
}
@media (max-width: 760px) and (min-height: 780px) {
	.mode { grid-column: 1 / -1; display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 12px; }
	.mode svg { height: 96px; }
}
@media (max-width: 360px) {
	.detail { grid-template-columns: 96px minmax(0, 1fr); }
	.tile__n { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
	.tile, .btn, .pcs i, .tip { transition: none; }
}

/* 暂停时（外层页面发来 pause、标签页隐藏或滚出视口），CSS 动画也一起停 */
.is-paused *, .is-paused *::before, .is-paused *::after { animation-play-state: paused !important; }
