/* avatar — a person's image, or a single-initial coloured circle. Shared by the mention picker and,
   via @tldraw/commenting, the comment UI. */
.tlui-cmt-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: var(--tl-color-selected);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	font-weight: 600;
	flex-shrink: 0;
}

.tlui-cmt-avatar--image {
	object-fit: cover;
	background: none;
}

/* mention pill */
.tlui-cmt-mention {
	color: var(--tl-color-selected);
	font-weight: 600;
	background: color-mix(in srgb, var(--tl-color-selected) 12%, transparent);
	padding: 0 4px;
	border-radius: 4px;
}

/* mention picker — row size, highlight, panel and shadow come from .tlui-menu and
   .tlui-button__menu; these rules only lay out the row's contents. */
.tlui-menu.tlui-cmt-mention-list {
	display: flex;
	flex-direction: column;
	width: 100%;
	/* Fits MAX_SUGGESTIONS (8) menu rows: .tlui-menu hides its scrollbar and the active row
	   isn't scrolled into view, so a cut-off last row would be unreachable. */
	max-height: 296px;
	color: var(--tl-color-text-1);
}

.tlui-cmt-mention-list .tlui-cmt-mention-list__item {
	/* min-height rather than the menu row's fixed 40px, so a taller renderMember row can grow. */
	height: auto;
	min-height: 40px;
	flex-shrink: 0;
	justify-content: flex-start;
	text-align: start;
}

.tlui-cmt-mention-list__item .tlui-cmt-avatar {
	width: 20px;
	height: 20px;
	font-size: 10px;
}

/* Name and secondary share one line so a row never outgrows the menu-row height. */
.tlui-cmt-mention-list__text {
	display: flex;
	align-items: baseline;
	gap: 6px;
	min-width: 0;
}

.tlui-cmt-mention-list__name {
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex-shrink: 0;
	max-width: 100%;
}

.tlui-cmt-mention-list__you {
	margin-left: 4px;
	font-weight: 400;
	color: var(--tl-color-text-3);
}

.tlui-cmt-mention-list__secondary {
	font-size: 12px;
	color: var(--tl-color-text-3);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tlui-menu.tlui-cmt-mention-list--empty {
	flex-direction: row;
	align-items: center;
	height: 40px;
	padding: 0 12px;
	color: var(--tl-color-text-3);
	font-size: 12px;
}

/* the @-picker popup — anchored under the editor field, positioned by the suggestion plugin */
.tlui-cmt-mention-popup {
	position: fixed;
	z-index: var(--tl-layer-menus);
}
.tlui-cmt-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 8px;
	width: 260px;
	background: var(--tl-color-panel);
	border: 1px solid var(--tl-color-divider);
	border-radius: var(--tl-radius-3);
}

/* The avatar lives in the byline row (see Byline), so the body text below indents to line up with
   the name — the avatar's width plus the head's gap. */
.tlui-cmt-body {
	padding-left: calc(28px + 6px);
}

.tlui-cmt-card__actions {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	gap: 0;
	opacity: 0;
}
.tlui-cmt-card:hover .tlui-cmt-card__actions,
/* Keyboard focus, not any focus: closing an edit hands focus back to the card's ⋯ button, and that
   alone mustn't leave the controls up for a pointer that has moved away. */
.tlui-cmt-card:has(:focus-visible) .tlui-cmt-card__actions,
/* an open menu is portaled out of the card, so neither :hover nor focus survives moving the
   pointer into it — keep the controls up while their menu is open */
.tlui-cmt-card__actions:has([data-state='open']) {
	opacity: 1;
}
/* The editor only rings a focused button once Tab or an arrow key has turned its focus ring on, but
   leaving an edit with Escape or Enter hands keyboard focus to the card's ⋯ button without either,
   which would leave the keyboard user nothing showing where focus went. Same ring as the editor's. */
.tlui-cmt-card__actions .tlui-button:focus-visible {
	border-radius: 10px;
	outline: 2px solid var(--tl-color-focus);
	outline-offset: -5px;
}

.tlui-cmt-body {
	flex: 1;
	min-width: 0;
}

.tlui-cmt-head {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: -4px;
}

.tlui-cmt-author {
	font-weight: 500;
	font-size: 12px;
	color: var(--tl-color-text);
	/* a long name ellipsizes rather than pushing the time out or running under the actions */
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tlui-cmt-time {
	font-size: 12px;
	color: var(--tl-color-text-3);
	flex-shrink: 0;
	white-space: nowrap;
}

.tlui-cmt-canvas-preview--thread .tlui-cmt-text {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 7;
	line-clamp: 7;
	overflow: hidden;
}

.tlui-cmt-text {
	margin: 0 0 6px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--tl-color-text-1);
	/* Break long unbroken strings (URLs, keyboard-mashing) so they wrap inside the card instead of
	   overflowing it. `anywhere` also lets the flex body shrink to the card width. */
	overflow-wrap: anywhere;
}

/* A comment body is read-only but its text must stay selectable so it can be copied. tldraw's
   container sets `user-select: none` on every descendant (`.tl-container *`) to keep canvas gestures
   from selecting UI text, so the body and its rendered children have to opt back in. */
.tlui-cmt-text,
.tlui-cmt-text * {
	-webkit-user-select: text;
	user-select: text;
}
/* In an opened thread the byline, the resolved banner and a host's own `CommentBody` (which may not
   use .tlui-cmt-text) are selectable too, so a quote can be copied with its author and time. Rows
   in the list stay unselectable: they're click targets, and a drag there would select instead. */
.tlui-cmt-thread :is(.tlui-cmt-author, .tlui-cmt-time, .tlui-cmt-body, .tlui-cmt-thread__resolved),
.tlui-cmt-thread
	:is(.tlui-cmt-author, .tlui-cmt-time, .tlui-cmt-body, .tlui-cmt-thread__resolved)
	* {
	-webkit-user-select: text;
	user-select: text;
}
/* …but not the controls inside them (reaction pills, See more), whose labels aren't content. */
.tlui-cmt-thread .tlui-cmt-body :is(button, button *) {
	-webkit-user-select: none;
	user-select: none;
}

/* A long comment in the thread view, clamped to 10 lines until expanded. A line clamp, not a max
   height, so it always ends on a whole line: paragraph gaps would leave a height cut mid-line. */
.tlui-cmt-collapsible--collapsed {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 10;
	line-clamp: 10;
	overflow: hidden;
}
/* Styled as the byline's time ("now"), so it reads as metadata rather than a button. */
.tlui-cmt-see-more {
	display: block;
	/* The clamped body's own bottom margin is clipped with its overflow. */
	margin: 4px 0 6px;
	padding: 0;
	border: none;
	background: none;
	font: inherit;
	font-size: 12px;
	font-weight: normal;
	color: var(--tl-color-text-3);
	cursor: pointer;
}
.tlui-cmt-see-more:hover {
	color: var(--tl-color-text-1);
}

.tlui-cmt-edited {
	font-style: italic;
}

.tlui-cmt-text p {
	margin: 0;
}

.tlui-cmt-text p + p,
.tlui-cmt-text p + ul,
.tlui-cmt-text p + ol,
.tlui-cmt-text ul + p,
.tlui-cmt-text ol + p {
	margin-top: 6px;
}

.tlui-cmt-text ul,
.tlui-cmt-text ol {
	margin: 0;
	padding-left: 18px;
}

.tlui-cmt-text code {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.92em;
	background: var(--tl-color-muted-2);
	border-radius: 3px;
	padding: 0 3px;
}

.tlui-cmt-text mark {
	background: color-mix(in srgb, #ffeb3b 60%, transparent);
	color: inherit;
	border-radius: 2px;
}

.tlui-cmt-text a {
	color: var(--tl-color-selected);
	text-decoration: underline;
}

/* Avatar and mention styles live in @tldraw/mentions and are imported by commenting.css. */

/* The avatar aligns to the top so it stays put as the field grows to multiple lines. */
.tlui-cmt-composer {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 4px 0 8px 4px;
}

.tlui-cmt-composer__field {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 3px 3px 8px;
	background: var(--tl-color-muted-0);
	border: 1px solid var(--tl-color-divider);
	border-radius: var(--tl-radius-2);
	/* The whole field reads as the text input — clicking its empty area focuses the editor
	   (see CommentComposer). The send button restores its own pointer cursor. */
	cursor: text;
}

.tlui-cmt-composer__field:focus-within {
	border-color: var(--tl-color-selected);
	background: var(--tl-color-panel);
}

/* Expanded: the content no longer fits on one line beside the send button, so the input takes
   the full width and the send button drops to its own row, right-aligned. */
.tlui-cmt-composer__field--expanded {
	flex-wrap: wrap;
	row-gap: 0;
}
.tlui-cmt-composer__field--expanded .tlui-cmt-composer__input-wrap {
	flex-basis: 100%;
	/* The field pads 8px left but only 3px right (the send button's inset). With the input
	   spanning the full width, give the text the same 8px on the right. */
	padding-right: 5px;
}
.tlui-cmt-composer__field--expanded .tlui-cmt-send {
	margin-left: auto;
}

.tlui-cmt-composer__input-wrap {
	position: relative;
	flex: 1;
	min-width: 0;
	/* Frames the input's line height symmetrically so the text sits centred in the field. Paired
	   with the input's min-height, which equals its line height (no gap for the text to top-align
	   into). Keeps the field's overall height. */
	padding: 4.5px 0;
}

/* The hidden single-line measuring clone of the editor's content (see CommentComposer). */
.tlui-cmt-composer__mirror {
	position: absolute;
	top: 0;
	left: 0;
	visibility: hidden;
	pointer-events: none;
	white-space: nowrap;
	width: max-content;
}

.tlui-cmt-input {
	font: inherit;
	font-size: 12px;
	line-height: 1.4;
	color: var(--tl-color-text-1);
	outline: none;
	min-height: 17px;
	white-space: pre-wrap;
	word-break: break-word;
}

.tlui-cmt-input p {
	margin: 0;
}

.tlui-cmt-input p + p,
.tlui-cmt-input p + ul,
.tlui-cmt-input p + ol {
	margin-top: 4px;
}

.tlui-cmt-input ul,
.tlui-cmt-input ol {
	margin: 0;
	padding-left: 18px;
}

.tlui-cmt-input__placeholder {
	position: absolute;
	top: 4.5px;
	left: 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--tl-color-text-3);
	pointer-events: none;
}

/* iOS Safari zooms the whole page in when a text input with a sub-16px font takes focus, and doesn't
   zoom back out. Raising the font to 16px on touch devices suppresses that without disabling
   pinch-zoom of the canvas (which a `maximum-scale` viewport lock would). Must come after both base
   rules above: a media query adds no specificity, so it only wins the placeholder on source order. */
@media (pointer: coarse) {
	.tlui-cmt-input,
	.tlui-cmt-input__placeholder {
		font-size: 16px;
	}
}

.tlui-cmt-send {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: var(--tl-radius-2);
	background: transparent;
	color: var(--tl-color-text-3);
	cursor: pointer;
	align-self: center;
}

.tlui-cmt-send:not(:disabled) {
	color: var(--tl-color-text-1);
}

.tlui-cmt-send:hover:not(:disabled) {
	background: var(--tl-color-muted-2);
}

.tlui-cmt-send:active:not(:disabled),
.pseudo-active .tlui-cmt-send:not(:disabled) {
	background: var(--tl-color-muted-1);
}

.tlui-cmt-send:focus-visible,
.pseudo-focus-visible .tlui-cmt-send {
	outline: 2px solid var(--tl-color-selected);
	outline-offset: 2px;
}

.tlui-cmt-send:disabled {
	background: transparent;
	color: var(--tl-color-text-3);
	cursor: not-allowed;
}

/* The shared marker treatment. To the pointer a comment pin and a count badge are the same
   object — a token sitting on the canvas — so their resting and hover shadows live here, where the
   two can't drift apart. Each opts out of the hover scale below; a canvas pin gets it back from
   canvas.css, keyed off its hit layer. */
.tlui-cmt-marker {
	box-shadow: var(--tlui-cmt-marker-shadow);
	cursor: pointer;
	transition:
		transform var(--tlui-cmt-marker-transition),
		box-shadow var(--tlui-cmt-marker-transition);
}

.tlui-cmt-marker:hover {
	transform: scale(var(--tlui-cmt-marker-hover-scale));
}

.tlui-cmt-marker:not(.tlui-cmt-marker--open):hover {
	box-shadow: var(--tlui-cmt-marker-shadow-hover);
}

.tlui-cmt-count-badge:hover {
	transform: none;
	box-shadow: var(--tlui-cmt-marker-shadow-hover);
}

/* A pin's own :hover doesn't scale it; on the canvas, canvas.css scales it from the hit layer. */
.tlui-cmt-pin:hover {
	transform: none;
}

.tlui-cmt-marker--open {
	box-shadow: var(--tlui-cmt-marker-shadow-hover);
}

.tlui-cmt-pin {
	--tlui-cmt-marker-size: var(--tlui-cmt-pin-size);
	width: var(--tlui-cmt-marker-size);
	height: var(--tlui-cmt-marker-size);
	border-radius: 50% 50% 50% 0;
	background: var(--tl-color-panel);
	color: var(--tl-color-panel-contrast);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 600;
}
.tlui-cmt-pin .tlui-cmt-avatar {
	width: 22px;
	height: 22px;
	box-shadow: inset 0px 0px 0px 1px var(--tl-color-hint);
}

/* resolved: a solid, muted grey per theme. The muted tokens are translucent (10% black, or 10% white
   in dark mode), so the canvas would show through a pin filled with one. */
.tlui-cmt-pin--resolved {
	background: #dfe0e1;
	color: hsl(214, 8%, 42%);
}
.tl-theme__dark .tlui-cmt-pin--resolved {
	background: hsl(240, 5%, 30%);
	color: hsl(0, 0%, 72%);
}

.tlui-cmt-count-badge {
	width: var(--tlui-cmt-marker-size);
	height: var(--tlui-cmt-marker-size);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--tl-color-text-1);
	color: var(--tl-color-panel);
	font-size: 12px;
	font-weight: 700;
	user-select: none;
}

.tlui-cmt-reactions {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 4px;
	/* Pull the row left by the pill's inline padding so the first emoji lines up with the text above. */
	margin-left: -6px;
}

.tlui-cmt-reaction {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 6px;
	border: none;
	border-radius: var(--tl-radius-1);
	background: none;
	font: inherit;
	font-size: 10px;
	font-weight: 400;
	color: var(--tl-color-text-1);
}

/* An inert pill renders as a span (e.g. in a notification row); only the button variant is
   clickable, so only it gets the pointer cursor and hover shade. */
button.tlui-cmt-reaction {
	cursor: pointer;
}

button.tlui-cmt-reaction:hover {
	background: var(--tl-color-muted-2);
}

/* The emoji renders larger than the 10px count, but its pinned line-height keeps the pill the
   count's height — the glyph overflows the line box rather than growing it. */
.tlui-cmt-reaction__emoji {
	font-size: 13px;
	line-height: 10px;
}

.tlui-cmt-reaction__count {
	color: var(--tl-color-text-3);
	font-variant-numeric: tabular-nums;
}

.tlui-cmt-reaction--active .tlui-cmt-reaction__count {
	color: var(--tl-color-text-1);
	font-weight: 700;
}

/* Laid out like tldraw's .tlui-grid (the actions menu): 40px hit areas overlapping 2px on every
   side, so the 32px hover squares sit 4px apart and 4px in from the panel edge. */
.tlui-cmt-emoji-picker {
	display: grid;
	grid-template-columns: repeat(5, 36px);
	gap: 0;
	padding: 2px;
}

.tlui-cmt-emoji-picker__item {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: -2px;
	padding: 0;
	border: none;
	background: none;
	font: inherit;
	font-size: 21px;
	line-height: 1;
	cursor: pointer;
}

/* Sits under the emoji so an opaque selected fill can't hide it. */
.tlui-cmt-emoji-picker__item::after {
	content: '';
	position: absolute;
	inset: 4px;
	z-index: -1;
	border-radius: var(--tl-radius-2);
}
.tlui-cmt-emoji-picker__item:hover {
	z-index: 1;
}
.tlui-cmt-emoji-picker__item:hover::after {
	background: var(--tl-color-muted-2);
}

.tlui-cmt-emoji-picker__item--active::after {
	background: color-mix(in srgb, var(--tl-color-selected) 28%, var(--tl-color-panel));
}

.tlui-cmt-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 24px;
	text-align: center;
	width: 240px;
}

.tlui-cmt-empty__icon {
	font-size: 28px;
}

.tlui-cmt-empty__message {
	margin: 0;
	color: var(--tl-color-text-3);
	font-size: 12px;
	line-height: 1.4;
}

/* The thread panel's layout metrics live on the container because two separate portals need them:
   the panel itself, and the canvas hover preview, which has to land its first comment on exactly
   the pixel the panel would. Deriving the preview's offset from these means the two can't drift —
   retune the padding or the header here and the preview follows. */
.tl-container {
	/* Everything that has to line up against a pin — its preview's bridge, the draft composer's
	   offsets, `PIN_SIZE` in thread-view.tsx — derives from this, so the pin's size stays one
	   number. */
	--tlui-cmt-pin-size: 28px;
	/* A cluster badge and a stack badge are this square — the same size as a pin, so the marker
	   kinds read as one family. The hover preview measures its bridge against it, so the bridge
	   stops at the marker's edge instead of covering it. Mirrored by `MARKER_SIZE` in
	   thread-view.tsx. */
	--tlui-cmt-marker-size: var(--tlui-cmt-pin-size);
	/* How a marker rests and lifts. Shared so a pin and a badge respond identically. shadow-3's
	   depth without its `inset 1px panel-contrast` edge, which would ring the text-coloured count
	   badge in the panel's contrast colour. */
	--tlui-cmt-marker-shadow:
		0px 1px 2px hsl(0, 0%, 0%, 28%), 0px 2px 6px hsl(0, 0%, 0%, 14%),
		inset 0px 0px 0px 1px var(--tl-color-panel-contrast);
	--tlui-cmt-marker-shadow-hover:
		0px 1px 2px hsl(0, 0%, 0%, 32%), 0px 2px 6px hsl(0, 0%, 0%, 14%),
		inset 0px 0px 0px 1px var(--tl-color-panel-contrast);
	--tlui-cmt-marker-hover-scale: 1.08;
	--tlui-cmt-marker-transition: 0.08s ease;
	--tlui-cmt-thread-padding: 12px;
	--tlui-cmt-thread-gap: 0px;
	/* Hit-area width of one .tlui-cmt-icon-btn button (drawn as a 32px square inset 4px). */
	--tlui-cmt-thread-action-size: 40px;
	/* A floating pill's edge — its hairline ring is the only thing separating it from the panel it
	   overlaps, so the ring is a theme token rather than a literal black: a near-black hairline
	   vanishes on a dark panel, where the divider token lightens instead. The drop below it stays
	   literal; a soft dark blur reads on both themes. */
	--tlui-cmt-pill-shadow: 0 0 0 1px var(--tl-color-divider), 0 1px 3px hsl(0, 0%, 0%, 0.05);
}

.tlui-cmt-thread {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 300px;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-4);
	box-shadow: var(--tl-shadow-3);
}
.tlui-cmt-thread__header {
	position: absolute;
	right: 10px;
	bottom: calc(100% - 15px);
	display: flex;
	gap: 2px;
	padding: 2px;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-3);
	box-shadow: var(--tlui-cmt-pill-shadow);
	transition: opacity 0.1s ease;
}
/* The first comment's hover actions surface right under the header pill, so hide the pill while
   that comment is hovered — one set of actions in the corner, never two stacked. */
.tlui-cmt-thread:has(.tlui-cmt-thread__list > :first-child:hover)
	.tlui-cmt-thread__header:not(:has(.tlui-cmt-thread__title)) {
	opacity: 0;
	pointer-events: none;
}
/* A title puts the header back in the panel, in flow — the case tldraw's own thread view uses
   ("Comment"). The pill above suits an actions-only header: right-anchored and only as wide as its
   buttons, so a title inside it would grow leftwards off the panel's edge. `header` is public API
   (see `CommentThreadProps`), so both layouts have to hold up. */
.tlui-cmt-thread__header:has(.tlui-cmt-thread__title) {
	position: static;
	align-items: center;
	padding: 0;
	background: none;
	border-radius: 0;
	box-shadow: none;
}
.tlui-cmt-thread__title {
	padding: 10px 12px;
	color: var(--tl-color-text);
}
.tlui-cmt-thread__actions {
	display: flex;
	gap: 0;
	/* Right-align the actions whether or not the header has a title (with none, space-between alone
	   would leave them at the left). */
	margin-left: auto;
}
/* Every icon button in the comment UI: thread and sidebar headers, and a comment's own actions.
   These are TldrawUiButtons (type="icon"), so the 40px box, the 32px ::after square carrying the
   hover wash, and the hover z-index flip all come from .tlui-button. Only the bits that differ
   from a toolbar button are set here, at .tlui-button's specificity + 1 so stylesheet order can't
   decide the winner. `.tlui-cmt-thread__action` and `.tlui-cmt-header-btn` are the class's former
   names, kept so a host's own buttons still pick the styles up. */
.tlui-button:is(.tlui-cmt-icon-btn, .tlui-cmt-thread__action, .tlui-cmt-header-btn) {
	width: 40px;
	padding: 0;
	border-radius: 6px;
	color: var(--tl-color-text-3);
	font-size: 14px;
	line-height: 1;
}
/* Overlap each button 4px into the previous so the 32px visual squares sit 4px apart, not 8px.
   On the leading side only, so the last button's hit area still stops at its row's edge. */
:is(.tlui-cmt-icon-btn, .tlui-cmt-thread__action, .tlui-cmt-header-btn)
	+ :is(.tlui-cmt-icon-btn, .tlui-cmt-thread__action, .tlui-cmt-header-btn) {
	margin-inline-start: -4px;
}
@media (hover: hover) {
	.tlui-button:is(.tlui-cmt-icon-btn, .tlui-cmt-thread__action, .tlui-cmt-header-btn):hover {
		color: var(--tl-color-text-1);
	}
}
.tlui-button:is(
		.tlui-cmt-icon-btn,
		.tlui-cmt-thread__action,
		.tlui-cmt-header-btn
	)[data-state='open'] {
	color: var(--tl-color-text-1);
}
.tlui-button:is(
		.tlui-cmt-icon-btn,
		.tlui-cmt-thread__action,
		.tlui-cmt-header-btn
	)[data-state='open']::after {
	background: var(--tl-muted-gradient-to-bottom);
	opacity: 1;
}
.tlui-cmt-thread__resolved {
	margin: 4px 12px;
	padding: 6px 10px;
	border-radius: 8px;
	background: var(--tl-color-muted-2);
	font-size: 12px;
	color: var(--tl-color-text-3);
}
.tlui-cmt-thread__list {
	display: flex;
	flex-direction: column;
	gap: var(--tlui-cmt-thread-gap);
}
/* When nothing follows the list (a resolved thread has no composer or footer) the last comment
   would sit against the panel's rounded bottom — restore the trailing inset the composer supplies. */
.tlui-cmt-thread__list:last-child {
	padding-bottom: 12px;
}
/* The footer slot sits where the composer would — its content (e.g. a sign-in prompt) sits at
   the thread's trailing edge, like the composer's send button. */
.tlui-cmt-thread__footer {
	display: flex;
	justify-content: flex-end;
	padding: 4px 2px 2px;
}
/* Inside a thread, author identity is a small colour dot, no initial — the letter doesn't fit
   at this size. */
.tlui-cmt-thread .tlui-cmt-avatar,
.tlui-cmt-canvas-preview--thread .tlui-cmt-avatar,
.tlui-cmt-canvas-preview--list .tlui-cmt-avatar,
.tlui-cmt-stack-list .tlui-cmt-avatar,
.tlui-cmt-list .tlui-cmt-avatar {
	width: 12px;
	height: 12px;
	font-size: 0;
}

.tlui-cmt-thread .tlui-cmt-composer {
	padding: 4px;
}
.tlui-cmt-thread .tlui-cmt-composer .tlui-cmt-avatar {
	display: none;
}

.tlui-cmt-thread .tlui-cmt-avatar--image,
.tlui-cmt-canvas-preview--thread .tlui-cmt-avatar--image,
.tlui-cmt-canvas-preview--list .tlui-cmt-avatar--image,
.tlui-cmt-stack-list .tlui-cmt-avatar--image,
.tlui-cmt-list .tlui-cmt-avatar--image {
	/* Match the 12px colour dot's width so the body's calc(12px + 6px) indent still lines up under
	   the byline name when the author has an image rather than a dot. */
	width: 12px;
	height: 12px;
	margin-top: 0;
}

/* inside the panel, comments are plain content — no surrounding box; the composer's field carries
   its own surface. The hover preview is the same panel without a header, so its comment is laid
   out by the same rule rather than a copy of it. */
.tlui-cmt-thread .tlui-cmt-card,
.tlui-cmt-canvas-preview--thread .tlui-cmt-card {
	width: 100%;
	gap: 0;
	padding: 0 var(--tlui-cmt-thread-padding);
	background: transparent;
	border: none;
}
/* The avatar is a 12px dot, so the body lines up 12px + the head's 6px gap in from the row. */
.tlui-cmt-thread .tlui-cmt-body,
.tlui-cmt-canvas-preview--thread .tlui-cmt-body,
.tlui-cmt-canvas-preview--list .tlui-cmt-body,
.tlui-cmt-stack-list .tlui-cmt-body,
.tlui-cmt-list .tlui-cmt-body {
	padding-left: calc(12px + 6px);
}
/* Line the card actions up with the header actions: flush to the full-width card's right edge (the
   panel edge, under the header's ⋯) and flush on the 40px byline row, so the 40px buttons fill it. */
.tlui-cmt-thread .tlui-cmt-card .tlui-cmt-card__actions {
	top: 0;
	right: 0;
}
/* The byline row is 40px: on the opened thread it fits the action buttons (⋯ menu, react) in its
   corner without the text running underneath; previews and stack lists carry the same height so
   every comment row reads identically, solo or in a stack. */
.tlui-cmt-thread .tlui-cmt-card .tlui-cmt-head,
.tlui-cmt-canvas-preview--thread .tlui-cmt-card .tlui-cmt-head,
.tlui-cmt-canvas-preview--list .tlui-cmt-card .tlui-cmt-head,
.tlui-cmt-stack-list .tlui-cmt-card .tlui-cmt-head,
.tlui-cmt-list__item .tlui-cmt-head {
	min-height: 40px;
}
/* Reserve head room only for buttons that actually rendered (one child / two children) — the count
   is a permissions question (see canModifyComment), not ownership, and empty slots (read-only
   viewers) keep the full row. Sized from the 40px hit areas (4px overlap), minus the card padding
   the right:0 buttons sit over; text stops 4px shy of the visible square. */
.tlui-cmt-thread .tlui-cmt-card:has(.tlui-cmt-card__actions > *) .tlui-cmt-head {
	padding-right: calc(var(--tlui-cmt-thread-action-size) - var(--tlui-cmt-thread-padding));
}
.tlui-cmt-thread .tlui-cmt-card:has(.tlui-cmt-card__actions > * + *) .tlui-cmt-head {
	padding-right: calc(
		2 * var(--tlui-cmt-thread-action-size) - 4px - var(--tlui-cmt-thread-padding)
	);
}

.tlui-cmt-list {
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 0;
}
.tlui-cmt-list__header {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	/* Flush top and right, like the thread popover's header: the 40px buttons' 32px hover squares
	   then sit 4px in from the panel edge, and the title shares the popover's 12px inset. */
	height: 40px;
	padding: 0 0 0 12px;
	border-bottom: 1px solid var(--tl-color-divider);
}
.tlui-cmt-list__header-title {
	font-size: 12px;
	color: var(--tl-color-text);
}

.tlui-cmt-list__header-actions {
	display: flex;
	align-items: center;
}

.tlui-cmt-list__items {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	/* A row's hover wash has no bottom inset, so rows tile; this is the last row's 4px. */
	padding-bottom: 4px;
}
.tlui-cmt-list__empty {
	/* extra 2px at the bottom of the list */
	padding: 12px 12px 14px 12px;
	font-weight: 400;
	font-size: 12px;
	min-height: 40px;
}
.tlui-cmt-list__item {
	position: relative;
	display: flex;
	gap: 10px;
	width: 100%;
	/* No top padding: the 40px byline row supplies the space above the name, as on a thread card.
	   The 6px bottom matches the thread card text's trailing margin, so a row is as tall as a card. */
	padding: 0 12px 6px;
	border: none;
	background: transparent;
	font: inherit;
	text-align: left;
	cursor: pointer;
	/* rows can render as anchors (for open-in-new-tab); keep them looking like list rows */
	color: inherit;
	text-decoration: none;
}
/* The highlight is an inset, rounded wash like tldraw's buttons and menu items — not an
   edge-to-edge band — so a comment row lights up the same way every other interactive row does. */
.tlui-cmt-list__item::after {
	content: '';
	position: absolute;
	inset: 4px 4px 0px 4px;
	border-radius: var(--tl-radius-2);
	pointer-events: none;
}
.tlui-cmt-list__item:hover::after {
	background: var(--tl-color-muted-2);
}
/* Selected sits a step above hover so the open thread's row stays distinguishable while
   pointing at other rows — but only a step: the muted-1 token (10%) reads too heavy here.
   These rows sit on the opaque sidebar panel, so a translucent tint composes safely. */
.tlui-cmt-list__item--selected::after,
.tlui-cmt-list__item--selected:hover::after {
	background: hsl(0, 0%, 0%, 5%);
}
.tl-theme__dark .tlui-cmt-list__item--selected::after,
.tl-theme__dark .tlui-cmt-list__item--selected:hover::after {
	background: hsl(0, 0%, 100%, 5%);
}
/* resolved rows mute their content but keep the "Resolved" marker legible */
.tlui-cmt-list__item[data-resolved] .tlui-cmt-head,
.tlui-cmt-list__item[data-resolved] .tlui-cmt-list__item-preview {
	opacity: 0.55;
}
.tlui-cmt-list__item-body {
	flex: 1;
	min-width: 0;
}
.tlui-cmt-list__item-preview {
	font-size: 12px;
	line-height: 1.4;
	color: var(--tl-color-text-1);
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	/* Long unbroken strings (URLs, mashed keys) wrap onto the clamped lines instead of clipping
	   mid-string — same treatment as the card body. */
	overflow-wrap: anywhere;
}
.tlui-cmt-list__item-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 5px;
	font-size: 11px;
	color: var(--tl-color-text-3);
}
.tlui-cmt-list__item-resolved {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	gap: 3px;
}
/* Block, not flex: an ellipsis only applies to text in a block container, not to a flex item's
   anonymous text. */
.tlui-cmt-list__item-page {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	padding: 1px 6px;
	border-radius: 4px;
}
/* Same alignment as the reactions row; only when it leads, since "Resolved" has no padding. */
.tlui-cmt-list__item-page:first-child {
	margin-left: -6px;
}
.tlui-cmt-list__item-replies {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
}
.tlui-cmt-card__replies {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: var(--tl-color-text-3);
}
/* The comments layer renders through `EditorPortal`, so its pieces can pick their own layer rather
   than the one the component is mounted in. Pins live in the canvas-in-front layer (beneath the UI
   panels at z-index 300), so the toolbar and style panel draw over them; the open thread's popover
   goes to the menus layer instead (`.tlui-cmt-canvas-popover`) so it isn't clipped. Click-through
   except on its own children. */
.tlui-cmt-canvas-layer {
	position: absolute;
	inset: 0;
	/* Just below the collaborator cursor layer, so cursors ride over the pins — and below the
	   in-front content (250), so active tool UI covers both. Derived, not a literal, so the
	   ordering can't silently drift if the cursor slot moves. */
	z-index: calc(var(--tl-layer-collaborators) - 5);
	pointer-events: none;
}

.tlui-cmt-canvas-pin,
.tlui-cmt-canvas-cluster,
.tlui-cmt-canvas-composer {
	position: absolute;
}

.tlui-cmt-canvas-composer {
	pointer-events: auto;
}

/* The pin's only interactive surface is the square hit layer below — the wrapper itself is
   inert. Its box sits at the anchor point, not over the (translated) visual, so letting it take
   events would put a phantom hit zone beside the pin. */
.tlui-cmt-canvas-pin {
	pointer-events: none;
}

.tlui-cmt-button {
	appearance: none;
	margin: 0;
	padding: 0;
	border: none;
	background: none;
	color: inherit;
	font: inherit;
}

/* Anchored by its bottom-left corner like a pin, so the badge sits up-and-right of the cluster's
   centroid — the same visual-to-anchor relationship a single comment pin has. */
.tlui-cmt-canvas-cluster {
	transform: translate(0, -100%);
	pointer-events: auto;
	cursor: pointer;
}

/* Keyboard focus has to be visible on the canvas, where there's no surrounding chrome to imply
   it. The ring goes on the marker visual (the rounded pin/badge), not the button box, so it
   traces the shape rather than a rectangle around it; the button's own outline is suppressed
   because its box is offset from what you see. */
.tlui-cmt-canvas-pin__marker:focus-visible,
.tlui-cmt-canvas-cluster:focus-visible {
	outline: none;
}
.tlui-cmt-canvas-pin__marker:focus-visible .tlui-cmt-marker,
.tlui-cmt-canvas-cluster:focus-visible .tlui-cmt-marker {
	outline: 2px solid var(--tl-color-selected);
	outline-offset: 2px;
}

.tlui-cmt-cluster-fade {
	opacity: 1;
	transition: opacity 150ms ease;
}

.tlui-cmt-cluster-fade--entering {
	opacity: 0;
}

.tlui-cmt-cluster-fade--present {
	opacity: 1;
}

.tlui-cmt-cluster-fade--exiting {
	opacity: 0;
}

.tlui-cmt-cluster-fade--entering *,
.tlui-cmt-cluster-fade--exiting * {
	pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.tlui-cmt-cluster-fade {
		transition: none;
	}
}

/* The open thread (its pin + popover) sits above the other pins, so nearby markers don't
   overlap its popover — they tuck behind it. */
.tlui-cmt-canvas-pin--open {
	z-index: 1;
}
/* A pin being dragged rides over everything it passes, the open thread's pin included. */
.tlui-cmt-canvas-pin--dragging {
	z-index: 2;
}

/* The count badge standing in for a stack of coincident pins — same face as a cluster badge,
   but clicking opens the stack's thread list rather than zooming (no zoom can separate them).
   Re-enables pointer events: the badge lives inside `.tlui-cmt-canvas-pin`, which is inert
   (`pointer-events: none`) so its box doesn't shadow the canvas — without this the badge renders
   but can't be hovered or clicked, like the cluster badge's own `pointer-events: auto`. */
.tlui-cmt-canvas-stack-badge {
	/* Bottom-left anchored like the pins it stands in for, and like the cluster badge. */
	transform: translate(0, -100%);
	width: max-content;
	pointer-events: auto;
	cursor: pointer;
}

.tlui-cmt-canvas-stack-badge:focus-visible {
	outline: none;
}
.tlui-cmt-canvas-stack-badge:focus-visible .tlui-cmt-marker {
	outline: 2px solid var(--tl-color-selected);
	outline-offset: 2px;
}

/* The stack's popover content: one card per thread, the expanded thread inline among them. */
.tlui-cmt-stack-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* The expanded thread is the only entry with pills floating above its panel — its header actions,
   and its first comment's hover actions. Those reach ~15px up, past the list's 10px gap, so give
   this one entry extra room: without it the pills land on the card above, and against the scroll
   box's clip edge. Collapsed cards keep their own actions inside, so they need none of this. */
.tlui-cmt-stack-list__thread {
	margin-top: 8px;
}

/* Collapsed entries match the expanded thread's surface (same width, panel, elevation) so the
   list reads as one column of cards with one of them opened up. */
.tlui-cmt-stack-list__card {
	box-sizing: border-box;
	position: relative;
	width: 300px;
	background: var(--tl-color-panel);
	border-radius: 12px;
	box-shadow: var(--tl-shadow-3);
	padding: 2px 12px 10px;
	cursor: pointer;
	text-align: left;
	display: block;
}

/* The card's keyboard affordance, covering the whole surface so it's one target rather than a
   control tucked in a corner. It's laid under the card's content instead of wrapping it: a comment
   body renders its links as anchors, which can't be nested inside a button (see the note in
   `StackThreadCard`). Pointer clicks anywhere still reach the card's own handler by bubbling. */
.tlui-cmt-stack-list__card-action {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	cursor: pointer;
}

.tlui-cmt-stack-list__card-action:focus-visible {
	outline: 2px solid var(--tl-color-selected);
	outline-offset: 2px;
}

/* The wrapper is the card's surface — inside it the comment is plain content, mirroring how the
   thread panel flattens its own cards. Stacked above the action overlay so the body's links stay
   clickable. */
.tlui-cmt-stack-list__card .tlui-cmt-card {
	position: relative;
	width: 100%;
	gap: 0;
	padding: 0;
	background: transparent;
	border: none;
}

/* The hover preview, shown for any marker — a pin, a coincident stack, or a cluster badge. Live,
   not a tooltip: the pointer travels into it to hover and click the cards.

   Two elements, deliberately: this root is the hover *region* (it reaches back over the marker via
   the bridge below), and `__panel` inside it is the visible surface. A pseudo-element's hover
   counts as its host's, so a surface on this root would light up whenever the pointer was on the
   marker — the pin would appear pressed just for being hovered. */
.tlui-cmt-canvas-preview {
	position: absolute;
	z-index: var(--tl-layer-menus);
	pointer-events: auto;
}

/* The bridge over the gap between the marker and the panel. Moving right off the pin would
   otherwise cross bare canvas, and that leave would retract the panel before the pointer arrived.
   Invisible, part of the panel's hover region, and only present while the panel is.

   It spans the gap and stops there. Reaching any further would put it over the marker itself, and
   since it sits in the menus layer — above the pins — it would take the marker's hover and clicks:
   the pin would go dead exactly where it looks most alive. The marker needs no covering anyway, as
   it carries the same hover handlers.

   The gap is the panel's own offset (`--tlui-cmt-preview-offset`, set from `POPOVER_OFFSET` so
   there's one source) less however far the marker reaches toward it, per variant below. */
.tlui-cmt-canvas-preview::before {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	right: 100%;
	width: max(0px, var(--tlui-cmt-preview-bridge, 0px));
}

/* A pin is anchored at its bottom-left corner, so its full width lies between anchor and panel.
   The popover and preview share a first-comment position now that the actions float outside the
   panel rather than reserving a header row, so no vertical shift is needed. */
.tlui-cmt-canvas-preview--thread {
	--tlui-cmt-preview-bridge: calc(var(--tlui-cmt-preview-offset) - var(--tlui-cmt-pin-size));
}

/* A badge is anchored at its bottom-left corner like a pin, so its full width does too. */
.tlui-cmt-canvas-preview--list {
	--tlui-cmt-preview-bridge: calc(var(--tlui-cmt-preview-offset) - var(--tlui-cmt-marker-size));
}

.tlui-cmt-canvas-preview__panel {
	display: flex;
	flex-direction: column;
}

/* Previewing a single pin: the thread panel itself, minus the header — the same surface, width,
   and flattened comment (see `.tlui-cmt-thread .tlui-cmt-card`), so the hover shows exactly what
   the click opens. */
.tlui-cmt-canvas-preview__panel--thread {
	box-sizing: border-box;
	width: 300px;
	gap: var(--tlui-cmt-thread-gap);
	/* Top/bottom only — the card pads its own sides now (12px), matching the expanded thread. A
	   little extra below so the (often truncated) last line doesn't sit against the rounded edge. */
	padding: 4px 0 8px;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-4);
	box-shadow: var(--tl-shadow-3);
}
/* The reply count is a short line that sits closer to the edge than a wrapped comment does, so give
   it more room below when it's the panel's last line. */
.tlui-cmt-canvas-preview__panel--thread:has(.tlui-cmt-card__replies) {
	padding-bottom: 12px;
}

/* Previewing a stack or cluster: one card per thread, matching the card list a click opens. */
.tlui-cmt-canvas-preview__panel--list {
	gap: 8px;
	padding: 4px 0 8px;
}

/* Matches the stack list's card surface, so a preview and the list it previews read as the same
   object seen twice — once on hover, once opened. */
.tlui-cmt-preview-card {
	box-sizing: border-box;
	width: 300px;
	background: var(--tl-color-panel);
	border-radius: 12px;
	box-shadow: var(--tl-shadow-3);
	/* A 2px nudge above the byline's centring — a boxed card reads a touch better with it than the
	   single preview's flat card, which pads 0 vertically and leans on the panel + byline. */
	padding: 2px 12px 10px;
}

.tlui-cmt-preview-card--selectable {
	cursor: pointer;
}

/* Every card surface that highlights on hover — a collapsed thread in a stack list, a preview
   card, and the single-comment preview panel. One rule, because they're the same object to the eye.
   The highlight is an inset, rounded wash like a menu item's, not a tint of the whole surface: the
   card stays panel-white and a wash sits 4px inside its edge, its corners following the card's.
   It paints behind the content (`isolation` keeps the -1 z-index above the card's own fill). */
.tlui-cmt-stack-list__card,
.tlui-cmt-preview-card--selectable,
.tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable {
	position: relative;
	isolation: isolate;
}
.tlui-cmt-stack-list__card::after,
.tlui-cmt-preview-card--selectable::after,
.tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable::after {
	content: '';
	position: absolute;
	inset: 4px;
	z-index: -1;
	/* The cards' 12px radius, less the inset. */
	border-radius: 8px;
	pointer-events: none;
}
.tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable::after {
	border-radius: calc(var(--tl-radius-4) - 4px);
}
.tlui-cmt-stack-list__card:hover::after,
.tlui-cmt-preview-card--selectable:hover::after,
.tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable:hover::after {
	background: var(--tl-color-muted-2);
}
.tlui-cmt-stack-list__card:hover,
.tlui-cmt-preview-card--selectable:hover,
.tlui-cmt-canvas-preview__panel--thread.tlui-cmt-canvas-preview__panel--selectable:hover {
	cursor: pointer;
}

.tlui-cmt-preview-card .tlui-cmt-card {
	width: 100%;
	gap: 0;
	padding: 0;
	background: transparent;
	border: none;
}

/* A preview is a glance, not a list — past a few cards it says how many were left out rather than
   growing to the height of the cluster. */
.tlui-cmt-preview-more {
	box-sizing: border-box;
	width: 300px;
	padding: 6px 14px;
	border-radius: 12px;
	background: var(--tl-color-panel);
	box-shadow: var(--tl-shadow-3);
	color: var(--tl-color-text-3);
	font-size: 12px;
}

@media (prefers-reduced-motion: no-preference) {
	.tlui-cmt-canvas-preview {
		animation: tlui-cmt-preview-in 120ms ease;
	}
	@keyframes tlui-cmt-preview-in {
		from {
			opacity: 0;
		}
		to {
			opacity: 1;
		}
	}
}

/* A region anchor's area: a dashed box under the pins, non-interactive so canvas events pass
   through. Drawn for the live drag draft and for a region thread while hovered or open. */
.tlui-cmt-canvas-region {
	position: absolute;
	pointer-events: none;
	background: color-mix(in srgb, var(--tl-color-selected) 10%, transparent);
}
.tlui-cmt-canvas-region__outline {
	position: absolute;
	inset: 0;
	overflow: visible;
	fill: none;
	stroke: var(--tl-color-selection-stroke);
	stroke-width: 1.5px;
	stroke-linecap: round;
}

.tlui-cmt-canvas-region-handles {
	display: contents;
}

/* Corner resize handles on a region box (three corners; the pin corner is the move handle). The
   element is the hit square, sized from the selection's corner hit area (see
   `selectionCornerSizing`); the visible square is drawn like a selection corner: an 8px fill with a
   1.5px stroke centred on its edge. */
.tlui-cmt-canvas-region-handle {
	position: absolute;
	transform: translate(-50%, -50%);
	pointer-events: auto;
	touch-action: none;
}
.tlui-cmt-canvas-region-handle::before {
	content: '';
	position: absolute;
	left: 50%;
	top: 50%;
	/* Not covered by the container's `*` border-box rule, which doesn't match pseudo-elements. */
	box-sizing: border-box;
	width: 9.5px;
	height: 9.5px;
	transform: translate(-50%, -50%);
	background: var(--tl-color-background);
	border: 1.5px solid var(--tl-color-selection-stroke);
}

/* Anchor the pin by its bottom-left corner, so the marker's one sharp corner (the pin shape's
   3px bottom-left) points at the exact anchor point. */
.tlui-cmt-canvas-pin__marker {
	position: relative;
	width: max-content;
	transform: translate(0, -100%);
	/* Default at rest, like hovering a shape; the editor's move cursor while dragging (below). */
	cursor: var(--tl-cursor-default);
	touch-action: none;
	pointer-events: none;
}

/* Dragging a pin shows the same move cursor as dragging a shape. */
.tlui-cmt-canvas-pin--dragging .tlui-cmt-canvas-pin__marker {
	cursor: var(--tl-cursor-move);
}

/* The predictable hit area: a fixed square over the marker's box, and the only part of the pin
   that takes pointer events. Events over it target the marker (a pseudo-element's events report
   its originating element), so the marker's handlers and :hover keep working — but the hit area
   no longer stretches with pin content or scales with the hover transform. */
.tlui-cmt-canvas-pin__marker::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: auto;
}

/* With the hit layer targeting the marker, the pin visual is never the hovered element itself
   (`:hover` matches the target and its ancestors, and the pin is the marker's child) — so the
   canvas pin's hover has to key off the hit layer instead of the marker's own `:hover`. Only the
   selector differs: the values come from the same tokens the shared rule uses, so a pin on the
   canvas and a badge (which is hovered directly) lift by exactly the same amount. */
.tlui-cmt-canvas-pin__marker:hover .tlui-cmt-marker {
	transform: scale(var(--tlui-cmt-marker-hover-scale));
}
.tlui-cmt-canvas-pin__marker:hover .tlui-cmt-marker:not(.tlui-cmt-marker--open) {
	box-shadow: var(--tlui-cmt-marker-shadow-hover);
}
/* The comment pin doesn't scale on hover — only the shadow lifts (badges still scale). */
.tlui-cmt-canvas-pin__marker:hover .tlui-cmt-pin {
	transform: none;
}

/* The open thread's popover — portaled to the menus layer (above the UI), positioned at the pin. */
.tlui-cmt-canvas-popover {
	position: absolute;
	z-index: var(--tl-layer-menus);
	pointer-events: auto;
}

/* The placement composer — a distinct floating view (portaled to the menus layer, below the click
   point): a draft avatar pin beside a pill field that is itself the surface (no wrapping panel).
   Scoped here so the in-thread reply composer keeps its own squarer look. */
.tlui-cmt-canvas-composer {
	position: absolute;
	z-index: var(--tl-layer-menus);
	pointer-events: auto;
	/* Anchor the draft avatar bottom-left like the pins it becomes: it is a pin wide and sits 4px
	   into the row, so its bottom-left corner is 4px right of and 4px + a pin below the composer's
	   top-left corner. */
	transform: translate(-4px, calc(-4px - var(--tlui-cmt-pin-size)));
}

/* A region placement centres the draft avatar on the region's pin corner — the pin it becomes
   straddles that corner. The avatar's centre sits 4px + half a pin into the composer. */
.tlui-cmt-canvas-composer--region {
	--tlui-cmt-draft-avatar-centre: calc(4px + var(--tlui-cmt-pin-size) / 2);
	transform: translate(
		calc(-1 * var(--tlui-cmt-draft-avatar-centre)),
		calc(-1 * var(--tlui-cmt-draft-avatar-centre))
	);
}

/* Fallback placement (no composer to show): no draft avatar to anchor by, so no offset — a small
   panel hanging off the click point, sized to its content (e.g. the host's sign-in prompt). */
.tlui-cmt-canvas-composer--fallback {
	transform: none;
	width: auto;
	display: flex;
	flex-direction: column;
	padding: 8px;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-4);
	box-shadow: var(--tl-shadow-3);
}
.tlui-cmt-canvas-composer .tlui-cmt-composer {
	gap: 6px;
}
/* The card: a fixed 300×42 surface whose uniform 3px padding derives the 294×36 focusable input. */
.tlui-cmt-canvas-composer .tlui-cmt-composer__field {
	position: relative;
	flex: none;
	width: 300px;
	min-height: 42px;
	padding: 3px;
	border: none;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-3);
	box-shadow: var(--tl-shadow-2);
	/* The pin is anchored by its bottom corner at the click point and can't move; raise the taller
	   card onto the shorter pin's centre instead. */
	margin-top: -6px;
}
/* Focused (the placement composer autofocuses on mount): a selection-blue ring inset 3px from the
   card edge, so the card frames a bordered input rather than the border sitting on the card edge. */
.tlui-cmt-canvas-composer .tlui-cmt-composer__field:focus-within::before {
	content: '';
	position: absolute;
	inset: 3px;
	border: 1px solid var(--tl-color-selected);
	border-radius: var(--tl-radius-2);
	pointer-events: none;
}
/* The text sits 12px in from the focus ring rather than against it. The placeholder is absolutely
   positioned (it ignores the wrap's padding), so it carries the same offset itself. */
.tlui-cmt-canvas-composer .tlui-cmt-composer__input-wrap {
	padding: 4.5px 12px;
}
.tlui-cmt-canvas-composer .tlui-cmt-composer__field--expanded .tlui-cmt-composer__input-wrap {
	/* The base expanded rule re-pads the right edge for the squarer composer's geometry; here the
	   12px is already symmetric. */
	padding-right: 12px;
	/* Collapsed, the 26px wrap is centred in the 36px input, 5px below its top. Expanded, the wrap
	   starts the first flex line, so without the extra 5px the text jumps up as it starts to wrap. */
	padding-top: 9.5px;
}
.tlui-cmt-canvas-composer .tlui-cmt-input__placeholder {
	left: 12px;
}
/* The draft avatar previews the pin it becomes and is the draft's drag handle. It keeps a 40×40 hit
   area (the ::after below). */
.tlui-cmt-canvas-composer .tlui-cmt-pin {
	position: relative;
	box-shadow: var(--tl-shadow-2);
	cursor: default;
}
.tlui-cmt-canvas-composer__handle {
	touch-action: none;
}
.tlui-cmt-canvas-composer--dragging .tlui-cmt-canvas-composer__handle,
.tlui-cmt-canvas-composer--dragging .tlui-cmt-pin {
	cursor: var(--tl-cursor-move);
}
.tlui-cmt-canvas-composer .tlui-cmt-pin::after {
	content: '';
	position: absolute;
	inset: -6px;
}
.tlui-cmt-canvas-composer .tlui-cmt-pin:hover {
	transform: none;
	box-shadow: var(--tl-shadow-2);
}
/* The placement composer's send button — a bare arrow, no pill: grey while empty, black once
   there's something to send. A 28px square centred in the 36px input height, so its hover wash
   clears the focus ring rather than butting against it; the ::after keeps a 40×40 hit area. */
.tlui-cmt-canvas-composer .tlui-cmt-send {
	position: relative;
	width: 28px;
	height: 28px;
	margin-right: 4px;
	background: transparent;
	border-radius: var(--tl-radius-2);
	color: var(--tl-color-text-3);
}
.tlui-cmt-canvas-composer .tlui-cmt-send::after {
	content: '';
	position: absolute;
	inset: -6px;
}
.tlui-cmt-canvas-composer .tlui-cmt-send:not(:disabled) {
	color: var(--tl-color-text-1);
}
/* Hover and press wash grey behind the bare arrow (the same treatment as the thread actions),
   overriding the base button's blue fill. */
.tlui-cmt-canvas-composer .tlui-cmt-send:hover:not(:disabled) {
	background: var(--tl-color-muted-2);
}
.tlui-cmt-canvas-composer .tlui-cmt-send:active:not(:disabled) {
	background: var(--tl-color-muted-1);
}
/* In the expanded (multi-line) layout the send drops to the bottom-right corner; give it the same
   4px gap from the focus ring on the bottom that it already keeps on the right. */
.tlui-cmt-canvas-composer .tlui-cmt-composer__field--expanded .tlui-cmt-send {
	margin-bottom: 4px;
}

/* The comments list panel — a right-side surface shown while the comments sidebar is open. Below
   the popover layer, so an open thread still draws over it. Its top aligns flush with the style
   panel (48px from the top, clearing the share panel) and it sizes to its content, scrolling past
   max-height rather than stretching the full canvas height. */
.tlui-cmt-canvas-sidebar {
	position: absolute;
	top: 48px;
	right: 8px;
	width: 280px;
	max-height: calc(100% - 56px);
	z-index: var(--tl-layer-panels);
	pointer-events: auto;
	display: flex;
	background: var(--tl-color-panel);
	border-radius: var(--tl-radius-4);
	box-shadow: var(--tl-shadow-3);
	overflow: hidden;
}
