/* Dendra — sistema visual ao estilo iOS.
   As cores da tela vêm do tema do mapa (variáveis definidas em runtime);
   o resto da interface usa a paleta escura do sistema. */

:root {
	color-scheme: light dark;
	--ios-bg: #f4f5f7;
	--ios-panel: #ffffff;
	--ios-panel-2: #eceef2;
	--ios-separator: #d8dce3;
	--ios-label: #202329;
	--ios-secondary: #626975;
	--ios-blue: #006d77;
	--ios-red: #bc303a;
	--ios-green: #24764d;
	--chrome: #ffffffed;
	--control-fill: #2023290a;
	--radius-row: 8px;
	--radius-card: 8px;
	--radius-sheet: 24px;

	/* Substituídas pelo tema do mapa. */
	--bg: #11151c;
	--grid: #1b212c;
	--surface: #171c25;
	--text: #e8ecf3;
}

* {
	box-sizing: border-box;
}

/* ---------- páginas de texto (termos, privacidade) ---------- */

body.page {
	display: block;
	height: auto;
	padding: 24px 18px 60px;
	background: var(--ios-bg);
	color: var(--ios-label);
	font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.paper {
	max-width: 640px;
	margin: 0 auto;
}

.paper h1 {
	font-size: 26px;
}

.paper h2 {
	margin-top: 28px;
	font-size: 18px;
}

.paper a {
	color: var(--ios-blue);
}

.paper table {
	width: 100%;
	margin: 14px 0;
	border-collapse: collapse;
	font-size: 15px;
}

.paper th,
.paper td {
	padding: 7px 10px 7px 0;
	border-bottom: 0.5px solid var(--ios-separator);
	text-align: left;
	vertical-align: top;
}

.paper kbd {
	padding: 1px 6px;
	border: 0.5px solid var(--ios-separator);
	border-radius: 5px;
	font: inherit;
	font-size: 14px;
	white-space: nowrap;
}

html,
body {
	height: 100%;
	margin: 0;
	overscroll-behavior: none;
	-webkit-text-size-adjust: 100%;
}

body {
	display: flex;
	flex-direction: column;
	background: var(--bg);
	color: var(--ios-label);
	font: 15px/1.5 'Manrope', sans-serif;
	overflow: hidden;
}

button {
	font: inherit;
	color: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

input,
select,
textarea {
	font: inherit;
	color: var(--ios-label);
}

/* ---------- barra de navegação ---------- */

.navbar {
	display: grid;
	grid-template-columns: auto auto minmax(100px, 1fr) auto;
	align-items: center;
	gap: 12px;
	padding: max(12px, env(safe-area-inset-top)) 16px 12px;
	border-bottom: 0.5px solid var(--ios-separator);
	background: var(--chrome);
	backdrop-filter: blur(24px);
}

.nav-action {
	flex: 0 0 auto;
	min-width: 44px;
	min-height: 44px;
	padding: 6px 10px;
	border: none;
	border-radius: 10px;
	background: none;
	color: var(--ios-blue);
	font-size: 16px;
}

.nav-action:active {
	background: #ffffff1a;
}

.navbar #btn-maps {
	grid-column: 1;
	grid-row: 1;
}

.recent-maps {
	display: flex;
	grid-column: 2;
	grid-row: 1;
	min-width: 0;
	gap: 4px;
}

.recent-maps[hidden] {
	display: none;
}

.recent-map {
	width: clamp(72px, 10vw, 112px);
	min-width: 0;
	height: 34px;
	padding: 6px 10px;
	overflow: hidden;
	border: 1px solid transparent;
	border-radius: 8px;
	background: var(--control-fill);
	color: var(--ios-secondary);
	font-size: 13px;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.recent-map:active {
	background: #ffffff1a;
}

.recent-map[aria-current="page"] {
	border-color: #0a84ff66;
	background: #0a84ff1f;
	color: var(--ios-blue);
}

.nav-title {
	grid-column: 3;
	grid-row: 1;
	flex: 1;
	min-width: 0;
	padding: 7px 10px;
	border: none;
	border-radius: 10px;
	background: none;
	font-size: 17px;
	font-weight: 600;
	text-align: center;
	text-overflow: ellipsis;
}

.nav-title:focus {
	background: var(--ios-panel-2);
	outline: none;
	text-align: left;
}

.navbar #btn-more {
	grid-column: 4;
	grid-row: 1;
}

@media (max-width: 620px) {
	.navbar {
		grid-template-columns: auto minmax(0, 1fr) auto;
		gap: 8px;
		padding-inline: max(12px, env(safe-area-inset-left))
			max(12px, env(safe-area-inset-right));
	}

	.navbar #btn-maps {
		min-width: 52px;
		padding-inline: 7px;
	}

	.navbar #btn-more {
		grid-column: 3;
		min-width: 44px;
		padding-inline: 5px;
	}

	.recent-maps {
		display: none;
	}

	.recent-map {
		width: auto;
		flex: 1 1 0;
		padding-inline: 7px;
		font-size: 12px;
	}

	.nav-title {
		grid-column: 2;
		grid-row: 1;
		min-height: 44px;
		padding-block: 8px;
		font-size: 17px;
	}
}

/* ---------- tela ---------- */

.viewport {
	position: relative;
	flex: 1;
	overflow: hidden;
	cursor: grab;
	touch-action: none;
	outline: none;
	background-color: var(--bg);
	background-image: radial-gradient(circle, var(--grid) 1px, transparent 1px);
	background-size: 24px 24px;
}

.viewport.panning {
	cursor: grabbing;
}

.world {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: 0 0;
}

.edges {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: visible;
	pointer-events: none;
}

.nodes {
	position: absolute;
	top: 0;
	left: 0;
}

/* ---------- stickies ---------- */

.stickies {
	position: absolute;
	top: 0;
	left: 0;
}

.sticky {
	position: absolute;
	display: flex;
	flex-direction: column;
	gap: 6px;
	width: 190px;
	height: 150px;
	padding: 10px 12px;
	border-radius: 4px;
	color: #1c1a12;
	font-size: 14px;
	line-height: 19px;
	cursor: grab;
	overflow-wrap: anywhere;
	-webkit-touch-callout: none;
	box-shadow: 0 6px 18px #00000073;
	transform: rotate(-1deg);
}

.sticky.dragging {
	opacity: 0.85;
	cursor: grabbing;
}

.sticky-text {
	flex: 1;
	overflow: hidden;
	white-space: pre-wrap;
	user-select: none;
	-webkit-user-select: none;
}

/* O WebKit só deixa escrever se o próprio elemento repuser a seleção com prefixo. */
.sticky-text.editing {
	overflow: auto;
	cursor: text;
	user-select: text;
	-webkit-user-select: text;
	-webkit-touch-callout: default;
	touch-action: auto;
	outline: none;
}

.sticky-who {
	font-size: 11px;
	opacity: 0.7;
}

.sticky-close {
	position: absolute;
	top: -8px;
	right: -8px;
	display: none;
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #1c1a12;
	color: #fff;
	font-size: 13px;
	line-height: 24px;
}

.sticky:hover>.sticky-close {
	display: block;
}

/* ---------- nós ---------- */

.node {
	position: absolute;
	display: flex;
	align-items: center;
	gap: 6px;
	width: max-content;
	min-width: 110px;
	max-width: 260px;
	min-height: 38px;
	padding: 9px 14px;
	border: 2px solid transparent;
	border-radius: 12px;
	background: var(--node-color, #2c3a52);
	color: #fff;
	font-weight: 500;
	line-height: 20px;
	overflow-wrap: anywhere;
	cursor: grab;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	box-shadow: 0 2px 10px #00000059;
}

.node.root {
	font-weight: 600;
	font-size: 15px;
	border-radius: 16px;
}

.node.selected {
	border-color: #fff;
	z-index: 3;
}

.node.dragging {
	opacity: 0.75;
	cursor: grabbing;
}

.node.drop-target {
	border-color: var(--ios-blue);
	box-shadow: 0 0 0 4px #0a84ff55;
}

/* Com imagem o nó passa a duas linhas: a imagem em cima, o texto por baixo. */
.node.has-image {
	flex-wrap: wrap;
	justify-content: center;
	max-width: 280px;
}

.node-media {
	flex: 0 0 100%;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
}

.node-media img {
	max-width: 100%;
	border-radius: 8px;
	background: #ffffff1f;
	object-fit: contain;
	cursor: zoom-in;
}

/* ---------- menu do clique direito ---------- */

.menu {
	position: fixed;
	z-index: 90;
	display: flex;
	flex-direction: column;
	min-width: 190px;
	padding: 6px;
	border: 0.5px solid #ffffff1f;
	border-radius: 12px;
	background: var(--chrome);
	backdrop-filter: blur(20px);
	box-shadow: 0 16px 40px #000000a6;
}

.menu[hidden] {
	display: none;
}

.menu-item {
	display: block;
	padding: 9px 10px;
	border: none;
	border-radius: 8px;
	background: none;
	color: var(--ios-label);
	font-size: 15px;
	text-align: left;
	white-space: nowrap;
}

.menu-item:hover,
.menu-item:active {
	background: #ffffff1f;
}

.menu-item.danger {
	color: var(--ios-red);
}

.menu-colors {
	display: flex;
	gap: 8px;
	padding: 8px 10px;
}

.menu-colors button {
	width: 22px;
	height: 22px;
	padding: 0;
	border: 1px solid #00000059;
	border-radius: 50%;
}

.lightbox {
	position: fixed;
	inset: 0;
	z-index: 80;	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px;
	background: #000000ee;
	cursor: zoom-out;
}

.lightbox[hidden] {
	display: none;
}

.lightbox img {
	max-width: 100%;
	max-height: 82vh;
	border-radius: 12px;
	object-fit: contain;
}

.lightbox-bar {
	display: flex;
	align-items: center;
	gap: 16px;
	color: var(--ios-secondary);
	font-size: 14px;
}

.lightbox-bar button {
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: #ffffff1f;
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.lightbox.single .lightbox-bar {
	display: none;
}

.lightbox-hint {
	margin: 0;
	color: var(--ios-secondary);
	font-size: 13px;
}

.node-label {
	flex: 1;
	display: -webkit-box;
	-webkit-line-clamp: 8;
	line-clamp: 8;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* O nó selecionado abre por cima dos vizinhos, sem mexer no arranjo do mapa.
   Não recebe cliques: o duplo clique e o arrasto têm de chegar ao nó. */
.node-full {
	position: absolute;
	left: -2px;
	top: -2px;
	z-index: 4;
	display: none;
	width: calc(100% + 4px);
	padding: 9px 14px;
	border: 2px solid #fff;
	border-radius: 12px;
	background: var(--node-color, #2c3a52);
	box-shadow: 0 10px 30px #000000b3;
	pointer-events: none;
}

.node.selected>.node-full {
	display: block;
}

.node.dragging>.node-full {
	display: none;
}

/* A editar mostra-se tudo; só a vista do mapa é que corta.
   O WebKit só deixa escrever se o próprio elemento repuser a seleção com prefixo. */
.node-label.editing {
	display: block;
	overflow: visible;
	-webkit-line-clamp: none;
	line-clamp: none;
	cursor: text;
	user-select: text;
	-webkit-user-select: text;
	-webkit-touch-callout: default;
	touch-action: auto;
	outline: none;
}

/* Nada de botões por cima do texto enquanto se escreve. */
.node.editing {
	z-index: 6;
	max-width: 420px;
	cursor: text;
	user-select: text;
	-webkit-user-select: text;
	box-shadow: 0 12px 34px #000000c4;
}

.node-badges {
	display: flex;
	gap: 3px;
	font-size: 11px;
}

.node-badges .badge {
	text-decoration: none;
	opacity: 0.85;
}

/* Etiqueta do prazo: a cor diz o que falta fazer antes de se ler a data. */
.node-badges .due {
	padding: 1px 6px;
	border-radius: 20px;
	background: #ffffff2e;
	color: #fff;
	font-weight: 600;
	opacity: 1;
	white-space: nowrap;
}

.node-badges .due.soon,
.node-badges .due.today {
	background: #ff9f0a;
	color: #1a1200;
}

.node-badges .due.late {
	background: var(--ios-red);
	color: #fff;
}

.node-toggle,
.node-add,
.node-check {
	position: absolute;
	display: grid;
	place-items: center;
	padding: 0;
	border-radius: 50%;
	line-height: 1;
}

.node-toggle {
	right: 8px;
	bottom: -11px;
	width: 22px;
	height: 22px;
	border: 1px solid var(--ios-separator);
	background: var(--ios-panel);
	color: var(--ios-label);
	font-size: 11px;
}

.node-add {
	right: -14px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	display: none;
	width: 26px;
	height: 26px;
	border: 2px solid var(--surface);
	background: var(--ios-blue);
	color: #fff;
	font-size: 17px;
	font-weight: 600;
}

.node-check {
	left: -14px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	display: none;
	width: 24px;
	height: 24px;
	border: 2px solid var(--surface);
	background: #ffffff2e;
	color: #fff;
	font-size: 13px;
}

.node:hover>.node-add,
.node.selected>.node-add,
.node:hover>.node-check,
.node.selected>.node-check {
	display: grid;
}

.node-check:hover {
	background: var(--ios-green);
	border-color: var(--ios-green);
}

.node-bar {
	position: absolute;
	bottom: calc(100% + 12px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 5;
	display: none;
	gap: 2px;
	padding: 5px;
	border-radius: 14px;
	background: #2c2c2eeb;
	backdrop-filter: saturate(180%) blur(20px);
	box-shadow: 0 8px 28px #000000a6;
	cursor: default;
}

.node.selected>.node-bar {
	display: flex;
}

.node-bar button {
	width: 34px;
	height: 34px;
	padding: 0;
	border: none;
	border-radius: 9px;
	background: none;
	font-size: 15px;
	line-height: 1;
}

.node-bar button:active {
	background: #ffffff26;
}

/* Depois de todas as regras que mostram estes elementos, para as vencer por ordem. */
.node.editing>.node-add,
.node.editing>.node-check,
.node.editing>.node-toggle,
.node.editing>.node-bar,
.node.editing>.node-badges,
.node.editing>.node-full {
	display: none;
}

.node-popover {
	position: absolute;
	top: calc(100% + 10px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 6;
	width: max-content;
	max-width: 270px;
	padding: 12px;
	border-radius: 16px;
	background: #2c2c2eeb;
	backdrop-filter: saturate(180%) blur(20px);
	box-shadow: 0 8px 28px #000000a6;
	cursor: default;
}

.popover-grid {
	display: grid;
	grid-template-columns: repeat(4, 30px);
	gap: 8px;
}

.popover-grid.icons {
	grid-template-columns: repeat(6, 30px);
}

.icon-option {
	width: 30px;
	height: 30px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 8px;
	background: none;
	font-size: 15px;
	line-height: 1;
}

.icon-option.active {
	border-color: var(--ios-blue);
}

.popover-form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 240px;
}

.popover-form input,
.popover-form textarea {
	padding: 9px 11px;
	border: none;
	border-radius: 10px;
	background: #00000059;
}

.popover-form textarea {
	min-height: 84px;
	resize: vertical;
}

.popover-form button {
	padding: 10px;
	border: none;
	border-radius: 10px;
	background: var(--ios-blue);
	color: #fff;
	font-weight: 600;
}

.popover-form button.ghost {
	background: #ffffff1f;
	color: var(--ios-label);
}

.popover-form .due-note {
	padding: 0;
}

.swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.image-box {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
}

/* ---------- notas assinadas ---------- */

.notes {
	display: flex;
	flex-direction: column;
}

.notes .empty {
	margin: 0;
	padding: 0 14px 10px;
	color: var(--ios-secondary);
	font-size: 13px;
}

.note-item {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 10px 14px;
	border-top: 0.5px solid var(--ios-separator);
	font-size: 15px;
}

.note-item .body {
	flex: 1;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.note-item .who {
	display: block;
	margin-top: 3px;
	color: var(--ios-secondary);
	font-size: 12px;
}

.note-item button {
	min-height: 30px;
	padding: 4px 10px;
	border: none;
	border-radius: 8px;
	background: #ffffff14;
	color: var(--ios-red);
	font-size: 13px;
}

.due-note {
	margin: 0;
	padding: 0 14px 12px;
	color: var(--ios-secondary);
	font-size: 13px;
}

.due-note.soon,
.due-note.today {
	color: #ff9f0a;
}

.due-note.late {
	color: var(--ios-red);
}

.list .tag.soon,
.list .tag.today {
	background: #ff9f0a;
	color: #1a1200;
}

.list .tag.late {
	background: var(--ios-red);
	color: #fff;
}

.image-box img {
	max-width: 100%;
	max-height: 180px;
	border-radius: 10px;
	background: #00000047;
	cursor: zoom-in;
}

.image-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.image-cell {
	position: relative;
}

.image-cell img {
	max-height: 120px;
	display: block;
}

.image-remove {
	position: absolute;
	top: -6px;
	right: -6px;
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--ios-red);
	color: #fff;
	font-size: 13px;
	line-height: 24px;
}

.image-box p {
	margin: 0;
	color: var(--ios-secondary);
	font-size: 13px;
}

.swatch {
	width: 30px;
	height: 30px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 50%;
	color: #fff;
	font-size: 11px;
}

.swatch.active {
	border-color: #fff;
}

.drop-line {
	position: absolute;
	z-index: 4;
	border-radius: 3px;
	background: var(--ios-blue);
	box-shadow: 0 0 0 4px #0a84ff40;
	pointer-events: none;
}

/* Sinal de "insere aqui" no meio da marca, para se ver de longe. */
.drop-line::after {
	content: "+";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border-radius: 50%;
	background: var(--ios-blue);
	color: #fff;
	font-size: 20px;
	font-weight: 700;
	line-height: 28px;
	text-align: center;
	box-shadow: 0 2px 12px #000000a6;
	animation: drop-pulse 1s ease-in-out infinite;
}

@keyframes drop-pulse {

	0%,
	100% {
		transform: scale(1);
	}

	50% {
		transform: scale(1.15);
	}
}

.drop-line[hidden] {
	display: none;
}

.drop-line.round {
	border-radius: 50%;
}

/* ---------- sobreposições da tela ---------- */

.pill-dock {
	position: absolute;
	top: 12px;
	right: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 6px;
}

.pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 0;
	border-radius: 20px;
	background: #1c1c1ee0;
	backdrop-filter: saturate(180%) blur(20px);
	color: var(--ios-secondary);
	font-size: 13px;
}

button.pill {
	font-family: inherit;
	cursor: pointer;
}

.pill[hidden] {
	display: none;
}

.pill::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}

.pill.online {
	color: var(--ios-green);
}

.pill.pending {
	color: #ffd60a;
}

.pill.error {
	color: var(--ios-red);
}

.zoom-dock {
	position: absolute;
	right: 12px;
	bottom: 12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	overflow: hidden;
	border-radius: 12px;
	background: var(--chrome);
	backdrop-filter: saturate(180%) blur(20px);
}

.zoom-dock button {
	width: 44px;
	height: 44px;
	padding: 0;
	border: none;
	background: none;
	color: var(--ios-blue);
	font-size: 20px;
}

.zoom-dock button:active {
	background: #ffffff1a;
}

#zoom-label {
	padding: 2px 0;
	border-block: 0.5px solid var(--ios-separator);
	color: var(--ios-secondary);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

/* ---------- barras inferiores ---------- */

.statusbar {
	padding: 4px 16px;
	background: var(--bg);
	color: var(--text);
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.guest-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px 14px;
	border-top: 0.5px solid var(--ios-separator);
	background: #0a84ff1f;
}

.guest-bar[hidden] {
	display: none;
}

.guest-text {
	flex: 1 1 200px;
	margin: 0;
	color: var(--ios-label);
	font-size: 12px;
}

.guest-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.guest-button {
	min-height: 36px;
	padding: 8px 12px;
	border: none;
	border-radius: 10px;
	background: #ffffff14;
	color: var(--ios-blue);
	font-size: 13px;
	font-weight: 600;
}

.guest-button[hidden] {
	display: none;
}

.guest-button.primary {
	background: var(--ios-blue);
	color: #fff;
}

.guest-button:active {
	filter: brightness(1.15);
}

.tabbar {
	display: flex;
	justify-content: center;
	gap: 2px;
	padding: 0;
}

.tabbar button {
	display: flex;
	flex: 1;
	max-width: 52px;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: none;
	border-radius: 10px;
	background: none;
	color: var(--ios-label);
	font-size: 10px;
}

.tabbar button span {
	font-size: 19px;
	line-height: 1;
}

.tabbar button:active {
	background: #ffffff1a;
	color: var(--ios-label);
}

.tabbar button:disabled {
	opacity: 0.3;
}

/* ---------- editor de texto iOS ---------- */

.text-editor {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	min-height: 0;
	flex-direction: column;
	background: var(--ios-bg);
	animation: text-editor-in 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

.text-editor[hidden] {
	display: none;
}

@keyframes text-editor-in {
	from {
		transform: translateY(24px);
		opacity: 0;
	}
}

.text-editor>header {
	display: grid;
	grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
	align-items: center;
	padding: max(8px, env(safe-area-inset-top)) 8px 8px;
	border-bottom: 0.5px solid var(--ios-separator);
	background: var(--ios-panel);
}

.text-editor h2 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
	text-align: center;
}

.text-editor button {
	min-height: 44px;
	padding: 8px 10px;
	border: none;
	background: none;
	color: var(--ios-blue);
	font-size: 16px;
}

#text-editor-cancel {
	justify-self: start;
}

#text-editor-done {
	justify-self: end;
	font-weight: 600;
}

.text-editor textarea {
	width: 100%;
	min-height: 0;
	flex: 1;
	padding: 24px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
	border: none;
	border-radius: 0;
	outline: none;
	background: var(--ios-bg);
	color: var(--ios-label);
	font-size: 20px;
	line-height: 1.5;
	letter-spacing: 0;
	resize: none;
	caret-color: var(--ios-blue);
}

/* ---------- folhas ---------- */

.sheet {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	background: #00000055;
	padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
}

.sheet[hidden] {
	display: none;
}

.sheet-panel {
	display: flex;
	width: 100%;
	max-width: 520px;
	max-height: calc(100dvh - max(16px, env(safe-area-inset-top)));
	flex-direction: column;
	padding-bottom: env(safe-area-inset-bottom);
	border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
	background: var(--chrome);
	backdrop-filter: blur(28px);
	animation: sheet-up 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-panel.wide {
	max-width: 880px;
}

@keyframes sheet-up {
	from {
		transform: translateY(100%);
	}
}

@media (min-width: 720px) {
	.sheet {
		align-items: center;
	}

	.sheet-panel {
		max-height: 82vh;
		border-radius: var(--radius-sheet);
	}

	@keyframes sheet-up {
		from {
			transform: translateY(16px);
			opacity: 0;
		}
	}
}

.grabber {
	width: 38px;
	height: 5px;
	margin: 8px auto 0;
	border-radius: 3px;
	background: var(--ios-separator);
}

.sheet-panel>header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 16px 12px;
}

.sheet-panel>header.sheet-nav {
	display: grid;
	grid-template-columns: minmax(72px, 1fr) minmax(0, 2fr) minmax(60px, 1fr);
	padding-inline: 8px;
}

.sheet-panel>header.sheet-nav h2 {
	overflow: hidden;
	font-size: 17px;
	text-align: center;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sheet-panel h2 {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
}

.sheet-close {
	min-height: 44px;
	padding: 6px 10px;
	border: none;
	border-radius: 10px;
	background: none;
	color: var(--ios-blue);
	font-size: 16px;
}

.sheet-close:active {
	background: #ffffff1a;
}

.sheet-nav .sheet-close {
	justify-self: end;
}

.sheet-back {
	justify-self: start;
	min-height: 44px;
	padding: 6px 8px;
	border: none;
	border-radius: 8px;
	background: none;
	color: var(--ios-blue);
	font-size: 16px;
}

.sheet-back:active {
	background: #ffffff1a;
}

.sheet-body {
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding: 0 16px 20px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* Num contentor flexível com altura limitada os filhos encolhem por omissão. */
.sheet-body>*,
.group>* {
	flex: 0 0 auto;
}

/* ---------- listas agrupadas ---------- */

.group {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: 0;
	background: transparent;
}

.group[hidden] {
	display: none;
}

.group h3 {
	margin: 0;
	padding: 12px 14px 6px;
	color: var(--ios-secondary);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: uppercase;
}

.group>.note {
	margin: 0;
	padding: 0 14px 10px;
}

.row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 48px;
	padding: 10px 14px;
	border: none;
	border-top: 0.5px solid var(--ios-separator);
	background: none;
	color: var(--ios-label);
	font-size: 16px;
	text-align: left;
}

.group h3+.row,
.row:first-child {
	border-top: none;
}

.row.stacked {
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
}

/* `display: flex` das linhas ganha ao [hidden] do HTML. */
.row[hidden] {
	display: none;
}

.row.stacked>span {
	color: var(--ios-secondary);
	font-size: 13px;
}

.row-copy {
	display: flex;
	min-width: 0;
	flex: 1;
	flex-direction: column;
	gap: 2px;
}

.row-copy strong {
	font-size: 15px;
	font-weight: 500;
}

.row-copy small {
	color: var(--ios-secondary);
	font-size: 12px;
	line-height: 1.35;
}

.nickname-row input {
	width: min(52%, 220px);
	min-width: 140px;
}

.people-add-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
	gap: 10px;
	padding: 14px;
	border-radius: var(--radius-card);
	background: var(--ios-panel-2);
}

.people-add-form[hidden] {
	display: none;
}

.people-add-form label {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 5px;
	color: var(--ios-secondary);
	font-size: 12px;
}

.people-add-form label small {
	font-size: 11px;
}

.people-add-form input {
	width: 100%;
	min-height: 42px;
	padding: 9px 10px;
	border: none;
	border-radius: 9px;
	background: #00000047;
	font-size: 15px;
}

.people-add-form>button {
	grid-column: 1 / -1;
	min-height: 42px;
	border: none;
	border-radius: 9px;
	background: var(--ios-blue);
	color: #fff;
	font-weight: 600;
}

.list li.person-item {
	display: grid;
	gap: 10px;
	padding-block: 12px;
}

.person-heading {
	display: grid;
	grid-template-columns: 36px minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
}

.person-avatar {
	display: grid;
	width: 36px;
	height: 36px;
	place-items: center;
	border-radius: 50%;
	background: #0a84ff24;
	color: var(--ios-blue);
	font-size: 15px;
	font-weight: 700;
}

.person-copy {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 2px;
}

.person-copy strong {
	font-size: 15px;
	font-weight: 600;
	overflow-wrap: anywhere;
}

.person-copy small {
	color: var(--ios-secondary);
	font-size: 12px;
	overflow-wrap: anywhere;
}

.person-nickname-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
	padding-left: 46px;
}

.person-nickname-form input {
	min-width: 0;
	min-height: 38px;
	padding: 8px 10px;
	border: none;
	border-radius: 8px;
	background: #00000047;
	font-size: 14px;
}

.person-nickname-form button:disabled {
	opacity: 0.35;
}

.person-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

@media (max-width: 440px) {
	.people-add-form {
		grid-template-columns: 1fr;
	}

	.people-add-form>button {
		grid-column: auto;
	}

	.person-nickname-form {
		padding-left: 0;
	}
}

@media (max-width: 360px) {
	.person-heading {
		grid-template-columns: 36px minmax(0, 1fr);
	}

	.person-heading .tag {
		grid-column: 2;
		justify-self: start;
	}
}

.row.action {
	width: 100%;
	color: var(--ios-blue);
	text-decoration: none;
}

.row.action:active {
	background: #ffffff14;
}

.row.action.danger {
	color: var(--ios-red);
}

.row.action:disabled {
	opacity: 0.4;
}

.choice-group h3 {
	padding-bottom: 8px;
}

.choice-row {
	display: grid;
	grid-template-columns: 30px minmax(0, 1fr) 12px;
	align-items: center;
	gap: 11px;
	width: 100%;
	min-height: 68px;
	padding: 11px 14px;
	border: none;
	border-top: 0.5px solid var(--ios-separator);
	background: none;
	text-align: left;
}

.choice-row[hidden] {
	display: none;
}

.choice-row:active {
	background: #ffffff14;
}

.choice-symbol {
	display: grid;
	width: 30px;
	height: 30px;
	place-items: center;
	border-radius: 8px;
	background: #0a84ff1f;
	color: var(--ios-blue);
	font-size: 18px;
	font-weight: 600;
}

.choice-symbol.live {
	color: var(--ios-green);
	font-size: 12px;
}

.choice-copy {
	display: flex;
	min-width: 0;
	flex-direction: column;
	gap: 3px;
}

.choice-copy strong {
	color: var(--ios-label);
	font-size: 15px;
	font-weight: 500;
}

.choice-copy small {
	color: var(--ios-secondary);
	font-size: 12px;
	line-height: 1.35;
}

.choice-chevron {
	color: #636366;
	font-size: 22px;
	line-height: 1;
}

/* A assinatura das notas é local; a conta abaixo é o estado real da sincronização. */
#group-account {
	border: 1px solid #ffffff0d;
	background: #242426;
	box-shadow: 0 10px 30px #00000024;
}

.account-summary {
	display: grid;
	grid-template-columns: 10px minmax(0, 1fr) auto;
	align-items: center;
	gap: 11px;
	padding: 5px 14px 14px;
}

.account-status-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--ios-secondary);
	box-shadow: 0 0 0 4px #98989f1f;
}

.account-copy {
	min-width: 0;
}

.account-copy strong {
	display: block;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.account-copy .note {
	margin-top: 3px;
	line-height: 1.35;
}

.account-badge {
	align-self: start;
	padding: 4px 7px;
	border-radius: 6px;
	background: #98989f1f;
	color: var(--ios-secondary);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.4px;
	line-height: 1;
	text-transform: uppercase;
}

.account-summary[data-state="signed-in"] .account-status-dot {
	background: var(--ios-green);
	box-shadow: 0 0 0 4px #30d1581f;
}

.account-summary[data-state="signed-in"] .account-badge {
	background: #30d1581f;
	color: var(--ios-green);
}

.account-summary[data-state="unavailable"] .account-status-dot {
	background: var(--ios-red);
	box-shadow: 0 0 0 4px #ff453a1f;
}

.account-summary[data-state="unavailable"] .account-badge {
	background: #ff453a1f;
	color: var(--ios-red);
}

.account-summary[data-state="checking"] .account-status-dot {
	animation: account-pulse 1.2s ease-in-out infinite;
}

@keyframes account-pulse {
	50% {
		opacity: 0.35;
	}
}

.account-actions {
	display: grid;
	gap: 8px;
	padding: 12px 14px 14px;
	border-top: 0.5px solid var(--ios-separator);
}

.account-button {
	min-height: 44px;
	padding: 10px 14px;
	border: none;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
}

.account-button[hidden] {
	display: none;
}

.account-button.primary {
	background: var(--ios-blue);
	color: #fff;
}

.account-button.secondary,
.account-button.sync {
	background: #0a84ff1f;
	color: var(--ios-blue);
}

.account-button.quiet {
	background: #ffffff0a;
	color: var(--ios-secondary);
}

.account-button.danger {
	background: #ff453a1f;
	color: #ff453a;
}

.account-button:active {
	filter: brightness(1.15);
}

.account-button:disabled {
	opacity: 0.4;
}

.row select,
.row input,
.row textarea {
	min-height: 36px;
	padding: 8px 10px;
	border: none;
	border-radius: 9px;
	background: #00000047;
	font-size: 16px;
}

.row.stacked textarea {
	resize: vertical;
}

.row>select {
	max-width: 55%;
}

.switch {
	position: relative;
	width: 51px;
	height: 31px;
	flex: 0 0 auto;
	padding: 0;
	border: none;
	border-radius: 16px;
	background: #78788052;
	transition: background 0.2s;
}

.switch::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 27px;
	height: 27px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 2px 6px #0000004d;
	transition: transform 0.2s;
}

.switch[aria-checked="true"] {
	background: var(--ios-green);
}

.switch[aria-checked="true"]::after {
	transform: translateX(20px);
}

.note {
	margin: 0;
	color: var(--ios-secondary);
	font-size: 13px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.mono {
	width: 100%;
	padding: 11px 12px;
	border: none;
	border-radius: var(--radius-row);
	background: var(--ios-panel-2);
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 12px;
}

.inline-form {
	display: flex;
	gap: 8px;
}

.inline-form input {
	flex: 1;
	min-height: 44px;
	padding: 10px 12px;
	border: none;
	border-radius: var(--radius-row);
	background: var(--ios-panel-2);
	font-size: 16px;
}

.inline-form button {
	min-height: 44px;
	padding: 10px 16px;
	border: none;
	border-radius: var(--radius-row);
	background: var(--ios-blue);
	color: #fff;
	font-weight: 600;
}

.list {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: var(--radius-card);
	background: var(--ios-panel-2);
	list-style: none;
}

.list li {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 50px;
	padding: 10px 14px;
	border-top: 0.5px solid var(--ios-separator);
	font-size: 15px;
}

.list li:first-child {
	border-top: none;
}

.list .who {
	flex: 1;
	overflow-wrap: anywhere;
}

.list .when,
.list .tag {
	color: var(--ios-secondary);
	font-size: 12px;
	white-space: nowrap;
}

.list .tag {
	padding: 3px 9px;
	border-radius: 20px;
	background: #ffffff14;
}

.list button {
	min-height: 34px;
	padding: 6px 12px;
	border: none;
	border-radius: 9px;
	background: #ffffff14;
	color: var(--ios-blue);
	font-size: 14px;
}

.list button.danger {
	color: var(--ios-red);
}

/* ---------- mapas ---------- */

.map-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
	gap: 16px;
}

.map-card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 16px;
	border: 1px solid var(--ios-separator);
	border-radius: var(--radius-card);
	background: var(--ios-panel-2);
}

.map-card.current {
	border-color: var(--ios-blue);
}

.map-card h3 {
	margin: 0;
	font-size: 18px;
	overflow-wrap: anywhere;
}

.map-card .meta {
	margin: 0;
	color: var(--ios-secondary);
	font-size: 12px;
}

.map-preview {
	height: 150px;
	overflow: hidden;
	border-radius: 0;
	background: var(--ios-bg);
}

.map-preview svg {
	width: 100%;
	height: 100%;
}

.map-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.map-actions button {
	/* Quatro ações não cabem numa linha estreita: passam a duas. */
	flex: 1 1 calc(50% - 3px);
	min-height: 44px;
	padding: 7px 4px;
	border: none;
	border-radius: 9px;
	background: var(--control-fill);
	color: var(--ios-blue);
	font-size: 13px;
}

.map-actions button.danger {
	color: var(--ios-red);
}

/* ---------- primeira utilização ---------- */

.intro-text {
	margin: 0;
	font-size: 17px;
	line-height: 1.45;
}

#onboarding .sheet-close {
	min-height: 44px;
}

.intro-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0 16px 20px;
}

.intro-progress {
	color: var(--ios-secondary);
	font-size: 13px;
}

.intro-actions {
	display: flex;
	gap: 8px;
}

.intro-button {
	min-height: 44px;
	padding: 8px 18px;
	border: none;
	border-radius: var(--radius-row);
	background: #ffffff14;
	color: var(--ios-blue);
	font-size: 16px;
}

.intro-button.primary {
	background: var(--ios-blue);
	color: #ffffff;
	font-weight: 600;
}

.intro-button:disabled {
	opacity: 0.4;
}

/* ---------- toque ---------- */

@media (pointer: coarse) and (max-width: 719px) {
	/* O tour fala da barra inferior: o cartão para em cima dela em vez de a tapar.
	   54px é a altura da .tabbar sem a área segura, que entra na conta à parte. */
	#onboarding {
		padding-bottom: calc(54px + max(6px, env(safe-area-inset-bottom)));
	}
}

@media (pointer: coarse) {
	.node-add {
		width: 34px;
		height: 34px;
		right: -19px;
		font-size: 21px;
	}

	.node-check {
		width: 32px;
		height: 32px;
		left: -18px;
		font-size: 16px;
	}

	.node-toggle {
		width: 28px;
		height: 28px;
		bottom: -14px;
		font-size: 12px;
	}

	.node-bar {
		bottom: calc(100% + 14px);
	}

	.node-bar button {
		width: 42px;
		height: 42px;
		font-size: 18px;
	}
}
