/* Shared chrome for stagingtable tools that use the dark editor look (null, diff, tidy). */

:root {
	--bg: #1f1f1f;
	--panel: #252526;
	--line: #333;
	--line-strong: #3c3c3c;
	--text: #d4d4d4;
	--text-dim: #9d9d9d;
	--text-faint: #6e6e6e;
	--blue: #1d74d0;
	--blue-hover: #2a84e3;
	--cursor: #4aa3ff;
	--green: #2ea043;
	--orange: #e8590c;
	--amber: #c98a00;
	--red: #c53030;
	--sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	-webkit-font-smoothing: antialiased;
}

[hidden] {
	display: none !important;
}

button {
	font: inherit;
	color: inherit;
}

/* ---------- Page: top bar + editor ---------- */

.room {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
	padding: 8px 12px;
	border-bottom: 1px solid var(--line);
	background: var(--bg);
}

.topbar .brand {
	font-family: var(--mono);
	font-size: 17px;
	font-weight: 700;
	color: var(--text);
	text-decoration: none;
	margin-right: 2px;
}

.pill {
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 10.5px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #fff;
	white-space: nowrap;
}

.status {
	background: var(--text-faint);
}

.status[data-state="connected"] {
	background: var(--green);
}

.status[data-state="reconnecting"] {
	background: var(--amber);
}

.status[data-state="closed"] {
	background: var(--red);
}

.countdown {
	background: var(--orange);
}

.peers {
	display: flex;
	align-items: center;
}

.peer {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	margin-left: -6px;
	border: 2px solid var(--bg);
	border-radius: 50%;
	font-size: 11px;
	font-weight: 700;
	color: #fff;
}

.peer:first-child {
	margin-left: 0;
}

.peer.you {
	box-shadow: 0 0 0 1.5px #e6e6e6;
}

.peer-more {
	margin-left: 6px;
	font-size: 12px;
	color: var(--text-dim);
}

.lang {
	height: 28px;
	padding: 0 26px 0 9px;
	border: 1px solid var(--line-strong);
	border-radius: 4px;
	background: var(--panel)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3-3 3 3M2 6l3 3 3-3' fill='none' stroke='%239d9d9d' stroke-width='1.2'/%3E%3C/svg%3E")
		no-repeat right 8px center;
	color: var(--text);
	font: 13px var(--sans);
	appearance: none;
	cursor: pointer;
}

.spacer {
	flex: 1;
}

.actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.tb-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 28px;
	padding: 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: 4px;
	background: var(--panel);
	font-size: 12.5px;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	transition:
		background 0.12s,
		border-color 0.12s;
}

.tb-btn:hover {
	background: #2d2d2d;
	border-color: #4a4a4a;
}

.tb-btn svg {
	width: 14px;
	height: 14px;
	flex: none;
}

.tb-btn.icon {
	width: 28px;
	padding: 0;
	justify-content: center;
}

.font-group {
	display: inline-flex;
}

.font-group .tb-btn:first-child {
	border-radius: 4px 0 0 4px;
}

.font-group .tb-btn:last-child {
	margin-left: -1px;
	border-radius: 0 4px 4px 0;
}

.tb-btn.danger {
	border-color: rgba(197, 48, 48, 0.55);
	background: rgba(197, 48, 48, 0.18);
	color: #ff8a8a;
}

.tb-btn.danger:hover {
	background: rgba(197, 48, 48, 0.32);
}

.tb-btn.danger.armed {
	width: auto;
	padding: 0 10px;
	background: var(--red);
	color: #fff;
}

@media (max-width: 760px) {
	.tb-btn .label {
		display: none;
	}

	.tb-btn:not(.icon) {
		width: 28px;
		padding: 0;
		justify-content: center;
	}

	.tb-btn.danger.armed .label {
		display: inline;
	}
}

.editor-wrap {
	position: relative;
	flex: 1;
	min-height: 0;
	margin: 12px;
	border: 1px solid var(--line-strong);
	border-radius: 4px;
	overflow: hidden;
	background: #1e1e1e;
}

#editor {
	position: absolute;
	inset: 0;
}

.loading {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 13px;
	color: var(--text-faint);
}

.loading::before {
	content: "";
	width: 16px;
	height: 16px;
	margin-bottom: 40px;
	border: 2px solid var(--line-strong);
	border-top-color: var(--cursor);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
	grid-area: 1 / 1;
}

.loading span {
	grid-area: 1 / 1;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---------- Toast ---------- */

.toast {
	position: fixed;
	left: 50%;
	bottom: 28px;
	z-index: 20;
	padding: 9px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 6px;
	background: #2b2b2b;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	font-size: 13px;
	color: #e6e6e6;
	transform: translate(-50%, 12px);
	opacity: 0;
	pointer-events: none;
	transition:
		opacity 0.18s,
		transform 0.18s;
}

.toast.show {
	transform: translate(-50%, 0);
	opacity: 1;
}

.toast.error {
	border-color: rgba(197, 48, 48, 0.7);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- Buttons ---------- */

.cta {
	padding: 11px 20px;
	border: 0;
	border-radius: 4px;
	background: var(--blue);
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;
}

.cta:hover {
	background: var(--blue-hover);
}

.cta:focus-visible,
.tb-btn:focus-visible,
.lang:focus-visible {
	outline: 2px solid var(--cursor);
	outline-offset: 2px;
}

.tb-btn.primary {
	border-color: var(--blue);
	background: var(--blue);
	color: #fff;
}

.tb-btn.primary:hover {
	border-color: var(--blue-hover);
	background: var(--blue-hover);
}

/* Toggle buttons (aria-pressed) */
.tb-btn[aria-pressed="true"] {
	border-color: rgba(74, 163, 255, 0.5);
	background: rgba(74, 163, 255, 0.14);
	color: #9cd0ff;
}

.tb-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.tb-check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 12.5px;
	color: var(--text-dim);
	white-space: nowrap;
	cursor: pointer;
	user-select: none;
}

.tb-check input {
	margin: 0;
	accent-color: var(--blue);
}

.topbar .brand-sub {
	font-size: 12px;
	color: var(--text-faint);
	white-space: nowrap;
}

@media (max-width: 760px) {
	.topbar .brand-sub {
		display: none;
	}
}
