:root {
	--bg: #101014;
	--card: #1a1a21;
	--cell: #0a0a0d;
	--cell-border: #26262e;
	--text: #e8e6df;
	--dim: #8b8b96;
	--accent: #f6821f; /* Cloudflare orange */
	--ok: #7bd88f;
	--err: #ff6b6b;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
	-webkit-font-smoothing: antialiased;
}

header {
	padding: 20px 16px 4px;
	text-align: center;
}

h1 {
	margin: 0 0 10px;
	font-size: 20px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--accent);
}

.pill {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--card);
	border: 1px solid var(--cell-border);
	font-size: 12px;
	color: var(--ok);
}

.pill.warn {
	color: var(--err);
}

.pill.link {
	color: var(--accent);
	text-decoration: none;
	margin-left: 6px;
}

.pill.sim {
	color: var(--accent);
	border-color: var(--accent);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 2px 8px;
}

main {
	max-width: 560px;
	margin: 0 auto;
	padding: 12px 12px 32px;
}

.card {
	background: var(--card);
	border: 1px solid var(--cell-border);
	border-radius: 14px;
	padding: 14px;
	margin-bottom: 14px;
}

.card-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 10px;
}

h2 {
	margin: 0;
	font-size: 13px;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--dim);
}

.meta {
	font-size: 12px;
	color: var(--dim);
}

/* ---- the split-flap render ---- */

.board {
	display: grid;
	grid-template-columns: repeat(22, 1fr);
	gap: 2px;
	background: #000;
	border-radius: 8px;
	padding: 6px;
}

.cell {
	aspect-ratio: 3 / 4;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(180deg, #17171c 48%, var(--cell) 52%);
	border: 1px solid var(--cell-border);
	border-radius: 2px;
	font-family: 'Courier New', monospace;
	font-size: clamp(7px, 2.9vw, 15px);
	font-weight: 700;
	color: var(--text);
	overflow: hidden;
}

.cell.blank {
	color: transparent;
}

/* Color chips (codes 63-71) — solid cells, no glyph, no split seam. */
.cell[class*='chip-'] {
	color: transparent;
	background: none;
}

.cell.chip-red { background-color: #d64541; }
.cell.chip-orange { background-color: #e8842c; }
.cell.chip-yellow { background-color: #e6c229; }
.cell.chip-green { background-color: #3ba55d; }
.cell.chip-blue { background-color: #3b78d8; }
.cell.chip-violet { background-color: #8b5cd6; }
.cell.chip-white { background-color: #e8e6df; }
.cell.chip-black { background-color: #000; }

/* Mid-riffle cells while the split-flap animation runs. */
.cell.flipping {
	color: var(--dim);
	animation: flap 90ms linear infinite;
}

@keyframes flap {
	50% {
		transform: scaleY(0.4);
	}
}

.queue {
	margin-top: 10px;
	font-size: 12px;
	color: var(--dim);
	overflow-x: auto;
	white-space: nowrap;
}

/* ---- tabs ---- */

.tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 14px;
}

.tab {
	flex: 1;
	padding: 10px 0;
	background: var(--card);
	border: 1px solid var(--cell-border);
	border-radius: 10px;
	color: var(--dim);
	font-size: 13px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
}

.tab.active {
	color: var(--bg);
	background: var(--accent);
	border-color: var(--accent);
	font-weight: 700;
}

.hint {
	margin: 2px 0 14px;
	font-size: 13px;
	color: var(--dim);
	line-height: 1.5;
}

/* ---- spot tab ---- */

.camera-button {
	display: block;
	text-align: center;
	padding: 18px;
	border: 2px dashed var(--accent);
	border-radius: 12px;
	color: var(--accent);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	margin-bottom: 12px;
}

#preview {
	width: 100%;
	border-radius: 10px;
	margin-bottom: 12px;
}

button.primary {
	width: 100%;
	padding: 14px;
	border: 0;
	border-radius: 10px;
	background: var(--accent);
	color: var(--bg);
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
}

button.primary:disabled {
	opacity: 0.5;
}

.status {
	min-height: 1.2em;
	font-size: 13px;
	margin: 10px 0 0;
}

.status.ok {
	color: var(--ok);
}

.status.err {
	color: var(--err);
}

.status.busy {
	color: var(--dim);
}

/* ---- message tab ---- */

textarea {
	width: 100%;
	background: var(--cell);
	border: 1px solid var(--cell-border);
	border-radius: 10px;
	color: var(--text);
	font-family: 'Courier New', monospace;
	font-size: 16px;
	text-transform: uppercase;
	padding: 12px;
	resize: none;
}

.row {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 10px;
}

.row .meta {
	white-space: nowrap;
}

/* ---- history + admin ---- */

.history,
.applets {
	list-style: none;
	margin: 0;
	padding: 0;
}

.history li,
.applets li {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	padding: 10px 2px;
	border-bottom: 1px solid var(--cell-border);
	font-size: 13px;
}

.history li:last-child,
.applets li:last-child {
	border-bottom: 0;
}

.h-lines {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.toggle {
	padding: 6px 16px;
	border-radius: 999px;
	border: 1px solid var(--cell-border);
	background: var(--cell);
	color: var(--dim);
	cursor: pointer;
}

.toggle.on {
	background: var(--ok);
	border-color: var(--ok);
	color: var(--bg);
	font-weight: 700;
}

.toggle:disabled {
	opacity: 0.4;
}

/* ---- tiles (status tab + admin console) ---- */

.tiles {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 10px;
}

.modes {
	display: grid;
	gap: 10px;
	margin-bottom: 2px;
}

#status-modes {
	margin-bottom: 12px;
}

.tile {
	background: var(--cell);
	border: 1px solid var(--cell-border);
	border-radius: 10px;
	padding: 12px;
}

.tile-head {
	display: flex;
	align-items: center;
	gap: 8px;
}

.tile-head strong {
	font-size: 14px;
	letter-spacing: 0.04em;
}

.tile-head .badge,
.tile-head .toggle {
	margin-left: auto;
}

.tile-desc {
	margin: 8px 0 0;
	font-size: 12px;
	color: var(--dim);
	line-height: 1.5;
}

.badge {
	padding: 3px 12px;
	border-radius: 999px;
	border: 1px solid var(--cell-border);
	font-size: 11px;
	text-transform: uppercase;
	color: var(--dim);
	white-space: nowrap;
}

.badge.on {
	background: var(--ok);
	border-color: var(--ok);
	color: var(--bg);
	font-weight: 700;
}

/* ---- sessions (admin console) ---- */

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

.sessions li {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 2px;
	border-bottom: 1px solid var(--cell-border);
	font-size: 13px;
}

.sessions li:last-child {
	border-bottom: 0;
}

.sessions .email {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sessions .reset {
	margin-left: auto;
}

footer {
	text-align: center;
	padding: 0 16px 28px;
	font-size: 11px;
	color: var(--dim);
}
