/* The dashboard on top of brand.css: a top bar, a slim sidebar and one view at
   a time, flat on the page's background with hairlines between things. One
   control height, one radius, two text sizes. */
:root {
	--width: 80rem;
	--gutter: 1.5rem;
	--topbar: 3.25rem;
	--form: 45rem;
	--radius: 6px;
	--control: 2rem;
	--text-xs: 0.8125rem;
	--color-ok: #2e7d32;
	--color-hover: color-mix(in srgb, var(--color-text) 6%, transparent);
}

@media (prefers-color-scheme: dark) {
	:root {
		--color-ok: #81c784;
	}
}

body {
	font-size: 0.9375rem;
}

#app {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
}

/* The bar's contents keep to the same column as the workspace under it. */
.topbar {
	display: flex;
	align-items: center;
	gap: 1.25rem;
	flex: none;
	height: var(--topbar);
	padding-inline: max(var(--gutter), calc((100% - var(--width)) / 2 + var(--gutter)));
	border-bottom: 1px solid var(--color-border);
}

.topbar .brand {
	gap: 0.5rem;
}

.topbar .brand img {
	width: 24px;
	height: 24px;
	border-radius: var(--radius);
}

.topbar .wordmark {
	height: 13px;
}

.topbar .brand-label {
	font-size: inherit;
}

.site-id {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	min-width: 0;
	padding-left: 1.25rem;
	border-left: 1px solid var(--color-border);
}

.site-id strong {
	color: var(--color-text);
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.site-id a {
	color: var(--color-text-muted);
	font-size: var(--text-xs);
	text-decoration: none;
	white-space: nowrap;
}

.site-id a:hover {
	color: var(--color-text);
}

.account {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-left: auto;
	color: var(--color-text-muted);
	font-size: var(--text-xs);
}

.workspace {
	flex: 1;
	display: grid;
	grid-template-columns: 11rem minmax(0, 1fr);
	gap: 2.5rem;
	width: 100%;
	max-width: var(--width);
	margin: 0 auto;
	padding-inline: var(--gutter);
}

/* With a page open the column holds the site's pages, whose names are longer. */
.workspace.editing {
	grid-template-columns: 14rem minmax(0, 1fr);
}

/* Pulled left by an item's padding, so the items' text lines up with the brand. */
.sidebar {
	position: sticky;
	top: 0;
	align-self: start;
	display: flex;
	flex-direction: column;
	gap: 1px;
	height: calc(100dvh - var(--topbar));
	margin-left: -0.6rem;
	padding-block: 1.5rem;
	overflow-y: auto;
}

.icon {
	flex: none;
	width: 1rem;
	height: 1rem;
}

.nav-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	flex: none;
	height: var(--control);
	padding: 0 0.6rem;
	border: 0;
	border-radius: var(--radius);
	background: none;
	font: inherit;
	color: var(--color-text-body);
	text-align: left;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
}

.nav-item:hover {
	background: var(--color-hover);
}

.nav-item.active {
	background: var(--color-hover);
	color: var(--color-text);
	font-weight: 500;
}

.nav-item .count,
.nav-item.external::after {
	font-size: var(--text-xs);
	font-weight: 400;
	font-variant-numeric: tabular-nums;
	color: var(--color-text-muted);
}

.nav-item.external::after {
	content: '↗';
}

.nav-text {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tree-top {
	display: flex;
	flex: none;
	gap: 1px;
}

.tree-back {
	flex: 1;
	justify-content: flex-start;
}

.tree-new {
	width: var(--control);
	padding: 0;
	justify-content: center;
}

.tree-group {
	display: flex;
	flex-direction: column;
	flex: none;
	gap: 1px;
}

.tree-label {
	padding: 1rem 0.6rem 0.3rem;
	font-size: var(--text-xs);
	color: var(--color-text-muted);
}

.nav-foot {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	margin-top: auto;
	padding: 1rem 0.6rem 0;
	font-size: var(--text-xs);
}

.nav-foot a {
	color: var(--color-text-muted);
	text-decoration: none;
}

.nav-foot a:hover {
	color: var(--color-text);
}

.content {
	min-width: 0;
	padding-block: 1.5rem 4rem;
}

/* Signing in and naming the site: one short form in the middle, each field
   under its label. */
.single {
	flex: 1;
	width: 100%;
	max-width: 24rem;
	margin: 0 auto;
	padding: 4rem var(--gutter);
}

.single .setting {
	flex-direction: column;
	align-items: stretch;
	gap: 0.4rem;
	padding: 0 0 1rem;
}

.single .setting-control {
	width: 100%;
}

/* Every view takes the width there is; only running text is kept short. */
.panel > p {
	max-width: var(--form);
}

.panel-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.25rem 1.5rem;
	margin-bottom: 1rem;
}

.panel h1 {
	font-size: 1.25rem;
	line-height: var(--control);
	letter-spacing: var(--tracking-normal);
	margin: 0;
	max-width: none;
}

.panel-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	font-size: var(--text-xs);
	color: var(--color-text-muted);
}

.panel h2 {
	font-size: inherit;
	margin: 0 0 0.5rem;
}

.panel > p {
	margin: 0 0 1rem;
}

.muted {
	font-size: var(--text-xs);
}

.panel > p.muted {
	font-size: var(--text-sm);
}

/* Settings in groups, a hairline over each: what the group is about on the
   left, and on the right its settings, one per line. */
.group {
	display: grid;
	grid-template-columns: 16rem minmax(0, 1fr);
	gap: 0 2rem;
	padding-block: 0.75rem;
	border-top: 1px solid var(--color-border);
}

.group-about {
	padding-top: 0.65rem;
}

.group-about h2 {
	margin: 0;
}

.group-about p {
	margin: 0;
}

.setting {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: 2.75rem;
	padding: 0.4rem 0;
}

.settings > .panel-actions {
	margin-block: 0.5rem;
}

.setting-label {
	display: flex;
	flex-direction: column;
	color: var(--color-text);
}

.setting-label small {
	font-size: var(--text-xs);
	color: var(--color-text-muted);
}

.setting-aside {
	margin-left: auto;
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

.setting-control {
	flex: none;
	display: flex;
	justify-content: flex-end;
	width: min(18rem, 55%);
}

input:not([type='checkbox']):not([type='file']),
select {
	font: inherit;
	color: var(--color-text);
	background: var(--color-bg);
	border: 1px solid var(--color-border-strong);
	border-radius: var(--radius);
	height: var(--control);
	padding: 0 0.55rem;
	width: 100%;
}

input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--color-accent);
	outline-offset: 1px;
	border-color: transparent;
}

input[type='checkbox'] {
	accent-color: var(--color-cta);
	width: 1rem;
	height: 1rem;
	margin: 0;
	flex: none;
}

.btn {
	height: var(--control);
	padding-inline: 0.75rem;
	border-radius: var(--radius);
	font-size: var(--text-sm);
	box-shadow: none;
}

/* The picker itself is hidden; its label is the button. */
.btn.file input {
	display: none;
}

.btn-danger {
	background: var(--color-danger);
	border-color: var(--color-danger);
	color: var(--color-bg);
}

.btn-danger:disabled {
	opacity: 0.4;
}

.panel-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 1rem;
	margin-top: 1rem;
}

/* Publish stays in reach under a list longer than the window. */
.panel-actions.sticky {
	position: sticky;
	bottom: 0;
	margin-top: 0;
	padding-block: 0.75rem;
	background: var(--color-bg);
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 1.25rem;
}

.toolbar input[type='search'] {
	width: 16rem;
	margin-left: auto;
}

.toolbar-end {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-left: auto;
}

/* Pages, files and DNS records are one table: quiet headings, hairlines, the
   name taking the room and the rest set to the right of it. */
table.list {
	width: 100%;
	border-collapse: collapse;
}

table.list th {
	padding: 0 1.25rem 0.4rem 0;
	border-bottom: 1px solid var(--color-border);
	font-size: var(--text-xs);
	font-weight: 400;
	color: var(--color-text-muted);
	text-align: left;
	white-space: nowrap;
}

table.list td {
	height: 2.75rem;
	padding: 0.4rem 1.25rem 0.4rem 0;
	border-bottom: 1px solid var(--color-border);
	white-space: nowrap;
}

table.list :is(th, td):last-child {
	padding-right: 0;
}

table.list td.name {
	width: 100%;
	color: var(--color-text);
	white-space: normal;
	overflow-wrap: anywhere;
}

table.list td.name > * {
	vertical-align: middle;
}

table.list td.name .muted {
	margin-left: 0.75rem;
}

table.list td.name :is(a, .link-button) {
	color: inherit;
	text-align: left;
	text-decoration: none;
}

table.list td.name :is(a, .link-button):hover {
	text-decoration: underline;
}

table.list td.num {
	font-size: var(--text-sm);
	font-variant-numeric: tabular-nums;
	color: var(--color-text-muted);
}

/* What can be done to a row: a column a verb, quiet until pointed at. */
table.list td.act {
	padding-right: 1rem;
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

table.list td.act .link-button {
	text-decoration: none;
}

table.list td.act .link-button:hover {
	text-decoration: underline;
}

.check {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	cursor: pointer;
}

.check + a {
	margin-left: 0.6rem;
}

/* A state is a dot and a word; the dot carries the colour. */
.status {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin: 0;
	font-size: var(--text-sm);
	color: var(--color-text-body);
	white-space: nowrap;
}

.status::before {
	content: '';
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--dot, var(--color-border-strong));
}

.status.live,
.status.same {
	--dot: var(--color-ok);
}

.status.changed {
	--dot: var(--color-accent);
}

.status + .muted {
	margin-left: 0.75rem;
}

table.records td {
	padding-block: 0.6rem;
	vertical-align: top;
}

table.records td:nth-child(3) {
	width: 100%;
	white-space: normal;
	overflow-wrap: anywhere;
}

table.records code {
	font-family: var(--font-mono, ui-monospace, monospace);
	font-size: var(--text-xs);
	user-select: all;
}

table.records .full-name {
	display: block;
	margin-top: 0.15rem;
	font-size: 0.75rem;
	color: var(--color-text-muted);
}

table.records tr.optional td,
table.records td.missing {
	color: var(--color-text-muted);
}

table.records td.ok {
	color: var(--color-ok);
	font-weight: 600;
}

.domain-line {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 1rem;
	margin-bottom: 1rem;
	color: var(--color-text);
}

.message {
	margin: 0 0 1.25rem;
	padding: 0.5rem 0.75rem;
	border-radius: var(--radius);
	background: var(--color-bg-secondary);
	color: var(--color-text);
	font-size: var(--text-sm);
}

.message.error {
	color: var(--color-danger);
	background: color-mix(in srgb, var(--color-danger) 8%, transparent);
}

.problems {
	margin-top: 1.5rem;
	font-size: var(--text-sm);
}

.problems ul {
	margin: 0;
	padding-left: 1.1rem;
}

.problems li {
	margin-bottom: 0.25rem;
}

h2.danger {
	color: var(--color-danger);
}

.confirm {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
	padding: 0.4rem 0;
	font-size: var(--text-sm);
}

.confirm input {
	flex: 1;
	min-width: 12rem;
}

.upload-control {
	display: flex;
	gap: 0.5rem;
	width: 100%;
}

.upload-control select {
	flex: 1;
	min-width: 0;
}

/* The editor: the title and what is saved, then the tools on the page. */
.editor-head {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin-bottom: 1rem;
}

.editor-state {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-inline: 0.4rem;
	font-size: var(--text-sm);
	white-space: nowrap;
}

/* The title is bare text: a box around it would stand out past the page's
   left edge, and the caret already shows where typing goes. */
.editor-head input.page-title {
	flex: 1 1 14rem;
	min-width: 0;
	height: 2.5rem;
	padding: 0;
	border: 0;
	background: none;
	font-size: 1.5rem;
	font-weight: 600;
	letter-spacing: var(--tracking-snug);
}

.editor-head input.page-title:focus-visible {
	outline: none;
}

.editor-date {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex: none;
	margin-left: auto;
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

.editor-date input[type='date'] {
	width: auto;
	border-color: transparent;
	font-size: var(--text-sm);
}

.editor-date input[type='date']:hover {
	border-color: var(--color-border);
}

/* The theme file, as its CSS. The token colours are Deft's own, which the
   editor's highlighting reads by these names. */
.theme-editor {
	--syntax-keyword: #7c3aed;
	--syntax-string: #2f7d3f;
	--syntax-number: #a84e08;
	--syntax-function: #2b6cb0;
	--syntax-constant: #ad3da4;
	--syntax-type: #0f766e;
	--syntax-comment: var(--color-text-muted);
	--editor-foreground-muted: var(--color-text-muted);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-surface);
	color: var(--color-text);
	cursor: text;
}

@media (prefers-color-scheme: dark) {
	.theme-editor {
		--syntax-keyword: #c792ea;
		--syntax-string: #9ece6a;
		--syntax-number: #ff9e64;
		--syntax-function: #63b3ed;
		--syntax-constant: #dc7ce0;
		--syntax-type: #4ec9b0;
	}
}

.theme-editor:focus-within {
	border-color: var(--color-border-strong);
}

.theme-editor .cm-editor.cm-focused {
	outline: none;
}

.theme-editor .cm-editor .cm-scroller {
	min-height: 34rem;
	max-height: calc(100vh - 12rem);
	padding: 0.75rem 1rem;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: var(--text-xs);
	line-height: 1.6;
}

.theme-dropped {
	margin: 0 0 0.75rem;
	font-size: var(--text-sm);
	overflow-wrap: anywhere;
}

/* The one box in the dashboard: the page is in its site's colours, not ours. */
.editor-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem;
	position: sticky;
	top: 0;
	z-index: 2;
	padding: 0.35rem;
	border: 1px solid var(--color-border);
	border-radius: var(--radius) var(--radius) 0 0;
	background: var(--color-bg);
}

.tool {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--control);
	height: var(--control);
	padding: 0;
	border: 0;
	border-radius: var(--radius);
	background: none;
	font: inherit;
	font-size: var(--text-sm);
	color: var(--color-text-body);
	cursor: pointer;
}

label.tool input {
	display: none;
}

select.tool {
	width: auto;
	margin-right: 0.25rem;
	border: 0;
	padding: 0 0.4rem;
	background: none;
	color: var(--color-text-body);
}

.tool:hover {
	background: var(--color-hover);
}

.tool.on {
	background: var(--color-accent-bg);
	color: var(--color-accent);
}

/* The page itself, in the site's theme (its tokens are set on this box), its
   text as wide as the box. */
.page-editor {
	--cm-line-inset-left: 6px;
	--cm-line-inset-right: 2px;
	--editor-inset: 1.5rem;
	--editor-title-gap: 1.5rem;
	--column-width: 100%;
	--column-left: 0px;
	--selection-background: Highlight;
	--selection-background-soft: color-mix(in srgb, Highlight 55%, transparent);
	min-height: 24rem;
	border: 1px solid var(--color-border);
	border-top: 0;
	border-radius: 0 0 var(--radius) var(--radius);
	background: var(--editor-background);
	accent-color: var(--accent);
	cursor: text;
}

.page-editor .cm-content {
	min-height: 24rem;
}

.page-editor .cm-content:focus-visible {
	outline: none;
}

/* Narrow screens: the sidebar becomes a row of tabs, and a table's rows
   become blocks, the name on a line of its own over the rest. */
@media (max-width: 720px) {
	:root {
		--gutter: 1rem;
	}

	.topbar {
		flex-wrap: wrap;
		gap: 0.25rem 1rem;
		height: auto;
		padding-block: 0.6rem;
	}

	.site-id {
		order: 3;
		width: 100%;
		padding-left: 0;
		border-left: 0;
	}

	.workspace,
	.workspace.editing {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
		align-content: start;
	}

	.sidebar {
		position: static;
		flex-direction: row;
		height: auto;
		margin-inline: -0.6rem;
		padding-block: 0.6rem 0;
		overflow-x: auto;
	}

	.nav-foot,
	.tree-group {
		display: none;
	}

	.tree-top {
		flex: 1;
	}

	.content {
		padding-block: 1rem 2.5rem;
	}

	.single {
		padding-block: 2rem;
	}

	.group {
		grid-template-columns: minmax(0, 1fr);
	}

	.setting {
		flex-direction: column;
		align-items: stretch;
		gap: 0.4rem;
	}

	.setting-control {
		width: 100%;
		justify-content: flex-start;
	}

	.setting-aside {
		margin-left: 0;
		align-self: flex-start;
	}

	.toolbar input[type='search'] {
		flex: 1 0 100%;
	}

	table.list,
	table.list thead,
	table.list tbody {
		display: block;
	}

	/* Of the headings only the box that ticks every row is kept. */
	table.list thead tr:not(:has(.all)),
	table.list th:not(.all),
	table.list td:empty {
		display: none;
	}

	table.list th {
		padding: 0;
		border: 0;
	}

	table.list tr {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 0.2rem 1rem;
		padding: 0.6rem 0;
		border-bottom: 1px solid var(--color-border);
	}

	table.list td,
	table.list td.act {
		min-width: 0;
		height: auto;
		padding: 0;
		border: 0;
		white-space: normal;
		overflow-wrap: anywhere;
	}

	table.list td.name,
	table.records td:nth-child(3) {
		flex: 1 0 100%;
	}

	table.records tr {
		align-items: baseline;
	}

	table.records td:nth-child(3) {
		order: 1;
	}

	table.records td:last-child {
		margin-left: auto;
	}

	/* The state fills its line, beside the date when there is one, so a
	   page's actions always start a line of their own. */
	table.list td.state {
		flex: 1 0 calc(100% - 7.5rem);
	}

	table.list td.num:empty + td.state {
		flex-basis: 100%;
	}

	.editor-head input.page-title {
		flex-basis: 100%;
	}

	.editor-state {
		margin-left: 0;
		margin-right: auto;
	}

	.editor-head {
		flex-wrap: wrap;
	}
}
