@font-face {
  font-family: "Instrument Serif";
  src: url("./assets/fonts/InstrumentSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: light;
  --paper: #f5f2ea;
  --ink: #211f1b;
  --muted: #615c51;
  --hairline: #c9c4b6;
  --accent: #a63e29;
  --card-paper: rgb(250 246 236 / .77);
  --card-filter: blur(10px) saturate(.86);
  --edge-x: max(16px, env(safe-area-inset-right));
  --edge-y: max(16px, env(safe-area-inset-bottom));
  --serif: "Instrument Serif", "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  --sans: "Inter", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height:100%; overflow:hidden; overscroll-behavior:none; }
body { margin:0; font-size:14px; background:#d7cdbd; }
.visually-hidden { position:absolute; width:1px; height:1px; margin:-1px; padding:0; clip-path:inset(50%); overflow:hidden; white-space:nowrap; }
button, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
button:disabled, select:disabled { cursor: default; }
button:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; text-underline-offset: .24em; }
a:hover { color: var(--accent); }
.shop { position:fixed; inset:0; height:100%; height:100dvh; isolation:isolate; }
.counter { position:absolute; inset:0; overflow:hidden; background:#d7cdbd; }
#scene { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; outline:none; }
#scene:not([data-pointer-focus]):focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.scene-keys { position: absolute; width:1px; height:1px; overflow: hidden; clip-path:inset(50%); pointer-events: none; }
#stage-caption:not(:empty) { display:block; margin-top:4px; font-weight:600; }
#scene:not([data-pointer-focus]):focus-visible + .scene-keys {
  width:min(260px,65%); height:auto; padding:10px 14px; z-index:3; top:max(12px,env(safe-area-inset-top)); left:max(12px,env(safe-area-inset-left)); margin:0;
  clip-path:none; font-size:12px; line-height:1.55; border-radius:12px; color:var(--ink); background:var(--card-paper); box-shadow:0 3px 16px #241a1433;
}
.stage-message, .drop-label, #shelf-notice {
  position:absolute; z-index:4; pointer-events:none; padding:9px 14px; color:var(--ink);
  background:var(--card-paper); border-radius:12px; box-shadow:0 3px 15px #211c1333; font-size:13px;
}
.stage-message { top:50%; left:50%; transform:translate(-50%,-50%); }
.stage-message:not([data-error]) { padding:0; box-shadow:none; background:none; }
.stage-message:not([data-error])::before { content:""; display:block; width:19px; height:19px; border:2px solid #84756755; border-top-color:#73563a; border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(1turn); } }
@media (prefers-reduced-motion:reduce) { .stage-message:not([data-error])::before { animation:none; } }
.drop-label, #shelf-notice { bottom:var(--edge-y); left:50%; transform:translateX(-50%); margin:0; max-width:calc(100% - 32px); width:max-content; }
.scene-card {
  --frame-edge:right;
  position:absolute; z-index:2; right:var(--edge-x); bottom:var(--edge-y);
  width:clamp(282px,25vw,364px); max-height:calc(100% - var(--edge-y) - max(16px,env(safe-area-inset-top)));
  overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#b5a68d transparent;
  padding:clamp(18px,1.6vw,25px); border:1px solid #fffaf0d9; border-radius:19px;
  color:var(--ink); background:var(--card-paper);
  -webkit-backdrop-filter:var(--card-filter); backdrop-filter:var(--card-filter);
  box-shadow:inset 0 1px 0 #fffdf68c,0 8px 32px #251c1226,0 1px 3px #251c1220;
}
.scene-close {
  position:sticky; z-index:1; top:0; float:right; width:36px; height:36px; margin:-6px -6px 0 5px;
  border-radius:50%; background:#fcf7eec9; color:#4e4438;
}
.scene-close::before,.scene-close::after { content:""; position:absolute; top:50%; left:50%; width:14px; height:1.5px; border-radius:2px; background:currentColor; transform:translate(-50%,-50%) rotate(45deg); }
.scene-close::after { transform:translate(-50%,-50%) rotate(-45deg); }
.scene-close:hover { background:#e1d6c6; }
.controls { padding:0 0 12px; }
.album-info { display: flex; align-items: center; gap: 13px; min-width: 0; }
.album-cover { width: 51px; height: 51px; display: block; object-fit: contain; }
.album-info strong { display:block; font:500 clamp(19px,1.65vw,25px)/1.2 var(--serif); }
.album-info p, #deck-state { color: var(--muted); font-size: 11px; line-height: 1.5; }
.album-info p { margin: 4px 0 0; letter-spacing: .025em; }
.readout { min-width:0; margin-top:12px; padding-top:10px; border-top:1px solid var(--hairline); }
.readout-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 3px; }
#audio-label { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#time { font: 13px/1.4 var(--mono); color: var(--muted); }
.music-source { display:flex; flex-direction:column; gap:7px; }
.music-line { display:contents; }
.music-line label { position:absolute; width:1px; height:1px; clip-path:inset(50%); overflow:hidden; }
.music-line select { width:100%; min-height:35px; padding:5px 9px; border:1px solid var(--hairline); background:#fdfaf3; color:var(--ink); border-radius:7px; }
#track-picker { border:1px solid #65534239; border-radius:12px; background:#fffcf326; }
#track-toggle {
  display:grid; grid-template-columns:1fr auto 8px; align-items:center; gap:11px;
  width:100%; min-height:46px; padding:8px 15px; text-align:left; font-weight:600;
}
#track-count { font-size:12px; font-weight:400; color:var(--muted); }
#track-toggle::after {
  content:""; width:7px; height:7px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor;
  transform:translateY(-2px) rotate(45deg);
}
#track-toggle[aria-expanded="true"]::after { transform:translateY(2px) rotate(225deg); }
#track-options {
  list-style:none; margin:0; padding:0 5px 4px; border-top:1px solid #57483930; 
  max-height:min(36dvh,325px); overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin;
  touch-action:pan-y; scrollbar-color:#9d8c75 transparent;
}
#track-options li + li { border-top:1px solid #5748391c; }
#track-options button {
  display:grid; grid-template-columns:2.3ch minmax(0,1fr) max-content; align-items:center; gap:11px;
  position:relative; width:100%; min-height:48px; padding:9px 10px; border-radius:7px; text-align:left;
  line-height:1.4;
}
.track-number,.track-duration { font:12px/1.4 var(--mono); color:var(--muted); font-variant-numeric:tabular-nums; }
.track-title { overflow-wrap:anywhere; }
#track-options [aria-current="true"] { background:#a63e2917; color:#7d301f; font-weight:650; }
#track-options [aria-current="true"]::before { content:""; position:absolute; left:0; top:calc(50% - 7px); height:14px; width:3px; background:var(--accent); border-radius:2px; }
#track-options [aria-current="true"] .track-number { color:inherit; }
#track-toggle:focus-visible,#track-options button:focus-visible { outline-offset:-3px; border-radius:8px; }
@media (hover:hover) {
  #track-toggle:hover,#track-options button:hover { background:#69523c0c; }
  #track-options button[aria-current="true"]:hover { background:#a63e2922; }
}
#playback-panel.choosing-tracks .readout,
#playback-panel.choosing-tracks .music-source :is(#source-name,.release-links,#music-notice,#stream-host,.stream-recovery) { display:none; }
#source-name, .release-links { font-size:12px; color:var(--muted); }
.release-links { order:2; display:flex; flex-wrap:wrap; align-items:center; gap:6px 16px; }
#music-notice, #stream-host p { margin:2px 0; font-size:12px; line-height:1.55; color:var(--accent); }
#stream-host iframe { display:block; border:0; width:100%; border-radius:10px; }
.stream-recovery { display:flex; align-items:center; flex-wrap:wrap; gap:4px 16px; margin-top:4px; font-size:13px; }
.stream-recovery button,.stream-recovery a,#stream-host summary { padding:10px 0; cursor:pointer; }
.stream-recovery button { color:var(--accent); text-decoration:underline; text-underline-offset:.24em; }
#stream-host summary { font-size:12px; color:var(--muted); }
.detail-head { color: var(--accent); border-bottom: 1px solid var(--hairline); padding-bottom: 10px; font-size: 11px; letter-spacing: .06em; }
.detail h2 { font:500 clamp(25px,2.6vw,38px)/1.12 var(--serif); margin:16px 0 8px; overflow-wrap:anywhere; }
#device-info h2 { margin:0 32px 5px 0; font-size:23px; }
#device-info p { margin:0; }
.detail p { margin: 9px 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.detail #detail-edition { color: var(--ink); font-size: 12px; }
.detail.book-in-hand > :is(h2,#detail-edition,details) { display:none; }
.detail.book-in-hand .detail-head { padding:2px 34px 0 0; border:0; line-height:1.5; }
.detail.book-in-hand .inspection-gesture { margin:6px 0 0; }
#book-original { display:inline-block; padding-block:4px; color:var(--accent); white-space:nowrap; }
#rack-details ul { list-style: none; padding: 0; margin: 18px 0 0; }
#rack-details li:has(strong) { display: grid; gap: 3px; padding: 9px 0; border-top: 1px solid var(--hairline); }
#rack-details li small { font: 11px/1.5 var(--mono); color: var(--accent); }
#rack-details li strong { font: 500 20px/1.2 var(--serif); }
#rack-details li span, #rack-details dl { font-size: 12px; line-height: 1.6; }
.detail ol { margin: 12px 0; padding-left: 1.7em; font-size: 13px; line-height: 1.75; }
.detail ol li::marker { color: var(--accent); font: 11px/1.4 var(--mono); }
.detail ol small { color: var(--muted); }
.detail details { padding: 9px 0; border-top: 1px solid var(--hairline); font-size: 12px; }
.detail summary { cursor: pointer; font-size: 13px; }
.detail summary::marker { color: var(--accent); }
.detail textarea { width: 100%; margin-top: 8px; border: 1px solid var(--hairline); background: #f9f6ee; padding: 7px; resize: vertical; font-size: 13px; }
#cassette-gesture { display: block; }
.cd-imprint dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 12px 0; line-height: 1.5; }
.cd-imprint dt, .cd-imprint figcaption { color: var(--muted); }
.cd-imprint dd { margin: 0; }
.cd-imprint figure { margin: 14px 0; }
.cd-imprint img, .cassette-photos img { display: block; width: 100%; height: auto; }
.cd-imprint figcaption { margin-top: 4px; }
.cd-scan-links, .cassette-photos { display: flex; flex-wrap: wrap; gap: 7px 14px; }
.cassette-photos { margin: 12px 0; }
.cassette-photos a { display: grid; gap: 4px; width: 100%; }
#read-booklet { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; width: 100%; text-align: left; color: var(--accent); border-top: 1px solid var(--hairline); padding: 11px 0; font-size: 13px; }
#read-booklet span { font: 10px/1.6 var(--mono); }
#booklet-reader { width: min(1020px,95vw); max-height: 95dvh; padding: 13px clamp(12px,2.5vw,28px); color: var(--ink); background: var(--card-paper); border: 1px solid #fff9eeba; border-radius:18px; box-shadow: 0 14px 60px #201c1840; -webkit-backdrop-filter:var(--card-filter); backdrop-filter:var(--card-filter); }
#booklet-reader::backdrop { background: #29251c63; }
#booklet-reader header, #booklet-reader nav { display: flex; align-items: center; justify-content: space-between; gap: 1em; }
#booklet-reader h2 { font: 400 33px/1 var(--serif); margin: 0; }
#reader-album { font-weight: inherit; }
#booklet-reader h2 span { font: 12px/1.5 var(--sans); }
#booklet-reader > a { display: grid; justify-items: center; margin: 12px 0; cursor: zoom-in; }
#booklet-reader img { display: block; max-width: 100%; max-height: 72dvh; object-fit: contain; box-shadow: 0 2px 8px #392e221c; }
#booklet-reader nav { border-top: 1px solid var(--hairline); padding-top: 5px; }
#booklet-reader button { font-size: 13px; min-height: 34px; }
#booklet-reader button:disabled { opacity: .4; }
#booklet-reader output { font: 12px/1 var(--mono); color: var(--accent); }
@media (max-width:860px) and (orientation:portrait) {
  :root { --edge-x:max(10px,env(safe-area-inset-right)); --edge-y:max(10px,env(safe-area-inset-bottom)); }
  .scene-card {
    --frame-edge:bottom;
    left:max(10px,env(safe-area-inset-left)); width:auto; max-height:39%;
    padding:15px 17px; border-radius:17px;
  }
  #playback-panel { max-height:42%; }
  #playback-panel.choosing-tracks { max-height:55%; }
  #track-options { max-height:min(32dvh,275px); }
  .scene-close { width:40px; height:40px; }
  .detail h2 { font-size:27px; margin:13px 0 5px; }
  .album-info { gap:10px; }
  .album-cover { width:40px; height:40px; }
  .detail-head { padding:3px 0 8px; }
  #booklet-reader h2 { font-size:24px; }
}
@media (orientation:landscape) and (max-height:540px) {
  :root { --edge-y:max(8px,env(safe-area-inset-bottom)); }
  .scene-card { width:clamp(205px,32vw,310px); padding:14px; max-height:calc(100% - var(--edge-y) - max(8px,env(safe-area-inset-top))); }
  .scene-close { width:34px; height:34px; }
  #track-options { max-height:min(51dvh,calc(100dvh - 148px)); }
  .detail h2 { font-size:25px; }
}
@media (prefers-reduced-transparency:reduce) {
  :root { --card-paper:#f8f4eb; --card-filter:none; }
}
