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

body {
	margin: 0;
	font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
	font-size: 14px;
	line-height: 1.4;
}

main {
	max-width: 900px;
	margin: 0 auto;
	padding: 1rem;
}

h1 {
	text-align: center;
	margin: 0 0 0.25rem 0;
	font-size: 1.5rem;
}

.external-links {
	text-align: center;
	margin-bottom: 1rem;
	font-size: 0.85rem;
}

.external-links a {
	color: #333;
	margin: 0 0.5rem;
}

.external-links a:hover {
	color: #000;
}

form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

form label:first-of-type {
	flex: 1;
	min-width: 150px;
}

form input[name="verb"] {
	flex: 1;
	min-width: 80px;
}

form label {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

form input {
	font-family: inherit;
	font-size: 16px; /* prevents iOS zoom on focus */
	padding: 0.25rem 0.5rem;
	border: 1px solid black;
}

form button {
	font-family: inherit;
	font-size: inherit;
	padding: 0.25rem 0.75rem;
	border: 1px solid black;
	background: white;
	color: black;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

form button:hover {
	background: black;
	color: white;
}

form .checkbox {
	cursor: pointer;
}

form .checkbox:has(input:disabled) {
	color: #999;
	cursor: not-allowed;
	text-decoration: line-through;
}

/* Autocomplete suggestions */
.search-wrapper {
	position: relative;
	display: inline-block;
	flex: 1;
	min-width: 80px;
}

.search-wrapper input {
	width: 100%;
}

.suggestions {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: white;
	border: 1px solid black;
	border-top: none;
	max-height: 200px;
	overflow-y: auto;
	z-index: 100;
}

.suggestions:empty {
	display: none;
}

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

.suggestion-list li button {
	width: 100%;
	padding: 0.35rem 0.5rem;
	text-align: left;
	background: none;
	border: none;
	cursor: pointer;
	font: inherit;
}

.suggestion-list li button:hover,
.suggestion-list li button:focus,
.suggestion-list li button.active {
	background: #eee;
}

.conjugation-tables {
	display: grid;
	gap: 1rem;
}

.conjugation-tables table {
	border-collapse: collapse;
	width: 100%;
	border: 1px solid black;
	table-layout: fixed;
}

.conjugation-tables .col-person {
	width: 6ch;
}

.conjugation-tables caption {
	text-align: left;
	font-weight: bold;
	padding: 0.25rem 0;
	border: 1px solid black;
	border-bottom: none;
	background: black;
	color: white;
	padding-left: 0.5rem;
}

.conjugation-tables th,
.conjugation-tables td {
	border: 1px solid black;
	padding: 0.25rem 0.5rem;
	text-align: left;
}

.conjugation-tables th {
	background: #eee;
	font-weight: bold;
	overflow-wrap: break-word;
	word-break: break-word;
	hyphens: auto;
}

.conjugation-tables td:first-child {
	font-weight: bold;
	background: #f5f5f5;
	white-space: nowrap;
}

/* Auxiliary info */
.auxiliary-info {
	text-align: center;
	font-size: 0.85rem;
	color: #666;
	margin-bottom: 0.25rem;
}

.auxiliary-label {
	font-weight: bold;
	color: #333;
}

/* Clickable auxiliary toggle for dual-auxiliary verbs */
.auxiliary-toggle {
	text-decoration: none;
	color: inherit;
	cursor: pointer;
	padding: 0.15rem 0.4rem;
	border-radius: 3px;
	transition: background 0.15s;
}

.auxiliary-toggle:hover {
	background: #eee;
}

.auxiliary-toggle .aux-option {
	color: #999;
	transition: color 0.15s;
}

.auxiliary-toggle .aux-option.active {
	font-weight: bold;
	color: #333;
}

.auxiliary-toggle .aux-separator {
	color: #ccc;
	margin: 0 0.15rem;
}

.auxiliary-info .aux-hint {
	font-size: 0.75rem;
	color: #999;
	margin-left: 0.25rem;
}

/* Participles */
.participles {
	display: flex;
	justify-content: space-between;
	padding: 0.5rem;
	border: 1px solid black;
	margin-bottom: 1rem;
	background: #f5f5f5;
}

.participle-group {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
}

.participle-label {
	font-weight: bold;
}

.participle-forms {
	display: flex;
	gap: 0.75rem;
}

.participle-forms .masc,
.participle-forms .fem {
	display: flex;
	align-items: baseline;
}

.participles .sep {
	color: #999;
	margin: 0 0.25rem;
}

.participles .form-with-ipa {
	display: inline-flex;
	gap: 0.25rem;
}

/* Stem/suffix coloring */
.stem-green {
	color: #228b22;
}

.stem-blue {
	color: #0066cc;
}

.stem-red {
	color: #cc3333;
}

/* Matching spellings indicator - subtle background tints */
.match-a { background: #ddeef7; }
.match-b { background: #f5ebe0; }
.match-c { background: #e5f0df; }
.match-d { background: #f0e5f0; }
.match-e { background: #f7e5e5; }

/* IPA pronunciation */
.form-with-ipa {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem;
}

.form-with-ipa .ipa {
	font-size: 0.8rem;
	color: #666;
	text-align: right;
}

/* IPA matching pronunciations - box-shadow extends to cell edge without layout shift */
.ipa-match-a { background: #ddeef7; box-shadow: 0.5rem 0 0 #ddeef7, -0.2rem 0 0 #ddeef7; }
.ipa-match-b { background: #f5ebe0; box-shadow: 0.5rem 0 0 #f5ebe0, -0.2rem 0 0 #f5ebe0; }
.ipa-match-c { background: #e5f0df; box-shadow: 0.5rem 0 0 #e5f0df, -0.2rem 0 0 #e5f0df; }
.ipa-match-d { background: #f0e5f0; box-shadow: 0.5rem 0 0 #f0e5f0, -0.2rem 0 0 #f0e5f0; }
.ipa-match-e { background: #f7e5e5; box-shadow: 0.5rem 0 0 #f7e5e5, -0.2rem 0 0 #f7e5e5; }

/* Mobile adjustments */
@media (max-width: 500px) {
	/* Force line break after button using pseudo-element */
	form {
		position: relative;
	}

	form::after {
		content: '';
		flex-basis: 100%;
		order: 1;
	}

	form label:first-of-type {
		order: 0;
		flex: 1;
		min-width: 0;
	}

	form button {
		order: 0;
	}

	form .checkbox {
		order: 2;
	}

	/* Auto-size columns to content */
	.conjugation-tables {
		font-size: 11px;
		overflow-x: auto;
	}

	.conjugation-tables,
	.conjugation-tables table,
	.conjugation-tables caption,
	.conjugation-tables th,
	.conjugation-tables td {
		font-size: 11px;
	}

	.conjugation-tables table {
		table-layout: auto;
	}

	.conjugation-tables caption,
	.conjugation-tables th,
	.conjugation-tables td {
		padding: 0.2rem 0.3rem;
	}

	.conjugation-tables .ipa {
		font-size: 9px;
	}

	.conjugation-tables th {
		word-break: break-word;
		hyphens: auto;
		min-width: 3em;
	}

	.conjugation-tables td {
		white-space: nowrap;
	}

	/* Stack IPA below conjugation on mobile */
	.form-with-ipa {
		flex-direction: column;
		align-items: flex-start;
		gap: 0;
	}

	.form-with-ipa .ipa {
		text-align: left;
	}
}
