:root {
	--bg: #f2f5f9;
	--surface: #ffffff;
	--primary: #0f4c81;
	--primary-dark: #0b3a63;
	--accent: #e9f2fb;
	--text: #1b2430;
	--muted: #6b7684;
	--user: #d9f3dc;
	--danger: #d64545;
	--radius: 16px;
}

* {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html, body {
	margin: 0;
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 17px;
}

body {
	display: flex;
	flex-direction: column;
	height: 100dvh;
	overflow: hidden;
}

.topbar {
	background: var(--primary);
	color: #fff;
	padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
}

.topbar .title {
	font-weight: 700;
	display: flex;
	flex-direction: column;
}

.topbar .progress {
	font-size: 14px;
	opacity: 0.9;
	text-align: left;
	white-space: pre-line;
	margin-inline-start: auto;
	margin-inline-end: 12px;
}

.topbar .reload {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.topbar .reload:active {
	background: rgba(255, 255, 255, 0.35);
}

/* Bilingual labels: Hebrew line first, Russian line below it, smaller. */
.he {
	display: block;
}

.ru {
	display: block;
	direction: ltr;
	font-size: 0.82em;
	opacity: 0.8;
}

.topbar .ru {
	font-weight: 500;
}

.intro p.ru {
	margin-top: -8px;
	color: var(--muted);
	text-align: left;
}

.primary .ru, .chip .ru {
	font-size: 0.75em;
	line-height: 1.1;
}

.review-label {
	white-space: pre-line;
}

.chat {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	-webkit-overflow-scrolling: touch;
}

.intro {
	margin: auto;
	max-width: 420px;
	background: var(--surface);
	border-radius: var(--radius);
	padding: 24px;
	text-align: center;
	line-height: 1.6;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.bubble {
	max-width: 85%;
	padding: 12px 14px;
	border-radius: var(--radius);
	line-height: 1.55;
	white-space: pre-wrap;
	word-wrap: break-word;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	animation: pop 0.15s ease-out;
}

.bubble.ai {
	align-self: flex-start;
	background: var(--surface);
	border-bottom-right-radius: 4px;
}

.bubble.user {
	align-self: flex-end;
	background: var(--user);
	border-bottom-left-radius: 4px;
}

.bubble.system {
	align-self: center;
	background: transparent;
	color: var(--muted);
	font-size: 14px;
	box-shadow: none;
}

/* Placeholder bubble while the server transcribes / thinks / synthesizes: three breathing dots. */
.bubble.thinking {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 12px 18px;
	animation: pop 0.15s ease-out, breathe 1.6s ease-in-out 0.3s infinite;
}

.bubble.thinking .dots {
	display: flex;
	align-items: center;
	gap: 6px;
	height: 14px;
}

.bubble.thinking .typing-label {
	font-size: 13px;
	color: var(--muted);
	line-height: 1.2;
}

.bubble.thinking .dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--primary);
	opacity: 0.35;
	animation: dot 1.2s ease-in-out infinite;
}

.bubble.thinking .dot:nth-child(2) {
	animation-delay: 0.2s;
}

.bubble.thinking .dot:nth-child(3) {
	animation-delay: 0.4s;
}

.bubble.user.thinking .dot {
	background: #2f8f4e;
}

@keyframes dot {
	0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
	40% { transform: translateY(-5px); opacity: 1; }
}

@keyframes breathe {
	0%, 100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
	50% { box-shadow: 0 0 0 6px rgba(15, 76, 129, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
	.bubble.thinking, .bubble.thinking .dot {
		animation: none;
	}
	.bubble.thinking .dot {
		opacity: 0.7;
	}
}

.bubble .replay {
	display: block;
	margin-top: 6px;
	font-size: 13px;
	color: var(--primary);
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	text-decoration: underline;
}

.shared {
	background: var(--accent);
	color: var(--primary-dark);
	padding: 8px 16px;
	font-size: 14px;
	flex-shrink: 0;
	border-top: 1px solid #d5e4f3;
}

.composer {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
	background: var(--surface);
	border-top: 1px solid #e0e6ee;
	flex-shrink: 0;
}

.composer input {
	flex: 1;
	font: inherit;
	padding: 12px 14px;
	border: 1px solid #cfd8e3;
	border-radius: 999px;
	outline: none;
	min-width: 0;
}

.composer input:focus {
	border-color: var(--primary);
}

button {
	font: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.primary {
	background: var(--primary);
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: 14px 28px;
	font-size: 18px;
	font-weight: 600;
	margin-top: 8px;
}

.primary:disabled {
	opacity: 0.6;
}

.mic, .send {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.send {
	background: var(--primary);
	color: #fff;
}

.send svg {
	transform: scaleX(-1);
}

.mic {
	background: var(--accent);
	color: var(--primary);
}

.mic.recording {
	background: var(--danger);
	color: #fff;
	animation: pulse 1s infinite;
}

.mic .timer {
	font-size: 15px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.mic.recording svg {
	display: none;
}

.review {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 12px;
	background: #fff8e6;
	border-top: 1px solid #f0dfae;
	flex-shrink: 0;
	flex-wrap: wrap;
}

.review-label {
	font-size: 14px;
	color: var(--muted);
}

.review-actions {
	display: flex;
	gap: 6px;
}

.chip {
	border: 1px solid #cfd8e3;
	background: var(--surface);
	color: var(--text);
	border-radius: 999px;
	padding: 6px 14px;
	font-size: 15px;
	text-align: center;
}

.chip-primary {
	background: var(--primary);
	border-color: var(--primary);
	color: #fff;
	font-weight: 600;
}

.chip:disabled {
	opacity: 0.5;
}

.mic:disabled, .send:disabled {
	opacity: 0.5;
	cursor: default;
}

/* Access gate overlay */
.gate {
	position: fixed;
	inset: 0;
	background: var(--bg);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	z-index: 20;
}

.gate-card {
	width: 100%;
	max-width: 340px;
	background: var(--surface);
	border-radius: var(--radius);
	padding: 24px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
	display: flex;
	flex-direction: column;
	gap: 14px;
	text-align: center;
}

.gate-title {
	font-weight: 700;
	font-size: 18px;
}

.gate-card input {
	font: inherit;
	font-size: 18px;
	padding: 12px 14px;
	border: 1px solid #cfd8e3;
	border-radius: 10px;
	text-align: center;
	letter-spacing: 0.15em;
}

.gate-card input:focus {
	outline: none;
	border-color: var(--primary);
}

.gate-error {
	color: var(--danger);
	font-size: 14px;
}

.gate-card .primary {
	margin-top: 0;
}

.toast {
	white-space: pre-line;
	text-align: center;
	position: fixed;
	bottom: 90px;
	left: 50%;
	transform: translateX(-50%);
	background: #333;
	color: #fff;
	padding: 10px 16px;
	border-radius: 8px;
	font-size: 14px;
	max-width: 90%;
	z-index: 10;
}

@keyframes pulse {
	0% { box-shadow: 0 0 0 0 rgba(214, 69, 69, 0.5); }
	100% { box-shadow: 0 0 0 14px rgba(214, 69, 69, 0); }
}

@keyframes pop {
	from { transform: translateY(6px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}
