/* style.css */
:root {
	--bg: #0f1115;
	--panel: #151924;
	--panel2: #0c0f16;
	--text: #e8e8ea;
	--muted: #a7a7ad;
	--line: #23283a;
	--btn: #1e2434;
	--btn2: #2a3350;
	--danger: #3a1e1e;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
	--radius: 14px;
	--font:
		ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
		'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;
}

* {
	box-sizing: border-box;
}
html,
body {
	height: 100%;
}
body {
	margin: 0;
	font-family: var(--font);
	background: var(--bg);
	color: var(--text);
}

.topbar {
	height: 52px;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 10px;
	border-bottom: 1px solid var(--line);
	background: rgba(15, 17, 21, 0.9);
	backdrop-filter: blur(8px);
	position: sticky;
	top: 0;
	z-index: 10;
}
.brand {
	font-weight: 600;
	letter-spacing: 0.2px;
}
.topbarRight {
	margin-left: auto;
	display: flex;
	gap: 8px;
	align-items: center;
}

.layout {
	display: flex;
	height: calc(100% - 52px);
	min-height: 0;
}

.sidebar {
	width: 280px;
	background: var(--panel);
	border-right: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	min-height: 0;
}
.sidebarHeader {
	padding: 10px;
	border-bottom: 1px solid var(--line);
}
.sidebarSectionTitle {
	padding: 10px 12px 6px;
	font-size: 12px;
	color: var(--muted);
}
.sidebarFooter {
	padding: 10px 12px;
	border-top: 1px solid var(--line);
}
.sessionList {
	padding: 6px;
	overflow: auto;
	min-height: 0;
}

.sessionItem {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 10px;
	border: 1px solid transparent;
	border-radius: 12px;
	cursor: pointer;
}
.sessionItem:hover {
	background: rgba(255, 255, 255, 0.03);
}
.sessionItem.active {
	border-color: var(--line);
	background: rgba(255, 255, 255, 0.04);
}
.sessionTitleRow {
	display: flex;
	gap: 8px;
	align-items: center;
}
.sessionTitle {
	flex: 1;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.sessionMeta {
	font-size: 12px;
	color: var(--muted);
}
.sessionActions {
	display: flex;
	gap: 8px;
}
.smallbtn {
	padding: 6px 8px;
	border-radius: 10px;
	background: var(--btn);
	border: 1px solid var(--line);
	color: var(--text);
	cursor: pointer;
}
.smallbtn:hover {
	background: var(--btn2);
}
.smallbtn.danger {
	background: var(--danger);
}

.main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	background: var(--panel2);
}
.chat {
	flex: 1;
	overflow: auto;
	padding: 14px 12px 10px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.bubble {
	max-width: 880px;
	width: fit-content;
	padding: 10px 12px;
	border-radius: var(--radius);
	border: 1px solid var(--line);
	line-height: 1.45;
	white-space: pre-wrap;
	word-break: break-word;
}
.bubble.user {
	margin-left: auto;
	background: rgba(255, 255, 255, 0.03);
}
.bubble.assistant {
	margin-right: auto;
	background: rgba(255, 255, 255, 0.02);
}
.bubble.meta {
	margin: 0 auto;
	color: var(--muted);
	border-style: dashed;
	background: transparent;
	font-size: 12px;
}

.composer {
	border-top: 1px solid var(--line);
	padding: 10px 10px 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.composerRow {
	display: flex;
	gap: 8px;
	align-items: center;
}
.input {
	flex: 1;
	resize: none;
	padding: 10px 10px;
	border-radius: 14px;
	border: 1px solid var(--line);
	background: #0c0f16;
	color: var(--text);
	outline: none;
	min-height: 42px;
	max-height: 160px;
}
.select {
	padding: 9px 10px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: #0c0f16;
	color: var(--text);
	outline: none;
}
.status {
	font-size: 12px;
}
.muted {
	color: var(--muted);
}
.small {
	font-size: 12px;
}

.btn {
	padding: 9px 12px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: var(--btn);
	color: var(--text);
	cursor: pointer;
}
.btn:hover {
	background: var(--btn2);
}
.btn.primary {
	background: #243154;
}
.btn.primary:hover {
	background: #2b3a66;
}
.iconbtn {
	width: 38px;
	height: 38px;
	border-radius: 12px;
	border: 1px solid var(--line);
	background: var(--btn);
	color: var(--text);
	cursor: pointer;
}
.iconbtn:hover {
	background: var(--btn2);
}

.checkbox {
	display: flex;
	gap: 8px;
	align-items: center;
	user-select: none;
	font-size: 12px;
	color: var(--muted);
}
.checkbox input {
	transform: translateY(1px);
}

.dialog {
	width: min(900px, 92vw);
	border: none;
	padding: 0;
	border-radius: 16px;
	background: var(--panel);
	color: var(--text);
	box-shadow: var(--shadow);
}
.dialog::backdrop {
	background: rgba(0, 0, 0, 0.5);
}
.dialogInner {
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.dialogHeader {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.dialogTitle {
	font-weight: 600;
}
.editor {
	width: 100%;
	height: min(60vh, 520px);
	border-radius: 14px;
	border: 1px solid var(--line);
	background: #0c0f16;
	color: var(--text);
	padding: 10px;
	font-family:
		ui-monospace, SFMono-Regular, Menlo, Consolas, 'Noto Sans Mono',
		monospace;
	font-size: 12px;
	outline: none;
}
.dialogActions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

.settingsGrid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 10px;
}
.settingRow {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
}
.label {
	color: var(--muted);
	font-size: 12px;
}

/* Responsive: narrow screens */
@media (max-width: 860px) {
	.sidebar {
		position: fixed;
		top: 52px;
		left: 0;
		height: calc(100% - 52px);
		z-index: 20;
		transform: translateX(0);
		transition: transform 0.15s ease;
		box-shadow: var(--shadow);
	}
	.sidebar.closed {
		transform: translateX(-105%);
	}
	.layout {
		position: relative;
	}
}

/* Wide: allow collapse to mini */
@media (min-width: 861px) {
	.sidebar.closed {
		width: 0;
		border-right: none;
		overflow: hidden;
	}
}
