/* Deck Tree: up to five link cards above Deck Cards, plus the member editor. */

.tbook-deck-tree {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
	margin-top: 2px;
	padding-top: 13px;
	border-top: 1px dashed var(--td-line);
}

.tbook-deck-tree-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.tbook-deck-tree-head h2 {
	margin: 0;
	color: var(--td-retro-author);
	font-family: 'McLaren', display;
	font-size: 10px;
	font-weight: 400;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.tbook-deck-tree-meta {
	display: flex;
	align-items: center;
	gap: 12px;
}

.tbook-deck-tree-count {
	color: var(--td-muted);
	font-size: 10px;
	font-weight: 700;
}

.tbook-deck-tree-edit {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--td-muted);
	font: inherit;
	font-size: 10px;
	font-weight: 700;
	cursor: pointer;
}

.tbook-deck-tree-edit:hover,
.tbook-deck-tree-edit:focus-visible {
	color: var(--td-retro-author);
	text-decoration: underline;
	outline: none;
}

.tbook-deck-tree-links {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 9px;
}

.tbook-deck-tree-link {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	min-height: 58px;
	padding: 10px 11px;
	border: 1px solid var(--td-line);
	border-radius: 6px;
	background: #fffdf7;
	color: var(--td-ink);
	text-decoration: none;
	box-shadow: 0 1px 0 rgba(58, 79, 102, 0.04);
	transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.tbook-deck-tree-link:nth-child(even) {
	background: #fffaf0;
}

.tbook-deck-tree-link:hover,
.tbook-deck-tree-link:focus-visible {
	border-color: var(--td-retro-green);
	color: var(--td-ink);
	text-decoration: none;
	transform: translateY(-2px);
	box-shadow: 0 7px 16px rgba(58, 79, 102, 0.12);
	outline: none;
}

.tbook-deck-tree-icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	overflow: hidden;
	border-radius: 50%;
	background: var(--td-retro-green-soft);
	color: #3f5a25;
}

.tbook-deck-tree-icon.has-image {
	background: #fff;
}

.tbook-deck-tree-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tbook-deck-tree-link:nth-child(even) .tbook-deck-tree-icon {
	background: var(--td-retro-orange-soft);
	color: #8a4b18;
}

.tbook-deck-tree-text {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tbook-deck-tree-title {
	overflow: hidden;
	color: var(--td-ink);
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.25;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tbook-deck-tree-domain {
	overflow: hidden;
	color: var(--td-muted);
	font-size: 10px;
	line-height: 1.25;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tbook-deck-tree-arrow {
	flex: 0 0 auto;
	margin-left: auto;
	color: var(--td-muted);
	font-size: 14px;
	line-height: 1;
}

.tbook-deck-tree-empty {
	margin: 0;
	padding: 13px 14px;
	border: 1px dashed var(--td-line);
	border-radius: 6px;
	background: rgba(255, 253, 247, 0.7);
	color: var(--td-muted);
	font-size: 12px;
}

/* Editor */
.tbook-dt-modal {
	--td-ink: #3a4f66;
	--td-muted: #64748b;
	--td-line: #dcdcde;
	--td-retro-author: #474747;
	--td-retro-green: #567a2b;
	--td-retro-green-soft: #e2ead8;
	--td-retro-orange-soft: #ebcc89;
	position: fixed;
	inset: 0;
	z-index: 100100;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(20, 30, 42, 0.55);
}

.tbook-dt-modal[hidden] {
	display: none;
}

.tbook-dt-dialog {
	width: min(560px, 100%);
	max-height: calc(100vh - 40px);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: 10px;
	background: #fffdf7;
	box-shadow: 0 24px 60px rgba(20, 30, 42, 0.28);
}

.tbook-dt-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	padding: 18px 20px 14px;
	border-bottom: 1px solid var(--td-line);
}

.tbook-dt-head h2 {
	margin: 0 0 4px;
	color: var(--td-ink);
	font-family: 'McLaren', display;
	font-size: 20px;
	font-weight: 400;
}

.tbook-dt-head p {
	margin: 0;
	color: var(--td-muted);
	font-size: 12px;
}

.tbook-dt-close {
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--td-muted);
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.tbook-dt-body {
	padding: 16px 20px;
	overflow-y: auto;
}

.tbook-dt-row {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	gap: 12px;
	align-items: center;
	margin-bottom: 10px;
	padding: 12px;
	border: 1px solid var(--td-line);
	border-radius: 8px;
	background: #fff;
}

.tbook-dt-icon-edit {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 5px;
}

.tbook-dt-icon-preview {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	overflow: hidden;
	border-radius: 50%;
	background: var(--td-retro-green-soft);
	color: #3f5a25;
}

.tbook-dt-icon-preview.has-image {
	background: #fff;
}

.tbook-dt-icon-preview img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tbook-dt-icon-actions {
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.tbook-dt-icon-btn {
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--td-retro-author);
	font: inherit;
	font-size: 9px;
	text-decoration: underline;
	cursor: pointer;
}

.tbook-dt-icon-btn:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.tbook-dt-fields {
	display: grid;
	grid-template-columns: 1fr 1.25fr;
	gap: 9px;
}

.tbook-dt-fields label {
	display: block;
	color: var(--td-ink);
	font-size: 11px;
	font-weight: 700;
}

.tbook-dt-fields input {
	display: block;
	width: 100%;
	margin-top: 4px;
	padding: 7px 9px;
	border: 1px solid var(--td-line);
	border-radius: 5px;
	background: #fffdf7;
	color: var(--td-ink);
	font: inherit;
	font-size: 12px;
	box-sizing: border-box;
}

.tbook-dt-remove {
	padding: 7px 9px;
	border: 1px solid #e1c9c1;
	border-radius: 5px;
	background: #fff8f5;
	color: #8a3e2b;
	font: inherit;
	font-size: 11px;
	cursor: pointer;
}

.tbook-dt-add {
	width: 100%;
	padding: 9px;
	border: 1px dashed var(--td-line);
	border-radius: 6px;
	background: #fffaf0;
	color: var(--td-retro-author);
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
}

.tbook-dt-add:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.tbook-dt-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 13px 20px;
	border-top: 1px solid var(--td-line);
}

.tbook-dt-status {
	min-height: 16px;
	color: var(--td-muted);
	font-size: 11px;
}

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

.tbook-dt-btn {
	padding: 7px 12px;
	border: 1px solid var(--td-line);
	border-radius: 5px;
	background: #fffdf7;
	color: var(--td-ink);
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
}

.tbook-dt-btn.is-primary {
	border-color: var(--td-retro-green);
	background: var(--td-retro-green);
	color: #fff;
}

.tbook-dt-btn:disabled {
	cursor: wait;
	opacity: 0.65;
}

@media (max-width: 620px) {
	.tbook-deck-tree-links {
		grid-template-columns: 1fr 1fr;
	}
	.tbook-deck-tree-link {
		min-height: 54px;
		padding: 9px;
	}
	.tbook-deck-tree-title {
		font-size: 11.5px;
	}
	.tbook-dt-modal {
		align-items: flex-end;
		padding: 10px;
	}
	.tbook-dt-dialog {
		max-height: calc(100vh - 20px);
	}
	.tbook-dt-fields {
		grid-template-columns: 1fr;
	}
	.tbook-dt-row {
		grid-template-columns: auto minmax(0, 1fr);
	}
	.tbook-dt-row > .tbook-dt-remove {
		grid-column: 2;
	}
	.tbook-dt-remove {
		justify-self: start;
	}
	.tbook-dt-foot {
		flex-wrap: wrap;
	}
}

@media (max-width: 420px) {
	.tbook-deck-tree-links {
		grid-template-columns: 1fr;
	}
}

/* Tree cards keep a light paper surface in every deck theme. */
.tbook-deck-tree-link,
.tbook-deck-tree-link:hover,
.tbook-deck-tree-link:focus-visible,
.tbook-deck-tree-title {
	color: #2f3e4e;
}

.tbook-deck-tree-domain,
.tbook-deck-tree-arrow {
	color: #64748b;
}
