/* The frame of the signed-in pages: the sidebar's cards, the page area, the phone top bar, menus, dialogs, toasts
   (taken from GeoI's chat.css, 2026-10-14). */
:root {
	--chat-bg: #ffffff;
	--sb-bg: #f9fafb;
	--menu-shadow: 0 10px 30px rgb(0 0 0 / 0.12), 0 1px 3px rgb(0 0 0 / 0.08);
	--sb-width: 320px;
	--sb-card-bg: #fcfcfd;
	--sb-card-shadow: 0 2px 6px rgb(0 0 0 / 0.04), 0 1px 2px rgb(0 0 0 / 0.03);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--chat-bg: #111827;
		--sb-bg: #0c111d;
		--menu-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
		--sb-card-bg: #182131;
		--sb-card-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
	}
}

:root[data-theme="dark"] {
	--chat-bg: #111827;
	--sb-bg: #0c111d;
	--menu-shadow: 0 10px 30px rgb(0 0 0 / 0.5);
	--sb-card-bg: #182131;
	--sb-card-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}

/* ---- shell ---- */

.shell {
	display: flex;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	background: var(--chat-bg);
}

.shell-main {
	position: relative; /* the leaving view sits on top while it goes (components/shell.js) */
	display: flex;
	flex: 1;
	min-width: 0;
	overflow: hidden;
}

.icon-btn {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: var(--radius);
	background: none;
	color: var(--muted);
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}

.icon-btn:hover:not(:disabled) {
	background: var(--surface-2);
	color: var(--text-strong);
}

.icon-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.icon-btn-sm {
	width: 28px;
	height: 28px;
}

/* ---- sidebar ---- */

.sb {
	display: flex;
	flex: none;
	flex-direction: column;
	gap: 10px;
	width: var(--sb-width);
	height: 100%;
	padding: 10px 0 10px 10px;
	background: var(--chat-bg);
	transition: margin-left 0.3s var(--ease);
}

html.sb-collapsed .sb {
	margin-left: calc(-1 * var(--sb-width) - 1px);
}

/* each part of the sidebar floats as a rounded card, like the composer */
.sb-card {
	flex: none;
	border: 1px solid var(--border);
	border-radius: 18px;
	background: var(--sb-card-bg);
	box-shadow: var(--sb-card-shadow);
}

.sb-top {
	padding-bottom: 6px;
}

.sb-convs {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-height: 0;
	overflow: hidden;
}

.sb-pages {
	padding: 6px;
}

.sb-page {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 10px;
	color: var(--text);
	text-decoration: none;
}

.sb-page:hover {
	background: var(--surface-2);
}

.sb-page svg {
	color: var(--muted);
}

.sb-page .mfd {
	display: flex; /* the icon and its memory-full dot, no baseline gap */
}

.sb-head {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 14px 16px;
}

.sb-app {
	min-width: 0;
	font-size: calc(24px * var(--ui-scale));
	font-weight: 600;
	line-height: 1.25;
	color: var(--text-strong);
}

/* text too long for one line at this size (up to 15 characters): two even, centred lines instead of an ellipsis */
.sb-app.brand-text {
	text-align: center;
	white-space: normal;
	overflow-wrap: anywhere;
	text-wrap: balance;
}

.sb-actions {
	padding: 2px 6px;
}

/* no logo or text above it: as much room above 「新聊天」 as around the other button cards */
.sb-top > .sb-actions:first-child {
	padding-top: 6px;
}

/* ---- the admin's logo or text (lib/branding.js); the logo shows the picture for the current theme ---- */

.brand-text {
	overflow: hidden;
	font-weight: 500;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.brand-text.is-bold {
	font-weight: 700;
}

.brand-text.is-italic {
	font-style: italic;
}

.brand-text.is-underline {
	text-decoration: underline;
	text-decoration-thickness: 0.08em;
	text-underline-offset: 0.18em;
}

.brand-logo {
	display: inline-flex;
	align-items: center;
	min-width: 0;
	max-width: 100%;
}

.brand-logo img {
	display: block;
	max-width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: left center;
}

.brand-logo-dark {
	display: none !important;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .brand-logo-light {
		display: none !important;
	}

	:root:not([data-theme="light"]) .brand-logo-dark {
		display: block !important;
	}
}

:root[data-theme="dark"] .brand-logo-light {
	display: none !important;
}

:root[data-theme="dark"] .brand-logo-dark {
	display: block !important;
}

.sb-app.brand-logo {
	justify-content: center;
	height: 56px;
}

.sb-app.brand-logo img {
	object-position: center;
}

/* the picture logo is a way to a new chat: no link look, a small press */
.sb-brand-link {
	display: flex;
	justify-content: center;
	min-width: 0;
	max-width: 100%;
	border-radius: 10px;
	text-decoration: none;
	transition: transform 120ms ease;
	-webkit-user-drag: none;
}

.sb-brand-link:active {
	transform: scale(0.96);
}

.sb-brand-link:focus-visible {
	outline: 2px solid var(--border-strong);
	outline-offset: 4px;
}

.chat-top-brand.brand-logo {
	justify-content: center;
	height: calc(1.3em + 1px);
	vertical-align: top;
}

.chat-top-brand.brand-logo img {
	object-position: center;
}

.sb-new {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: 10px;
	color: var(--text);
	font-weight: 500;
	text-decoration: none;
}

.sb-new:hover {
	background: var(--surface-2);
}

.sb-list {
	flex: 1;
	overflow-y: auto;
	padding: 0 6px 8px;
}

.sb-group {
	padding: 14px 10px 4px;
	font-size: calc(12px * var(--ui-scale));
	color: var(--faint);
}

.sb-empty {
	padding: 12px 10px;
	color: var(--faint);
}

.sb-item {
	display: flex;
	align-items: center;
	border-radius: var(--radius);
}

.sb-item:hover,
.sb-item.is-current {
	background: var(--surface-2);
}

.sb-item-link {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 6px;
	min-width: 0;
	padding: 7px 4px 7px 10px;
	color: var(--text);
	font-weight: 400;
	text-decoration: none;
}

.sb-item-title {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sb-dot {
	flex: none;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #3c78d8;
	animation: pulse 1.2s ease-in-out infinite;
}

.sb-item-more {
	width: 28px;
	height: 28px;
	margin-right: 2px;
	opacity: 0;
}

.sb-item:hover .sb-item-more,
.sb-item-more[aria-expanded="true"],
.sb-item-more:focus-visible {
	opacity: 1;
}

@media (hover: none) {
	.sb-item.is-current .sb-item-more {
		opacity: 1;
	}
}

.sb-expand {
	position: fixed;
	top: 10px;
	left: 10px;
	z-index: 5;
	display: none;
	background: var(--chat-bg);
}

html.sb-collapsed .sb-expand {
	display: inline-flex;
}

.sb-backdrop {
	display: none;
}

/* phones and narrow windows: the sidebar is a drawer */
@media (max-width: 767px) {
	.sb {
		position: fixed;
		inset: 0 auto 0 0;
		z-index: 30;
		width: min(86vw, var(--sb-width));
		margin-left: 0 !important;
		padding-right: 10px;
		background: transparent; /* the cards float over the dimmed page */
		transform: translateX(-102%);
		transition: transform 0.3s var(--ease);
	}

	html.sb-drawer-open .sb {
		transform: none;
	}

	.sb-backdrop {
		position: fixed;
		inset: 0;
		z-index: 29;
		display: block;
		background: rgb(0 0 0 / 0.35);
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.3s;
	}

	html.sb-drawer-open .sb-backdrop {
		opacity: 1;
		pointer-events: auto;
	}

	.sb-collapse,
	.sb-expand,
	html.sb-collapsed .sb-expand {
		display: none;
	}
}

/* ---- the phone top bar: menu · title · (the account) ---- */

.page-top {
	display: none;
}

@media (max-width: 767px) {
	.page-top {
		display: grid;
		flex: none;
		grid-template-columns: 38px minmax(0, 1fr) 38px;
		grid-template-rows: 38px;
		align-items: center;
		gap: 8px;
		padding: 8px 8px 4px;
	}

	.page-top-btn {
		justify-self: center;
		width: 34px;
		height: 34px;
		border: 1px solid var(--border);
		border-radius: 50%;
		background: var(--sb-card-bg);
		color: var(--text);
	}
}

.page-top-title {
	justify-self: stretch;
	overflow: hidden;
	padding: 7px 14px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--sb-card-bg);
	font-weight: 500;
	line-height: 1.3;
	text-align: center;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---- avatars ---- */

.user-avatar {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	color: #fff;
	font-weight: 500;
	line-height: 1;
	user-select: none;
}

.user-avatar-img {
	object-fit: cover;
	background: var(--surface-2);
}

/* ---- menus, dialogs, toasts ---- */

.menu {
	position: fixed;
	z-index: 50;
	min-width: 180px;
	max-width: min(320px, calc(100vw - 16px));
	max-height: 320px;
	padding: 4px;
	overflow-y: auto;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
	box-shadow: var(--menu-shadow);
}

.menu-fade {
	animation: menu-in 0.12s ease-out;
}

.menu-leaving {
	opacity: 0;
	transition: opacity 0.12s;
}

@keyframes menu-in {
	from {
		opacity: 0;
		transform: scale(0.97);
	}
}

.menu-item {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 32px;
	padding: 0 8px;
	border: 0;
	border-radius: var(--radius);
	background: none;
	font-size: calc(14px * var(--ui-scale));
	text-align: left;
	cursor: pointer;
}

.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
	background: var(--surface-2);
	outline: none;
}

.menu-item:disabled {
	opacity: 0.5;
	cursor: default;
}

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

.menu-icon {
	display: inline-flex;
	color: var(--muted);
}

.menu-item-danger .menu-icon {
	color: inherit;
}

.menu-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.menu-label-row {
	display: flex;
	flex: 1;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.menu-label-row .menu-label {
	flex: 0 1 auto;
}

.menu-check {
	display: inline-flex;
	color: var(--muted);
}

.menu-hint {
	padding: 4px 8px 6px;
	font-size: calc(11px * var(--ui-scale));
	color: var(--muted);
}

.menu-sep {
	height: 1px;
	margin: 4px 0;
	background: var(--border);
}

.modal-backdrop {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgb(0 0 0 / 0.4);
	animation: fade-in 0.15s;
}

.modal-leaving {
	opacity: 0;
	transition: opacity 0.15s;
}

@keyframes fade-in {
	from {
		opacity: 0;
	}
}

.modal {
	width: min(440px, 100%);
	padding: 24px;
	border-radius: var(--radius-lg);
	background: var(--surface);
	box-shadow: var(--menu-shadow);
}

.modal-title {
	margin: 0 0 12px;
	font-size: calc(18px * var(--ui-scale));
	font-weight: 600;
	color: var(--text-strong);
}

.modal-body {
	margin: 0 0 16px;
	color: var(--muted);
}

.modal-check {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
	color: var(--muted);
}

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

.btn-danger-solid {
	background: var(--danger);
	color: #fff;
}

.btn-danger-solid:hover {
	filter: brightness(0.92);
}

.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	z-index: 70;
	max-width: min(480px, calc(100vw - 32px));
	padding: 10px 16px;
	border-radius: 12px;
	background: var(--text-strong);
	color: var(--bg);
	box-shadow: var(--menu-shadow);
	transform: translateX(-50%);
	animation: fade-in 0.2s;
}

.toast-leaving {
	opacity: 0;
	transition: opacity 0.3s;
}

/* ---- display settings (data-* on <html>, from the user's settings) ---- */

html[data-sidebar-width="narrow"] {
	--sb-width: 260px;
}

html[data-sidebar-width="wider"] {
	--sb-width: 380px;
}

/* the sidebar's edge switch (desktop): a bookmark tab or a thin handle in place of the buttons */
.sb-edge {
	display: none;
}

@media (min-width: 768px) {
	html:not([data-sidebar-toggle="none"]) .sb-collapse,
	html:not([data-sidebar-toggle="none"]).sb-collapsed .sb-expand {
		display: none;
	}

	html[data-sidebar-toggle="tab"] .sb-edge,
	html[data-sidebar-toggle="handle"] .sb-edge {
		position: fixed;
		top: 50%;
		left: var(--sb-width);
		z-index: 6;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 0;
		border: 0;
		color: var(--muted);
		cursor: pointer;
		transform: translateY(-50%);
		transition:
			left 0.3s var(--ease),
			width 0.15s,
			background 0.15s,
			transform 0.42s var(--ease),
			opacity 0.3s var(--ease);
	}

	/* a settings card stands in for the chats card: the bookmark steps out to the left with it
	   (sidebar.js followDeck moves it along; this is where it stays meanwhile) */
	.sb-wrap.has-panel .sb-edge {
		opacity: 0;
		pointer-events: none;
		translate: calc(-1 * var(--sb-width) - 40px) 0;
		transition: none;
	}

	html.sb-collapsed .sb-edge {
		left: 0 !important;
	}

	html[data-sidebar-toggle="tab"] .sb-edge {
		width: 22px;
		height: 72px;
		border: 1px solid var(--border);
		border-left: 0;
		border-radius: 0 10px 10px 0;
		background: var(--sb-card-bg);
		transform-origin: left center;
	}

	html[data-sidebar-toggle="tab"] .sb-edge:hover {
		color: var(--text-strong);
	}

	html[data-sidebar-toggle="tab"] .sb-edge svg {
		transition: transform 0.3s var(--ease);
	}

	html[data-sidebar-toggle="tab"].sb-collapsed .sb-edge svg {
		transform: rotate(180deg);
	}

	html[data-sidebar-toggle="handle"] .sb-edge {
		width: 14px;
		height: 72px;
		margin-left: 2px;
		background: none;
	}

	html[data-sidebar-toggle="handle"] .sb-edge::before {
		content: "";
		width: 4px;
		height: 44px;
		border-radius: 999px;
		background: var(--border-strong);
		transition: height 0.15s, background 0.15s;
	}

	html[data-sidebar-toggle="handle"] .sb-edge:hover::before {
		height: 60px;
		background: var(--muted);
	}

	html[data-sidebar-toggle="handle"] .sb-edge svg {
		display: none;
	}
}
