/* Command dialogs share one stationary frame. Only the content body scrolls,
   leaving the header, action footer and all four border edges visible. */
body.dashboard-app :is(.card-view-overlay, .popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) {
	background: transparent;
}
/* Blur a sibling paint layer, keeping mobile fixed bars anchored to the viewport. */
body.dashboard-app :is(.card-view-overlay, .popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay)::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	background: rgba(0, 0, 0, .8);
	-webkit-backdrop-filter: blur(20px) saturate(180%);
	backdrop-filter: blur(20px) saturate(180%);
	pointer-events: none;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-scroll {
	box-sizing: border-box;
	padding: 10px;
	overflow: hidden;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-content {
	display: flex;
	flex-direction: column;
	min-height: 0;
	max-height: 100%;
	height: auto;
	margin: 0;
	border: 1px solid var(--command-border, #252729);
	border-radius: 12px;
	background: #000;
	overflow: hidden;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-header {
	position: relative;
	flex: 0 0 calc(var(--detail-header-content-height) + 1px);
	height: calc(var(--detail-header-content-height) + 1px);
	padding: 0;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-top {
	float: none;
	height: calc(var(--detail-header-content-height) + 1px);
	border: 0;
	border-bottom: 1px solid var(--command-border, #252729);
	border-radius: 11px 11px 0 0;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-card {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	float: none;
	min-height: 0;
	margin: 0;
	border: 0;
	overflow: hidden;
	box-shadow: none;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) :is(.popup-body, .create-offer-body),
body.dashboard-app .command-search-overlay #searchResults {
	flex: 1 1 auto;
	float: none;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}
body.dashboard-app :is(.popup-overlay, .command-search-overlay, .pm-compose-overlay, .command-error-overlay) .popup-footer {
	flex: 0 0 auto;
	float: none;
}
/* The composer has a form between its card shell and body/footer. */
body.dashboard-app .pm-compose-overlay .pm-modal-form {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}
/* The full-width message viewport scrolls while the route and character count
   stay anchored over its bottom inset. The outer popup can scroll on short screens. */
body.dashboard-app .pm-compose-overlay .popup-scroll { overflow-y: auto; }
body.dashboard-app .pm-compose-overlay .pm-modal-form .popup-body { flex: 0 0 auto; overflow: visible; }

/* Linkers use the same inset frame and one content scroller. Collection search
   stays below the header while candidate groups scroll together. */
body.dashboard-app .planet-picker-popup .popup-title { padding-left: 10px; }
body.dashboard-app .planet-picker-popup .popup-body { padding: 10px; }
body.dashboard-app .planet-picker-popup .create-offer-selectable-items {
	float: none;
	max-height: none;
	margin: 0;
	overflow: visible;
}
/* Resource linkers have no collection headers: their rows meet the header and
   frame directly, retaining only the separators between candidates. */
body.dashboard-app .planet-picker-popup .popup-body:has(> .create-offer-selectable-items) { padding-top: 0; padding-bottom: 0; }
body.dashboard-app .planet-picker-popup .popup-body > .create-offer-selectable-items { border: 0; }
body.dashboard-app .planet-picker-popup .popup-body > .create-offer-selectable-items > .create-offer-empty { padding: 20px 0; }
body.dashboard-app .planet-picker-popup .card-box + .card-box { margin-top: 10px; }
body.dashboard-app .planet-picker-progress {
	display: flex;
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
}
body.dashboard-app .planet-picker-progress .planet-game-count {
	position: static;
	flex: 0 0 40px;
	width: 40px;
	max-width: none;
	height: 40px;
	margin: 0;
}
body.dashboard-app .planet-picker-search {
	flex: 0 0 auto;
	min-width: 0;
	margin: 0;
	padding: 10px;
	border-bottom: 1px solid var(--command-border, #252729);
}
body.dashboard-app .planet-picker-search .search-menu {
	width: 100%;
	max-width: none;
	margin: 0;
	background: rgba(0, 0, 0, .9);
}
body.dashboard-app .planet-picker-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
body.dashboard-app .planet-picker-search .search-close {
	font: inherit;
	border: 0;
	background: transparent;
}

/* Linked Civilizations are browsable without entering the owner-only linker. */
body.dashboard-app .planet-civilization-popup .popup-content {
	width: min(1120px, 100%);
	max-width: 100%;
	margin-bottom: 0;
}
body.dashboard-app .planet-civilization-popup .popup-title { padding-left: 20px; }
body.dashboard-app .planet-civilization-popup-identity {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}
body.dashboard-app .planet-civilization-popup-logo {
	display: block;
	flex: 0 0 40px;
	box-sizing: border-box;
	width: 40px;
	height: 40px;
	border: 1px solid var(--command-border, #262626);
	border-radius: 50%;
	background: #000;
	overflow: hidden;
}
body.dashboard-app .planet-civilization-popup-logo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
body.dashboard-app .planet-civilization-popup .popup-body { padding: 20px; }
body.dashboard-app .planet-civilization-popup-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
	grid-auto-rows: 1fr;
	gap: 10px;
	justify-items: stretch;
}
body.dashboard-app .planet-civilization-popup-grid > .planet-civilization-card {
	position: relative;
	width: 100%;
	max-width: 300px;
	overflow: visible;
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-image {
	border-radius: 11px 11px 0 0;
}
body.dashboard-app .planet-civilization-popup-grid > .planet-civilization-add {
	aspect-ratio: auto;
}
body.dashboard-app .planet-civilization-popup-grid > .planet-civilization-add:only-child {
	aspect-ratio: 4 / 5;
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-remove {
	position: absolute;
	top: -5px;
	right: -5px;
	z-index: 1;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--command-grey, #727578);
	font: inherit;
	font-size: 12px;
	line-height: 1;
	cursor: pointer;
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-remove-face {
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 24px;
	height: 24px;
	border: 1px solid var(--command-border, #262626);
	border-radius: 50%;
	background: rgba(0, 0, 0, .8);
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-remove-face i {
	color: #dd0002;
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-remove:focus-visible .planet-civilization-remove-face {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}
body.dashboard-app .planet-civilization-popup-grid .planet-civilization-remove:disabled {
	cursor: default;
	opacity: .5;
}
@media (max-width: 800px) {
	body.dashboard-app .planet-civilization-popup .popup-body { padding: 10px; }
	body.dashboard-app .planet-civilization-popup .popup-title { padding-left: 10px; }
	/* Keep three card slots even when a collection contains only one civilian. */
	body.dashboard-app .planet-civilization-popup-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		justify-items: stretch;
	}
}

/* Item previews opened from a picker use the legacy card markup, with no
   dashboard scrolling wrapper. Their body still scrolls inside the frame. */
body.dashboard-app .card-view-overlay:not(.dashboard-card-overlay) .card-view-scroll {
	padding: 10px;
	overflow: hidden;
}
body.dashboard-app .card-view-overlay:not(.dashboard-card-overlay) .card-view-content {
	display: flex;
	flex-direction: column;
	height: auto;
	min-height: 0;
	max-height: 100%;
	border: 1px solid var(--command-border, #252729);
	border-radius: 12px;
	background: #000;
	overflow: hidden;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .75);
}
body.dashboard-app .card-view-overlay:not(.dashboard-card-overlay) .card-view-header {
	position: relative;
	flex: 0 0 calc(var(--detail-header-content-height) + 1px);
	height: calc(var(--detail-header-content-height) + 1px);
	padding: 0;
}
body.dashboard-app .card-view-overlay:not(.dashboard-card-overlay) .card-view-top {
	float: none;
	height: calc(var(--detail-header-content-height) + 1px);
	border: 0;
	border-bottom: 1px solid var(--command-border, #252729);
	border-radius: 11px 11px 0 0;
}
body.dashboard-app .card-view-overlay:not(.dashboard-card-overlay) .card-view {
	flex: 1 1 auto;
	float: none;
	min-height: 0;
	margin: 0;
	border: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	box-shadow: none;
}

/* Picker footer: a slider that links the next eligible items (Marketplace multi-select
   slider sizes: 4px track, 32px thumb) in Command colours. It sits under the scrolling list. */
body.dashboard-app .planet-picker-popup .planet-picker-footer {
	flex: 0 0 auto;
	box-sizing: border-box;
	padding: 10px;
	border-top: 1px solid var(--command-border, #252729);
	background: #000;
}
body.dashboard-app .planet-picker-slider {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	height: 4px;
	margin: 14px 0;
	border-radius: 9999px;
	/* The fill ends under the thumb's centre: the 32px thumb travels 100% - 32px. */
	--fill-stop: calc(16px + (100% - 32px) * var(--fill-ratio, 0));
	background: linear-gradient(to right, #3a8a50 var(--fill-stop), var(--command-border, #252729) var(--fill-stop));
	outline: none;
	cursor: pointer;
}
body.dashboard-app .planet-picker-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--command-action-background, #5acc77);
	cursor: pointer;
	box-shadow: 0 2px 5px rgba(0, 0, 0, .75);
}
body.dashboard-app .planet-picker-slider::-moz-range-thumb {
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: var(--command-action-background, #5acc77);
	cursor: pointer;
	box-shadow: 0 2px 5px rgba(0, 0, 0, .75);
}
body.dashboard-app .planet-picker-slider::-moz-range-track { height: 4px; border-radius: 9999px; background: var(--command-border, #252729); }
body.dashboard-app .planet-picker-slider::-moz-range-progress { height: 4px; border-radius: 9999px; background: #3a8a50; }
body.dashboard-app .planet-picker-slider.slider-disabled { opacity: .4; pointer-events: none; }

/* ---------- Clear buttons (Font Awesome sharp-light delete-left, drawn inline) ---------- */
body.dashboard-app .command-clear-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; font-size: 0; line-height: 0; }
body.dashboard-app .command-clear-icon::before { display: none; }
body.dashboard-app .command-clear-icon svg { display: block; width: 20px; height: 20px; }
/* In a search input the clear button sits inside it, its icon 10px from the input's right side. */
body.dashboard-app .search-menu .search-close:not(.hidden):not([hidden]) {
	display: flex; align-items: center; justify-content: center; flex: none;
	box-sizing: border-box; height: 100%; margin: 0; padding: 0 10px;
	border: 0; background: transparent; color: var(--command-grey, #727578); font: inherit; cursor: pointer;
}
body.dashboard-app .search-menu .search-close[hidden] { display: none; }
/* The main search: a clear button between the input and the close button — the close button's
   height, 10px inside on both sides, 10px from the close button, no border. */
body.dashboard-app .command-search-overlay .command-search-clear {
	display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
	box-sizing: border-box; height: 40px; margin: 0; padding: 0 10px;
	border: 0; border-radius: 0; background: transparent; color: var(--command-grey, #727578); cursor: pointer; touch-action: manipulation;
}
body.dashboard-app .command-search-overlay .command-search-clear[hidden] { display: none; }

/* ---------- Add Civilizations: collection cards, then one collection ---------- */
body.dashboard-app .planet-picker-popup .planet-picker-collection-grid {
	grid-template-columns: repeat(3, minmax(0, 1fr));
	padding: 0;
}
body.dashboard-app .planet-picker-popup .planet-picker-collection-grid > .planet-civilization-card { max-width: none; }
body.dashboard-app .planet-picker-popup .planet-picker-collection-grid .planet-civilization-image { border-radius: 11px 11px 0 0; }
/* Step 2's bar is one button back to the collection cards: a chevron 10px in, 10px to the
   collection's logo (a Planet-avatar style 40px circle), then its name and your count. */
body.dashboard-app .planet-picker-search[data-picker-step="collection"] { padding: 0; }
/* The bar row: the back button (chevron, logo, name) on the left, the sort dropdown on the right. */
body.dashboard-app .planet-picker-search[data-picker-step="collection"] { position: relative; z-index: 3; }
body.dashboard-app .planet-picker-collection-row { display: flex; align-items: center; gap: 10px; box-sizing: border-box; min-height: 60px; padding: 10px 10px 10px 0; }
body.dashboard-app .planet-picker-collection-bar {
	display: flex; align-items: center; gap: 10px; flex: 1 1 auto; width: auto; min-width: 0; box-sizing: border-box; height: 40px; margin: 0; padding: 0 10px;
	border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
	animation: cmd-fade-in var(--cmd-fade, 280ms) ease-out both;
}
body.dashboard-app .planet-picker-collection-chevron { display: block; flex: 0 0 auto; width: 16px; height: 16px; color: var(--command-grey, #727578); transition: color .2s, transform .2s var(--cmd-ease); }
@media (hover: hover) {
	body.dashboard-app .planet-picker-collection-bar:hover .planet-picker-collection-chevron { color: #fff; transform: translateX(-2px); }
}
body.dashboard-app .planet-picker-collection-logo {
	display: block; flex: 0 0 40px; box-sizing: border-box; width: 40px; height: 40px;
	border: 1px solid var(--command-border, #262626); border-radius: 50%; background: #000; overflow: hidden;
}
body.dashboard-app .planet-picker-collection-logo img { display: block; width: 100%; height: 100%; object-fit: cover; }
body.dashboard-app .planet-picker-collection-text { display: flex; flex: 1 1 auto; flex-direction: column; justify-content: center; min-width: 0; }
body.dashboard-app .planet-picker-collection-name { color: #ededed; font-size: var(--font-md); line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.dashboard-app .planet-picker-collection-count { color: var(--command-grey, #727578); font-size: var(--font-sm); line-height: 16px; }
/* Each step enters like the rest of Command; cards and rows that arrive later fade in. */
/* One fade per thing: a step's rows fade in as a block; the collection grid itself does not
   fade (its cards do, one animation each — a grid fade on top multiplied into a double fade). */
body.dashboard-app .planet-picker-step:not(.planet-picker-collection-grid) { animation: cmd-fade-in var(--cmd-fade, 280ms) ease-out both; }
/* Cards don't animate on their own: the step fades in once, and a card that replaces its
   skeleton later fades in by itself (new node inside an existing grid). */
body.dashboard-app .planet-picker-collection-grid > .planet-civilization-card:not(.command-civilization-skeleton-card) { animation: cmd-fade-in var(--cmd-fade, 280ms) ease-out both; }
/* The slider bar arrives with a collection's rows instead of popping in. */
body.dashboard-app .planet-picker-popup .planet-picker-footer { animation: cmd-fade-in var(--cmd-fade, 280ms) ease-out both; }

/* Search results that appear later fade in; results already shown stay as they are. */
body.dashboard-app .command-search-overlay .search-result-enter { animation: cmd-fade-in 220ms ease-out both; }

/* Picker: green = saved, darker green = selected but still being confirmed (ring and checks). */
body.dashboard-app .planet-picker-progress .planet-game-count-ring::before {
	background: conic-gradient(#5acc77 var(--linked-progress, 0%), #2f7a45 var(--linked-progress, 0%) var(--linked-pending, var(--linked-progress, 0%)), var(--linked-track, #262626) 0);
}
body.dashboard-app .planet-picker-popup .create-offer-selectable-item.selected.pending .create-offer-selectable-check i { color: #2f7a45; }
body.dashboard-app .planet-picker-popup .planet-picker-pending {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	margin-left: auto;
}
/* command-cards.css turns .loader into a 48x12 skeleton bar; this one is a round 14px spinner. */
body.dashboard-app .planet-picker-popup .planet-picker-pending .loader {
	display: block;
	flex: 0 0 14px;
	box-sizing: border-box;
	width: 14px;
	height: 14px;
	aspect-ratio: 1 / 1;
	border: 0;
	border-radius: 50%;
	transform: none;
	margin: 0;
	background: conic-gradient(#0000 30%, var(--command-grey, #727578));
	animation: spin 1.5s linear infinite, fadeIn .3s ease-out;
}

/* Civilizations: the homepage sort dropdown, sized for the picker bar. */
body.dashboard-app .planet-picker-sort { position: relative; flex: none; animation: cmd-fade-in var(--cmd-fade, 280ms) ease-out both; }
body.dashboard-app .planet-picker-sort .sort-button { float: none; box-sizing: border-box; height: 40px; padding: 0 12px; white-space: nowrap; }
/* The menu's top border lands on the bar's bottom border (the bar has 10px under the button). */
body.dashboard-app .planet-picker-sort .sort-options { top: calc(100% + 10px); right: 0; }
/* Facilities and Relics: the sort sits in the header row, right before the progress circle. */
body.dashboard-app .planet-picker-popup .popup-top > .popup-title { flex: 1 1 auto; min-width: 0; }
body.dashboard-app .planet-picker-popup .popup-top > .planet-picker-sort-header { margin-left: auto; }
/* An open sort menu (5 rows, ~200px) must fit inside the popup: its rounded card keeps clipping, so a
   short list gets room for the menu instead (letting it overflow broke the card's corners). */
body.dashboard-app .planet-picker-popup .popup-content:has(.planet-picker-sort .sort-options:not(.hidden)) .popup-body { min-height: 210px; }

/* A row linked to another Planet: that Planet in an owner-badge style pill (25px, rounded, grey
   border) with a small ✕ 10px from the name and from the right edge. Tapping it removes the link
   there, after which the row is free to add here. */
body.dashboard-app .planet-picker-linked-badge {
	display: inline-flex; flex: 0 1 auto; align-items: center; gap: 10px; box-sizing: border-box; min-width: 0; max-width: 55%;
	height: 25px; margin: 0 0 0 auto; padding: 0 10px; border: 1px solid var(--command-border, #262626); border-radius: 9999px;
	background: #000; color: var(--command-grey, #727578); font: inherit; font-size: var(--font-sm); line-height: 23px;
	cursor: pointer; -webkit-tap-highlight-color: transparent;
}
body.dashboard-app .planet-picker-linked-badge.is-static { cursor: default; }
body.dashboard-app .planet-picker-linked-badge .planet-picker-linked-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.dashboard-app .planet-picker-linked-badge i { flex: none; font-size: 11px; line-height: 1; }
@media (hover: hover) { body.dashboard-app .planet-picker-linked-badge:not(.is-static):hover { border-color: #ededed; color: #ededed; } }
body.dashboard-app .planet-picker-linked-badge:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* Share (Intel group): Command's popup with the Intel rows. */
body.dashboard-app .planet-share-popup .popup-content { width: min(420px, 100%); }
body.dashboard-app .planet-share-popup .popup-title { display: flex; align-items: center; min-width: 0; padding-left: 10px; }
body.dashboard-app .planet-share-title-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
body.dashboard-app .planet-share-title-icon {
	display: flex;
	flex: 0 0 40px;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 40px;
	height: 40px;
	border: 1px solid var(--command-border, #262626);
	border-radius: 50%;
	background: #000;
	color: var(--command-grey, #727578);
	font-size: 16px;
}
body.dashboard-app .planet-share-popup .popup-body { padding: 10px; }
body.dashboard-app .planet-share-rows .planet-details-row.is-ready > span:first-child,
body.dashboard-app .planet-share-rows .planet-details-row.is-ready > i { color: #ededed; }
body.dashboard-app .planet-share-rows .planet-details-row.is-busy { cursor: progress; }
body.dashboard-app .planet-share-rows .planet-details-row.is-busy > i { animation: planet-share-busy 1.2s ease-in-out infinite; }
@keyframes planet-share-busy { 50% { opacity: .25; } }
