/* MusicStand — designed for thumbs: every control sits in a rail at the left or
   right edge of the screen. Colours come from the theme variables below. */

/* style fonts (SIL Open Font License), fetched only when a style uses them */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/zen-kaku-gothic-new-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/zen-kaku-gothic-new-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Zen Kaku Gothic New"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/zen-kaku-gothic-new-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/dm-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/dm-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/eb-garamond-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "EB Garamond"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/eb-garamond-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/cormorant-garamond-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/lora-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Lora"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/lora-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-style: normal; font-display: swap; src: url(../fonts/playfair-display-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/playfair-display-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 400; font-style: normal; font-display: swap; src: url(../fonts/jost-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 500; font-style: normal; font-display: swap; src: url(../fonts/jost-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 700; font-style: normal; font-display: swap; src: url(../fonts/jost-latin-700-normal.woff2) format("woff2"); }

/* ================= themes ================= */
:root, [data-theme="midnight"] {
  --bg: #0e1320; --bg-2: #141b2c;
  --surface: #161d2d; --surface-2: #1d2639; --surface-3: #27324a;
  --border: rgba(255, 255, 255, .07); --border-strong: rgba(255, 255, 255, .14);
  --text: #edf0f7; --muted: #98a2b8;
  --accent: #e8b04b; --on-accent: #1c1405; --accent-soft: rgba(232, 176, 75, .15);
  --ok: #3f9e63; --on-ok: #f1fbf4; --danger: #ef6b62; --danger-soft: rgba(239, 107, 98, .14);
  --stage: #1b2130; --page-shadow: 0 6px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  --overlay: rgba(4, 7, 14, .62); --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --field-bg: #0f1524; --field-text: #edf0f7; --field-border: rgba(255, 255, 255, .16);
  --edit-rail: #1a1830; --btn-border: 1px solid transparent; --rail-sheen: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  color-scheme: dark;
}
[data-theme="ivory"] {
  --bg: #f3efe6; --bg-2: #ebe5d8;
  --surface: #fffdf8; --surface-2: #f4efe4; --surface-3: #e8e1d2;
  --border: rgba(60, 45, 20, .10); --border-strong: rgba(60, 45, 20, .22);
  --text: #1f1b14; --muted: #6b6355;
  --accent: #8c2f39; --on-accent: #fff7f3; --accent-soft: rgba(140, 47, 57, .10);
  --ok: #2f7a4b; --on-ok: #f3fbf5; --danger: #b3261e; --danger-soft: rgba(179, 38, 30, .09);
  --stage: #e4ddcf; --page-shadow: 0 6px 22px rgba(60, 45, 20, .18), 0 1px 3px rgba(60, 45, 20, .2);
  --overlay: rgba(40, 30, 15, .35); --shadow: 0 18px 50px rgba(60, 45, 20, .22);
  --field-bg: #fffdf8; --field-text: #1f1b14; --field-border: rgba(60, 45, 20, .25);
  --edit-rail: #f6ecec; --btn-border: 1px solid transparent; --rail-sheen: none;
  color-scheme: light;
}
[data-theme="graphite"] {
  --bg: #161719; --bg-2: #1b1c1f;
  --surface: #202124; --surface-2: #28292d; --surface-3: #34363b;
  --border: rgba(255, 255, 255, .06); --border-strong: rgba(255, 255, 255, .13);
  --text: #ececee; --muted: #a0a2a8;
  --accent: #7aa7ff; --on-accent: #08142e; --accent-soft: rgba(122, 167, 255, .15);
  --ok: #45a06a; --on-ok: #f1fbf4; --danger: #f07167; --danger-soft: rgba(240, 113, 103, .14);
  --stage: #1e1f22; --page-shadow: 0 6px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  --overlay: rgba(0, 0, 0, .6); --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --field-bg: #18191b; --field-text: #ececee; --field-border: rgba(255, 255, 255, .16);
  --edit-rail: #1f2130; --btn-border: 1px solid transparent; --rail-sheen: none;
  color-scheme: dark;
}
[data-theme="contrast-dark"] {
  --bg: #000; --bg-2: #000;
  --surface: #000; --surface-2: #000; --surface-3: #262626;
  --border: #fff; --border-strong: #fff;
  --text: #fff; --muted: #fff;
  --accent: #ffd400; --on-accent: #000; --accent-soft: #ffd400;
  --ok: #00e676; --on-ok: #000; --danger: #ff5c5c; --danger-soft: #000;
  --stage: #000; --page-shadow: 0 0 0 2px #fff;
  --overlay: rgba(0, 0, 0, .8); --shadow: 0 0 0 2px #fff;
  --field-bg: #000; --field-text: #fff; --field-border: #fff;
  --edit-rail: #000; --btn-border: 2px solid #fff; --rail-sheen: none;
  color-scheme: dark;
}
[data-theme="contrast-light"] {
  --bg: #fff; --bg-2: #fff;
  --surface: #fff; --surface-2: #fff; --surface-3: #e6e6e6;
  --border: #000; --border-strong: #000;
  --text: #000; --muted: #000;
  --accent: #0038b8; --on-accent: #fff; --accent-soft: #0038b8;
  --ok: #006b2e; --on-ok: #fff; --danger: #b00000; --danger-soft: #fff;
  --stage: #fff; --page-shadow: 0 0 0 2px #000;
  --overlay: rgba(255, 255, 255, .75); --shadow: 0 0 0 2px #000;
  --field-bg: #fff; --field-text: #000; --field-border: #000;
  --edit-rail: #fff; --btn-border: 2px solid #000; --rail-sheen: none;
  color-scheme: light;
}
/* ===== more styles (chrome only: the music page always stays white and untouched) ===== */
[data-theme="utilitarian"] {
  --bg: #eceef0; --bg-2: #e4e7ea;
  --surface: #ffffff; --surface-2: #f3f4f6; --surface-3: #e2e5e9;
  --border: rgba(0, 0, 0, .16); --border-strong: rgba(0, 0, 0, .32);
  --text: #111418; --muted: #4a5260;
  --accent: #0b57d0; --accent-text: #0842a0; --on-accent: #ffffff; --accent-soft: rgba(11, 87, 208, .12);
  --ok: #1e7d3a; --on-ok: #ffffff; --danger: #c5221f; --danger-soft: rgba(197, 34, 31, .1);
  --stage: #d9dce0; --page-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
  --overlay: rgba(20, 24, 30, .4); --shadow: 0 0 0 1px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .16);
  --field-bg: #ffffff; --field-text: #111418; --field-border: rgba(0, 0, 0, .4);
  --edit-rail: #e8eef9; --btn-border: 1px solid rgba(0, 0, 0, .22); --rail-sheen: none;
  --r-btn: 4px; --r-panel: 6px; --radius: 4px;
  color-scheme: light;
}
[data-theme="utilitarian"] .rbtn .lbl { font-weight: 600; color: var(--text); letter-spacing: .02em; }
[data-theme="utilitarian"] .pop-title, [data-theme="utilitarian"] .set-sec h3 { color: var(--text); }
[data-theme="utilitarian"] .stage { background: var(--stage); }

[data-theme="japandi"] {
  --bg: #ece6dc; --bg-2: #e6dfd3;
  --surface: #f6f2ea; --surface-2: #ebe4d8; --surface-3: #ddd4c4;
  --border: rgba(70, 60, 45, .09); --border-strong: rgba(70, 60, 45, .18);
  --text: #2e2a25; --muted: #665e53;
  --accent: #56664a; --accent-text: #445238; --on-accent: #ffffff; --accent-soft: rgba(86, 102, 74, .14);
  --ok: #56664a; --on-ok: #ffffff; --danger: #a4483c; --danger-soft: rgba(164, 72, 60, .1);
  --stage: #d8d0c2; --page-shadow: 0 8px 30px rgba(70, 55, 35, .14), 0 1px 2px rgba(70, 55, 35, .12);
  --overlay: rgba(60, 50, 38, .28); --shadow: 0 20px 50px rgba(70, 55, 35, .16);
  --field-bg: #fbf8f2; --field-text: #2e2a25; --field-border: rgba(70, 60, 45, .22);
  --edit-rail: #e6e2d4; --btn-border: 1px solid transparent; --rail-sheen: none;
  --r-btn: 20px; --r-panel: 26px; --radius: 22px;
  --font-display: "Avenir Next", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color-scheme: light;
}
[data-theme="japandi"] .rail { gap: 9px; border-color: transparent; }
[data-theme="japandi"] .lib-list { gap: 14px; }
[data-theme="japandi"] h1, [data-theme="japandi"] .crumb, [data-theme="japandi"] .modal h2 { font-weight: 500; letter-spacing: .005em; }

[data-theme="bento"] {
  --bg: #eef0f4; --bg-2: #e8ebf1;
  --surface: #ffffff; --surface-2: #f4f5f8; --surface-3: #e6e8ee;
  --border: rgba(20, 22, 40, .07); --border-strong: rgba(20, 22, 40, .14);
  --text: #14151a; --muted: #555a66;
  --accent: #3d3dd6; --on-accent: #ffffff; --accent-soft: rgba(61, 61, 214, .1);
  --ok: #1f8a4c; --on-ok: #ffffff; --danger: #d0342c; --danger-soft: rgba(208, 52, 44, .09);
  --stage: #e3e6ec; --page-shadow: 0 10px 30px rgba(20, 22, 40, .12), 0 1px 3px rgba(20, 22, 40, .1);
  --overlay: rgba(20, 22, 40, .3); --shadow: 0 24px 60px rgba(20, 22, 40, .18);
  --field-bg: #f4f5f8; --field-text: #14151a; --field-border: rgba(20, 22, 40, .16);
  --edit-rail: #eef0fb; --btn-border: 1px solid transparent; --rail-sheen: none;
  --r-btn: 16px; --r-panel: 24px; --radius: 20px;
  color-scheme: light;
}
/* rails become a column of tiles floating on the background */
[data-theme="bento"] .rail { background: var(--bg); border-color: transparent; }
[data-theme="bento"] .rbtn { background: var(--surface); box-shadow: 0 1px 2px rgba(20, 22, 40, .08), 0 0 0 1px var(--border); }
[data-theme="bento"] .rbtn.active, [data-theme="bento"] .rbtn.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
[data-theme="bento"] .rbtn.active .lbl, [data-theme="bento"] .rbtn.on .lbl { color: var(--on-accent); }
[data-theme="bento"] .rbtn.done { background: var(--ok); }
[data-theme="bento"] .lib-row { box-shadow: 0 1px 3px rgba(20, 22, 40, .07); }
[data-theme="bento"] .lib-list { gap: 12px; }
[data-theme="bento"] .set-sec { background: var(--surface-2); border: 0; border-radius: 18px; padding: 16px; margin-bottom: 10px; }
[data-theme="bento"] .set-sec:first-child { padding-top: 16px; }
[data-theme="bento"] .modal-buttons { background: var(--surface); }

[data-theme="light-academia"] {
  --bg: #efe6d2; --bg-2: #e8dcc2;
  --surface: #f8f1e1; --surface-2: #efe4cc; --surface-3: #e3d5b8;
  --border: rgba(80, 55, 20, .14); --border-strong: rgba(80, 55, 20, .28);
  --text: #2b2016; --muted: #64543f;
  --accent: #7a3b2e; --on-accent: #fff8ef; --accent-soft: rgba(122, 59, 46, .12);
  --ok: #4f6b3a; --on-ok: #fbf6ea; --danger: #9e2a1f; --danger-soft: rgba(158, 42, 31, .09);
  --stage: #dccfb3; --page-shadow: 0 6px 22px rgba(70, 45, 15, .2), 0 1px 3px rgba(70, 45, 15, .2);
  --overlay: rgba(50, 35, 15, .35); --shadow: 0 18px 50px rgba(70, 45, 15, .22);
  --field-bg: #fcf8ee; --field-text: #2b2016; --field-border: rgba(80, 55, 20, .3);
  --edit-rail: #efe0d2; --btn-border: 1px solid rgba(80, 55, 20, .12); --rail-sheen: none;
  --r-btn: 8px; --r-panel: 12px; --radius: 10px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
[data-theme="light-academia"] h1, [data-theme="light-academia"] .crumb, [data-theme="light-academia"] .modal h2 { font-weight: 600; letter-spacing: 0; }
[data-theme="light-academia"] .pop-title, [data-theme="light-academia"] .set-sec h3 { font-family: var(--font-display); letter-spacing: .01em; }

[data-theme="dark-academia"] {
  --bg: #121014; --bg-2: #18151a;
  --surface: #1a171b; --surface-2: #231f24; --surface-3: #2e292f;
  --border: rgba(201, 162, 94, .12); --border-strong: rgba(201, 162, 94, .26);
  --text: #ece3d3; --muted: #b3a690;
  --accent: #c9a25e; --on-accent: #1a1208; --accent-soft: rgba(201, 162, 94, .15);
  --ok: #6f9a5b; --on-ok: #0f160b; --danger: #d9776b; --danger-soft: rgba(217, 119, 107, .13);
  --stage: #19161a; --page-shadow: 0 8px 30px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .5);
  --overlay: rgba(5, 4, 6, .66); --shadow: 0 20px 55px rgba(0, 0, 0, .6);
  --field-bg: #141215; --field-text: #ece3d3; --field-border: rgba(201, 162, 94, .3);
  --edit-rail: #1f1a1c; --btn-border: 1px solid rgba(201, 162, 94, .1); --rail-sheen: linear-gradient(180deg, rgba(201, 162, 94, .04), rgba(0, 0, 0, 0));
  --r-btn: 10px; --r-panel: 14px; --radius: 12px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: dark;
}
[data-theme="dark-academia"] h1, [data-theme="dark-academia"] .crumb, [data-theme="dark-academia"] .modal h2 { font-weight: 600; letter-spacing: .01em; }
[data-theme="dark-academia"] .pop-title, [data-theme="dark-academia"] .set-sec h3 { font-family: var(--font-display); letter-spacing: .01em; color: var(--accent); }

[data-theme="mid-century"] {
  --bg: #f4ead8; --bg-2: #efe1c6;
  --surface: #fbf5ea; --surface-2: #f1e4cc; --surface-3: #e7d3b0;
  --border: rgba(60, 40, 20, .12); --border-strong: rgba(60, 40, 20, .26);
  --text: #22201c; --muted: #5c5447;
  --accent: #b24a22; --accent-text: #8f3a19; --on-accent: #ffffff; --accent-soft: rgba(178, 74, 34, .12);
  --ok: #2f6f6a; --on-ok: #ffffff; --danger: #a32f22; --danger-soft: rgba(163, 47, 34, .1);
  --stage: #e3d6bd; --page-shadow: 0 6px 20px rgba(60, 40, 20, .18), 0 1px 3px rgba(60, 40, 20, .18);
  --overlay: rgba(40, 30, 15, .32); --shadow: 0 16px 44px rgba(60, 40, 20, .2);
  --field-bg: #fffaf1; --field-text: #22201c; --field-border: rgba(60, 40, 20, .3);
  --edit-rail: #f3dfd0; --btn-border: 1.5px solid rgba(34, 32, 28, .14); --rail-sheen: none;
  --r-btn: 6px; --r-panel: 10px; --radius: 8px;
  --font-display: Futura, "Century Gothic", "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color-scheme: light;
}
[data-theme="mid-century"] h1, [data-theme="mid-century"] .crumb, [data-theme="mid-century"] .modal h2 { font-weight: 700; letter-spacing: .01em; }
[data-theme="mid-century"] .rail.left { box-shadow: inset -4px 0 0 #2f6f6a; }
[data-theme="mid-century"] .rail.right { box-shadow: inset 4px 0 0 #d9a23a; }
[data-theme="mid-century"] .pop-title, [data-theme="mid-century"] .set-sec h3 { color: #2f6f6a; }

/* in the high-contrast themes an "active" button is solid accent */
[data-theme^="contrast"] .rbtn.active, [data-theme^="contrast"] .rbtn.on { color: var(--on-accent) !important; }
[data-theme^="contrast"] .rbtn.active .lbl, [data-theme^="contrast"] .rbtn.on .lbl { color: var(--on-accent) !important; }
[data-theme^="contrast"] .rbtn .lbl { font-weight: 700; }

html, [data-theme] { /* defaults; themes and computer mode override these */
  --rail-w: 88px;
  --btn-h: 66px;
  --radius: 16px;
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ================= base ================= */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 17px/1.4 var(--font);
  overscroll-behavior: none; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .32; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.015em; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }
.ic { display: inline-flex; width: 26px; height: 26px; position: relative; flex: none; }
.ic svg { width: 100%; height: 100%; stroke-width: 1.75; }
.hint { color: var(--muted); font-size: 15px; margin: 6px 0; }

/* ================= rails ================= */
.viewer { position: fixed; inset: 0; display: flex; background: var(--stage); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rail { width: calc(var(--rail-w) + var(--sa-l)); flex: none; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); background-image: var(--rail-sheen); border-right: 1px solid var(--border);
  padding: calc(10px + var(--sa-t)) 9px calc(10px + var(--sa-b)) calc(9px + var(--sa-l)); overflow-y: auto; overflow-x: hidden; scrollbar-width: none; z-index: 5; }
.rail::-webkit-scrollbar { display: none; }
.rail.right { width: calc(var(--rail-w) + var(--sa-r)); padding-left: 9px; padding-right: calc(9px + var(--sa-r)); border-right: 0; border-left: 1px solid var(--border); }
.rail .spacer { flex: 1; min-height: 6px; }
.rail-gap { flex: none; height: 1px; background: var(--border-strong); margin: 4px 8px; }
.rbtn { position: relative; flex: none; width: 100%; min-height: var(--btn-h); border: var(--btn-border); border-radius: var(--r-btn, 14px); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 7px 2px;
  transition: background .15s, transform .08s, color .15s; }
.rbtn .lbl { font-size: 11.5px; line-height: 1.12; letter-spacing: .01em; color: var(--muted); text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.rbtn:active { background: var(--surface-3); transform: scale(.97); }
.rbtn.active, .rbtn.on { background: var(--accent-soft); color: var(--accent-text, var(--accent)); box-shadow: inset 0 0 0 1.5px var(--accent); }
.rbtn.active .lbl, .rbtn.on .lbl { color: var(--accent-text, var(--accent)); font-weight: 600; }
.rbtn.done { background: var(--ok); color: var(--on-ok); }
.rbtn.done .lbl { color: var(--on-ok); font-weight: 600; }
.rbtn.turn { min-height: 92px; background: var(--surface-3); }
.rbtn.turn .ic { width: 38px; height: 38px; }
.rbtn.big { min-height: 80px; }
.rbtn.warn { box-shadow: inset 0 0 0 1.5px var(--danger); }
.rbtn.warn .lbl { color: var(--danger); }
.rbtn.danger { color: var(--danger); }
.rbtn.danger .lbl { color: var(--danger); }
.rbtn.spinning .ic { animation: spin 1.1s linear infinite; }
.rbtn .swatch { position: absolute; right: -6px; bottom: -4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface-2); }
.viewer.editing .rail.left { background: var(--edit-rail); }
.page-label { text-align: center; font-size: 14px; color: var(--muted); padding: 4px 0; font-variant-numeric: tabular-nums; }
.page-label .prog-item { display: block; font-size: 11px; line-height: 1.2; color: var(--accent); max-height: 3.6em; overflow: hidden; margin-bottom: 2px; font-weight: 600; }
.page-label .prog-pg { display: block; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.viewer.rails-hidden .rail { display: none; }
.show-rails { display: none; position: fixed; bottom: calc(12px + var(--sa-b)); width: 56px; height: 56px; border-radius: 16px; border: var(--btn-border);
  background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--text); z-index: 6; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.show-rails.l { left: calc(12px + var(--sa-l)); }
.show-rails.r { right: calc(12px + var(--sa-r)); }
.viewer.rails-hidden .show-rails { display: flex; }

/* ================= stage & pages ================= */
.stage { flex: 1; min-width: 0; overflow: auto; position: relative; touch-action: pan-x pan-y; outline: none; scrollbar-width: thin;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--stage) 85%, #fff 15%) 0%, var(--stage) 60%); }
[data-theme^="contrast"] .stage { background: var(--stage); }
.stage.finger-draw { touch-action: none; }
.spread { display: flex; align-items: flex-start; will-change: transform; }
.page { position: relative; flex: none; overflow: hidden; background: #fff; box-shadow: var(--page-shadow); border-radius: 2px; }
.page .inner { position: absolute; }
.pg-content, .ink { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.ink { pointer-events: none; }
.ink.hl { mix-blend-mode: multiply; opacity: .42; }
.inner.loading::after { content: ''; position: absolute; left: 50%; top: 40%; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
  border: 4px solid #ccc; border-top-color: #555; animation: spin .9s linear infinite; }
.inner.error::after { content: 'This page could not be shown'; position: absolute; left: 0; right: 0; top: 40%; text-align: center; color: #a33; }
.viewer.night .page { background: #000; }
.viewer.night .inner { filter: invert(1) hue-rotate(180deg); }

/* selected mark */
.sel-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.sel-box { position: absolute; border: 2px dashed var(--accent); border-radius: 6px; background: color-mix(in srgb, var(--accent) 8%, transparent); pointer-events: auto; touch-action: none; cursor: move; }
.sel-handle { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: var(--accent); border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); pointer-events: auto; touch-action: none; }

/* ================= popovers ================= */
.popover { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-panel, 18px); padding: 8px;
  box-shadow: var(--shadow); max-height: calc(100vh - 16px); overflow-y: auto; min-width: 260px; max-width: min(440px, 60vw); animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.popover.wide { max-width: min(480px, 70vw); }
.pop-title { font-size: 14px; letter-spacing: .01em; color: var(--muted); padding: 8px 10px 8px; font-weight: 600; }
.menu { display: flex; flex-direction: column; }
.menu hr { border: 0; border-top: 1px solid var(--border-strong); margin: 6px 6px; width: auto; }
.mitem { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 8px 14px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-size: 17px; width: 100%; color: var(--text); }
.mitem .ic { color: var(--muted); }
.mitem:active { background: var(--surface-3); }
.mitem.on { color: var(--accent-text, var(--accent)); }
.mitem.on .ic { color: var(--accent-text, var(--accent)); }
.mitem.on::after { content: '✓'; margin-left: auto; font-weight: 700; }
.mitem.danger, .mitem.danger .ic { color: var(--danger); }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; padding: 4px; }
.pg-num { height: 56px; border: var(--btn-border); border-radius: 12px; background: var(--surface-2); font-size: 18px; font-variant-numeric: tabular-nums; }
.pg-num.on { background: var(--accent); color: var(--on-accent); }
.stamp-grid { display: grid; grid-template-columns: repeat(5, 66px); gap: 7px; padding: 4px; }
.stamp-btn { width: 66px; height: 66px; border: 2px solid var(--border); border-radius: 13px; background: #fff; padding: 4px; display: grid; place-items: center; }
.stamp-btn canvas { width: 54px; height: 54px; }
.stamp-btn.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.stamp-btn.small { width: 54px; height: 54px; }
.stamp-btn.small canvas { width: 44px; height: 44px; }
.shape-swap { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; }
.style-pop { display: flex; flex-direction: column; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 8px; }
.sw { width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.sw.on { box-shadow: 0 0 0 3px var(--accent); }
.sizes { display: flex; gap: 10px; padding: 4px 8px; }
.sz { width: 64px; height: 58px; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); display: grid; place-items: center; }
.sz.on { border-color: var(--accent); }
.sz .dot { border-radius: 50%; display: block; }

/* ================= library ================= */
.library { background: var(--bg); background-image: linear-gradient(180deg, var(--bg-2), var(--bg) 320px); }
.lib-main { flex: 1; min-width: 0; overflow-y: auto; padding: calc(22px + var(--sa-t)) calc(18px + var(--sa-r)) calc(28px + var(--sa-b)) 22px; -webkit-overflow-scrolling: touch; }
.lib-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.lib-head h1 { margin: 0; font-size: 30px; font-weight: 700; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.crumb { border: 0; background: transparent; font: 700 30px/1.15 var(--font-display); letter-spacing: -0.015em; padding: 4px 8px; margin-left: -8px; border-radius: 10px; color: var(--muted); min-height: 48px; }
.crumb + .sep + .crumb { margin-left: 0; }
.crumb.here { color: var(--text); }
.crumb:active { background: var(--surface-2); }
.crumbs .sep { color: var(--muted); font-size: 24px; opacity: .6; }
.search { display: none; }
.search.open { display: block; max-width: 560px; }
.lib-list { display: flex; flex-direction: column; gap: 10px; }
.lib-row { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 104px;
  transition: border-color .15s, transform .1s; }
[data-theme^="contrast"] .lib-row { border-width: 2px; }
.lib-row:active { transform: scale(.995); }
.lib-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 18px; padding: 12px 14px; border: 0; background: transparent; text-align: left; }
.lib-open:active, .lib-more:active, .ud:active { background: var(--surface-2); }
.thumb { width: 64px; height: 84px; object-fit: cover; object-position: top; background: #fff; border-radius: 5px; flex: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .25), 0 0 0 1px rgba(0, 0, 0, .06); }
.thumb.tile { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text, var(--accent)); box-shadow: none; border-radius: 12px; width: 64px; height: 64px; }
[data-theme^="contrast"] .thumb.tile { background: transparent; border: 2px solid var(--accent); }
.thumb.tile .ic { width: 32px; height: 32px; }
.lib-row.folder .lib-open { min-height: 88px; }
.lib-row.folder { min-height: 88px; }
.lib-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lib-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sub { font-size: 14px; color: var(--muted); }
.lib-sub .pending { color: var(--accent-text, var(--accent)); }
.lib-more { width: 92px; flex: none; border: 0; border-left: 1px solid var(--border); background: transparent; display: grid; place-items: center; color: var(--muted); }
.lib-more .ic { width: 30px; height: 30px; }
.empty { text-align: center; color: var(--muted); padding: 70px 24px; max-width: 560px; margin: 0 auto; }
.empty h2 { color: var(--text); margin: 0 0 10px; }

/* programs */
.prog-row .lib-open { gap: 14px; }
.prog-num { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.lib-open.missing { opacity: .6; }
.updown { flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.ud { flex: 1; width: 72px; border: 0; background: transparent; display: grid; place-items: center; color: var(--muted); }
.ud + .ud { border-top: 1px solid var(--border); }
.pthumb { position: relative; display: block; width: 70px; flex: none; background: #fff; border-radius: 3px; overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.pthumb-img { display: block; width: 100% !important; height: 100% !important; }

/* ================= forms & modals ================= */
.field { width: 100%; font-size: 18px; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--field-border); background: var(--field-bg); color: var(--field-text); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.modal-back { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 12px; backdrop-filter: blur(3px); }
.modal { width: min(640px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--r-panel, 22px); padding: 22px 22px 0; box-shadow: var(--shadow); animation: pop .16s ease-out; }
.modal.wide { width: min(880px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 23px; font-family: var(--font-display); }
.modal-body { margin-bottom: 16px; }
.modal-body p { margin: 0 0 10px; }
.modal-buttons { position: sticky; bottom: 0; display: flex; justify-content: space-between; gap: 12px; padding: 14px 0 20px; background: var(--surface); }
.mbtn { min-height: 54px; padding: 0 22px; border-radius: var(--r-btn, 14px); border: var(--btn-border); background: var(--surface-2); color: var(--text); font-size: 17px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.mbtn:active { background: var(--surface-3); }
.mbtn.primary { background: var(--accent); color: var(--on-accent); }
.mbtn.secondary { background: var(--surface-2); }
.mbtn.danger { background: var(--danger); color: #fff; }
.mbtn .ic { width: 22px; height: 22px; }
.modal-buttons .mbtn { min-width: 140px; }
.modal-buttons .mbtn:only-child { margin-left: auto; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 58px; border: 1px solid var(--border); border-radius: var(--r-btn, 14px); background: var(--surface-2); color: var(--text); padding: 0 16px; font-size: 18px; text-align: left; }
[data-theme^="contrast"] .choice { border-width: 2px; }
.choice:active { background: var(--surface-3); }
.choice.new { background: var(--accent-soft); color: var(--accent-text, var(--accent)); }
[data-theme^="contrast"] .choice.new { color: var(--on-accent); }
.choice.on { box-shadow: inset 0 0 0 2px var(--accent); }
.choice .hint { margin: 0; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 17px; }
.check input { width: 26px; height: 26px; accent-color: var(--accent); }
.modal ul { padding-left: 20px; }
.pick-list { max-height: 55vh; overflow-y: auto; margin-top: 10px; }
.mini-thumb { width: 40px; height: 52px; object-fit: cover; object-position: top; background: #fff; border-radius: 3px; flex: none; }
.pick-text { display: flex; flex-direction: column; }
.range-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.range-info { font-size: 19px; font-weight: 600; }
.range-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.range-cell { position: relative; border: 3px solid transparent; border-radius: 12px; background: var(--surface-2); padding: 5px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text); }
.range-cell .pthumb { width: 100%; }
.range-cell .n { font-weight: 600; }
.range-cell.in { background: var(--accent-soft); }
.range-cell.edge { border-color: var(--accent); }

/* settings */
.settings { display: flex; flex-direction: column; gap: 6px; }
.set-sec { border-top: 1px solid var(--border-strong); padding: 16px 0; }
.set-sec:first-child { border-top: 0; padding-top: 0; }
.set-sec h3 { margin: 0 0 12px; font-size: 17px; letter-spacing: 0; font-family: var(--font-display); color: var(--muted); }
.set-sec h4 { margin: 16px 0 6px; font-size: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; }
.btn-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-b { min-height: 50px; padding: 0 16px; border-radius: var(--r-btn, 12px); border: 1.5px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 16px; }
.seg-b.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.toggle { flex: none; width: 70px; height: 40px; border-radius: 20px; border: var(--btn-border); background: var(--surface-3); position: relative; }
.toggle .knob { position: absolute; top: 4px; left: 4px; width: 32px; height: 32px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle.on { background: var(--ok); }
.toggle.on .knob { left: 34px; }
.keys { font-size: 15px; display: flex; flex-direction: column; gap: 4px; }
.mini { width: 52px; height: 48px; border-radius: 12px; border: var(--btn-border); background: var(--surface-2); margin-left: 6px; display: inline-grid; place-items: center; }
.mini.danger { background: var(--danger-soft); color: var(--danger); }
.mini .ic { width: 22px; height: 22px; }
.person-row { border-bottom: 1px solid var(--border); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; border-radius: 16px; border: 2px solid var(--border-strong); background: var(--surface-2); text-align: left; color: var(--text); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-swatch { position: relative; width: 100%; height: 74px; border-radius: 10px; overflow: hidden; margin-bottom: 4px; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35); }
.ts-rail { position: absolute; left: 0; top: 0; bottom: 0; width: 26%; border-right: 1px solid rgba(128, 128, 128, .35); }
.ts-accent { position: absolute; left: 7%; top: 14%; width: 12%; height: 22%; border-radius: 4px; }
.ts-page { position: absolute; left: 40%; top: 12%; width: 34%; bottom: 0; background: #fff; border-radius: 2px 2px 0 0; box-shadow: 0 0 0 1px rgba(128, 128, 128, .4), 0 2px 6px rgba(0, 0, 0, .3); }
.theme-name { font-family: var(--font-display); font-weight: 650; font-size: 17px; }
.theme-card { font-family: var(--font); }
.theme-note { font-size: 13px; color: var(--muted); }

/* ================= sign in ================= */
.login { position: fixed; inset: 0; overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: calc(44px + var(--sa-t)) 18px 40px;
  background: radial-gradient(90% 60% at 50% 0%, var(--bg-2), var(--bg)); }
.login-card { width: min(480px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login-logo { width: 88px; height: 88px; border-radius: 22px; align-self: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.login h1 { text-align: center; margin: 6px 0 10px; font-size: 32px; }
.login p { color: var(--muted); margin: 0; }
.login .warn { color: var(--accent); }
.login-msg { color: var(--danger) !important; min-height: 1.3em; }
.login-buttons { display: flex; justify-content: space-between; }
.login-buttons .mbtn { min-width: 170px; }
.people { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.people-title { color: var(--muted); font-size: 15px; letter-spacing: 0; font-weight: 600; }
.person { display: flex; align-items: center; gap: 14px; min-height: 64px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 0 16px; font-size: 19px; text-align: left; }
.person-text { display: flex; flex-direction: column; align-items: flex-start; }
.person-text .hint { font-size: 13px; margin: 0; }
.big-choice { width: 100%; min-height: 78px; justify-content: flex-start; text-align: left; gap: 14px; padding: 12px 18px; border-radius: 18px; }
.big-choice .ic { width: 30px; height: 30px; flex: none; }
.secondary-choice { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice-text b { font-size: 18px; }
.choice-text small { font-size: 14px; font-weight: 400; opacity: .82; }
.server-box { display: flex; flex-direction: column; gap: 10px; }
.server-box summary { color: var(--muted); padding: 10px 0; cursor: pointer; }
.server-box[open] { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 10px 16px 16px; }
.server-box[open] > * + * { margin-top: 10px; }
.server-box.main summary { font-size: 18px; color: var(--text); font-weight: 600; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 14px 0; }
.privacy-link { align-self: center; color: var(--muted); font-size: 14px; margin-top: 18px; }

/* ================= scanner ================= */
.scanner { z-index: 40; background: var(--bg); }
.scan-stage { display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; background: var(--stage); }
.scan-grid { align-self: stretch; flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; padding: 22px; overflow-y: auto; align-content: start; touch-action: pan-y; }
.scan-grid .empty { grid-column: 1 / -1; }
.scan-thumb { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; color: var(--text); }
.scan-thumb img { width: 100%; aspect-ratio: 0.77; object-fit: contain; background: #fff; border-radius: 4px; }
.crop-wrap { position: relative; }
.crop-img, .crop-overlay { position: absolute; left: 0; top: 0; }
.crop-wrap.preview { display: flex; justify-content: center; align-items: center; height: 100%; width: 100%; padding: 16px; }
.scan-preview { max-width: 100%; max-height: 100%; background: #fff; box-shadow: var(--page-shadow); }
.handle { position: absolute; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; border: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 25%, transparent); touch-action: none; z-index: 2; }
.handle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--accent); }

/* ================= busy + toast ================= */
.busy { position: fixed; inset: 0; z-index: 200; background: var(--overlay); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; backdrop-filter: blur(3px); }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid color-mix(in srgb, var(--text) 20%, transparent); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.busy-msg { font-size: 18px; text-align: center; padding: 0 20px; color: var(--text); }
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--sa-b)); transform: translate(-50%, 30px); background: var(--text); color: var(--bg);
  padding: 12px 22px; border-radius: 14px; z-index: 300; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: min(560px, 80vw); text-align: center; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= smaller screens ================= */
@media (max-width: 640px) {
  :root { --rail-w: 70px; --btn-h: 56px; }
  .rbtn .lbl { font-size: 10px; }
  .lib-more { width: 70px; }
  .stamp-grid { grid-template-columns: repeat(4, 60px); }
  .stamp-btn { width: 60px; height: 60px; }
}
@media (max-height: 700px) {
  :root { --btn-h: 54px; }
  .rbtn.turn { min-height: 72px; }
  .rbtn .lbl { display: none; }
}
.mtext { display: flex; flex-direction: column; gap: 1px; }
.mtext small { font-size: 13px; color: var(--muted); }

/* ================= computer (mouse / trackpad) ================= */
[data-device="computer"] {
  --rail-w: 80px;
  --btn-h: 58px;
}
[data-device="computer"] .rbtn { border-radius: var(--r-btn, 12px); min-height: var(--btn-h); }
[data-device="computer"] .rbtn .lbl { font-size: 11px; }
[data-device="computer"] .rbtn.turn { min-height: 76px; }
[data-device="computer"] .rbtn.big { min-height: 66px; }
[data-device="computer"] .rbtn:hover:not(:disabled) { background: var(--surface-3); }
[data-device="computer"] .rbtn.active:hover, [data-device="computer"] .rbtn.on:hover { background: var(--accent-soft); }
[data-device="computer"] .rbtn.done:hover { filter: brightness(1.08); background: var(--ok); }
[data-device="computer"] .mitem { min-height: 46px; font-size: 16px; }
[data-device="computer"] .mitem:hover, [data-device="computer"] .choice:hover, [data-device="computer"] .mbtn:hover:not(.primary):not(.danger) { background: var(--surface-3); }
[data-device="computer"] .mbtn.primary:hover { filter: brightness(1.07); }
[data-device="computer"] .mbtn { min-height: 46px; }
[data-device="computer"] .choice { min-height: 50px; }
[data-device="computer"] .lib-main { padding-left: 28px; padding-right: calc(28px + var(--sa-r)); }

/* library as a grid of cards */
[data-device="computer"] .lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; }
[data-device="computer"] .lib-row { position: relative; flex-direction: column; min-height: 0; }
[data-device="computer"] .lib-row:hover { border-color: var(--border-strong); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
[data-device="computer"] .lib-row:hover .lib-more { opacity: 1; }
[data-device="computer"] .lib-open { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
[data-device="computer"] .lib-row .thumb { width: 100%; height: auto; aspect-ratio: 0.77; border-radius: 4px; }
[data-device="computer"] .lib-row .thumb.tile { aspect-ratio: auto; height: 96px; width: 100%; border-radius: 12px; }
[data-device="computer"] .lib-row .thumb.tile .ic { width: 40px; height: 40px; }
[data-device="computer"] .lib-row.folder, [data-device="computer"] .lib-row.folder .lib-open { min-height: 0; }
[data-device="computer"] .lib-title { font-size: 16px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
[data-device="computer"] .lib-sub { font-size: 13px; }
[data-device="computer"] .lib-more { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: 0 1px 6px rgba(0, 0, 0, .25); opacity: .85; }
[data-device="computer"] .lib-more .ic { width: 22px; height: 22px; }
/* the program editor keeps its list (order matters there) */
[data-device="computer"] .lib-list.prog-list { display: flex; }
[data-device="computer"] .prog-list .lib-row { flex-direction: row; }
[data-device="computer"] .prog-list .lib-open { flex-direction: row; align-items: center; }
[data-device="computer"] .prog-list .lib-more { position: static; width: 72px; height: auto; border-radius: 0; background: transparent; box-shadow: none; border-left: 1px solid var(--border); opacity: 1; }

/* tall, narrow screens (a tablet held upright): a little more room for the music */
@media (orientation: portrait) and (max-width: 900px) {
  [data-device="touch"] { --rail-w: 80px; }
}

/* drag and drop */
.drop-zone { position: fixed; inset: 10px; z-index: 150; border: 4px dashed var(--accent); border-radius: 26px; background: color-mix(in srgb, var(--bg) 80%, transparent);
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; pointer-events: none; backdrop-filter: blur(3px); }
.drop-zone.on { display: flex; }
.drop-zone .ic { width: 64px; height: 64px; color: var(--accent); }
.drop-zone b { font-size: 26px; font-family: var(--font-display); }
.drop-zone span { color: var(--muted); }

/* ===== each style's lettering and icon drawing ===== */
.ic svg { stroke-width: var(--ic-stroke, 1.75); stroke-linecap: var(--ic-cap, round); stroke-linejoin: var(--ic-join, round); }
[data-theme^="contrast"] { --ic-stroke: 2.4; }
[data-theme="graphite"] { --ic-stroke: 1.5; }
[data-theme="utilitarian"] { --font: "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif; --font-display: var(--font); --ic-stroke: 2.2; --ic-cap: square; --ic-join: miter; }
[data-theme="japandi"] { --font: "Zen Kaku Gothic New", "Avenir Next", "Segoe UI", sans-serif; --font-display: var(--font); }
[data-theme="bento"] { --font: "DM Sans", "Segoe UI", Roboto, sans-serif; --font-display: var(--font); }
[data-theme="light-academia"] { --font: "EB Garamond", "Iowan Old Style", Palatino, Georgia, serif; --font-display: "Cormorant Garamond", "EB Garamond", Georgia, serif; }
[data-theme="dark-academia"] { --font: "Lora", "Iowan Old Style", Palatino, Georgia, serif; --font-display: "Playfair Display", "Lora", Georgia, serif; }
[data-theme="mid-century"] { --font: "Jost", Futura, "Century Gothic", "Avenir Next", sans-serif; --font-display: var(--font); }
/* serif lettering reads smaller, so the little labels get a touch bigger */
[data-theme="light-academia"] .rbtn .lbl { font-size: 13px; font-weight: 600; }
[data-theme="dark-academia"] .rbtn .lbl { font-size: 11.5px; letter-spacing: -.01em; }
[data-theme="light-academia"] h1, [data-theme="light-academia"] .crumb { font-weight: 700; }
[data-theme="mid-century"] .rbtn .lbl { font-size: 12px; font-weight: 500; }
[data-theme="japandi"] .rbtn .lbl { font-weight: 500; }
/* Phosphor icon sets: two-tone icons are tinted with the style's accent */
.ic svg[data-set="ph"] { stroke: none; }
[data-theme="bento"] .rbtn .ic svg [opacity="0.2"], [data-theme="dark-academia"] .rbtn .ic svg [opacity="0.2"] { fill: var(--accent); opacity: .45; }
.lib-more .ic svg [opacity="0.2"], .mini .ic svg [opacity="0.2"] { opacity: 0; }
[data-theme="dark-academia"] .rbtn .ic { color: var(--accent); }
[data-theme="dark-academia"] .rbtn.done .ic, [data-theme="dark-academia"] .rbtn.active .ic { color: inherit; }
[data-theme="mid-century"] .rail.left .rbtn:not(.active):not(.done) .ic { color: #2f6f6a; }
[data-theme="mid-century"] .rail.right .rbtn:not(.active):not(.done):not(.turn) .ic { color: #8f3a19; }
[data-theme="light-academia"] .rbtn:not(.active):not(.done) .ic { color: #5a3a2a; }
[data-theme="japandi"] .rbtn:not(.active):not(.done) .ic { color: #4f4a42; }
