/* Tokens from DESIGN.md. Keep in sync. */
@font-face {
	font-family: 'Noto Sans Sinhala';
	src: url(fonts/NotoSansSinhala.woff2) format('woff2');
	font-weight: 400 800;
	font-display: swap;
}
@font-face {
	font-family: 'Abhaya Libre';
	src: url(fonts/AbhayaLibre-Regular.woff2) format('woff2');
	font-weight: 400;
	font-display: swap;
}
@font-face {
	font-family: 'Abhaya Libre';
	src: url(fonts/AbhayaLibre-SemiBold.woff2) format('woff2');
	font-weight: 600;
	font-display: swap;
}

:root {
	color-scheme: light;
	--page: #f5f5f7;
	--surface: #ffffff;
	--raised: #fafafc;
	--ink: #18181b;
	--muted: #63636e;
	--line: #e4e4e7;
	--fill: rgb(120 120 128 / 0.12); /* tinted buttons, segmented track */
	--fill-strong: rgb(120 120 128 / 0.2);

	--guru: #7c3aed;
	--guru-text: #6d28d9;
	--guru-soft: #ede9fe;
	--laghu: #38bdf8;
	--laghu-text: #0369a1;
	--laghu-soft: #e0f2fe;
	--yati: #db2777;
	--note: #f59e0b;
	--note-text: #b45309;
	--note-soft: #fef3c7;
	--fits: #10b981;
	--fits-text: #047857;
	--off: #f43f5e;
	--off-text: #be123c;

	--focus: rgb(124 58 237 / 0.45);
	--material: rgb(255 255 255 / 0.72);
	--material-edge: rgb(255 255 255 / 0.7);
	--float-shadow: 0 10px 30px -12px rgb(24 24 27 / 0.28), 0 0 0 0.5px rgb(24 24 27 / 0.08);
	--backdrop: rgb(0 0 0 / 0.32);

	--ui: 'Noto Sans Sinhala', -apple-system, 'Segoe UI', system-ui, sans-serif;
	--verse: 'Abhaya Libre', 'Noto Serif Sinhala', 'Iskoola Pota', serif;

	/* Motion: iOS springs baked into linear() (js/spring.js cssSpring). */
	--spring: linear(0, 0.038, 0.127, 0.241, 0.362, 0.479, 0.584, 0.677, 0.754, 0.818, 0.868, 0.908, 0.938, 0.96, 0.976, 0.987, 0.995, 1, 1.003, 1.004, 1.005, 1.005, 1.005, 1.004, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1.001, 1);
	--spring-ms: 533ms;
	--spring-bounce: linear(0, 0.043, 0.147, 0.281, 0.424, 0.561, 0.682, 0.785, 0.867, 0.93, 0.975, 1.006, 1.025, 1.035, 1.038, 1.037, 1.034, 1.029, 1.024, 1.018, 1.013, 1.009, 1.006, 1.003, 1.001, 1, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 1);
	--spring-bounce-ms: 808ms;
	--spring-smooth: linear(0, 0.036, 0.118, 0.222, 0.329, 0.433, 0.527, 0.61, 0.682, 0.742, 0.793, 0.834, 0.868, 0.895, 0.917, 0.935, 0.949, 0.96, 0.969, 0.976, 0.981, 0.985, 0.989, 0.991, 0.993, 0.995, 0.996, 0.997, 0.998, 0.998, 0.999, 0.999, 1);
	--spring-smooth-ms: 750ms;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		color-scheme: dark;
		--page: #000000;
		--surface: #161618;
		--raised: #212124;
		--ink: #f4f4f5;
		--muted: #a1a1aa;
		--line: #2a2a2e;
		--fill: rgb(120 120 128 / 0.24);
		--fill-strong: rgb(120 120 128 / 0.36);
		--guru: #a78bfa;
		--guru-text: #c4b5fd;
		--guru-soft: #2e1f5e;
		--laghu: #7dd3fc;
		--laghu-text: #7dd3fc;
		--laghu-soft: #0c2e44;
		--yati: #f472b6;
		--note: #fbbf24;
		--note-text: #fbbf24;
		--note-soft: #3a2a06;
		--fits: #34d399;
		--fits-text: #34d399;
		--off: #fb7185;
		--off-text: #fb7185;
		--focus: rgb(167 139 250 / 0.55);
		--material: rgb(30 30 32 / 0.72);
		--material-edge: rgb(255 255 255 / 0.08);
		--float-shadow: 0 10px 30px -12px rgb(0 0 0 / 0.7), 0 0 0 0.5px rgb(255 255 255 / 0.08);
		--backdrop: rgb(0 0 0 / 0.55);
	}
}
:root[data-theme='dark'] {
	color-scheme: dark;
	--page: #000000;
	--surface: #161618;
	--raised: #212124;
	--ink: #f4f4f5;
	--muted: #a1a1aa;
	--line: #2a2a2e;
	--fill: rgb(120 120 128 / 0.24);
	--fill-strong: rgb(120 120 128 / 0.36);
	--guru: #a78bfa;
	--guru-text: #c4b5fd;
	--guru-soft: #2e1f5e;
	--laghu: #7dd3fc;
	--laghu-text: #7dd3fc;
	--laghu-soft: #0c2e44;
	--yati: #f472b6;
	--note: #fbbf24;
	--note-text: #fbbf24;
	--note-soft: #3a2a06;
	--fits: #34d399;
	--fits-text: #34d399;
	--off: #fb7185;
	--off-text: #fb7185;
	--focus: rgb(167 139 250 / 0.55);
	--material: rgb(30 30 32 / 0.72);
	--material-edge: rgb(255 255 255 / 0.08);
	--float-shadow: 0 10px 30px -12px rgb(0 0 0 / 0.7), 0 0 0 0.5px rgb(255 255 255 / 0.08);
	--backdrop: rgb(0 0 0 / 0.55);
}

/* Base */
*,
*::before,
*::after {
	box-sizing: border-box;
}
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}
body {
	margin: 0;
	background: var(--page);
	color: var(--ink);
	font: 400 17px/1.6 var(--ui);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}
button,
textarea,
select {
	font: inherit;
	color: inherit;
}
button {
	cursor: pointer;
	border: 0;
	background: none;
	padding: 0;
	touch-action: manipulation;
}
:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
	border-radius: 10px;
}
h1,
h2,
h3,
p {
	margin: 0;
}
kbd {
	font: 600 15px/1 var(--ui);
	padding: 1px 7px 2px;
	border-radius: 6px;
	background: var(--fill);
	color: var(--yati);
}
.ic {
	width: 22px;
	height: 22px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.vh {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Press feedback: a spring scale, never a colour flash. */
.press,
.plain,
.icon-btn,
.chip,
.syl,
.btn,
.row-btn {
	transition: transform var(--spring-ms) var(--spring);
}
.press:active,
.plain:active,
.icon-btn:active,
.chip:active,
.syl:active,
.btn:active,
.row-btn:active {
	transform: scale(0.96);
	transition-duration: 120ms;
}

/* Page */
.page {
	max-width: 1180px;
	margin: 0 auto;
	padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 32px
		max(16px, env(safe-area-inset-left));
}
.top {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	padding: 20px 0 20px;
}
.brand h1 {
	font: 800 40px/1.15 var(--ui);
	letter-spacing: -0.01em;
}
.sub {
	color: var(--muted);
	font-size: 15px;
	margin-top: 4px;
}
.tools {
	display: flex;
	gap: 8px;
}
.icon-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 14px;
	border-radius: 22px;
	background: var(--fill);
	color: var(--guru-text);
	font-size: 15px;
	font-weight: 600;
}
.icon-btn .ic {
	width: 20px;
	height: 20px;
}
@media (max-width: 560px) {
	.icon-btn {
		width: 44px;
		padding: 0;
		justify-content: center;
	}
	.icon-btn .lbl {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}
	.brand h1 {
		font-size: 34px;
	}
}

.layout {
	display: grid;
	gap: 20px;
}
@media (min-width: 960px) {
	.layout {
		grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
		gap: 24px;
		align-items: start;
	}
	.compose {
		position: sticky;
		top: 16px;
	}
}

h2 {
	font: 700 22px/1.3 var(--ui);
	white-space: nowrap;
}
@media (max-width: 560px) {
	.results .verse .syl .tx {
		font-size: 28px;
	}
	.results .verse {
		column-gap: 12px;
	}
	.results .line {
		grid-template-columns: 1fr auto;
		padding: 10px 14px 12px;
		gap: 0 8px;
	}
	.results .ln {
		grid-column: 1;
		grid-row: 1;
		text-align: left;
		line-height: 28px;
		font-size: 13px;
	}
	.results .total {
		grid-column: 2;
		grid-row: 1;
		display: flex;
		align-items: baseline;
		gap: 4px;
		padding: 0;
	}
	.results .total b {
		font-size: 22px;
	}
	.results .total .want {
		order: 3;
		margin-left: 6px;
	}
	.results .body {
		grid-column: 1 / 3;
		grid-row: 2;
	}
	.results .notes {
		grid-column: 1 / 3;
	}
	.results .sumrow {
		padding-left: 14px;
	}
	.compose-actions .plain span {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}
	.compose-actions .plain {
		width: 44px;
		justify-content: center;
	}
}

/* Composer */
.compose {
	background: var(--surface);
	border-radius: 16px;
	padding: 16px;
}
.compose-head,
.res-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
}
.compose-actions {
	display: flex;
	gap: 2px;
	margin-right: -8px;
}
.plain {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 10px;
	border-radius: 12px;
	color: var(--guru-text);
	font-size: 15px;
	font-weight: 600;
}
.plain .ic {
	width: 19px;
	height: 19px;
}
.plain[disabled] {
	color: var(--muted);
	opacity: 0.5;
	cursor: default;
}
.field {
	margin-top: 8px;
	background: var(--raised);
	border-radius: 12px;
	box-shadow: inset 0 0 0 1px var(--line);
	transition: box-shadow var(--spring-ms) var(--spring);
}
.field:focus-within {
	box-shadow: inset 0 0 0 2px var(--guru);
}
textarea {
	display: block;
	width: 100%;
	min-height: 220px;
	max-height: 60vh;
	resize: vertical;
	border: 0;
	outline: 0;
	background: transparent;
	padding: 14px 16px;
	font: 400 26px/1.55 var(--verse);
	field-sizing: content;
}
textarea::placeholder {
	color: var(--muted);
	opacity: 0.8;
}
.hint {
	font-size: 13px;
	line-height: 1.6;
	color: var(--muted);
	margin-top: 10px;
}
.examples {
	margin-top: 16px;
}
.ex-title {
	display: block;
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
	margin-bottom: 8px;
}
.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.chip {
	min-height: 40px;
	padding: 6px 14px;
	border-radius: 20px;
	background: var(--fill);
	font-size: 15px;
	font-weight: 600;
	text-align: left;
	line-height: 1.3;
}
.chip small {
	display: block;
	font-size: 12px;
	font-weight: 400;
	color: var(--muted);
}
.chip[aria-pressed='true'] {
	background: var(--guru-soft);
	color: var(--guru-text);
}

/* Results */
.results {
	min-width: 0;
}
.res-head {
	padding: 0 4px;
}
.legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 16px;
	padding: 10px 4px 4px;
	font-size: 13px;
	color: var(--muted);
}
.key {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.lk {
	display: inline-flex;
	align-items: center;
	font-weight: 700;
}
.lk.L {
	color: var(--laghu-text);
}
.lk.G {
	color: var(--guru-text);
}
.key b {
	font-weight: 700;
	color: var(--ink);
	font-variant-numeric: tabular-nums;
}
.key.tip {
	margin-left: auto;
}
@media (max-width: 560px) {
	.key.tip {
		margin-left: 0;
		width: 100%;
	}
}
.blk {
	display: inline-block;
	height: 10px;
	border-radius: 3px;
}
.blk.L {
	width: 12px;
	background: var(--laghu-soft);
	box-shadow: inset 0 0 0 1.5px var(--laghu);
}
.blk.G {
	width: 26px;
	background: var(--guru);
}
.tick {
	display: inline-block;
	width: 3px;
	height: 16px;
	border-radius: 2px;
	background: var(--yati);
}

/* Segmented control with a sliding thumb */
.seg {
	position: relative;
	display: inline-grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	padding: 2px;
	border-radius: 10px;
	background: var(--fill);
	isolation: isolate;
}
.seg button {
	position: relative;
	z-index: 1;
	min-height: 36px;
	padding: 0 14px;
	font-size: 14px;
	font-weight: 600;
	border-radius: 8px;
	white-space: nowrap;
}
.seg button[aria-checked='false'] {
	color: var(--muted);
}
.seg-thumb {
	position: absolute;
	z-index: 0;
	top: 2px;
	bottom: 2px;
	left: 2px;
	border-radius: 8px;
	background: var(--surface);
	box-shadow: 0 3px 8px rgb(0 0 0 / 0.12), 0 0 0 0.5px rgb(0 0 0 / 0.04);
	transition: transform var(--spring-ms) var(--spring), width var(--spring-ms) var(--spring);
}
:root[data-theme='dark'] .seg-thumb {
	background: #636366;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) .seg-thumb {
		background: #636366;
	}
}

/* Empty state */
.empty {
	margin-top: 12px;
	background: var(--surface);
	border-radius: 16px;
	padding: 28px 20px;
}
.empty h3 {
	font: 700 17px/1.5 var(--ui);
}
.empty p {
	color: var(--muted);
	font-size: 15px;
	margin-top: 6px;
	max-width: 46ch;
}
.empty .demo {
	margin-top: 18px;
}

/* Stanza */
.stanza {
	margin-top: 12px;
	background: var(--surface);
	border-radius: 16px;
	padding: 6px 0 4px;
	overflow: hidden;
}
.verdict {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	width: 100%;
	padding: 12px 16px;
	text-align: left;
	border-bottom: 1px solid var(--line);
}
.verdict .dot {
	flex: none;
	width: 10px;
	height: 10px;
	margin-top: 8px;
	border-radius: 50%;
	background: var(--muted);
}
.verdict.fits .dot {
	background: var(--fits);
}
.verdict.near .dot {
	background: var(--note);
}
.verdict .what {
	flex: 1;
	min-width: 0;
}
.verdict .what b {
	display: block;
	font: 650 17px/1.5 var(--ui);
}
.verdict.fits .what b {
	color: var(--fits-text);
}
.verdict .what span {
	display: block;
	font-size: 13px;
	color: var(--muted);
}
.verdict .what .open-g {
	margin-top: 4px;
	font-weight: 600;
	color: var(--fits-text);
}
.verdict .what .open-g.bad {
	color: var(--off-text);
}
.verdict .ic {
	margin-top: 4px;
	color: var(--muted);
	width: 18px;
	height: 18px;
}

/* Line */
.line {
	display: grid;
	grid-template-columns: 22px minmax(0, 1fr) auto;
	gap: 4px 10px;
	padding: 14px 16px 14px 12px;
	border-bottom: 1px solid var(--line);
}
.line:last-child {
	border-bottom: 0;
}
.ln {
	font-size: 12px;
	line-height: 44px;
	color: var(--muted);
	text-align: right;
	font-variant-numeric: tabular-nums;
}
.total {
	grid-column: 3;
	grid-row: 1;
	align-self: start;
	text-align: right;
	padding-top: 2px;
	min-width: 48px;
}
.total b {
	display: block;
	font: 800 28px/1.1 var(--ui);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.02em;
}
.total span {
	display: block;
	font-size: 12px;
	color: var(--muted);
}
.total.off b {
	color: var(--off-text);
}
.total.fits b {
	color: var(--fits-text);
}
.total .want {
	font-size: 12px;
	color: var(--off-text);
}
.total.lic .want {
	color: var(--muted);
}
.body {
	grid-column: 2;
	min-width: 0;
}

/* Verse with marks above each syllable */
.verse {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	column-gap: 18px;
	row-gap: 2px;
}
.word {
	display: inline-flex;
	align-items: flex-end;
}
.syl {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	min-width: 22px;
	min-height: 44px;
	padding: 0 1px 2px;
	border-radius: 8px;
}
.syl .mk {
	font: 700 12px/1.3 var(--ui);
	padding: 1px 5px 0;
	border-radius: 5px;
}
.syl.L .mk {
	color: var(--laghu-text);
}
.syl.G .mk,
.syl.P .mk {
	color: var(--guru-text);
}
.syl.X .mk {
	color: var(--off-text);
}
.syl .tx {
	font: 400 34px/1.25 var(--verse);
	white-space: nowrap;
}
.sh {
	display: inline-block;
	vertical-align: middle;
}
.sh-l {
	width: 14px;
	height: 2.5px;
	border-radius: 2px;
	background: currentColor;
	margin: 6px 0;
}
.sh-c {
	width: 12px;
	height: 8px;
	margin: 2px 0 4px;
	border: 2.5px solid currentColor;
	border-top: 0;
	border-radius: 0 0 8px 8px;
}
.syl .mk {
	display: inline-flex;
	align-items: center;
	min-height: 16px;
}
.syl .n {
	font: 600 11px/1.2 var(--ui);
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.syl.noted::after {
	content: '';
	position: absolute;
	top: 3px;
	right: -2px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--note);
}
.syl.mine .mk {
	box-shadow: inset 0 0 0 1.5px currentColor;
}
.syl.on {
	background: var(--fill);
}
@media (hover: hover) {
	.syl:hover {
		background: var(--fill);
	}
	.plain:hover,
	.icon-btn:hover {
		background: var(--fill-strong);
	}
	.chip:hover {
		background: var(--fill-strong);
	}
}
.punct {
	font: 400 30px/1.3 var(--verse);
	color: var(--muted);
	align-self: flex-end;
	padding-bottom: 2px;
	margin-left: -12px;
}
.pmark {
	align-self: stretch;
	width: 3px;
	margin: 18px -4px 6px;
	border-radius: 2px;
	background: var(--yati);
}
.foreign {
	font-size: 15px;
	color: var(--off-text);
	align-self: center;
}

/* The rhythm ribbon: width is mātrā on the stanza's shared scale. */
.ribbon {
	position: relative;
	display: flex;
	gap: 2px;
	height: 12px;
	margin: 10px 0 4px;
}
.seg-m {
	height: 100%;
	border-radius: 3px;
	flex: none;
	transform-origin: left center;
	transition: transform var(--spring-ms) var(--spring);
}
.seg-m.L {
	background: var(--laghu-soft);
	box-shadow: inset 0 0 0 1.5px var(--laghu);
}
.seg-m.G {
	background: var(--guru);
}
.seg-m.P {
	background: repeating-linear-gradient(90deg, var(--guru) 0 6px, var(--guru-soft) 6px 8px);
}
.seg-m.X {
	background: var(--off);
	opacity: 0.5;
}
.seg-m.on {
	transform: scaleY(1.6);
}
.ribbon .yt {
	position: absolute;
	top: -6px;
	bottom: -6px;
	width: 3px;
	margin-left: -2.5px;
	border-radius: 2px;
	background: var(--yati);
}
.ribbon .goal {
	position: absolute;
	top: -4px;
	bottom: -4px;
	width: 0;
	border-left: 2px dashed var(--muted);
	opacity: 0.55;
}
.ribbon.grow .seg-m {
	animation: grow var(--spring-smooth-ms) var(--spring-smooth) both;
	animation-delay: calc(var(--i) * 14ms);
}
@keyframes grow {
	from {
		transform: scaleX(0);
	}
}
.scale-note {
	font-size: 12px;
	color: var(--muted);
}

/* Beat view: each syllable's cell is as wide as its mātrā. */
.beat {
	position: relative;
	display: flex;
	gap: 2px;
}
.beat .syl {
	flex: none;
	min-width: 0;
	padding: 4px 0;
	justify-content: flex-end;
	border-radius: 6px;
	overflow: hidden;
}
.beat .syl .tx {
	font-size: clamp(16px, 3.4vw, 26px);
}
.beat .syl.L {
	background: var(--laghu-soft);
	box-shadow: inset 0 -3px 0 var(--laghu);
}
.beat .syl.G,
.beat .syl.P {
	background: var(--guru-soft);
	box-shadow: inset 0 -3px 0 var(--guru);
}
.beat .syl.X {
	box-shadow: inset 0 -3px 0 var(--off);
}
.beat .syl .mk {
	padding-top: 0;
}
.beat .yt {
	flex: none;
	width: 3px;
	border-radius: 2px;
	background: var(--yati);
}
.beat-scale {
	position: relative;
	height: 16px;
	margin-top: 4px;
	font-size: 11px;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.beat-scale span {
	position: absolute;
	transform: translateX(-50%);
}

/* Gaṇa view */
.ganas {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.gana {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	padding: 4px 6px 6px;
	border-radius: 10px;
	background: var(--raised);
	box-shadow: inset 0 0 0 1px var(--line);
	min-width: 64px;
}
.gana .gn {
	font: 800 15px/1.4 var(--ui);
	color: var(--guru-text);
}
.gana .gn.none {
	color: var(--muted);
	font-weight: 600;
}
.gana .gs {
	display: flex;
}
.gana .gs .syl {
	min-height: 40px;
}
.gana .gs .syl .tx {
	font-size: 24px;
}
.gana .gp {
	font-size: 12px;
	color: var(--muted);
	letter-spacing: 0.04em;
}

/* Reading notes under a line */
.notes {
	grid-column: 2 / 4;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px;
}
.note-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 32px;
	padding: 4px 10px;
	border-radius: 16px;
	background: var(--note-soft);
	color: var(--note-text);
	font-size: 13px;
	font-weight: 600;
	text-align: left;
}
.note-chip .ic {
	width: 16px;
	height: 16px;
}

/* Stanza summary row */
.sumrow {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	padding: 10px 16px 10px 44px;
	font-size: 13px;
	color: var(--muted);
	border-top: 1px solid var(--line);
}
.sumrow b {
	color: var(--ink);
	font-variant-numeric: tabular-nums;
}

/* Sheets: iOS modal sheets (js/sheet.js moves them). */
dialog.sheet {
	position: fixed;
	inset: auto 0 0 0;
	margin: 0 auto;
	width: 100%;
	max-width: 600px;
	max-height: min(86vh, 760px);
	padding: 0 0 max(16px, env(safe-area-inset-bottom));
	border: 0;
	border-radius: 14px 14px 0 0;
	background: var(--surface);
	color: var(--ink);
	overflow-y: auto;
	overscroll-behavior: contain;
	box-shadow: 0 -10px 40px -10px rgb(0 0 0 / 0.25);
}
dialog.sheet.tall {
	height: min(92vh, 900px);
	max-height: none;
}
dialog.sheet::backdrop {
	background: var(--backdrop);
	animation: fade var(--spring-smooth-ms) var(--spring-smooth);
}
dialog.sheet.closing::backdrop {
	opacity: 0;
	transition: opacity 300ms ease-out;
}
@keyframes fade {
	from {
		opacity: 0;
	}
}
.grab {
	position: sticky;
	top: 0;
	z-index: 2;
	height: 24px;
	background: linear-gradient(var(--surface) 60%, transparent);
	cursor: grab;
	touch-action: none;
}
.grab::before {
	content: '';
	position: absolute;
	top: 8px;
	left: 50%;
	width: 36px;
	height: 5px;
	margin-left: -18px;
	border-radius: 3px;
	background: var(--fill-strong);
}
.sheet-body {
	padding: 0 20px 8px;
}
.sheet-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}
.sheet-top h2 {
	font: 700 22px/1.35 var(--ui);
}
.close {
	flex: none;
	width: 32px;
	height: 32px;
	margin: 6px -4px 0 0;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--fill);
	color: var(--muted);
}
.close .ic {
	width: 18px;
	height: 18px;
	stroke-width: 2.5;
}
/* make the 32px close button a 44px target */
.close {
	position: relative;
}
.close::after {
	content: '';
	position: absolute;
	inset: -6px;
}

/* Syllable sheet */
.big-syl {
	display: flex;
	align-items: center;
	gap: 16px;
}
.big-syl .glyph {
	font: 400 64px/1.2 var(--verse);
}
.badge {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 999px;
	font-weight: 700;
	font-size: 15px;
}
.badge.L {
	background: var(--laghu-soft);
	color: var(--laghu-text);
}
.badge.G,
.badge.P {
	background: var(--guru-soft);
	color: var(--guru-text);
}
.badge.X {
	background: var(--fill);
	color: var(--off-text);
}
.parts {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 4px;
}
.part {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	padding: 6px 10px;
	border-radius: 10px;
	background: var(--raised);
	box-shadow: inset 0 0 0 1px var(--line);
}
.part .pg {
	font: 400 28px/1.2 var(--verse);
}
.part .pl {
	font-size: 12px;
	color: var(--muted);
}

/* Inset grouped list (sheets) */
.group-title {
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
	margin: 20px 4px 6px;
}
.group {
	background: var(--raised);
	border-radius: 12px;
	box-shadow: inset 0 0 0 1px var(--line);
	overflow: hidden;
}
.row {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
	font-size: 15px;
}
.row:last-child {
	border-bottom: 0;
}
.row .ic {
	width: 20px;
	height: 20px;
	margin-top: 2px;
}
.row .ic.ok {
	color: var(--fits-text);
}
.row .ic.warn {
	color: var(--note-text);
}
.row .ic.bad {
	color: var(--off-text);
}
.row p + p {
	margin-top: 4px;
}
.row .sm {
	font-size: 13px;
	color: var(--muted);
}
.row-btn {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 48px;
	padding: 10px 16px;
	text-align: left;
	border-bottom: 1px solid var(--line);
	font-size: 15px;
}
.row-btn:last-child {
	border-bottom: 0;
}
.row-btn .grow {
	flex: 1;
}
.row-btn .ic {
	width: 18px;
	height: 18px;
	color: var(--muted);
}
.setting {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.setting:last-child {
	border-bottom: 0;
}
.setting .st {
	font-weight: 600;
	font-size: 15px;
}
.setting .sd {
	font-size: 13px;
	color: var(--muted);
	margin: 2px 0 10px;
}
.setting .seg {
	display: grid;
	width: 100%;
}
.setting .seg button {
	padding: 0 6px;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 50px;
	padding: 0 20px;
	border-radius: 12px;
	font-weight: 700;
	font-size: 17px;
}
.btn.fill {
	background: var(--guru);
	color: #fff;
}
.btn.tint {
	background: var(--guru-soft);
	color: var(--guru-text);
}
.btn.wide {
	width: 100%;
}

/* Learn / about content */
.prose p,
.prose li {
	font-size: 15px;
	line-height: 1.75;
}
.prose p + p {
	margin-top: 10px;
}
.prose h3 {
	font: 700 17px/1.5 var(--ui);
	margin: 22px 0 6px;
}
.prose ul,
.prose ol {
	padding-left: 22px;
	margin: 6px 0 0;
}
.prose a {
	color: var(--guru-text);
}
.prose .src {
	font-size: 13px;
	color: var(--muted);
	word-break: break-word;
}
.rule {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 4px 14px;
	align-items: center;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.rule:last-child {
	border-bottom: 0;
}
.rule .eg {
	grid-row: span 2;
	font: 400 32px/1.2 var(--verse);
	min-width: 72px;
	text-align: center;
}
.rule .rt {
	font-weight: 650;
	font-size: 15px;
}
.rule .rd {
	font-size: 13px;
	color: var(--muted);
}
.term {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.term:last-child {
	border-bottom: 0;
}
.term dt {
	font-weight: 700;
}
.term dd {
	margin: 2px 0 0;
	font-size: 15px;
	color: var(--muted);
}

/* View help */
.view-ctl {
	display: flex;
	align-items: center;
	gap: 6px;
}
.icon-btn.help {
	width: 44px;
	padding: 0;
	justify-content: center;
	background: none;
}

/* Guide */
.ch-tabs {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	gap: 8px;
	margin: 0 -20px 8px;
	padding: 6px 20px 10px;
	overflow-x: auto;
	scrollbar-width: none;
	background: linear-gradient(var(--surface) 80%, transparent);
}
.ch-tabs::-webkit-scrollbar {
	display: none;
}
.ch-tabs .chip {
	flex: none;
	min-height: 40px;
}
.ch-tabs .chip[aria-selected='true'] {
	background: var(--guru-text);
	color: var(--surface);
}
.lh {
	font: 700 17px/1.5 var(--ui);
	margin: 26px 4px 8px;
}
.q {
	margin: 12px 0;
	padding: 12px 16px;
	border-left: 3px solid var(--guru);
	border-radius: 0 12px 12px 0;
	background: var(--fill);
}
.q p {
	font: 400 17px/1.7 var(--verse);
}
.q cite {
	display: block;
	margin-top: 4px;
	font-size: 13px;
	font-style: normal;
	color: var(--muted);
}
.try {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 44px;
	margin: 6px 8px 0 0;
	padding: 0 14px 0 10px;
	border-radius: 22px;
	background: var(--fill);
	color: var(--guru-text);
	font-size: 14px;
	font-weight: 600;
}
.try .ic {
	width: 16px;
	height: 16px;
}
.next {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 52px;
	margin: 28px 0 8px;
	padding: 0 16px;
	border-radius: 14px;
	background: var(--fill);
	color: var(--muted);
	font-size: 14px;
}
.next b {
	flex: 1;
	text-align: left;
	color: var(--guru-text);
	font-size: 16px;
}
.steps {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	background: var(--raised);
	border-radius: 12px;
	box-shadow: inset 0 0 0 1px var(--line);
	overflow: hidden;
}
.steps li + li {
	border-top: 1px solid var(--line);
}
.step {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 52px;
	padding: 10px 14px;
	text-align: left;
	font-size: 15px;
	line-height: 1.6;
}
.step b {
	flex: none;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--fill);
	color: var(--guru-text);
	font-size: 14px;
}
.step span {
	flex: 1;
}
.step .ic,
.next .ic {
	width: 18px;
	height: 18px;
	color: var(--muted);
}
.mlist .mrow {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.mlist .mrow:last-child {
	border-bottom: 0;
}
.mrow .mn {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}
.mrow .mn b {
	font-size: 16px;
}
.mrow .mc {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	color: var(--guru-text);
	white-space: nowrap;
}
.mrow .rd {
	margin-top: 2px;
	font-size: 13px;
	line-height: 1.6;
	color: var(--muted);
}
.gtable .grow-r {
	display: grid;
	grid-template-columns: 40px auto 1fr;
	align-items: center;
	gap: 14px;
	padding: 10px 16px;
	border-bottom: 1px solid var(--line);
}
.gtable .grow-r:last-child {
	border-bottom: 0;
}
.gtable .gl {
	font: 700 24px/1 var(--verse);
	text-align: center;
}
.pat {
	display: inline-flex;
	gap: 10px;
	font-size: 18px;
}
.pat > span {
	display: inline-grid;
	place-items: center;
	min-width: 18px;
	height: 20px;
}
.pat .sh-l {
	height: 3px;
	margin: 0;
}
.pat .sh-c {
	height: 8px;
	margin: 0;
	border-width: 3px;
}
.gtable .gd {
	font-size: 13px;
	line-height: 20px; /* whole pixels keep the marks crisp */
	color: var(--muted);
	text-align: right;
}
.gtable .good {
	color: var(--fits-text);
	font-weight: 600;
}
.gtable .bad {
	color: var(--off-text);
	font-weight: 600;
}
.sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
.marks-demo {
	display: flex;
	gap: 28px;
	margin: 12px 4px;
	font-size: 20px;
}
.marks-demo span {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}
.marks-demo small {
	font-size: 14px;
	color: var(--muted);
}
.legend-list .dot {
	flex: none;
	width: 10px;
	height: 10px;
	margin-top: 8px;
	border-radius: 50%;
	background: var(--muted);
}
.legend-list .dot.fits {
	background: var(--fits);
}
.legend-list .dot.near {
	background: var(--note);
}

/* Footer */
.foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin-top: 28px;
	padding: 0 4px;
	font-size: 13px;
	color: var(--muted);
}
.foot .plain {
	margin-left: -10px;
}

/* Toast: glass, floats above the home indicator. */
.toast {
	position: fixed;
	left: 50%;
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 50;
	max-width: min(92vw, 440px);
	padding: 12px 18px;
	border-radius: 16px;
	background: var(--material);
	-webkit-backdrop-filter: blur(20px) saturate(180%);
	backdrop-filter: blur(20px) saturate(180%);
	box-shadow: var(--float-shadow), inset 0 0 0 0.5px var(--material-edge);
	font-size: 15px;
	font-weight: 600;
	opacity: 0;
	transform: translate(-50%, 24px) scale(0.96);
	pointer-events: none;
	transition:
		transform var(--spring-bounce-ms) var(--spring-bounce),
		opacity 200ms ease-out;
}
.toast.show {
	opacity: 1;
	transform: translate(-50%, 0) scale(1);
}

.toast:lang(en) {
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	letter-spacing: -0.01em;
}
.toast.show.act {
	pointer-events: auto;
}

.toast button {
	margin-inline-start: 14px;
	min-height: 32px;
	padding: 0 4px;
	border: 0;
	background: none;
	font: inherit;
	color: var(--guru-text);
	cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 1ms !important;
		animation-delay: 0ms !important;
		transition-duration: 1ms !important;
	}
}

@media print {
	body {
		background: #fff;
	}
	.compose,
	.tools,
	.foot,
	.res-head .seg,
	.legend .tip,
	.toast {
		display: none !important;
	}
	.layout {
		display: block;
	}
	.stanza {
		break-inside: avoid;
	}
}
.lnw {
	display: none;
}
@media (max-width: 560px) {
	.lnw {
		display: inline;
	}
}
/* Wide screens: a centred form sheet, as on iPad. */
@media (min-width: 720px) {
	dialog.sheet {
		inset: 0;
		margin: auto;
		height: fit-content;
		max-height: min(84vh, 760px);
		border-radius: 14px;
		box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.35);
	}
	dialog.sheet.tall {
		height: min(84vh, 820px);
	}
}

.src-note {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	margin: 12px 4px 0;
	font-size: 13px;
	color: var(--muted);
}
.src-note .ic {
	width: 16px;
	height: 16px;
	margin-top: 3px;
}
