/* Settings pages. Each block is scoped to the settings component of the same `data-c` name. */

@scope ([data-c="setting-card"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
		min-width: 0;
		padding: var(--s4);
		background: var(--surface);
		border: 1px solid var(--line);
		border-radius: var(--r-card);
	}

	h2 {
		font-size: var(--t-lg);
	}

	.description {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

@scope ([data-c="settings-page"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s4);
		padding: var(--s4);
	}
}

@scope ([data-c="settings-index"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s4);
		padding: var(--s4);
	}

	.me,
	.entry {
		position: relative;
		overflow: hidden;
		display: flex;
		align-items: center;
		gap: var(--s3);
		padding: var(--s4);
		color: var(--ink);
		text-decoration: none;
	}

	.me {
		background: var(--surface);
		border: 1px solid var(--line);
		border-radius: var(--r-card);
	}

	.who,
	.text {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.handle,
	.description {
		max-width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	ul {
		margin: 0;
		padding: 0;
		list-style: none;
		border: 1px solid var(--line);
		border-radius: var(--r-card);
		overflow: hidden;
	}

	li + li {
		border-top: 1px solid var(--line);
	}

	.title {
		font-weight: 600;
	}
}

@scope ([data-c="setting-switch"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s1);
	}

	.hint {
		padding-left: calc(44px + var(--s3));
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

@scope ([data-c="muted-words"]) to ([data-c]) {
	.add {
		display: flex;
		align-items: flex-end;
		gap: var(--s2);
	}

	ul {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2);
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.chip {
		position: relative;
		overflow: hidden;
		display: inline-flex;
		align-items: center;
		gap: var(--s1);
		max-width: 100%;
		padding: var(--s1) var(--s3);
		border: 1px solid var(--line);
		border-radius: var(--r-pill);
		background: transparent;
		color: var(--ink);
	}

	.chip:hover {
		border-color: var(--line-hot);
	}

	.word {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.none {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

/* The add form's field and button are components of their own. */
[data-c="muted-words"] .add [data-c="text-field"] {
	flex: 1;
	min-width: 0;
}

[data-c="muted-words"] .add [data-c="button"] {
	min-height: 44px;
}

@scope ([data-c="relation-list"]) to ([data-c]) {
	.people {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	.row {
		display: flex;
		align-items: center;
		gap: var(--s3);
		padding-block: var(--s3);
	}

	.who {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
		color: var(--ink);
		text-decoration: none;
	}

	.handle {
		overflow: hidden;
		text-overflow: ellipsis;
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.more {
		display: flex;
		justify-content: center;
		padding-top: var(--s2);
	}
}

@scope ([data-c="desktop-notifications"]) to ([data-c]) {
	.row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--s3);
	}

	.row[hidden],
	.note[hidden] {
		display: none;
	}

	.state,
	.note {
		font-size: var(--t-sm);
	}

	.note {
		color: var(--ink-dim);
	}
}

@scope ([data-c="account-line"]) to ([data-c]) {
	:scope {
		display: flex;
		align-items: center;
		gap: var(--s3);
	}

	.who {
		display: flex;
		flex-direction: column;
		min-width: 0;
	}

	.meta {
		overflow-wrap: anywhere;
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

@scope ([data-c="account-edit"]) to ([data-c]) {
	:scope {
		align-self: flex-start;
		display: inline-flex;
		align-items: center;
		min-height: 40px;
		padding: 0 var(--s4);
		border: 1px solid var(--line);
		border-radius: var(--r-ctl);
		color: var(--ink);
		font-weight: 500;
		text-decoration: none;
		transition: border-color var(--dur-fast) ease;
	}

	:scope:hover {
		border-color: var(--line-hot);
	}

	@media (pointer: coarse) {
		:scope {
			min-height: 44px;
		}
	}
}

@scope ([data-c="password-form"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
	}

	.end {
		display: flex;
		justify-content: flex-end;
	}
}

@scope ([data-c="profile-preview"]) to ([data-c]) {
	:scope {
		display: flex;
		align-items: center;
		gap: var(--s3);
	}

	.who {
		display: flex;
		flex-direction: column;
		min-width: 0;
	}

	.name {
		overflow-wrap: anywhere;
	}

	.handle {
		overflow-wrap: anywhere;
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

[data-c="profile-form"] .bio {
	display: flex;
	flex-direction: column;
	gap: var(--s1);
}

[data-c="profile-form"] .counter {
	align-self: flex-end;
	color: var(--ink-dim);
	font-family: var(--font-mono);
	font-size: var(--t-xs);
}

[data-c="profile-form"] .failure {
	color: var(--danger);
	font-size: var(--t-sm);
}

[data-c="profile-form"] .failure[hidden] {
	display: none;
}

[data-c="profile-form"] .end {
	display: flex;
	justify-content: flex-end;
}

@scope ([data-c="image-field"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
	}

	.current {
		min-width: 0;
	}

	.banner {
		position: relative;
		aspect-ratio: 3;
		overflow: hidden;
		background: var(--surface);
		border: 1px solid var(--line);
	}

	.banner img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.controls {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
	}

	.buttons {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2);
	}

	.hint {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

@scope ([data-c="shape-picker"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		min-width: 0;
		padding: 0;
		border: 0;
	}

	.options {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2);
	}

	.option {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: var(--s1);
		min-width: 72px;
		padding: var(--s2);
		border: 1px solid var(--line);
		border-radius: var(--r-ctl);
		cursor: pointer;
		transition: border-color var(--dur-fast) ease;
	}

	.option:hover {
		border-color: var(--line-hot);
	}

	.option:has(input:checked) {
		border-color: var(--ink-dim);
		background: var(--surface-hover);
		box-shadow: inset 0 -2px 0 var(--ink);
	}

	.option:has(input:focus-visible) {
		outline: 2px solid var(--ink);
		outline-offset: 2px;
	}

	input {
		position: absolute;
		inset: 0;
		margin: 0;
		opacity: 0;
		cursor: pointer;
	}

	.name {
		color: var(--ink-dim);
		font-family: var(--font-mono);
		font-size: var(--t-xs);
		letter-spacing: 0.12em;
		text-transform: uppercase;
	}
}

@scope ([data-c="ink-picker"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		min-width: 0;
		padding: 0;
		border: 0;
	}

	.options {
		display: flex;
		flex-wrap: wrap;
		gap: var(--s2);
	}

	.option {
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: var(--s1);
		min-width: 64px;
		padding: var(--s2);
		border: 1px solid var(--line);
		border-radius: var(--r-ctl);
		cursor: pointer;
		transition: border-color var(--dur-fast) ease;
	}

	.option:hover {
		border-color: var(--line-hot);
	}

	.option:has(input:checked) {
		border-color: var(--ink-dim);
		background: var(--surface-hover);
		box-shadow: inset 0 -2px 0 var(--ink);
	}

	.option:has(input:focus-visible) {
		outline: 2px solid var(--ink);
		outline-offset: 2px;
	}

	input {
		position: absolute;
		inset: 0;
		margin: 0;
		opacity: 0;
		cursor: pointer;
	}

	.swatch {
		width: 28px;
		height: 28px;
		background: var(--ink);
		border: 1px solid var(--line);
		clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
	}

	.name {
		color: var(--ink-dim);
		font-family: var(--font-mono);
		font-size: var(--t-xs);
		letter-spacing: 0.12em;
		text-transform: uppercase;
	}

	@media (pointer: coarse) {
		.option {
			min-height: 44px;
		}
	}
}

@scope ([data-c="pref-control"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s1);
		min-width: 0;
		max-width: 100%;
	}
}

/* `prefs.js` marks the stored choice with aria-selected; only that segment draws its pill. */
[data-c="pref-control"] .segment[aria-selected="false"] .pill {
	display: none;
}

@scope ([data-c="appearance-sample"]) to ([data-c]) {
	:scope {
		display: flex;
		gap: var(--s3);
		padding: var(--s3);
		border: 1px solid var(--line);
		border-radius: var(--r-ctl);
	}

	.body {
		min-width: 0;
	}

	.handle {
		margin-left: var(--s1);
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

/* Lists of sessions, passkeys, tokens and affiliations share one row layout. */
@scope ([data-c="sessions"]) to ([data-c]) {
	ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	li {
		display: flex;
		align-items: center;
		gap: var(--s3);
		padding-block: var(--s3);
		border-top: 1px solid var(--line);
	}

	.text {
		flex: 1;
		min-width: 0;
	}

	.device {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: var(--s2);
		font-weight: 600;
	}

	.meta {
		overflow-wrap: anywhere;
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.end {
		display: flex;
		justify-content: flex-end;
	}
}

@scope ([data-c="passkeys"]) to ([data-c]) {
	ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	li {
		display: flex;
		align-items: center;
		gap: var(--s2);
		padding-block: var(--s3);
		border-top: 1px solid var(--line);
	}

	.icon {
		display: inline-grid;
		flex: none;
		margin-right: var(--s1);
	}

	.text {
		flex: 1;
		min-width: 0;
	}

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

	.dim {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}

	.dim[hidden] {
		display: none;
	}

	.end {
		display: flex;
		justify-content: flex-end;
	}

	@media (max-width: 480px) {
		li {
			flex-wrap: wrap;
		}

		.text {
			flex-basis: calc(100% - 40px);
		}
	}
}

[data-c="passkey-rename"] .error {
	color: var(--danger);
	font-size: var(--t-sm);
}

[data-c="passkey-rename"] .error[hidden] {
	display: none;
}

@scope ([data-c="affiliation"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s4);
	}

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

	li {
		display: flex;
		align-items: center;
		gap: var(--s2);
		padding-block: var(--s3);
		border-top: 1px solid var(--line);
	}

	.who {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
	}

	.dim {
		color: var(--ink-dim);
		font-size: var(--t-sm);
		overflow-wrap: anywhere;
	}

	.note {
		padding-inline: var(--s1);
	}
}

/* The invite form sits in a card of its own, so it carries its rules. */
[data-c="affiliation"] .invite {
	display: flex;
	flex-direction: column;
	gap: var(--s3);
}

[data-c="affiliation"] .invite .error,
[data-c="affiliation"] .invite .end {
	font-size: var(--t-sm);
}

[data-c="affiliation"] .invite .error {
	color: var(--danger);
}

[data-c="affiliation"] .invite .error[hidden] {
	display: none;
}

[data-c="affiliation"] .invite .end {
	display: flex;
	justify-content: flex-end;
}

@scope ([data-c="bot-switch"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
	}
}

[data-c="setting-card"] .owner,
[data-c="setting-card"] .create {
	display: flex;
	flex-direction: column;
	gap: var(--s3);
}

[data-c="setting-card"] .owner[hidden] {
	display: none;
}

[data-c="setting-card"] .owner [data-c="button"] {
	align-self: flex-start;
}

@scope ([data-c="token-list"]) to ([data-c]) {
	.tokens {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	li {
		display: flex;
		align-items: center;
		gap: var(--s2);
		padding-block: var(--s3);
		border-top: 1px solid var(--line);
	}

	.icon {
		display: inline-grid;
		flex: none;
		margin-right: var(--s1);
	}

	.text {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
	}

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

	.dim {
		color: var(--ink-dim);
		font-size: var(--t-sm);
		overflow-wrap: anywhere;
	}

	code {
		font-family: var(--font-mono);
	}
}

@scope ([data-c="token-form"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
	}

	fieldset {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		margin: 0;
		padding: 0;
		border: 0;
		min-width: 0;
	}

	legend {
		margin-bottom: var(--s2);
		font-family: var(--font-mono);
		font-size: var(--t-xs);
		letter-spacing: 0.2em;
		text-transform: uppercase;
		color: var(--ink-dim);
	}

	.scope {
		display: flex;
		flex-direction: column;
		gap: var(--s1);
	}

	.scope .dim {
		padding-left: calc(var(--s3) + 24px);
		color: var(--ink-dim);
		font-size: var(--t-sm);
		overflow-wrap: anywhere;
	}

	.error {
		color: var(--danger);
		font-size: var(--t-sm);
	}

	.error[hidden] {
		display: none;
	}

	.end {
		display: flex;
		justify-content: flex-end;
	}
}

@scope ([data-c="token-secret"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s3);
	}

	.warning {
		padding: var(--s3);
		border: 1px solid var(--danger);
		border-radius: var(--r-ctl);
		color: var(--ink);
		font-size: var(--t-sm);
	}

	.label {
		font-family: var(--font-mono);
		font-size: var(--t-xs);
		letter-spacing: 0.2em;
		text-transform: uppercase;
		color: var(--ink-dim);
	}

	.secret {
		width: 100%;
		min-height: 44px;
		padding: var(--s3);
		background: var(--paper);
		border: 1px solid var(--line-hot);
		border-radius: var(--r-ctl);
		color: var(--ink);
		font-family: var(--font-mono);
		font-size: var(--t-sm);
		overflow-wrap: anywhere;
		resize: none;
	}
}

@scope ([data-c="bot-docs"]) to ([data-c]) {
	:scope {
		position: relative;
		overflow: hidden;
		display: flex;
		align-items: center;
		gap: var(--s3);
		padding: var(--s4);
		background: var(--surface);
		border: 1px solid var(--line);
		border-radius: var(--r-card);
		color: var(--ink);
		text-decoration: none;
	}

	.text {
		flex: 1;
		min-width: 0;
		display: flex;
		flex-direction: column;
	}

	.name {
		font-weight: 600;
	}

	.dim {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}

@scope ([data-c="about-facts"]) to ([data-c]) {
	:scope {
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		margin: 0;
	}

	:scope > div {
		display: flex;
		justify-content: space-between;
		gap: var(--s4);
	}

	dt {
		color: var(--ink-dim);
	}

	dd {
		margin: 0;
		min-width: 0;
		overflow-wrap: anywhere;
		text-align: right;
	}
}

@scope ([data-c="about-links"]) to ([data-c]) {
	:scope {
		margin: 0;
		padding: 0;
		list-style: none;
		display: flex;
		flex-direction: column;
		gap: var(--s2);
	}
}

@scope ([data-c="about-rules"]) to ([data-c]) {
	:scope {
		margin: 0;
		padding: 0;
		padding-left: var(--s5);
		display: flex;
		flex-direction: column;
		gap: var(--s2);
		list-style: decimal;
	}
}

@scope ([data-c="about-shortcuts"]) to ([data-c]) {
	.group + .group {
		margin-top: var(--s3);
	}

	h3 {
		margin-bottom: var(--s2);
	}

	dl {
		margin: 0;
	}

	.item {
		display: flex;
		justify-content: space-between;
		gap: var(--s4);
		padding-block: var(--s1);
	}

	dt {
		display: flex;
		align-items: center;
		gap: var(--s1);
	}

	dd {
		margin: 0;
	}

	kbd {
		padding: 0 var(--s2);
		border: 1px solid var(--line-hot);
		border-radius: var(--r-ctl);
		font-family: var(--font-mono);
		font-size: var(--t-sm);
	}

	.join {
		color: var(--ink-dim);
		font-size: var(--t-sm);
	}
}
