/* The Tunebook: a bottle-green cloth binding over white engraved pages. */

:root {
	--bg: #fcfcfa;
	--paper: #ffffff;
	--ink: #161616;
	--muted: #5c5c55;
	--line: #d9d9d1;
	--rule: #161616;
	--lane-line: #e2e2db;
	--card-line: #3a3a35;
	--panel: #f1f2ee;
	--accent: #1e5a3c;
	--accent-bg: #e3eee6;
	--focus: #2f7a52;
	--rubric: #b3261e;
	--rubric-ink: #ffffff;
	--rubric-bg: #f8e3e1;
	--missing: #b3261e;
	--go: #1e5a3c;
	--go-ink: #ffffff;
	--cloth: #1e3b2c;
	--cloth-deep: #152b20;
	--gilt: #c8a04a;
	--gilt-hi: #f2dfa8;
	--highlight: #eef3ef;
	--key-line: #8a8a82;
	--overlay: rgba(252, 252, 250, 0.82);
	--scrim: rgba(12, 20, 15, 0.45);
	--shadow: rgba(20, 30, 24, 0.18);
	--chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23161616' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	--chevron-accent: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e5a3c' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	--sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
	--book: "Libertinus Serif", Georgia, serif;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	--small: 0.8125rem;

	/* Keep --card in step with CARD in app.js, and --gutter with GUTTER. */
	--card: 40px;
	--lane: 76px;
	--gutter: 88px;
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--bg: #121413;
	--paper: #1b1e1c;
	--ink: #ecebe4;
	--muted: #a6a79d;
	--line: #323632;
	--rule: #8f918a;
	--lane-line: #2c302d;
	--card-line: #9a9c94;
	--panel: #222623;
	--accent: #8fc9a5;
	--accent-bg: #1d3327;
	--focus: #8fc9a5;
	--rubric: #e5574a;
	--rubric-ink: #160c0b;
	--rubric-bg: #3a1d1a;
	--missing: #ff7b6e;
	--go: #8fc9a5;
	--go-ink: #0f1a14;
	--cloth: #0e2419;
	--cloth-deep: #08170f;
	--gilt: #d4b068;
	--gilt-hi: #f4e4b4;
	--highlight: #243028;
	--key-line: #6e7069;
	--overlay: rgba(18, 20, 19, 0.82);
	--scrim: rgba(0, 0, 0, 0.55);
	--shadow: rgba(0, 0, 0, 0.5);
	--chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ecebe4' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	--chevron-accent: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238fc9a5' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Pub: the cloth turns violin red, the gilt turns whisky, the page turns table wood. */
:root[data-theme="pub"] {
	color-scheme: dark;
	--bg: #2a1912;
	--paper: #36211a;
	--ink: #f5e6cc;
	--muted: #cdb093;
	--line: #553628;
	--rule: #b8946f;
	--lane-line: #4a2f23;
	--card-line: #c8a684;
	--panel: #3f271d;
	--accent: #eaa53f;
	--accent-bg: #4d331c;
	--focus: #eaa53f;
	--rubric: #ef6a4f;
	--rubric-ink: #2a1912;
	--rubric-bg: #4f2318;
	--missing: #ff8a70;
	--go: #eaa53f;
	--go-ink: #2a1912;
	--cloth: #6b1d14;
	--cloth-deep: #50150e;
	--gilt: #eeb04d;
	--gilt-hi: #fde7bd;
	--highlight: #4a2e21;
	--key-line: #8c6a52;
	--overlay: rgba(42, 25, 18, 0.84);
	--scrim: rgba(10, 4, 2, 0.6);
	--shadow: rgba(0, 0, 0, 0.55);
	--chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f5e6cc' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	--chevron-accent: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23eaa53f' stroke-width='2.5' stroke-linecap='square'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Base */

* {
	box-sizing: border-box;
}

html {
	scrollbar-color: var(--key-line) var(--bg);
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 16px/1.5 var(--sans);
	accent-color: var(--accent);
	caret-color: var(--rubric);
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
}

::selection {
	background: var(--gilt-hi);
	color: var(--cloth-deep);
}

h1,
h2 {
	margin: 0;
	font-weight: 800;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

h1 {
	font-size: 2rem;
	line-height: 1.1;
}

h2 {
	font-size: 1.6rem;
	line-height: 1.15;
}

a {
	color: var(--accent);
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

button {
	font: inherit;
}

/* Cloth band */

.topbar {
	position: sticky;
	top: 0;
	z-index: 5;
	background: var(--cloth);
	color: var(--gilt);
	box-shadow: inset 0 -1px var(--cloth-deep);
}

.topbar::after {
	content: "";
	display: block;
	height: 4px;
	border-top: 1px solid var(--gilt);
	border-bottom: 1px solid var(--gilt);
	background: var(--cloth-deep);
}

.topbar-inner {
	max-width: 1440px;
	margin: 0 auto;
	padding: 0.85rem 2.5rem;
	display: flex;
	align-items: center;
	gap: 0.75rem 2.5rem;
	flex-wrap: wrap;
}

.logo {
	margin: 0;
}

.logo a {
	display: grid;
	font-family: "Libertinus Sans", var(--sans);
	font-size: 1.6rem;
	font-weight: 700;
	line-height: 0.85;
	letter-spacing: -0.01em;
	color: var(--gilt);
	text-decoration: none;
}

.logo a:focus-visible {
	outline-color: var(--gilt);
	outline-offset: 5px;
}

.nav {
	display: flex;
	gap: 2rem;
	margin-right: auto;
}

.nav a {
	position: relative;
	padding: 0.55rem 0;
	color: var(--gilt);
	text-decoration: none;
	font-size: var(--small);
	font-weight: 800;
	letter-spacing: 0.2em;
	text-transform: uppercase;
}

.nav a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0.2em;
	bottom: 0.2rem;
	height: 2px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav a:hover {
	color: var(--gilt-hi);
}

.nav a:hover::after {
	transform: scaleX(0.4);
}

.nav a[aria-current="page"] {
	color: var(--gilt-hi);
}

.nav a[aria-current="page"]::after {
	transform: none;
}

.nav a:focus-visible,
.settings-toggle:focus-visible {
	outline-color: var(--gilt);
}

.sound-hint {
	display: none;
	font-size: var(--small);
	color: var(--gilt-hi);
}

body.audio-locked .sound-hint {
	display: inline;
}

.settings-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.45rem 0.85rem;
	border: 1px solid color-mix(in srgb, var(--gilt) 55%, transparent);
	border-radius: 0;
	background: transparent;
	color: var(--gilt);
	font-size: var(--small);
	font-weight: 800;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	cursor: pointer;
	transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.settings-toggle:hover,
.settings-toggle[aria-expanded="true"] {
	border-color: var(--gilt);
	color: var(--gilt-hi);
	background: var(--cloth-deep);
}

.settings-toggle svg {
	transition: transform 0.3s ease;
}

.settings-toggle[aria-expanded="true"] svg {
	transform: rotate(60deg);
}

/* Page */

main {
	max-width: 1440px;
	margin: 0 auto;
	padding: 2.25rem 2.5rem 3rem;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 2.25rem;
}

.colophon {
	border-top: 1px solid var(--rule);
	padding-top: 1.5rem;
}

.colophon h1 {
	font-size: 1.25rem;
}

.colophon p {
	margin: 0.4rem 0 0;
	max-width: 68ch;
	color: var(--muted);
}

/* The tune page title is the largest mark on the page, as in a tunebook. */
.sheet-head h2 {
	font-size: 2.75rem;
	line-height: 1.05;
}

.title-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

.star-toggle {
	display: grid;
	place-items: center;
	flex: none;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

.star-toggle svg {
	fill: none;
	transition: fill 0.15s, color 0.15s;
}

.star-toggle:hover {
	color: var(--ink);
}

.star-toggle[aria-pressed="true"] {
	color: var(--accent);
}

.star-toggle[aria-pressed="true"] svg {
	fill: currentColor;
}

.library h1 {
	font-size: 2.75rem;
	line-height: 1.05;
}

.library-count {
	margin-top: 0.75rem;
}

.library-list {
	list-style: none;
	margin: 1.25rem 0 0;
	padding: 0;
	border-top: 1px solid var(--line);
	max-width: 46rem;
}

.library-list li {
	display: flex;
	align-items: center;
	gap: 1rem;
	border-bottom: 1px solid var(--line);
}

.library-tune {
	flex: 1;
	min-width: 0;
	display: grid;
	gap: 0.15rem;
	padding: 0.85rem 0;
	color: var(--ink);
	text-decoration: none;
}

.library-tune b {
	font-size: 1.2rem;
	font-weight: 800;
}

.library-tune:hover b {
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

.library-tune span {
	color: var(--muted);
	font-size: var(--small);
}

.library-remove {
	display: grid;
	place-items: center;
	flex: none;
	width: 2.75rem;
	height: 2.75rem;
	border: 0;
	background: none;
	color: var(--muted);
	cursor: pointer;
}

.library-remove:hover {
	color: var(--bg);
	background: var(--ink);
}

.notice {
	padding-bottom: 1.75rem;
}

.notice-actions {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 1.25rem;
	margin-top: 1.5rem;
}

.chord-list-wrap .sheet-head h2 {
	font-size: 1.6rem;
}

.inline-icon {
	vertical-align: -1px;
}

.sheet,
.keyboard-wrap,
.input {
	border-top: 1px solid var(--rule);
	padding-top: 1.5rem;
}

main > :first-child {
	border-top: 0;
	padding-top: 0.5rem;
}

.sheet-head {
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	gap: 1rem 2.5rem;
	flex-wrap: wrap;
}

.sheet-sub {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.6rem 1.75rem;
	margin: 1.1rem 0 0;
	padding-bottom: 1.1rem;
	border-bottom: 1px solid var(--line);
}

.meta,
.hint {
	margin: 0;
	color: var(--muted);
	font-size: var(--small);
}

.sheet > .hint {
	margin: 0.9rem 0 1.5rem;
}

.link {
	border: 0;
	background: none;
	color: var(--accent);
	cursor: pointer;
	padding: 0 0 0 0.4rem;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

.link:hover {
	text-decoration-thickness: 2px;
}

.empty {
	color: var(--muted);
	padding: 1.25rem 0;
	max-width: 60ch;
}

/* Controls: a tunebook tune-header line of inline fields */

.field.bare > span:first-child {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Settings read as one printed tune-header line: values joined by middots. */
.tune-line > .field + .field::before,
.list-tools > .field + .field::before {
	content: "·";
	margin-right: 1.1rem;
	color: var(--muted);
	font-weight: 800;
}

.field {
	display: inline-flex;
	align-items: baseline;
	gap: 0.55rem;
	font-size: var(--small);
	font-weight: 600;
	color: var(--muted);
	white-space: nowrap;
}

.music-fields,
.tune-line {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.75rem 1.75rem;
}

select {
	appearance: none;
	-webkit-appearance: none;
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	color: var(--ink);
	padding: 0.3rem 1.6rem 0.3rem 0.1rem;
	border: 0;
	border-bottom: 2px solid var(--ink);
	border-radius: 0;
	background: transparent var(--chevron) no-repeat right 0.1rem center / 14px;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s;
}

select option,
select optgroup {
	background: var(--paper);
	color: var(--ink);
}

input[type="number"] {
	font: inherit;
	font-size: 1rem;
	font-weight: 600;
	color: var(--ink);
	width: 3.6rem;
	padding: 0.3rem 0.1rem;
	border: 0;
	border-bottom: 2px solid var(--ink);
	border-radius: 0;
	background: transparent;
}

select:hover,
input[type="number"]:hover,
input[type="url"]:hover {
	background-color: var(--panel);
}

select:focus-visible,
input[type="number"]:focus-visible,
input[type="url"]:focus-visible {
	outline: none;
	border-bottom-color: var(--focus);
	background-color: var(--accent-bg);
}

.unit {
	font-weight: 600;
	color: var(--muted);
}

.title-picker {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 0.15rem 0.5rem;
}

.title-select {
	field-sizing: content;
	font-size: inherit;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: var(--accent);
	padding: 0 1.9rem 0.05rem 0;
	border-bottom: 3px solid var(--accent);
	background-image: var(--chevron-accent);
	background-size: 20px;
	background-position: right 0.1rem center;
}

.title-select option,
.title-select optgroup {
	font-size: 1rem;
	font-weight: 400;
}

.check {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	color: var(--muted);
	cursor: pointer;
}

.check input {
	accent-color: var(--ink);
}

.play-group {
	display: flex;
	align-items: center;
	gap: 0.6rem 1.1rem;
	flex-wrap: wrap;
}

.play-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	min-height: 2.75rem;
	padding: 0.6rem 1.35rem;
	border: 1px solid var(--ink);
	border-radius: 0;
	background: var(--ink);
	color: var(--bg);
	font-weight: 800;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	font-size: 0.875rem;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}

.play-toggle:hover {
	background: color-mix(in srgb, var(--ink) 85%, var(--bg));
}

.play-toggle:active {
	transform: translateY(1px);
}

.play-toggle .icon-stop,
.play-toggle[aria-pressed="true"] .icon-play {
	display: none;
}

.play-toggle[aria-pressed="true"] .icon-stop {
	display: block;
}

.play-toggle[aria-pressed="true"] {
	background: var(--rubric);
	border-color: var(--rubric);
	color: var(--rubric-ink);
}

.play-toggle:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.skip-count {
	font-size: var(--small);
}

/* Segmented choice: square, one ink frame */

.segmented {
	display: inline-flex;
	border: 1px solid var(--ink);
}

.segmented label {
	position: relative;
	cursor: pointer;
}

.segmented label + label {
	border-left: 1px solid var(--ink);
}

.segmented input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.segmented span {
	display: block;
	padding: 0.35rem 0.85rem;
	font-size: var(--small);
	font-weight: 600;
	color: var(--ink);
	white-space: nowrap;
	transition: background-color 0.15s, color 0.15s;
}

.segmented label:hover span {
	background: var(--panel);
}

.segmented input:checked + span {
	background: var(--ink);
	color: var(--bg);
}

.segmented input:focus-visible + span {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

/* Legend: one quiet line of keys */

.legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	margin: 0 0 0 auto;
	padding: 0;
	border: 0;
	font-size: var(--small);
}

.legend[hidden] {
	display: none;
}

.legend legend {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.lg {
	color: var(--muted);
	white-space: nowrap;
}

.lg b {
	font-weight: 800;
}

.lg svg {
	vertical-align: -1px;
	margin-right: 0.2rem;
	color: var(--ink);
}

/* Tablature: engraved lines of bars, three lanes per bar */

#output {
	overflow-x: auto;
}

.system {
	display: flex;
	align-items: flex-start;
	padding-top: 1.35rem;
	margin-bottom: 1.25rem;
	transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* During playback the line being played keeps full ink and the rest of the page drops back. */
body.is-playing:has(.card.playing) .system:not(:has(.card.playing)) {
	opacity: 0.28;
}

.gutter {
	flex: none;
	width: var(--gutter);
	display: grid;
	grid-template-rows: repeat(3, var(--lane));
}

.gutter span {
	align-self: center;
	font: 400 0.95rem/1 var(--book);
	font-variant: small-caps;
	letter-spacing: 0.06em;
	text-transform: lowercase;
	color: var(--muted);
}

.measures {
	display: flex;
}

.measure {
	position: relative;
	display: grid;
	grid-template-rows: repeat(3, var(--lane));
	padding: 0 8px;
	border-right: 1px solid var(--rule);
}

.measures > .measure:first-child {
	border-left: 1px solid var(--rule);
}

.measure.rep-start {
	border-left: 4px double var(--rule);
}

.measure.rep-end {
	border-right: 4px double var(--rule);
}

/* The last bar closes with a thin-thick final bar line: the border is the thin line. */
.measure.final::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	right: -6px;
	width: 3px;
	background: var(--rule);
}

.bar-no {
	position: absolute;
	top: -1.2rem;
	left: 0;
	font: 400 0.85rem/1 var(--book);
	color: var(--muted);
}

/* A volta bracket over 1st and 2nd endings. */
.ending {
	position: absolute;
	top: -0.95rem;
	left: 0;
	right: 35%;
	height: 0.75rem;
	padding: 0 0 0 4px;
	border-top: 1px solid var(--rule);
	border-left: 1px solid var(--rule);
	font: 600 0.75rem/1.1 var(--sans);
	color: var(--ink);
}

.ending + .bar-no,
.measure:has(.ending) .bar-no {
	display: none;
}

.lane-line {
	grid-column: 1 / -1;
	align-self: center;
	border-top: 1px solid var(--lane-line);
}

.cell {
	display: flex;
	align-items: center;
	min-width: 0;
	pointer-events: none;
}

/* The cell lets clicks through to the column behind it. Only the card takes them. */
.cell .card {
	pointer-events: auto;
}

.hold {
	flex: 1;
	height: 2px;
	margin: 0 4px 0 2px;
	background: var(--ink);
	opacity: 0.45;
}

.card {
	flex: none;
	width: var(--card);
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 5px 0 4px;
	background: var(--paper);
	border: 1px solid var(--card-line);
	position: relative;
	cursor: default;
	user-select: none;
}

.card.clickable,
.col-hit {
	cursor: pointer;
}

.col-hit:hover {
	background: var(--highlight);
}

body.no-concertina .concertina-only,
body.no-concertina .gutter {
	display: none;
}

body.no-concertina .measure {
	grid-template-rows: var(--lane);
}

.card:hover {
	background: var(--highlight);
}

/* A picked card is filled with the accent tint. */
.card.picked {
	background: var(--accent-bg);
	border-color: var(--accent);
}

/* Joined cards: the gap between two cells is bridged so the cards read as one push or pull block. */
.card.join-r {
	border-right-color: transparent;
}

.card.join-l {
	border-left-color: transparent;
}

.card.join-r::after {
	content: "";
	position: absolute;
	top: -1px;
	bottom: -1px;
	left: 100%;
	width: 6px;
	border-top: 1px solid var(--card-line);
	border-bottom: 1px solid var(--card-line);
	background: var(--paper);
}

/* No button plays this note: the card is struck through. */
.card.missing {
	cursor: default;
	border-color: var(--missing);
	color: var(--missing);
	background: linear-gradient(to top right, transparent calc(50% - 1px), var(--missing) 50%, transparent calc(50% + 1px)) var(--paper);
}

.pitch {
	font-size: 0.75rem;
	line-height: 1.15;
	color: var(--muted);
}

.pitch sub {
	font-size: 1em;
	line-height: 0;
	vertical-align: -0.25em;
}

.note-only {
	font: 800 1.05rem/1.2 var(--sans);
	padding: 8px 0;
}

.note-only sub {
	font-size: 0.65rem;
}

.tab {
	font: 800 1.25rem/1.1 var(--sans);
	white-space: nowrap;
	letter-spacing: -0.02em;
}

.tab .hand-L,
.tab .hand-R {
	font-size: 1rem;
	margin-right: 1px;
}

.dir {
	white-space: nowrap;
	margin-top: 2px;
}

.dir-arrows svg {
	display: block;
	margin: 4px auto 3px;
}

.dir-words {
	font: 800 0.75rem/1.5 var(--sans);
	letter-spacing: 0;
}

.reach {
	font-weight: 800;
	margin-left: -1px;
}

.alts {
	position: absolute;
	top: 2px;
	right: 2px;
	display: flex;
	color: var(--muted);
}

.card.clickable:hover .alts {
	color: var(--accent);
}

.cell-rest {
	justify-content: center;
}

.rest-mark {
	font: 400 0.85rem var(--book);
	font-style: normal;
	color: var(--muted);
	background: var(--bg);
	padding: 0 4px;
}

/* The note being played: reversed to ink, ringed in rubric red. */
.card.playing {
	background: var(--ink);
	color: var(--bg);
	border-color: var(--ink);
	outline: 3px solid var(--rubric);
	outline-offset: 2px;
	z-index: 1;
}

.card.playing .pitch,
.card.playing .hand-L,
.card.playing .hand-R,
.card.playing .alts {
	color: var(--bg);
}

/* Hand colors */

body,
body[data-palette="blue-green"] {
	--hand-L: #1f56c4;
	--hand-R: #23883f;
}

body[data-palette="blue-orange"] {
	--hand-L: #1f56c4;
	--hand-R: #c45a08;
}

body[data-palette="purple-teal"] {
	--hand-L: #7a3db8;
	--hand-R: #0b7d7d;
}

:root:is([data-theme="dark"], [data-theme="pub"]) body[data-palette="blue-green"] {
	--hand-L: #8fb2ff;
	--hand-R: #6fd896;
}

:root:is([data-theme="dark"], [data-theme="pub"]) body[data-palette="blue-orange"] {
	--hand-L: #8fb2ff;
	--hand-R: #ffa461;
}

:root:is([data-theme="dark"], [data-theme="pub"]) body[data-palette="purple-teal"] {
	--hand-L: #cba2f7;
	--hand-R: #5ed6d6;
}

.hand-L {
	color: var(--hand-L);
}

.hand-R {
	color: var(--hand-R);
}

/* Keyboard diagram */

.keyboard-wrap {
	background: var(--bg);
}

.keyboard-head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.75rem 1.5rem;
}

.keyboard-head h2 {
	font-size: 1.25rem;
}

.keyboard-wrap .sheet-head {
	align-items: center;
	margin-bottom: 1.25rem;
}

.pin-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.35rem 0.75rem;
	border: 1px solid var(--ink);
	border-radius: 0;
	background: transparent;
	color: var(--ink);
	font-size: var(--small);
	font-weight: 600;
	cursor: pointer;
}

.pin-toggle:hover {
	background: var(--panel);
}

.pin-toggle[aria-pressed="true"] {
	color: var(--bg);
	background: var(--ink);
}

.pin-toggle[aria-pressed="true"] svg {
	transform: rotate(45deg);
}

#keyboard {
	display: flex;
	justify-content: space-between;
	gap: 2rem;
	flex-wrap: wrap;
}

.kside {
	display: grid;
	gap: 8px;
}

.kside-label,
.kside-label.hand-L,
.kside-label.hand-R {
	font-size: 0.75rem;
	font-weight: 800;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--ink);
	margin-bottom: 0.35rem;
}

.krow {
	display: flex;
	gap: 8px;
}

.kside-L .krow-C,
.kside-R .krow-C {
	margin-left: 16px;
}

.kside-L .krow-G,
.kside-R .krow-acc {
	margin-left: 32px;
}

.row-C,
.row-G,
.row-acc {
	--row: var(--key-line);
}

.key {
	width: 54px;
	height: 62px;
	border-radius: 50%;
	border: 1px solid var(--row);
	background: var(--paper);
	display: grid;
	grid-template-rows: 1fr 1fr;
	padding: 0;
	overflow: visible;
	position: relative;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--ink);
	transition: box-shadow 0.12s;
}

.key.row-acc {
	border-style: dashed;
}

.k-half {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
}

.k-push {
	border-bottom: 1px solid var(--line);
	border-radius: 27px 27px 0 0;
}

.k-pull {
	border-radius: 0 0 27px 27px;
}

.k-half.active {
	background: var(--highlight);
}


.key.hl-push .k-push,
.key.hl-pull .k-pull {
	background: var(--rubric-bg);
}

.key.hl-push,
.key.hl-pull {
	border-color: var(--rubric);
	box-shadow: 0 0 0 2px var(--rubric);
}

.keyboard-wrap.pinned {
	position: fixed;
	z-index: 4;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0 auto;
	width: min(1440px, 100%);
	max-height: 50vh;
	overflow-y: auto;
	padding: 0.85rem 2.5rem 1rem;
	border-top: 1px solid var(--rule);
	box-shadow: 0 -10px 30px var(--shadow);
}

.keyboard-wrap.pinned .sheet-head {
	margin-bottom: 0.5rem;
}

.keyboard-wrap.pinned .hint {
	display: none;
}

/* Settings panel */

.settings {
	position: relative;
}

.settings-panel {
	position: fixed;
	z-index: 31;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(380px, 100vw);
	overflow-y: auto;
	padding: 1.25rem 1.75rem 2rem;
	background: var(--bg);
	color: var(--ink);
	border-left: 1px solid var(--rule);
	box-shadow: -16px 0 40px var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 1.4rem;
	transform: translateX(100%);
	visibility: hidden;
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.32s;
}

.settings-panel.open {
	transform: none;
	visibility: visible;
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-scrim {
	position: fixed;
	z-index: 30;
	inset: 0;
	background: var(--scrim);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

body.settings-open .settings-scrim {
	opacity: 1;
	pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
	.settings-panel,
	.settings-panel.open,
	.settings-scrim,
	.system,
	.nav a::after {
		transition: none;
	}
}

.settings-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: 0.9rem;
	border-bottom: 1px solid var(--rule);
	margin-right: -0.5rem;
}

.settings-head h2 {
	font-size: 1.4rem;
}

.settings-panel fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}

.settings-panel legend {
	font: 800 0.75rem/1 var(--sans);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
	margin-bottom: 0.5rem;
	padding: 0;
}

.settings-panel .check {
	color: var(--ink);
}

.settings-panel select {
	justify-self: start;
}

.theme-choice {
	justify-self: start;
}

.swatch-option {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	cursor: pointer;
}

.swatch {
	width: 30px;
	height: 14px;
	background: linear-gradient(90deg, var(--a) 50%, var(--b) 50%);
}

.settings-reset {
	border-top: 1px solid var(--line) !important;
	padding-top: 1rem !important;
}

.settings-reset .hint {
	margin: 0;
}

.reset-all {
	justify-self: start;
	font-size: var(--small);
	font-weight: 800;
	padding: 0.45rem 0.85rem;
	border: 1px solid var(--ink);
	border-radius: 0;
	background: transparent;
	color: var(--ink);
	cursor: pointer;
}

.reset-all:hover {
	background: var(--ink);
	color: var(--bg);
}

/* The second click deletes everything, so the confirm state is red. */
.reset-all[data-confirm="true"] {
	background: var(--missing);
	border-color: var(--missing);
	color: var(--bg);
}

/* About */

.about {
	width: min(452px, calc(100vw - 2rem));
	max-height: calc(100vh - 2rem);
	padding: 0 0 1.5rem;
	border: 1px solid var(--rule);
	border-radius: 0;
	background: var(--bg);
	color: var(--ink);
	box-shadow: 0 18px 50px var(--shadow);
	text-align: center;
}

.about::before {
	content: "";
	display: block;
	height: 14px;
	margin-bottom: 1.75rem;
	background: var(--cloth);
	border-bottom: 4px double var(--gilt);
}

.about::backdrop {
	background: var(--scrim);
}

.about > * {
	margin-left: 1.75rem;
	margin-right: 1.75rem;
}

.about img {
	display: block;
	margin: 0 auto 1rem;
	border-radius: 50%;
	object-fit: cover;
	box-shadow: 0 0 0 1px var(--rule), 0 0 0 5px var(--bg), 0 0 0 6px var(--gilt);
}

.about h2 {
	margin-bottom: 0.6rem;
	font-size: 1.4rem;
}

.about p {
	margin-top: 0;
	margin-bottom: 0.7rem;
}

.about-close-form {
	position: absolute;
	top: 1.1rem;
	right: 0.6rem;
	margin: 0 !important;
}

.about-close {
	width: 36px;
	height: 36px;
	border: 0;
	background: none;
	color: var(--muted);
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}

.about-close:hover {
	background: var(--panel);
	color: var(--ink);
}

.pint {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0.5rem 0 1.25rem;
	padding: 0.7rem 1.35rem;
	background: var(--cloth);
	color: var(--gilt-hi);
	border: 1px solid var(--gilt);
	box-shadow: inset 0 0 0 3px var(--cloth), inset 0 0 0 4px var(--gilt);
	font-weight: 800;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	font-size: 0.875rem;
	text-decoration: none;
}

.pint:hover {
	background: var(--cloth-deep);
	box-shadow: inset 0 0 0 3px var(--cloth-deep), inset 0 0 0 4px var(--gilt);
}

.about .about-thanks {
	padding-top: 0.9rem;
	border-top: 1px solid var(--line);
	font-size: var(--small);
	color: var(--muted);
	margin-bottom: 0;
}

.about-thanks a {
	color: inherit;
}

/* Stop button: always in view during playback, for touch screens without Escape. */

.stop-all {
	position: absolute;
	top: calc(100% + 0.9rem);
	right: max(2.5rem, calc((100% - 1440px) / 2 + 2.5rem));
	display: none;
	align-items: center;
	gap: 0.55rem;
	min-height: 3rem;
	padding: 0.7rem 1.5rem;
	border: 0;
	border-radius: 0;
	background: var(--rubric);
	color: var(--rubric-ink);
	font-weight: 800;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	box-shadow: 0 8px 22px var(--shadow);
	cursor: pointer;
}

.stop-all:hover {
	filter: brightness(1.08);
}

body.is-playing.stop-offscreen .stop-all {
	display: inline-flex;
}

/* Keeps the button above the count-in overlay. */
body.is-playing .topbar {
	z-index: 21;
}

/* Count-in overlay */

.countdown {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: grid;
	place-items: center;
	background: var(--overlay);
	pointer-events: none;
}

.countdown-number {
	font: 800 clamp(6rem, 22vw, 14rem) / 1 var(--sans);
	color: var(--ink);
	animation: count-pop 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes count-pop {
	from {
		transform: scale(1.35);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.countdown-number {
		animation: none;
	}
}

/* Tunes input */

.label {
	display: block;
	font-weight: 800;
	margin-bottom: 0.5rem;
}

textarea {
	width: 100%;
	min-height: 8rem;
	font: 0.875rem/1.6 var(--mono);
	color: var(--ink);
	padding: 0.85rem 1rem;
	border: 1px solid var(--rule);
	border-radius: 0;
	background: var(--paper);
	resize: vertical;
}

textarea:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 0;
}

textarea::placeholder {
	color: var(--muted);
}

.input-help {
	margin: 0.6rem 0 0;
}

.tune-source {
	margin-bottom: 1.25rem;
}

.url-form {
	display: flex;
	align-items: flex-end;
	gap: 1rem;
	max-width: 42rem;
}

input[type="url"] {
	flex: 1;
	min-width: 0;
	font: 0.9375rem var(--mono);
	color: var(--ink);
	padding: 0.4rem 0.1rem;
	border: 0;
	border-bottom: 2px solid var(--ink);
	border-radius: 0;
	background: transparent;
}

input[type="url"]::placeholder {
	color: var(--muted);
	font-weight: 400;
}

.load-btn {
	min-height: 2.75rem;
	padding: 0.5rem 1.25rem;
	border: 1px solid var(--ink);
	border-radius: 0;
	background: transparent;
	color: var(--ink);
	font-weight: 800;
	font-size: 0.875rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	cursor: pointer;
}

.load-btn:hover {
	background: var(--ink);
	color: var(--bg);
}

.setting-field {
	display: flex;
	max-width: 100%;
	margin-top: 1rem;
}

.setting-field[hidden] {
	display: none;
}

.setting-field select {
	min-width: 0;
	max-width: 100%;
	text-overflow: ellipsis;
}

#url-status.is-error {
	color: var(--missing);
}

.input-help + .input-help {
	margin-top: 0.3rem;
}

.input-help code {
	font: 0.8rem var(--mono);
	background: var(--panel);
	padding: 0 4px;
}

.input-help .link {
	padding: 0;
}

.sheet > .tempo-help {
	margin-bottom: -0.9rem;
}

body.no-concertina .sheet > .tempo-help {
	margin-bottom: 1.5rem;
}

/* Chords */

.chord-system .measures {
	flex-wrap: wrap;
	gap: 3rem 1.25rem;
}

.chord-system {
	padding-top: 2.4rem;
}

.chord-system .measure,
.chord-system .measures > .measure:first-child {
	border: 1px solid var(--rule);
}

/* Chord boxes are wider than their cards, so the lanes are drawn on the box itself. */
.measure.chord {
	background:
		linear-gradient(var(--lane-line), var(--lane-line)) 0 calc(var(--lane) * 0.5) / 100% 1px no-repeat,
		linear-gradient(var(--lane-line), var(--lane-line)) 0 calc(var(--lane) * 1.5) / 100% 1px no-repeat,
		linear-gradient(var(--lane-line), var(--lane-line)) 0 calc(var(--lane) * 2.5) / 100% 1px no-repeat;
}

.measure.chord .lane-line {
	visibility: hidden;
}

body.no-concertina .measure.chord {
	background: linear-gradient(var(--lane-line), var(--lane-line)) 0 calc(var(--lane) * 0.5) / 100% 1px no-repeat;
}

.chord-head {
	position: absolute;
	left: -1px;
	right: -1px;
	bottom: calc(100% + 6px);
	display: flex;
	align-items: center;
	gap: 0.45rem;
	white-space: nowrap;
}

.chord-name {
	font-weight: 800;
	font-size: 1.15rem;
}

.chord-roman {
	font: 400 1rem/1 var(--book);
	color: var(--muted);
}

.chord-actions {
	display: flex;
	gap: 0.3rem;
	margin-left: auto;
}

.chord-next,
.chord-play,
.chord-add,
.chord-remove,
.chord-sample {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	min-width: 1.75rem;
	height: 1.75rem;
	padding: 0 0.4rem;
	border: 1px solid var(--line);
	border-radius: 0;
	background: var(--bg);
	color: var(--muted);
	font-size: 0.75rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.chord-sample {
	vertical-align: middle;
	margin: 0 0.15rem;
	cursor: default;
}

.chord-next:hover,
.chord-add:hover {
	color: var(--ink);
	border-color: var(--ink);
}

.chord-play {
	color: var(--go-ink);
	background: var(--go);
	border-color: var(--go);
}

.chord-play:hover {
	filter: brightness(1.12);
}

.chord-add.added {
	color: var(--bg);
	background: var(--ink);
	border-color: var(--ink);
}

.chord-remove {
	color: var(--ink);
	border-color: var(--ink);
}

.chord-remove:hover {
	color: var(--bg);
	background: var(--ink);
}

.list-tools {
	display: flex;
	align-items: center;
	gap: 0.75rem 1.75rem;
	flex-wrap: wrap;
	margin: 1.1rem 0 0.5rem;
	padding-bottom: 1.1rem;
	border-bottom: 1px solid var(--line);
}

/* Phone */

@media (max-width: 700px) {
	main {
		padding: 1.25rem 1rem 2rem;
		gap: 1.75rem;
	}

	.sheet-head h2,
	.library h1 {
		font-size: 2rem;
	}

	.tune-line > .field + .field::before,
	.list-tools > .field + .field::before {
		content: none;
	}

	h1 {
		font-size: 1.5rem;
	}

	h2 {
		font-size: 1.35rem;
	}

	.topbar-inner {
		padding: 0.7rem 1rem 0.4rem;
		gap: 0.25rem 0.6rem;
	}

	.logo a {
		font-size: 1.4rem;
	}

	.nav {
		order: 5;
		flex-basis: 100%;
		gap: 0;
		justify-content: space-between;
		border-top: 1px solid color-mix(in srgb, var(--gilt) 35%, transparent);
	}

	.nav a {
		flex: 1;
		text-align: center;
		padding: 0.7rem 0 0.6rem;
	}

	.nav a::after {
		left: 30%;
		right: 30%;
		bottom: 0.25rem;
	}

	.about-toggle {
		margin-left: auto;
	}

	.settings-toggle {
		padding: 0.5rem 0.65rem;
		letter-spacing: 0.08em;
	}

	/* Overlay the hint so the page does not jump when the first tap hides it. */
	body.audio-locked .sound-hint {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		right: 0;
		padding: 0.4rem 1rem;
		background: var(--cloth-deep);
	}

	.sheet-head {
		align-items: flex-start;
	}

	.legend {
		margin-left: 0;
	}

	.keyboard-wrap.pinned {
		padding: 0.6rem 0.75rem;
	}

	.keyboard-wrap.pinned #keyboard {
		flex-direction: row;
		flex-wrap: nowrap;
		overflow-x: auto;
	}

	#keyboard {
		flex-direction: column;
		gap: 1.25rem;
	}

	.krow {
		gap: 5px;
	}

	.key {
		width: 46px;
		height: 54px;
		font-size: 0.72rem;
	}

	.kside-L .krow-C,
	.kside-R .krow-C {
		margin-left: 12px;
	}

	.kside-L .krow-G,
	.kside-R .krow-acc {
		margin-left: 24px;
	}

	.stop-all {
		right: 1rem;
	}

	:root {
		--gutter: 44px;
	}

	/* Short lane names on phones: the gutter keeps more room for the bars. */
	.gutter span {
		font-size: 0;
	}

	.gutter span::before {
		font-size: 0.8rem;
		letter-spacing: 0;
	}

	.gutter-acc::before {
		content: "acc";
	}

	.gutter-C::before {
		content: "C";
	}

	.gutter-G::before {
		content: "G";
	}
}

@media print {
	.controls,
	.keyboard-wrap,
	.topbar {
		display: none !important;
	}

	body {
		background: #fff;
	}

	.sheet {
		border: 0;
	}

	main {
		padding: 0;
		max-width: none;
	}

	.system {
		break-inside: avoid;
	}
}
