:root {
	color-scheme: dark;
	--bg: #15191d;
	--surface: #1e242a;
	--fg: #eef2f5;
	--muted: #a3b1bd;
	--accent: #f2a93b;
	--border: #323b44;
	--danger: #ff8a7a;
	--radius: 6px;
	--space: 1rem;
	--font: "Raleway", "Helvetica Neue", Arial, sans-serif;
	--display: "Anton", Impact, "Arial Narrow", sans-serif;
	--c-urban: #e0457b;
	--c-sentences: #f2a93b;
	--c-perfect: #4fb3e8;
	--c-phrases: #9b7bf0;
	--c-near: #45c48f;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

h1 {
	margin: 0 0 0.5rem;
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	letter-spacing: -0.02em;
}

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/*
 * The scaffold once had no width breakpoint at all, so the shell was a 42rem
 * column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

/* ---------- Rhyme Vault ---------- */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.wide {
	width: 100%;
	max-width: 78rem;
	margin: 0 auto;
	padding: 0 1rem;
}

@media (min-width: 48rem) {
	.wide {
		padding: 0 2rem;
	}
}

.hero {
	position: relative;
	overflow: hidden;
	background: linear-gradient(115deg, #1b2a5c 0%, #3d2470 40%, #7a2669 75%, #a8324f 100%);
	padding: 1.5rem 0 2.5rem;
}

.wave {
	position: absolute;
	inset: auto 0 0 0;
	height: 45%;
	display: flex;
	align-items: flex-end;
	gap: 0.6%;
	opacity: 0.16;
	pointer-events: none;
}

.wave span {
	flex: 1;
	height: 100%;
	background: #fff;
	transform-origin: bottom;
	animation: bar 2.4s ease-in-out infinite alternate;
}

.wave span:nth-child(3n) { transform: scaleY(0.4); }
.wave span:nth-child(3n + 1) { transform: scaleY(0.7); }
.wave span:nth-child(3n + 2) { transform: scaleY(0.25); }

@keyframes bar {
	from { transform: scaleY(0.15); }
	to { transform: scaleY(0.85); }
}

.hero-inner {
	position: relative;
}

.brand {
	margin: 0 0 2rem;
	font-size: 1.5rem;
	font-weight: 500;
	letter-spacing: 0.01em;
}

.brand b {
	color: var(--accent);
	font-weight: 700;
}

.hero h1 {
	font-family: var(--display);
	font-weight: 400;
	font-size: clamp(2.8rem, 9vw, 5.5rem);
	line-height: 0.98;
	letter-spacing: 0.005em;
	margin: 0 0 0.75rem;
	max-width: 14ch;
}

.hero .lede {
	color: #e3e6f5;
	max-width: 38rem;
	margin-bottom: 1.5rem;
}

.search {
	display: flex;
	gap: 0.5rem;
	max-width: 40rem;
}

.search-input {
	flex: 1;
	min-width: 0;
	padding: 0.9rem 1rem;
	font: inherit;
	font-size: 1.15rem;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-radius: var(--radius);
	background: rgba(10, 12, 20, 0.55);
	color: #fff;
}

.search-input:focus {
	border-color: var(--accent);
	outline: none;
}

.search-btn {
	padding: 0 1.4rem;
	min-height: 48px;
	border: 0;
	border-radius: var(--radius);
	background: var(--accent);
	color: #1a1206;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

.search-btn:disabled {
	opacity: 0.6;
}

.starters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
	margin-top: 1rem;
	color: #d6daec;
	font-size: 0.9rem;
}

.chip {
	min-height: 36px;
	padding: 0.3rem 0.8rem;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: var(--radius);
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font: inherit;
	cursor: pointer;
}

.chip:hover {
	background: rgba(255, 255, 255, 0.18);
}

.results {
	padding-top: 2rem;
	padding-bottom: 3rem;
	min-height: 40vh;
	scroll-margin-top: 0.5rem;
}

.summary h2 {
	margin: 0 0 0.75rem;
	font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.target {
	color: var(--accent);
}

.jump {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.jump-link {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 40px;
	padding: 0.3rem 0.8rem;
	border-radius: var(--radius);
	border-left: 4px solid var(--tone);
	background: var(--surface);
	color: var(--fg);
	text-decoration: none;
	font-weight: 600;
	font-size: 0.92rem;
}

.jump-link span {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.c-urban { --tone: var(--c-urban); }
.c-sentences { --tone: var(--c-sentences); }
.c-perfect { --tone: var(--c-perfect); }
.c-phrases { --tone: var(--c-phrases); }
.c-near { --tone: var(--c-near); }

.meaning {
	padding: 1rem 1.25rem;
	background: var(--surface);
	border-radius: var(--radius);
	border: 1px solid var(--border);
}

.meaning h3 {
	margin: 0 0 0.4rem;
	font-size: 1rem;
}

.meaning p {
	margin: 0;
}

.columns {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 1rem;
	align-items: start;
}

@media (min-width: 60rem) {
	.columns {
		grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
		gap: 1.5rem;
	}
}

.panel {
	background: var(--surface);
	border-radius: var(--radius);
	border-top: 4px solid var(--tone);
	padding: 1.1rem 1.1rem 1.25rem;
	scroll-margin-top: 1rem;
}

.panel h3 {
	margin: 0 0 0.9rem;
	font-family: var(--display);
	font-weight: 400;
	font-size: 1.6rem;
	letter-spacing: 0.01em;
	color: var(--tone);
}

.panel h4 {
	margin: 0.9rem 0 0.4rem;
	font-size: 0.85rem;
	color: var(--muted);
	font-weight: 600;
}

.cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.word {
	min-height: 36px;
	padding: 0.25rem 0.6rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: transparent;
	color: var(--fg);
	font: inherit;
	font-size: 0.95rem;
	cursor: pointer;
}

.word:hover {
	border-color: var(--tone);
	color: var(--tone);
}

.slang-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 0.9rem;
}

.slang {
	padding-bottom: 0.9rem;
	border-bottom: 1px solid var(--border);
}

.slang:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.slang-term {
	padding: 0;
	border: 0;
	background: none;
	color: var(--c-urban);
	font: inherit;
	font-size: 1.15rem;
	font-weight: 700;
	cursor: pointer;
	text-decoration: underline;
	text-decoration-color: transparent;
	text-underline-offset: 3px;
}

.slang-term:hover {
	text-decoration-color: currentColor;
}

.votes {
	margin-left: 0.6rem;
	font-size: 0.8rem;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.slang p {
	margin: 0.3rem 0 0;
	white-space: pre-line;
}

.example {
	color: var(--muted);
	font-style: italic;
	white-space: pre-line;
}

.lines {
	margin: 0;
	padding-left: 1.6rem;
	display: grid;
	gap: 0.7rem;
	font-size: 1.05rem;
}

.lines li::marker {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

.lines mark {
	background: none;
	color: var(--c-sentences);
	font-weight: 700;
}

/* Side-by-side brackets, RhymeWave style */
.results.wide {
	max-width: 110rem;
}

.brackets {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
	gap: 0.5rem;
	align-items: start;
	/* All results scroll inside their own box instead of stretching the page */
	max-height: 75vh;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0.5rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.bracket {
	min-width: 0;
	background: var(--surface);
	border-radius: var(--radius);
	border-top: 3px solid var(--tone);
	padding: 0.45rem 0.5rem 0.55rem;
	scroll-margin-top: 1rem;
}

.wide-bracket {
	grid-column: span 2;
}

@media (min-width: 60rem) {
	.wide-bracket {
		grid-column: span 3;
	}
}

.bracket h3 {
	margin: 0 0 0.3rem;
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--tone);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bracket-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.bracket .word {
	display: block;
	width: 100%;
	min-height: 0;
	padding: 0.08rem 0.2rem;
	border: 0;
	border-radius: 3px;
	text-align: left;
	font-size: 0.78rem;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bracket .word:hover {
	background: rgba(255, 255, 255, 0.07);
}

.bracket .slang-list {
	gap: 0.3rem;
}

.bracket .slang {
	padding-bottom: 0.3rem;
}

.bracket .slang-term {
	font-size: 0.8rem;
	text-align: left;
}

.bracket .slang p {
	margin: 0.1rem 0 0;
	font-size: 0.7rem;
	line-height: 1.3;
	color: var(--muted);
	white-space: normal;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.bracket .lines {
	padding-left: 1.2rem;
	gap: 0.25rem;
	font-size: 0.78rem;
	line-height: 1.35;
}

.ai-lines {
	--tone: #35d0a5;
	background: var(--surface);
	border-radius: var(--radius);
	border-top: 3px solid var(--tone);
	padding: 0.6rem 0.75rem 0.75rem;
}

.ai-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
}

.ai-head h3 {
	margin: 0;
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--tone);
	scroll-margin-top: 1rem;
}

.ai-count {
	margin-left: 0.4rem;
	color: var(--muted);
	font-weight: 600;
}

.ai-btn {
	background: var(--tone);
	color: #06231b;
	border-color: transparent;
	font-weight: 700;
}

.ai-hint {
	margin: 0.4rem 0 0;
	font-size: 0.8rem;
	color: var(--muted);
}

.ai-list {
	margin-top: 0.5rem;
	max-height: 22rem;
	overflow-y: auto;
	padding-left: 1.6rem;
	font-size: 0.82rem;
	line-height: 1.4;
	display: grid;
	gap: 0.2rem;
}

.ai-list mark {
	background: none;
	color: var(--tone);
	font-weight: 700;
}

@media (min-width: 60rem) {
	.ai-list {
		grid-template-columns: 1fr 1fr;
		column-gap: 2rem;
	}
}

.verse-writer {
	--tone: #f5a524;
	margin-top: 0.75rem;
}

.vw-panel {
	margin-top: 0.5rem;
	display: grid;
	gap: 0.5rem;
}

.vw-panel > summary {
	cursor: pointer;
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--muted);
	margin-bottom: 0.4rem;
}

.vw-group {
	border: 0;
	padding: 0;
	margin: 0 0 0.55rem;
	min-width: 0;
}

.vw-group legend {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
	margin-bottom: 0.3rem;
}

.vw-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}

.vw-chip {
	font: inherit;
	font-size: 0.76rem;
	padding: 0.3rem 0.6rem;
	border-radius: 999px;
	border: 1px solid color-mix(in srgb, var(--muted) 40%, transparent);
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.vw-chip[aria-pressed="true"] {
	background: var(--tone);
	border-color: var(--tone);
	color: #2a1a00;
	font-weight: 700;
}

.vw-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.vw-row .field span,
.verse-writer > .vw-panel > .field span {
	font-size: 0.72rem;
	font-weight: 700;
	color: var(--muted);
}

.vw-go {
	margin-top: 0.6rem;
	width: 100%;
}

.vw-verses {
	margin-top: 0.75rem;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
	gap: 0.6rem;
	max-height: 40rem;
	overflow-y: auto;
	scroll-margin-top: 1rem;
}

.vw-verse {
	border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent);
	border-radius: var(--radius);
	padding: 0.55rem 0.65rem;
}

.vw-verse header {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	flex-wrap: wrap;
	font-size: 0.85rem;
}

.vw-verse header strong {
	flex: 1;
	min-width: 0;
}

.vw-scheme {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	color: var(--tone);
}

.vw-copy {
	font: inherit;
	font-size: 0.72rem;
	padding: 0.2rem 0.55rem;
	border-radius: 999px;
	border: 1px solid var(--tone);
	background: transparent;
	color: var(--tone);
	cursor: pointer;
	min-height: 28px;
}

.vw-verse ol {
	list-style: none;
	margin: 0.4rem 0 0;
	padding: 0;
	display: grid;
	gap: 0.15rem;
	font-size: 0.8rem;
	line-height: 1.4;
}

.vw-verse li {
	display: flex;
	gap: 0.45rem;
}

.vw-letter {
	flex: none;
	width: 1rem;
	font-size: 0.68rem;
	font-weight: 800;
	opacity: 0.85;
	padding-top: 0.1rem;
}

.vw-verse mark {
	background: none;
	font-weight: 700;
}

.l-A { color: #f5a524; }
.l-B { color: #35d0a5; }
.l-C { color: #8fa8ff; }
.l-X { color: var(--muted); }

.foot {
	border-top: 1px solid var(--border);
	padding: 1.25rem 0;
	color: var(--muted);
	font-size: 0.85rem;
}

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

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
