/* ==========================================================================
   Genki Music metronome
   Tokens follow the main site (genkimusic.com) so the two read as one family.
   Mobile-first: this gets used on a phone on a music stand more than anywhere.
   ========================================================================== */

:root {
	--bg:            #0b0c10;
	--bg-elevated:   #13151c;
	--surface:       #171a22;
	--surface-hover: #1e222c;
	--line:          #272b36;
	--line-soft:     #1f232c;

	--text:          #eceef3;
	--text-muted:    #9aa2b1;
	--text-faint:    #6b7383;

	--red:     #ff5f6d;
	--orange:  #ff9f45;
	--yellow:  #ffd166;
	--green:   #5ddc95;
	--teal:    #45c9d6;
	--blue:    #6f8cff;
	--purple:  #b98cff;

	--accent: var(--teal);

	--font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
	             Roboto, Helvetica, Arial, sans-serif;
	--font-display: "Space Grotesk", var(--font-sans);

	--wrap: 980px;
	--radius: 14px;
	--radius-sm: 8px;
	--header-h: 60px;
	--shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }

/* Panels, the stage view and the conductor all set a display of their own,
   which would otherwise beat the browser's rule for [hidden]. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.18); }
a:hover { border-bottom-color: currentColor; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* --- Header ------------------------------------------------------------- */

.site-header {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	gap: 14px;
	height: var(--header-h);
	padding: 0 16px;
	background: rgba(11, 12, 16, .88);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--line);
}

.brand {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 14px;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--text-muted);
	border: 0;
}
.brand:hover { color: var(--text); }

.site-title {
	margin: 0;
	font-size: 18px;
	letter-spacing: -.01em;
}
.site-title::before {
	content: "";
	display: inline-block;
	width: 6px; height: 6px;
	margin-right: 9px;
	border-radius: 50%;
	background: var(--accent);
	vertical-align: middle;
}

.header-actions { margin-left: auto; }

/* --- Layout ------------------------------------------------------------- */

.wrap {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 18px 14px 60px;
}

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px;
	margin-bottom: 16px;
	box-shadow: var(--shadow);
}

.panel__title {
	margin: 0 0 14px;
	font-size: 15px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--text-muted);
}
.panel__hint {
	text-transform: none;
	letter-spacing: 0;
	font-size: 13px;
	font-weight: 400;
	color: var(--text-faint);
	margin-left: 8px;
}

.sub {
	margin: 22px 0 6px;
	font-size: 14px;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: var(--accent);
}

.note {
	margin: 6px 0;
	font-size: 13px;
	color: var(--text-faint);
	line-height: 1.5;
}

/* --- Transport ---------------------------------------------------------- */

.panel--transport {
	background: linear-gradient(180deg, var(--bg-elevated), var(--surface));
	text-align: center;
}

.readout { margin-bottom: 6px; }

.readout__row {
	display: flex;
	align-items: baseline;
	justify-content: center;
	gap: 12px;
	flex-wrap: wrap;
}
.readout__row--small { font-size: 13px; color: var(--text-faint); min-height: 20px; }

.readout__section {
	font-family: var(--font-display);
	font-size: 19px;
	font-weight: 600;
}
.readout__sig {
	font-family: var(--font-display);
	font-size: 19px;
	color: var(--accent);
	font-variant-numeric: tabular-nums;
}

.bpm {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin: 4px 0 2px;
}

.bpm__main { min-width: 190px; }

.bpm__value {
	display: block;
	font-family: var(--font-display);
	font-size: 76px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -.03em;
	font-variant-numeric: tabular-nums;
}
.bpm__value.is-trained { color: var(--yellow); }

.bpm__unit {
	display: block;
	font-size: 12px;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--text-faint);
}

.bpm__step {
	width: 48px; height: 48px;
	flex: 0 0 auto;
	font-size: 24px;
	line-height: 1;
	color: var(--text);
	background: var(--surface-hover);
	border: 1px solid var(--line);
	border-radius: 50%;
	cursor: pointer;
}
.bpm__step:active { background: var(--accent); color: #0b0c10; }

.bpm__slider { width: 100%; max-width: 520px; margin: 10px 0 4px; }

/* Range inputs, styled the same across the app */
input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	height: 26px;
	background: transparent;
	cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
	height: 5px;
	border-radius: 3px;
	background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 20px; height: 20px;
	margin-top: -8px;
	border-radius: 50%;
	background: var(--accent);
	border: 0;
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--line); }
input[type="range"]::-moz-range-thumb {
	width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--accent);
}

/* --- Visual beat -------------------------------------------------------- */

.visual { min-height: 74px; margin: 6px 0 12px; }

.beat-strip {
	display: flex;
	justify-content: center;
	align-items: flex-end;
	gap: 6px;
	flex-wrap: wrap;
	min-height: 46px;
}

.beat-dot {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: var(--line);
	border: 1px solid var(--line-soft);
	transition: transform .06s ease-out, background-color .18s ease-out;
}
.beat-dot--accent { width: 34px; height: 34px; }
.beat-dot--sub { width: 12px; height: 12px; opacity: .6; }
.beat-dot--silent { background: transparent; border-style: dashed; }
.beat-dot--gap { margin-left: 14px; }

.beat-dot.is-on { background: var(--accent); transform: scale(1.18); }
.beat-dot--accent.is-on { background: var(--yellow); }
.beat-dot.is-muted { background: var(--line-soft); box-shadow: inset 0 0 0 2px var(--text-faint); }

.visual__note { margin: 4px 0 0; font-size: 12px; color: var(--text-faint); min-height: 18px; }

.conductor { width: 100%; max-width: 300px; height: 130px; display: block; margin: 0 auto; }
.conductor__path { fill: none; stroke: var(--line); stroke-width: 1.2; stroke-dasharray: 3 3; }
.conductor__dot { fill: var(--accent); }

.flash {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 5;
	opacity: 0;
	background: var(--accent);
	transition: opacity .12s ease-out;
}
.flash.is-on { opacity: .30; transition: none; }
.flash.is-accent { background: var(--yellow); }

/* --- Buttons ------------------------------------------------------------ */

.transport__buttons {
	display: flex;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
}

.btn {
	font-family: var(--font-sans);
	font-size: 15px;
	font-weight: 600;
	color: var(--text);
	background: var(--surface-hover);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	padding: 11px 18px;
	cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease, transform .06s ease;
}
.btn:hover { background: #232734; border-color: #3a4050; }
.btn:active { transform: translateY(1px); }

.btn--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #08131a;
	min-width: 130px;
}
.btn--primary:hover { background: #63dae6; border-color: #63dae6; }
.btn--primary.is-playing { background: var(--red); border-color: var(--red); color: #2b0a0d; }
.btn--primary.is-playing:hover { background: #ff7480; border-color: #ff7480; }

.btn--ghost { background: transparent; padding: 8px 12px; font-size: 14px; }
.btn--tiny { font-size: 13px; padding: 7px 12px; font-weight: 500; }
.btn--wide { width: 100%; margin-top: 10px; }
.btn--danger:hover { border-color: var(--red); color: var(--red); }
.btn.is-active { border-color: var(--accent); color: var(--accent); }

/* --- Fields ------------------------------------------------------------- */

.grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; }

.field__label {
	font-size: 12px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.val { color: var(--text-faint); letter-spacing: 0; text-transform: none; }

input[type="text"],
input[type="number"],
select {
	font-family: var(--font-sans);
	font-size: 15px;
	color: var(--text);
	background: var(--bg-elevated);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	padding: 9px 10px;
	width: 100%;
	min-height: 42px; /* comfortable on a touchscreen */
}
input:disabled { opacity: .45; }

select {
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
	                  linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
	background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	padding-right: 30px;
}

.sig { display: flex; align-items: center; gap: 6px; }
.sig input { width: 74px; text-align: center; }
.sig select { width: 84px; }
.sig__slash { color: var(--text-faint); font-size: 20px; }

.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type="number"] { width: 90px; }
.inline--share input { flex: 1 1 220px; font-size: 12px; color: var(--text-muted); }
.unit { font-size: 13px; color: var(--text-faint); }

.check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: var(--text);
	cursor: pointer;
	min-height: 42px;
}
.check--block { display: flex; margin-top: 4px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
.check .note { margin: 0; }

/* --- Accent grid -------------------------------------------------------- */

.accents { margin-top: 18px; }
.accents__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 8px;
	flex-wrap: wrap;
}

.accent-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	padding: 10px;
	background: var(--bg-elevated);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
}

.cell {
	display: block;
	width: 30px;
	height: 42px;
	border-radius: 5px;
	border: 1px solid var(--line);
	background: var(--line-soft);
	cursor: pointer;
	position: relative;
	padding: 0;
}
.cell--0 { background: transparent; border-style: dashed; }
.cell--1 { background: #2c3140; }
.cell--2 { background: var(--teal); opacity: .55; }
.cell--3 { background: var(--yellow); }
.cell--group { margin-left: 16px; }
.cell--group::before {
	content: "";
	position: absolute;
	left: -10px; top: -2px; bottom: -2px;
	border-left: 1px solid var(--line);
}
.cell.is-now { box-shadow: 0 0 0 2px var(--text); }
.cell__num {
	position: absolute;
	bottom: 2px;
	left: 0; right: 0;
	font-size: 10px;
	color: rgba(11, 12, 16, .75);
	text-align: center;
	pointer-events: none;
}
.cell--0 .cell__num, .cell--1 .cell__num { color: var(--text-faint); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 0; font-size: 12px; color: var(--text-faint); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend .cell { width: 14px; height: 14px; cursor: default; }

/* --- Song blocks -------------------------------------------------------- */

.blocks { list-style: none; margin: 4px 0 0; padding: 0; }

.block {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	margin-bottom: 8px;
	background: var(--bg-elevated);
	border: 1px solid var(--line);
	border-left: 3px solid var(--line);
	border-radius: var(--radius-sm);
	cursor: pointer;
}
.block:hover { background: var(--surface-hover); }
.block.is-selected { border-left-color: var(--accent); }
.block.is-playing { border-left-color: var(--yellow); background: var(--surface-hover); }

.block__index {
	font-family: var(--font-display);
	font-size: 13px;
	color: var(--text-faint);
	width: 20px;
	flex: 0 0 auto;
}
.block__body { flex: 1 1 auto; min-width: 0; }
.block__name { font-weight: 600; font-size: 15px; }
.block__meta { font-size: 12px; color: var(--text-faint); }
.block__tools { display: flex; gap: 4px; flex: 0 0 auto; }

.icon-btn {
	width: 32px; height: 32px;
	display: grid;
	place-items: center;
	font-size: 14px;
	color: var(--text-muted);
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 6px;
	cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: #3a4050; }
.icon-btn--danger:hover { color: var(--red); border-color: var(--red); }

/* --- Tabs --------------------------------------------------------------- */

.tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	border-bottom: 1px solid var(--line);
	margin: -4px -4px 14px;
	padding: 0 4px;
	scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
	font-family: var(--font-sans);
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	color: var(--text-faint);
	background: transparent;
	border: 0;
	border-bottom: 2px solid transparent;
	padding: 10px 12px;
	cursor: pointer;
}
.tab:hover { color: var(--text-muted); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.tabpanel { display: none; }
.tabpanel.is-active { display: block; }

.session {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px;
	font-size: 14px;
	color: var(--text-muted);
}
.session strong { color: var(--text); font-variant-numeric: tabular-nums; }

.freq { font-family: var(--font-display); font-size: 18px; color: var(--accent); padding-top: 6px; }

.saved { list-style: none; margin: 6px 0 0; padding: 0; }
.saved li {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	margin-bottom: 6px;
	font-size: 14px;
}
.saved li span { flex: 1 1 auto; }
.saved__empty { color: var(--text-faint); font-size: 13px; }

/* --- Stage view --------------------------------------------------------- */

.stage {
	position: fixed;
	inset: 0;
	z-index: 40;
	background: var(--bg);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 20px;
	text-align: center;
}

.stage__exit {
	position: absolute;
	top: 12px; right: 14px;
	width: 44px; height: 44px;
	font-size: 26px;
	color: var(--text-muted);
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 50%;
	cursor: pointer;
}

.stage__section {
	font-family: var(--font-display);
	font-weight: 700;
	font-size: clamp(30px, 9vw, 84px);
	line-height: 1.05;
	letter-spacing: -.02em;
}
.stage__bars {
	font-family: var(--font-display);
	font-size: clamp(56px, 22vw, 190px);
	font-weight: 700;
	line-height: 1;
	color: var(--accent);
	font-variant-numeric: tabular-nums;
}
.stage__beats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.stage__beats .beat-dot { width: 32px; height: 32px; }
.stage__beats .beat-dot--accent { width: 42px; height: 42px; }
.stage__meta {
	display: flex;
	gap: 22px;
	flex-wrap: wrap;
	justify-content: center;
	font-size: clamp(15px, 4vw, 24px);
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}
.stage__play { margin-top: 8px; font-size: 18px; padding: 14px 30px; }

/* --- Modal -------------------------------------------------------------- */

.modal {
	position: fixed;
	inset: 0;
	z-index: 50;
	background: rgba(5, 6, 9, .7);
	backdrop-filter: blur(3px);
	overflow-y: auto;
	padding: 20px;
}
.modal__box {
	position: relative;
	max-width: 620px;
	margin: 40px auto;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: var(--shadow);
}
.modal__box h2 { margin-top: 0; }
.modal__box h3 { margin: 18px 0 4px; font-size: 15px; color: var(--accent); }
.modal__box p { margin: 4px 0; font-size: 15px; color: var(--text-muted); }
.modal__close {
	position: absolute;
	top: 10px; right: 12px;
	width: 40px; height: 40px;
	font-size: 24px;
	color: var(--text-muted);
	background: transparent;
	border: 1px solid var(--line);
	border-radius: 50%;
	cursor: pointer;
}
.keys { list-style: none; margin: 6px 0; padding: 0; font-size: 15px; color: var(--text-muted); }
.keys li { padding: 3px 0; }
kbd {
	display: inline-block;
	min-width: 26px;
	text-align: center;
	font-family: var(--font-sans);
	font-size: 12px;
	color: var(--text);
	background: var(--bg-elevated);
	border: 1px solid var(--line);
	border-bottom-width: 2px;
	border-radius: 5px;
	padding: 2px 6px;
	margin-right: 6px;
}
code {
	font-size: 14px;
	background: var(--bg-elevated);
	border: 1px solid var(--line);
	border-radius: 4px;
	padding: 1px 5px;
}

.site-footer {
	margin-top: 26px;
	text-align: center;
	font-size: 13px;
	color: var(--text-faint);
}

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	z-index: 60;
	background: var(--surface);
	border: 1px solid var(--accent);
	border-radius: var(--radius-sm);
	padding: 10px 16px;
	font-size: 14px;
	box-shadow: var(--shadow);
}

/* --- Wider screens ------------------------------------------------------ */

@media (min-width: 560px) {
	.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.wrap { padding: 24px 20px 70px; }
}

@media (min-width: 820px) {
	.grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.field { grid-column: span 2; }
	.field--narrow { grid-column: span 1; }
	.panel { padding: 20px 22px; }
	.site-header { padding: 0 24px; }
}

/* --- Touch devices ------------------------------------------------------
   This gets used on a phone on a music stand more than anywhere, so the
   controls are sized for a finger rather than a cursor. */

@media (pointer: coarse) {
	/* iOS Safari zooms the whole page in when a field smaller than 16px takes
	   focus, which throws you out of the layout mid-practice. */
	input[type="text"],
	input[type="number"],
	select,
	.inline--share input { font-size: 16px; }

	/* A taller hit area for the sliders. The track and thumb are unchanged:
	   the thumb is offset against the track, not against the input box. */
	input[type="range"] { height: 44px; }

	.btn--tiny { padding: 11px 14px; }
	.btn--ghost { padding: 11px 14px; }
	.brand { display: inline-flex; align-items: center; min-height: 44px; }
	.site-footer a { display: inline-block; padding: 6px 0; }
}

/* On a narrow screen the four section tools leave the name barely a third of
   the row, so they drop to a line of their own. */
@media (max-width: 559px) {
	.block { flex-wrap: wrap; }
	.block__tools {
		flex: 0 0 100%;
		justify-content: flex-end;
		margin-top: 8px;
		padding-top: 8px;
		border-top: 1px solid var(--line);
	}
	.icon-btn { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
	* { transition: none !important; }
}
