:root {
	color-scheme: dark;
	font-family: system-ui, -apple-system, sans-serif;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: #0b0f1a;
	color: #e7ecf5;
}

/* --- Entry page --- */
.center {
	min-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.card {
	width: 100%;
	max-width: 420px;
	background: #141a2b;
	border: 1px solid #243049;
	border-radius: 16px;
	padding: 28px;
}

h1 {
	margin: 0 0 4px;
	font-size: 1.5rem;
}

p.sub {
	margin: 0 0 20px;
	color: #97a3bd;
}

label {
	display: block;
	font-size: 0.85rem;
	color: #97a3bd;
	margin: 16px 0 6px;
}

input[type='text'] {
	width: 100%;
	padding: 12px 14px;
	font-size: 1rem;
	border-radius: 10px;
	border: 1px solid #2c3a59;
	background: #0e1322;
	color: #e7ecf5;
}

button {
	margin-top: 18px;
	width: 100%;
	padding: 13px 16px;
	font-size: 1rem;
	font-weight: 600;
	border: none;
	border-radius: 10px;
	background: #3b82f6;
	color: white;
	cursor: pointer;
}

button.secondary {
	background: #243049;
}

button:disabled {
	opacity: 0.5;
	cursor: default;
}

/* --- Viewer: book fills the screen, reader's face is a small PiP --- */
.stage {
	position: fixed;
	inset: 0;
	background: #000;
}

#book,
#bookpage {
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #000;
}

#bookpage {
	position: absolute;
	inset: 0;
}

.pip {
	position: fixed;
	bottom: 16px;
	right: 16px;
	width: 22vw;
	max-width: 220px;
	min-width: 110px;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 12px;
	border: 2px solid rgba(255, 255, 255, 0.6);
	background: #111;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

/* The kid's own self-view sits in the opposite corner from the reader's face. */
.pip-self {
	right: auto;
	left: 16px;
	width: 16vw;
	max-width: 150px;
	min-width: 90px;
	border-color: rgba(255, 255, 255, 0.35);
}

.overlay-start {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #0b0f1a;
	z-index: 10;
}

/* "Reconnecting…" banner, shown across the top during a connection drop. */
.netbanner {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 30;
	text-align: center;
	padding: 8px 12px;
	font-size: 0.9rem;
	font-weight: 600;
	color: #0b0f1a;
	background: #f5b301;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

/* "Tap for sound" — shown only when audio autoplay is blocked (iOS). */
.sound-btn {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translateX(-50%);
	width: auto;
	margin: 0;
	z-index: 20;
	font-size: 1.1rem;
	padding: 14px 26px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

/* --- Reader: kids' faces are the main view, book + self are small --- */
.reader-grid {
	position: fixed;
	inset: 0;
	display: grid;
	grid-template-rows: 1fr auto;
}

#kids {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 12px;
	align-content: center;
	justify-content: center;
}

#kids video {
	width: min(46vw, 520px);
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 12px;
	background: #111;
}

/* Small "what you're sharing" preview tile, placed to the right of the kids. */
#kids .share-tile {
	margin: 0;
	position: relative;
	align-self: center;
	order: 1; /* after the kid tiles (which keep the default order 0) */
}

#kids .share-tile video {
	width: 240px;
	height: auto; /* keep the shared content's real aspect ratio */
	aspect-ratio: auto; /* cancel the 4:3 box inherited from #kids video */
	object-fit: contain; /* show the whole page, don't crop the top */
	display: block;
	background: #000;
	border: 1px solid #2c3a59;
	border-radius: 10px;
}

#kids .share-tile figcaption {
	position: absolute;
	left: 6px;
	bottom: 6px;
	font-size: 0.7rem;
	color: #e7ecf5;
	background: rgba(0, 0, 0, 0.55);
	padding: 2px 6px;
	border-radius: 6px;
}

.reader-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px;
	background: #0e1322;
	border-top: 1px solid #243049;
}

.reader-bar #selfcam {
	width: 160px;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 10px;
	background: #111;
}

.reader-bar .grow {
	flex: 1;
}

.reader-bar input {
	width: 100%;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid #2c3a59;
	background: #0e1322;
	color: #e7ecf5;
}

.reader-bar button {
	margin: 0;
	width: auto;
	white-space: nowrap;
}

.hint {
	font-size: 0.8rem;
	color: #97a3bd;
	margin-top: 6px;
}

.muted {
	color: #97a3bd;
	font-weight: 400;
}

input[type='file'] {
	width: 100%;
	margin-top: 8px;
	color: #e7ecf5;
}

/* --- Reader, book-file mode --- */
.book-reader .page-wrap {
	position: relative;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 12px;
	background: #000;
}

#page {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	background: #fff;
	border-radius: 6px;
}

.page-controls {
	display: flex;
	align-items: center;
	gap: 16px;
	padding-top: 10px;
	color: #c7d0e0;
}

.page-controls button {
	margin: 0;
	width: auto;
	padding: 10px 18px;
}

.kids-inline {
	display: flex;
	gap: 8px;
}

.kids-inline video {
	width: 140px;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 10px;
	background: #111;
}
