/* The shell around every page: the platform bar, a world's head, the three columns of a world
   page, the page tree, the connections, the drawers a phone uses instead, and the frame the graph,
   map and timeline sit in. Reads only tokens.css. One component per block, each scoped to its class. */

/* ---- Page widths ------------------------------------------------------------ */
/* Everything that has to line up - the bar, a world's head, its columns, the portal - is one width. */

.top-bar,
.page-head,
.portal-main,
.container {
	width: 100%;
	max-width: var(--page-max);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

/* ---- The platform bar ---------------------------------------------------------- */

.platform-bar {
	position: sticky;
	top: 0;
	z-index: var(--z-bar);
	display: flex;
	align-items: center;
	gap: var(--space-4);
	min-height: calc(var(--control-h) + var(--space-4));
	padding: var(--space-2) var(--gutter);
	padding-top: max(var(--space-2), env(safe-area-inset-top));
	border-bottom: var(--rule);
	background: color-mix(in srgb, var(--paper) 92%, transparent);
	backdrop-filter: blur(8px);
	font-size: var(--text-sm);
}

/* An admin looking through someone else's eyes: plainly said, for as long as it lasts. */
.mimic-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--space-3);
	padding: var(--space-2) var(--gutter);
	border-bottom: var(--rule);
	background: color-mix(in srgb, var(--warn) 22%, var(--paper));
	font-size: var(--text-sm);
}

.platform-bar .brand {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	font-family: var(--font-titles);
	font-size: var(--text-lg);
	color: var(--accent);
	white-space: nowrap;
}

.platform-nav {
	display: flex;
	gap: var(--space-1);
	min-width: 0;
}

.platform-nav a {
	padding: var(--space-1) var(--space-3);
	border-radius: var(--radius);
	color: var(--ink-muted);
	white-space: nowrap;
}

.platform-nav a:hover {
	color: var(--ink);
	background: var(--surface);
}

.platform-nav a[aria-current="page"] {
	color: var(--ink);
	font-weight: 600;
	box-shadow: inset 0 -2px 0 var(--accent);
}

.platform-search {
	flex: 1 1 10rem;
	min-width: 0;
	max-width: 24rem;
	margin-left: auto;
}

.platform-search input {
	min-height: calc(var(--control-h) - var(--space-1));
	background: var(--surface);
	border-color: transparent;
}

.platform-search input:focus-visible {
	background: var(--paper);
}

.platform-account {
	display: flex;
	align-items: center;
	gap: var(--space-2);
}

@media (max-width: 760px) {
	.platform-bar {
		flex-wrap: wrap;
		gap: var(--space-2) var(--space-3);
	}

	.platform-nav {
		order: 3;
		flex: 1 0 100%;
		overflow-x: auto;
	}

	.platform-search {
		order: 4;
		flex: 1 0 100%;
		max-width: none;
	}

	.platform-account {
		margin-left: auto;
	}

	.platform-account .new-world span {
		display: none;
	}

	/* Over a world on a phone the world's own bar is the one that stays: this one scrolls away and
	   keeps only the brand and the avatar, whose menu has the rest. */
	body:has(.mobile-bar) .platform-bar {
		position: static;
	}

	body:has(.mobile-bar) .platform-nav,
	body:has(.mobile-bar) .platform-search {
		display: none;
	}
}

/* ---- A world's head: search and who you are, then the bar -------------------------- */

.top-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-4);
	padding-top: var(--space-5);
}

.top-bar .search {
	flex: 1 1 12rem;
	display: flex;
	gap: var(--space-2);
	min-width: 0;
}

.top-bar .search button {
	flex: none;
}

/* Who you are: one sentence and the controls beside it. The DM's view is marked in the accent. */
.identity {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-1) var(--space-3);
	padding: var(--space-1) var(--space-3);
	border: var(--rule);
	border-radius: var(--radius);
	background: var(--paper);
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-tight);
	color: var(--ink-muted);
}

.identity.dm {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.identity .who strong {
	color: var(--ink);
}

.identity a,
.identity button,
.identity select {
	min-height: calc(var(--control-h) - var(--space-2));
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	background: none;
	color: var(--ink);
	font-size: var(--text-xs);
	white-space: nowrap;
	cursor: pointer;
}

.identity a:hover,
.identity button:hover,
.identity select:hover {
	border-color: var(--accent);
	color: var(--accent-ink);
}

.identity > form:not(.view-as) {
	margin-left: auto;
}

.identity .view-as {
	display: flex;
	align-items: center;
	gap: var(--space-2);
}

.identity .view-as label {
	text-transform: uppercase;
	letter-spacing: var(--tracking-caps);
}

.identity .view-as.worn label {
	color: var(--accent-ink);
}

.identity .view-as select {
	width: auto;
	background: var(--paper);
}

.identity.guest {
	padding: 0;
	border: 0;
	background: none;
}

.identity.guest a {
	min-height: var(--control-h);
	padding: 0 var(--space-4);
	font-size: var(--text-sm);
}

/* The world bar: the way back, the views, and the actions on the right. One row on a hairline. */
.page-head {
	padding-top: var(--space-4);
}

/* On its own paper, so it reads over a banner. */
.world-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-3) var(--space-4);
	padding: var(--space-2) var(--space-3);
	border: var(--rule);
	border-radius: var(--radius);
	background: color-mix(in srgb, var(--paper) 88%, transparent);
	font-size: var(--text-sm);
}

/* The world's name, in its own heading font: which world this is, and the way to its start. */
.world-bar-back {
	font-family: var(--font-titles);
	font-size: var(--text-lg);
	color: var(--accent);
	white-space: nowrap;
}

/* Whose eyes the world is read with: a select for those who run it, a word for everyone else. */
.world-bar-as {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	color: var(--ink-muted);
	white-space: nowrap;
}

.world-bar-as select {
	min-height: calc(var(--control-h) - var(--space-2));
	font-size: var(--text-sm);
}

.world-bar-as select.worn {
	border-color: var(--accent);
	color: var(--accent-ink);
}

.world-views {
	display: inline-flex;
	gap: var(--space-1);
}

.world-views a {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-1) var(--space-3);
	border-radius: var(--radius);
	color: var(--ink-muted);
	white-space: nowrap;
}

.world-views a:hover {
	color: var(--ink);
	background: var(--surface);
}

.world-views a[aria-current="page"] {
	color: var(--ink);
	font-weight: 600;
	box-shadow: inset 0 -2px 0 var(--accent);
}

.world-bar svg,
.world-views svg,
.edit-fab svg,
.frame-toggle svg {
	width: 1.05rem;
	height: 1.05rem;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.world-bar-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-4);
	margin-left: auto;
}

.world-bar-link,
button.world-bar-link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--ink-muted);
	font-size: var(--text-sm);
	white-space: nowrap;
}

.world-bar-link:hover {
	color: var(--accent-ink);
}

.world-bar-health {
	font-weight: 600;
}

.world-bar-note {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
}

.world-bar-note input {
	width: 12rem;
	min-height: calc(var(--control-h) - var(--space-2));
	font-size: var(--text-sm);
}

.world-bar-icon {
	display: inline-grid;
	place-items: center;
	width: calc(var(--control-h) - var(--space-1));
	height: calc(var(--control-h) - var(--space-1));
	border: var(--rule);
	border-radius: var(--radius);
	color: var(--ink-muted);
}

.world-bar-icon:hover {
	border-color: var(--accent);
	color: var(--accent-ink);
}

/* A menu: a details whose summary is the button and whose list drops under it, at its right edge.
   The world's ⋯ and the account's avatar both are one. */
.menu {
	position: relative;
}

.menu > summary {
	position: relative;
	list-style: none;
	cursor: pointer;
}

.menu > summary::-webkit-details-marker {
	display: none;
}

.menu[open] > summary {
	border-color: var(--accent);
	color: var(--accent-ink);
}

.world-bar .menu > summary {
	font-size: var(--text-lg);
	line-height: 1;
}

.menu-dot {
	position: absolute;
	top: 3px;
	right: 3px;
	width: 7px;
	height: 7px;
	border-radius: var(--radius-round);
	background: var(--warn);
}

.menu-list {
	position: absolute;
	top: calc(100% + var(--space-1));
	right: 0;
	z-index: var(--z-dialog);
	display: flex;
	flex-direction: column;
	min-width: 14rem;
	padding: var(--space-2) 0;
	border: var(--rule);
	border-radius: var(--radius);
	background: var(--paper);
	box-shadow: var(--shadow-drawer);
	font-size: var(--text-sm);
}

.menu-list > a,
.menu-list > button,
.menu-list > form {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	padding: var(--space-2) var(--space-4);
	border: 0;
	background: none;
	color: var(--ink);
	font: inherit;
	text-align: left;
	white-space: nowrap;
}

.menu-list > a:hover,
.menu-list > button:hover {
	background: var(--surface);
	color: var(--accent-ink);
}

.menu-list > form[hidden] {
	display: none;
}

.menu-heading {
	padding: var(--space-2) var(--space-4) var(--space-1);
	color: var(--ink-muted);
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
}

.menu-heading:not(:first-child) {
	margin-top: var(--space-1);
	border-top: var(--rule);
	padding-top: var(--space-3);
}

.world-bar-edit {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: calc(var(--control-h) - var(--space-1));
	padding: 0 var(--space-3);
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--on-accent);
	font-weight: 600;
	white-space: nowrap;
}

.world-bar-edit:hover {
	color: var(--on-accent);
	background: color-mix(in srgb, var(--accent) 88%, white);
}

/* On a phone Edit is the round button in the corner; on a desk it is in the bar. */
.edit-fab {
	display: none;
}

@media (max-width: 768px) {
	.world-bar-edit {
		display: none;
	}

	.edit-fab {
		position: fixed;
		right: var(--space-4);
		bottom: max(var(--space-4), env(safe-area-inset-bottom));
		z-index: var(--z-fab);
		display: grid;
		place-items: center;
		width: 3.25rem;
		height: 3.25rem;
		border-radius: var(--radius-round);
		background: var(--accent);
		color: var(--on-accent);
	}

	.edit-fab svg {
		width: 1.4rem;
		height: 1.4rem;
	}
}

/* ---- A world page: three columns ------------------------------------------------- */
/* The tree, the article at reading width, the connections. The row holds the banner behind it. */

.row {
	position: relative;
	display: flex;
	flex-direction: column;
}

.row .top-image {
	position: absolute;
	top: 0;
	z-index: -1;
	width: 100%;
	-webkit-mask-image: url(/ui/mask.webp);
	mask-image: url(/ui/mask.webp);
	mask-repeat: no-repeat;
	mask-size: contain;
}

.container {
	display: grid;
	grid-template-columns: minmax(0, var(--nav-col)) minmax(0, 1fr) minmax(0, var(--aside-col));
	grid-template-areas: "nav main aside";
	column-gap: var(--col-gap);
	row-gap: var(--space-6);
	padding-top: var(--space-5);
	padding-bottom: var(--space-7);
}

.container > nav {
	grid-area: nav;
	min-width: 0;
}

.container > main {
	grid-area: main;
	justify-self: center;
	width: 100%;
	max-width: var(--prose-max);
	min-width: 0;
}

.container > aside {
	grid-area: aside;
	position: sticky;
	top: var(--space-4);
	max-height: calc(100vh - var(--space-6));
	min-width: 0;
	overflow-y: auto;
	scrollbar-color: transparent transparent;
}

.container > aside:hover,
.container > aside:focus-within {
	scrollbar-color: var(--surface-open) transparent;
}

/* The article's own pieces above its text. */
.container > main .page-played {
	font-family: var(--font-ui);
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
	color: var(--ink-muted);
}

/* An article image: full width, its edges worn by the mask. */
.container > main > p > img:only-child {
	-webkit-mask-image: url(/ui/header-image-mask-full.webp);
	mask-image: url(/ui/header-image-mask-full.webp);
	mask-repeat: no-repeat;
	mask-size: 100% 100%;
	border-radius: 0;
}

@media (max-width: 1200px) {
	.container {
		grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
		grid-template-areas:
			"nav main"
			"nav aside";
	}

	.container > aside {
		position: static;
		max-height: none;
		overflow: visible;
	}
}

/* ---- The page tree ----------------------------------------------------------- */

.container > nav {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
}

.container > nav > header {
	display: flex;
	justify-content: center;
	padding-bottom: var(--space-3);
}

.world-home {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-2);
	font-family: var(--font-titles);
	font-size: var(--text-xl);
	line-height: 1.1;
	text-align: center;
	color: var(--accent);
}

.world-home img {
	max-height: 6rem;
	width: auto;
}

.world-home .tagline {
	font-family: var(--font-ui);
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--ink-muted);
}

#nav-toggle {
	align-self: flex-start;
	min-height: calc(var(--control-h) - var(--space-2));
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	background: none;
	color: var(--ink-muted);
	font-size: var(--text-xs);
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
}

#nav-toggle:hover {
	border-color: var(--accent);
	color: var(--accent-ink);
}

.nav-dir { display: none; }
body.dir-mode .nav-virtual { display: none; }
body.dir-mode .nav-dir,
.nav-dir.nav-only { display: block; }

.container > nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: var(--text-sm);
}

.container > nav ul ul {
	margin-left: var(--space-3);
	padding-left: var(--space-2);
	border-left: var(--rule);
}

.container > nav li.folder > details > summary {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius);
	font-weight: 600;
	color: var(--ink);
}

.container > nav li.folder > details > summary:hover {
	background: var(--surface);
}

.container > nav li.folder > details[open] > summary {
	color: var(--accent-ink);
}

/* A chevron that turns when the folder opens. */
.container > nav li.folder > details > summary::before {
	content: "";
	flex: none;
	width: 0.4em;
	height: 0.4em;
	margin-inline: 0.1rem 0.15rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(-45deg);
	opacity: 0.7;
	transition: transform var(--ease);
}

.container > nav li.folder > details[open] > summary::before {
	transform: rotate(45deg);
}

.container > nav li.file {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding-left: var(--space-2);
}

.container > nav li.file::before {
	content: "";
	flex: none;
	width: 4px;
	height: 4px;
	border-radius: var(--radius-round);
	background: currentColor;
	opacity: 0.35;
}

.container > nav li.file a {
	flex: 1;
	min-width: 0;
	padding: var(--space-1) var(--space-2);
	border-radius: var(--radius);
	color: var(--ink);
	transition: background var(--ease), color var(--ease);
}

.container > nav li.file a:hover {
	background: var(--surface);
	color: var(--accent-ink);
}

.container > nav li.file a.active {
	background: var(--accent-soft);
	color: var(--accent-ink);
	font-weight: 600;
}

/* How an entry sits in the one above it: "originates in", "member of". */
.container > nav .tree-rel {
	flex: none;
	font-size: var(--text-xs);
	font-weight: 400;
	font-style: italic;
	color: var(--ink-muted);
}

/* A page of another world in the tree: that world named beside it. */
.container > nav .tree-world {
	flex: none;
	margin-left: auto;
	font-size: var(--text-xs);
	font-weight: 400;
	color: var(--ink-muted);
}

/* What the sidebar shows: the world's menu, or this page's relations. */
.container > nav .tree-switch {
	margin-block: var(--space-2) var(--space-3);
}

.container > nav .tree-empty {
	padding-left: var(--space-2);
	font-size: var(--text-sm);
	color: var(--ink-muted);
}

/* One top tag's part of the relations, under its own heading (styled with the connections panel's). */
.container > nav .tree-part + .tree-part {
	margin-top: var(--space-4);
}

/* Where a path from this page runs on through another world. */
.container > nav .tree-section {
	margin: var(--space-4) 0 var(--space-1);
	padding-left: var(--space-2);
	font-size: var(--text-xs);
	color: var(--ink-muted);
}

/* ---- Connections -------------------------------------------------------------- */

.relations {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	font-size: var(--text-sm);
}

.relations > h2 {
	padding-bottom: var(--space-1);
	border-bottom: var(--rule-strong);
	font-family: var(--font-titles);
	font-size: var(--text-md);
	font-weight: normal;
	color: var(--accent);
}

.relations .relation {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
}

.relations .relation h3,
.container > nav .tree-part h3 {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-2);
	padding-bottom: var(--space-1);
	border-bottom: var(--rule);
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
	color: var(--ink-muted);
}

.relations .count {
	font-size: var(--text-xs);
	font-variant-numeric: tabular-nums;
	color: var(--ink-faint);
}

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

.relations li a {
	display: block;
	padding: var(--space-1) var(--space-2);
	border-left: 2px solid transparent;
	line-height: 1.35;
	color: var(--ink);
	transition: background var(--ease), color var(--ease);
}

.relations li a:hover {
	border-left-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent-ink);
}

/* The other end is in another world: its name, then the world's, on one line. */
.relations li.external > a {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-2);
}

.relations li.external .world {
	font-size: var(--text-xs);
	color: var(--ink-faint);
	white-space: nowrap;
}

/* Not everyone may see this one: the same mark as a secret block. */
.relations li.restricted > a {
	border-left-color: var(--accent);
	background: var(--surface);
}

/* Short links side by side: session numbers. */
.relations .relation.compact ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1);
}

.relations .relation.compact a {
	min-width: 2.2rem;
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.relations .relation.compact a:hover {
	border-color: var(--accent);
	background: none;
}

/* ---- A phone: the tree and the connections as drawers --------------------------- */

.mobile-bar,
.nav-backdrop,
.nav-close {
	display: none;
}

@media (max-width: 768px), (pointer: coarse), (orientation: portrait) {
	.container {
		display: flex;
		flex-direction: column;
		gap: var(--space-6);
	}

	.container > main {
		order: 1;
		max-width: none;
	}

	.container > nav {
		order: 2;
	}

	.container > aside {
		order: 3;
	}

	/* A framed view has the screen to itself: its own bar carries the views. */
	body.framed .frame-head {
		display: none;
	}

	.has-drawer .mobile-bar {
		position: sticky;
		top: 0;
		z-index: var(--z-bar);
		display: flex;
		align-items: center;
		gap: var(--space-3);
		padding: var(--space-2) var(--space-4);
		padding-top: max(var(--space-2), env(safe-area-inset-top));
		border-bottom: var(--rule-strong);
		background: var(--paper);
	}

	.menu-button,
	.links-button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: var(--space-1);
		flex: none;
		min-width: var(--target);
		min-height: var(--target);
		padding: 0;
		border: 0;
		background: none;
		color: var(--accent);
		font-weight: 600;
	}

	.links-button .count {
		padding: 0 var(--space-2);
		border-radius: var(--radius);
		background: var(--accent-soft);
		font-size: var(--text-xs);
		font-variant-numeric: tabular-nums;
	}

	.mobile-world {
		flex: 1;
		min-width: 0;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-family: var(--font-titles);
		font-size: var(--text-lg);
		color: var(--accent);
	}

	.has-drawer .container > nav,
	.has-links .container > aside {
		position: fixed;
		top: 0;
		bottom: 0;
		z-index: var(--z-drawer);
		width: min(85vw, var(--nav-col));
		max-height: none;
		padding: var(--space-8) var(--space-4) max(var(--space-5), env(safe-area-inset-bottom));
		overflow-y: auto;
		overscroll-behavior: contain;
		background: var(--ground) var(--paper);
		box-shadow: var(--shadow-drawer);
		visibility: hidden;
		transition: transform 0.25s ease, visibility 0s linear 0.25s;
	}

	.has-drawer .container > nav {
		left: 0;
		transform: translateX(-100%);
	}

	.has-links .container > aside {
		right: 0;
		width: min(85vw, 20rem);
		transform: translateX(100%);
	}

	.has-drawer.nav-open .container > nav,
	.has-links.aside-open .container > aside {
		transform: none;
		visibility: visible;
		transition: transform 0.25s ease;
	}

	.has-drawer .nav-close {
		position: absolute;
		top: var(--space-2);
		right: var(--space-2);
		display: grid;
		place-items: center;
		width: var(--target);
		height: var(--target);
		border: 0;
		background: none;
		font-size: var(--text-xl);
		line-height: 1;
		color: var(--ink);
	}

	.has-drawer .nav-backdrop {
		position: fixed;
		inset: 0;
		z-index: var(--z-drawer-backdrop);
		display: block;
		background: rgba(0, 0, 0, 0.45);
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.25s ease;
	}

	.has-drawer.nav-open .nav-backdrop,
	.has-drawer.aside-open .nav-backdrop {
		opacity: 1;
		pointer-events: auto;
	}

	.has-drawer.nav-open,
	.has-drawer.aside-open {
		overflow: hidden;
	}

	/* Finger-sized targets in the drawers. 16px in the search box: smaller and iOS zooms in. */
	.container > nav li.folder > details > summary,
	.container > nav li.file a,
	.relations li a {
		min-height: var(--target);
		display: flex;
		align-items: center;
	}

	.top-bar .search input,
	.identity select {
		font-size: 16px;
	}
}

/* Who you are is in the frame's head; the filter drawers need not say it again. */
body.framed:not(.view-full) .graph-filters .identity,
body.framed:not(.view-full) .timeline-filters .identity {
	display: none;
}

/* ---- The frame: graph, map and timeline in the page's columns ----------------------- */
/* The same head over them, the same three columns under it. Fullscreen (body.view-full) takes it away. */

.frame-head {
	display: flex;
	flex-direction: column;
}

body.view-full .frame-head {
	display: none;
}

body.graph-page.framed:not(.view-full) {
	display: flex;
	flex-direction: column;
}

body.graph-page.framed:not(.view-full) .frame-head {
	flex: none;
}

body.graph-page.framed:not(.view-full) .graph-app {
	flex: 1 1 auto;
	min-height: 0;
}

.frame-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	min-height: calc(var(--control-h) - var(--space-2));
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	background: none;
	color: inherit;
	font-size: var(--text-sm);
}

.frame-toggle .frame-close,
body.view-full .frame-toggle .frame-open {
	display: none;
}

body.view-full .frame-toggle .frame-close {
	display: inline;
}

@media (min-width: 769px) and (pointer: fine) and (orientation: landscape) {
	body.framed:not(.view-full) {
		--frame-h: max(28rem, calc(100dvh - 12.5rem));
	}

	body.graph-page.framed:not(.view-full) {
		height: auto;
		overflow: visible;
	}

	body.framed:not(.view-full) .graph-app {
		display: grid;
		grid-template-columns: minmax(0, var(--nav-col)) minmax(0, 1fr) minmax(0, var(--aside-col));
		grid-template-rows: auto var(--frame-h);
		grid-template-areas:
			"nav bar aside"
			"nav stage aside";
		column-gap: var(--col-gap);
		width: 100%;
		max-width: var(--page-max);
		height: auto;
		margin: 0 auto;
		padding: var(--space-4) var(--gutter) var(--space-6);
	}

	body.framed:not(.view-full) .graph-body {
		display: contents;
	}

	body.framed:not(.view-full) .graph-app .mobile-bar {
		display: none;
	}

	body.framed:not(.view-full) .graph-bar {
		grid-area: bar;
		position: static;
		padding: 0 0 var(--space-3);
		border: 0;
		background: transparent;
	}

	body.framed:not(.view-full) .graph-bar .graph-back,
	body.framed:not(.view-full) .graph-bar .graph-name,
	body.framed:not(.view-full) .graph-bar .world-views {
		display: none;
	}

	body.framed:not(.view-full) .graph-app .graph-filters {
		grid-area: nav;
		height: calc(var(--frame-h) + var(--space-6));
		padding: 0 var(--space-1) var(--space-4) 0;
		overflow-y: auto;
	}

	body.framed:not(.view-full) .graph-app .graph-stage {
		grid-area: stage;
		border: var(--rule);
		border-radius: var(--radius);
	}

	body.framed:not(.view-full) .graph-app .graph-panel,
	body.framed:not(.view-full) .graph-app .graph-place {
		grid-area: aside;
		width: auto;
		height: calc(var(--frame-h) + var(--space-6));
		padding: 0 0 var(--space-4);
		overflow-y: auto;
	}

	body.framed:not(.view-full) .graph-filters .identity,
	body.framed:not(.view-full) .timeline-filters .identity {
		display: none;
	}

	body.framed:not(.view-full) .timeline-app {
		display: grid;
		grid-template-columns: minmax(0, var(--nav-col)) minmax(0, 1fr);
		grid-template-areas:
			"nav bar"
			"nav body";
		column-gap: var(--col-gap);
		align-items: start;
		width: 100%;
		max-width: var(--page-max);
		margin: 0 auto;
		padding: var(--space-4) var(--gutter) var(--space-8);
	}

	body.framed:not(.view-full) .timeline-main {
		display: contents;
	}

	body.framed:not(.view-full) .timeline-filters {
		grid-area: nav;
		margin-top: 0;
	}

	body.framed:not(.view-full) .timeline-body {
		grid-area: body;
	}

	body.framed:not(.view-full) .timeline-bar {
		grid-area: bar;
		margin: 0 calc(var(--aside-col) + var(--col-gap)) 0 0;
		padding: var(--space-1) 0;
		border-bottom: 0;
		background: transparent;
		backdrop-filter: none;
	}

	body.framed:not(.view-full) .timeline-bar .timeline-back,
	body.framed:not(.view-full) .timeline-bar .timeline-name,
	body.framed:not(.view-full) .timeline-bar .world-views,
	body.framed:not(.view-full) .timeline-bar .timeline-menu {
		display: none;
	}

	body.framed:not(.view-full) .timeline-body,
	body.framed:not(.view-full) .tl-in-columns .timeline-body {
		grid-template-columns: minmax(0, 1fr) minmax(0, var(--aside-col));
		gap: var(--col-gap);
		max-width: none;
	}
}

@media (min-width: 861px) {
	body.timeline-page.view-full .timeline-main {
		grid-template-columns: 260px minmax(0, 1fr);
		gap: var(--space-6);
	}

	body.timeline-page.view-full .timeline-body,
	body.timeline-page.view-full .tl-in-columns .timeline-body {
		grid-template-columns: minmax(0, 1fr) 260px;
		gap: var(--space-6);
		max-width: none;
	}

	body.timeline-page.view-full .timeline-lines {
		width: 100%;
		max-width: 1100px;
		justify-self: center;
	}
}

/* ---- Option panels: the graph's and the timeline's filters ------------------------ */
/* .opts the panel; .opts-sum the count and Reset; section > h3 a group; .chips on/off buttons;
   .seg one of a few; .opts-row controls side by side; details more, folded; .hint quiet help. */

.opts {
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
	font-size: var(--text-sm);
}

.opts section {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.opts h3 {
	font-size: var(--text-xs);
	font-weight: 600;
	letter-spacing: var(--tracking-caps);
	text-transform: uppercase;
	color: var(--ink-muted);
}

.opts-sum {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2);
}

.opts-sum button,
.opts-row button {
	min-height: calc(var(--control-h) - var(--space-3));
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	background: none;
	font-size: var(--text-xs);
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1);
	margin: 0;
	padding: 0;
	list-style: none;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	min-height: calc(var(--control-h) - var(--space-2));
	padding: 0 var(--space-2);
	border: var(--rule);
	border-radius: var(--radius);
	background: none;
	font-size: var(--text-sm);
	transition: border-color var(--ease), background var(--ease), opacity var(--ease);
}

.chip[aria-pressed="true"] {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.chip[aria-pressed="false"] {
	opacity: 0.5;
}

.chip small,
.chip sup {
	font-size: var(--text-xs);
	color: var(--ink-muted);
}

.seg {
	display: inline-flex;
	flex-wrap: wrap;
	width: fit-content;
	border: var(--rule);
	border-radius: var(--radius);
	overflow: hidden;
}

.seg button {
	min-height: calc(var(--control-h) - var(--space-2));
	padding: 0 var(--space-3);
	border: 0;
	background: none;
	font-size: var(--text-sm);
}

.seg button[aria-pressed="true"] {
	background: var(--accent-soft);
	color: var(--accent-ink);
}

.opts-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2);
}

.opts-row input[type="range"] {
	flex: 1;
	min-width: 0;
}

.opts label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
}

.opts input[type="checkbox"] {
	appearance: none;
	position: relative;
	flex: none;
	width: 2.1rem;
	height: 1.2rem;
	margin: 0;
	border-radius: 1rem;
	background: var(--surface-open);
	cursor: pointer;
	transition: background var(--ease);
}

.opts input[type="checkbox"]::before {
	content: "";
	position: absolute;
	top: 0.15rem;
	left: 0.15rem;
	width: 0.9rem;
	height: 0.9rem;
	border-radius: var(--radius-round);
	background: var(--paper);
	transition: transform var(--ease);
}

.opts input[type="checkbox"]:checked {
	background: var(--accent);
}

.opts input[type="checkbox"]:checked::before {
	transform: translateX(0.9rem);
}

.opts details {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.opts summary {
	font-size: var(--text-sm);
	color: var(--ink-muted);
}

.opts .hint {
	font-size: var(--text-xs);
	color: var(--ink-muted);
}

.opts ul.hint {
	padding-left: var(--space-4);
}

/* ---- Print ------------------------------------------------------------------------ */

@media print {
	.platform-bar,
	.top-bar,
	.world-bar,
	.mobile-bar,
	.edit-fab,
	.container > nav,
	.container > aside,
	footer {
		display: none;
	}

	.container {
		display: block;
	}
}
