/* whyterabbit's desktop layout: projects, sessions and the open session side by
   side, with the details of the open session in a fourth column. */

:root {
	color-scheme: light dark;
	--background: #ffffff;
	--panel: #f5f5f7;
	--text: #1d1d1f;
	--muted: #6e6e73;
	--line: #d2d2d7;
	--hover: #ebebef;
	--selected: #e3e3e8;
	--link: #0a64c8;
	--running: #0a7ae0;
	--waiting: #6e6e73;
	--ok: #2f9e44;
	--warn: #e8590c;
	--alert: #d92d20;
	--added-line: rgba(47, 158, 68, 0.14);
	--removed-line: rgba(217, 45, 32, 0.12);
	--token-keyword: #a626a4;
	--token-string: #2f7d32;
	--token-number: #b35c00;
	--token-comment: #6e6e73;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-size: 15px;
	line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
	:root {
		--background: #1c1c1e;
		--panel: #2c2c2e;
		--text: #f5f5f7;
		--muted: #98989d;
		--line: #3a3a3c;
		--hover: #333336;
		--selected: #3a3a3e;
		--link: #6cb4ff;
		--added-line: rgba(47, 158, 68, 0.22);
		--removed-line: rgba(217, 45, 32, 0.22);
		--token-keyword: #d68cf0;
		--token-string: #8fd18a;
		--token-number: #f0a860;
		--token-comment: #98989d;
	}
}

* {
	box-sizing: border-box;
}

/* The layout's display rules would otherwise show hidden parts of the page. */
[hidden] {
	display: none !important;
}

body {
	margin: 0;
	height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--background);
	color: var(--text);
}

.top-bar {
	display: flex;
	align-items: center;
	padding: 0 16px;
	height: 48px;
	border-bottom: 1px solid var(--line);
}

.top-bar h1 {
	margin: 0;
	font-size: 17px;
}

.account {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 12px;
	color: var(--muted);
}

button {
	font: inherit;
	padding: 4px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--panel);
	color: var(--text);
	cursor: pointer;
}

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

.problem {
	margin: 0;
	padding: 8px 16px;
	background: #fde8e8;
	color: #9b1c1c;
	border-bottom: 1px solid #f5b5b5;
}

@media (prefers-color-scheme: dark) {
	.problem {
		background: #3b1414;
		color: #f8b4b4;
		border-bottom-color: #6b2121;
	}
}

.login {
	flex: 1;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 12vh;
}

.login-form {
	width: 320px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.login-form h2 {
	margin: 0;
	font-size: 20px;
}

.login-form label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	color: var(--muted);
}

.login-form input {
	font: inherit;
	padding: 6px 8px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--background);
	color: var(--text);
}

.login-form button {
	align-self: flex-start;
}

.columns {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: 240px 300px minmax(0, 1fr) 280px;
}

.column {
	overflow-y: auto;
	padding: 12px 16px;
	border-right: 1px solid var(--line);
}

#inspector,
#usage,
#files {
	border-right: none;
}

/* Files being dragged over the Files screen, which uploads them into the open folder when dropped. */
#files.dropping {
	outline: 2px dashed var(--link);
	outline-offset: -6px;
	background: var(--hover);
}

/* The session scrolls above the message box, which stays at the bottom. */
.session-column {
	display: flex;
	flex-direction: column;
	padding: 0;
	overflow: hidden;
}

.session-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 12px 16px;
}

.composer {
	border-top: 1px solid var(--line);
	padding: 8px 16px 12px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.composer textarea {
	font: inherit;
	resize: vertical;
	min-height: 60px;
	max-height: 40vh;
	padding: 6px 8px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--background);
	color: var(--text);
}

.composer-bar {
	display: flex;
	align-items: center;
	gap: 12px;
}

.composer-bar button {
	margin-left: auto;
}

.composer-note {
	font-size: 13px;
	color: var(--muted);
}

.composer-note.failed {
	color: var(--alert);
}

#notify-note {
	font-size: 13px;
}

/* New session and Files sit side by side above the room's sessions. */
.room-actions {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.new-session {
	flex: 1;
}

.new-session.selected,
.room-files.selected {
	background: var(--selected);
}

/* The Usage screen takes the place of the sessions, the session and the details. */
.columns.usage-open {
	grid-template-columns: 240px minmax(0, 1fr);
}

.columns.usage-open #sessions,
.columns.usage-open #session,
.columns.usage-open #inspector {
	display: none;
}

/* A room's Files screen takes the place of the session and the details, keeping its sessions in view. */
.columns.files-open {
	grid-template-columns: 240px 300px minmax(0, 1fr);
}

.columns.files-open #session,
.columns.files-open #inspector {
	display: none;
}

#projects,
#inspector {
	background: var(--panel);
}

.column h2 {
	margin: 0 0 12px;
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
}

.empty {
	color: var(--muted);
}

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

.list li {
	margin: 0 0 2px;
}

/* A project or session in a list: a button filling the width. */
.entry {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 8px 10px;
	border: 1px solid transparent;
	border-radius: 8px;
	background: none;
	text-align: left;
}

.entry:hover {
	background: var(--hover);
}

.entry.selected {
	background: var(--selected);
	border-color: var(--line);
}

.entry.closed {
	opacity: 0.6;
}

.entry-title {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.entry-meta {
	font-size: 13px;
	color: var(--muted);
}

.entry-remit {
	font-size: 13px;
	color: var(--muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.badge {
	display: inline-block;
	padding: 0 6px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;
	background: var(--line);
	color: var(--text);
}

.badge-running {
	background: var(--running);
	color: #ffffff;
}

.badge-idle {
	background: var(--waiting);
	color: #ffffff;
}

.badge-approval,
.badge-pending {
	background: var(--warn);
	color: #ffffff;
}

.badge-approved {
	background: var(--ok);
	color: #ffffff;
}

.badge-denied,
.badge-timeout {
	background: var(--alert);
	color: #ffffff;
}

.badge-added {
	background: var(--ok);
	color: #ffffff;
}

.badge-deleted {
	background: var(--alert);
	color: #ffffff;
}

.badge-renamed {
	background: var(--waiting);
	color: #ffffff;
}

.problem-inline {
	color: var(--alert);
}

/* The open session. */
.session-header {
	position: sticky;
	top: -12px;
	margin: -12px -16px 12px;
	padding: 12px 16px 8px;
	background: var(--background);
	border-bottom: 1px solid var(--line);
	z-index: 1;
}

.session-heading {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.session-heading .session-title {
	flex: 1;
}

.stop {
	color: var(--alert);
	border-color: var(--alert);
}

.session-title {
	margin: 0 0 4px;
	font-size: 17px;
}

.column h2.session-title {
	text-transform: none;
	letter-spacing: normal;
	color: var(--text);
	font-size: 17px;
}

/* The running turn's card stays in view with the title while the timeline scrolls. */
.pinned {
	margin-top: 8px;
}

.timeline {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.message {
	max-width: 900px;
}

.message.mine .text {
	background: var(--panel);
	border-radius: 8px;
	padding: 8px 12px;
}

.message-meta {
	font-size: 12px;
	color: var(--muted);
	margin-bottom: 4px;
}

.sender {
	font-weight: 600;
}

.text {
	overflow-wrap: anywhere;
}

.text > :first-child {
	margin-top: 0;
}

.text > :last-child {
	margin-bottom: 0;
}

.text p,
.text ul,
.text ol,
.text pre,
.text blockquote,
.text .table-wrap {
	margin: 0 0 8px;
}

.text ul,
.text ol {
	padding-left: 22px;
}

.text blockquote {
	padding-left: 10px;
	border-left: 3px solid var(--line);
	color: var(--muted);
}

code {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 13px;
	background: var(--panel);
	padding: 1px 4px;
	border-radius: 4px;
}

pre {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 13px;
	background: var(--panel);
	padding: 8px 10px;
	border-radius: 6px;
	overflow-x: auto;
	white-space: pre;
}

pre code {
	padding: 0;
	background: none;
}

/* Tables scroll sideways rather than squeezing their columns. */
.table-wrap {
	overflow-x: auto;
}

table {
	border-collapse: collapse;
	font-size: 14px;
}

th,
td {
	padding: 4px 10px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

th {
	font-weight: 600;
}

.align-right {
	text-align: right;
}

.align-center {
	text-align: center;
}

.card {
	border: 1px solid var(--line);
	border-left: 4px solid var(--muted);
	border-radius: 8px;
	padding: 8px 12px;
	background: var(--background);
}

.card-running {
	border-left-color: var(--running);
}

.card-done {
	border-left-color: var(--ok);
}

.card-failed {
	border-left-color: var(--alert);
}

.card-approval.card-pending {
	border-left-color: var(--warn);
}

.card-title {
	font-weight: 600;
}

.card-step {
	margin-top: 4px;
	overflow-wrap: anywhere;
}

.card-meta {
	margin-top: 4px;
	font-size: 13px;
	color: var(--muted);
}

.card .text {
	margin-top: 6px;
}

.card-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
}

.action-approve {
	color: var(--ok);
	border-color: var(--ok);
}

.action-deny {
	color: var(--alert);
	border-color: var(--alert);
}

.card-links {
	display: flex;
	gap: 12px;
	margin-top: 4px;
	font-size: 13px;
}

/* A turn's diff, below its summary card. */
.diff-counts {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 12px;
	white-space: nowrap;
}

.diff-added {
	color: var(--ok);
}

.diff-removed {
	color: var(--alert);
}

.diff {
	margin-top: 8px;
}

.diff-file {
	border: 1px solid var(--line);
	border-radius: 6px;
	margin-bottom: 6px;
	overflow: hidden;
}

.diff-file-head {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	border: none;
	border-radius: 0;
	text-align: left;
}

.diff-file-head:hover {
	background: var(--hover);
}

.diff-toggle {
	width: 1em;
	color: var(--muted);
}

.diff-path {
	flex: 1;
	min-width: 0;
	overflow-wrap: anywhere;
	background: none;
}

.diff-body {
	overflow-x: auto;
	border-top: 1px solid var(--line);
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 12px;
	line-height: 1.45;
}

.diff-body > .entry-meta {
	padding: 4px 8px;
	margin: 0;
}

.diff-line {
	display: flex;
	min-width: max-content;
}

.diff-line code {
	flex: 1;
	padding: 0 8px;
	background: none;
	border-radius: 0;
	font-size: inherit;
	white-space: pre;
}

.diff-no {
	flex: none;
	width: 4em;
	padding: 0 6px;
	text-align: right;
	color: var(--muted);
	user-select: none;
}

.diff-add {
	background: var(--added-line);
}

.diff-del {
	background: var(--removed-line);
}

.diff-hunk,
.diff-note {
	color: var(--muted);
	background: var(--panel);
}

.tok-keyword {
	color: var(--token-keyword);
}

.tok-string {
	color: var(--token-string);
}

.tok-number {
	color: var(--token-number);
}

.tok-comment {
	color: var(--token-comment);
	font-style: italic;
}

/* A finished turn's actions, in the details column. */
.turn-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 6px;
}

a.action {
	padding: 4px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--panel);
	text-decoration: none;
}

a {
	color: var(--link);
}

/* The details column. */
.inspector-section {
	margin-bottom: 16px;
}

.inspector-section h3 {
	margin: 0 0 6px;
	font-size: 13px;
}

.inspector-section p {
	margin: 0 0 6px;
	overflow-wrap: anywhere;
}

.files,
.steps {
	margin: 0;
	padding: 0;
	list-style: none;
}

.files li {
	margin-bottom: 2px;
	overflow-wrap: anywhere;
}

.step summary {
	cursor: pointer;
	font-size: 13px;
	padding: 2px 0;
	overflow-wrap: anywhere;
}

.step.failed summary {
	color: var(--alert);
}

.step pre {
	margin: 4px 0 8px;
	max-height: 300px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* The Usage screen. */
.usage-header {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 8px;
}

.usage-header .session-title {
	margin: 0;
}

.usage-refresh {
	display: flex;
	align-items: center;
	gap: 8px;
}

#usage h3 {
	margin: 20px 0 8px;
	font-size: 15px;
}

.tiles {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 12px;
}

.tile {
	flex: 1 1 200px;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 10px 12px;
}

.tile-name {
	font-size: 13px;
	color: var(--muted);
}

.tile-value {
	font-size: 24px;
	font-weight: 600;
}

.plan {
	margin: 6px 0 0;
	padding: 0;
	list-style: none;
	max-width: 600px;
}

.plan li {
	margin-bottom: 8px;
}

.plan-label {
	display: flex;
	gap: 8px;
	font-size: 13px;
}

.plan-figure {
	margin-left: auto;
	color: var(--muted);
}

.bar {
	height: 8px;
	border-radius: 4px;
	background: var(--line);
	overflow: hidden;
}

.bar-fill {
	height: 100%;
}

.bar-ok {
	background: var(--ok);
}

.bar-warn {
	background: var(--warn);
}

.bar-alert {
	background: var(--alert);
}

.days {
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
	max-width: 600px;
}

.day {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	font-size: 12px;
}

.day-bar {
	width: 100%;
	height: 120px;
	display: flex;
	align-items: flex-end;
	background: var(--panel);
	border-radius: 4px;
}

.day-fill {
	width: 100%;
	background: var(--running);
	border-radius: 4px;
}

.day-figure,
.day-name {
	color: var(--muted);
}

/* The Files screen. */
.crumbs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	margin-bottom: 12px;
}

.crumb,
.file-folder {
	padding: 2px 4px;
	border: none;
	background: none;
	color: var(--link);
	text-align: left;
	overflow-wrap: anywhere;
}

/* The folder that is open is plain text, not a link. */
.crumb:disabled {
	color: var(--text);
	font-weight: 600;
	opacity: 1;
}

.crumb-gap {
	color: var(--muted);
}

.uploads {
	margin: 0 0 8px;
	padding: 0;
	list-style: none;
	max-width: 600px;
}

.upload {
	margin-bottom: 10px;
}

.upload-cancel,
.uploads-clear {
	margin-top: 4px;
	font-size: 13px;
}

.uploads-clear {
	margin-bottom: 12px;
}

.player {
	margin-bottom: 16px;
	max-width: 960px;
}

.player-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 6px;
}

.player-bar button {
	margin-left: auto;
}

.player video {
	display: block;
	width: 100%;
	max-height: 60vh;
	background: #000000;
	border-radius: 6px;
}

.player audio {
	width: 100%;
}

.files-table {
	width: 100%;
}

.files-table td {
	vertical-align: middle;
}

.file-name {
	overflow-wrap: anywhere;
}

.file-actions {
	white-space: nowrap;
	text-align: right;
}

.file-actions button + button {
	margin-left: 6px;
}

.file-actions .file-delete {
	color: var(--alert);
}

/* Narrower windows drop the details column; the session view shows them inline. */
@media (max-width: 1100px) {
	.columns,
	.columns.files-open {
		grid-template-columns: 220px 280px minmax(0, 1fr);
	}

	#inspector {
		display: none;
	}
}
