:root {
	--bg: #ffffff;
	--surface: #f7f8fb;
	--card: #ffffff;
	--muted: #6b7280;
	--text: #0f1724;
	--accent: #2563eb;
	--accent-2: #06b6d4;
	--border: #e6e9ef;
	--radius: 12px;
	--font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* {
	box-sizing: border-box
}

html,
body {
	height: 100%
}

body {
	margin: 0;
	background: var(--surface);
	color: var(--text);
	font-family: var(--font-sans);
	-webkit-font-smoothing: antialiased;
	line-height: 1.4;
	min-height: 100%;
}

.container {
	height: 100vh;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.card {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	background: var(--card);
}

header.appbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	flex: 0 0 auto;
	flex-wrap: wrap;
	min-height: 0;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	min-width: 0
}

.logo {
	width: 44px;
	height: 44px;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--accent), var(--accent-2));
	color: #fff;
	font-weight: 800;
	font-size: 18px;
	flex: 0 0 auto
}

.title {
	font-size: 16px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 220px
}

.toolbar {
	display: flex;
	gap: 10px;
	align-items: center;
	margin-left: auto;
	flex: 1 1 1%;
	min-width: 0;
	justify-content: flex-end
}

.input,
input[type=text],
input[type=search] {
	height: 40px;
	padding: 0 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: transparent;
	outline: none;
	color: var(--text);
	min-width: 0;
	flex: 0 1 auto
}

.toolbar .input {
	flex: 1 1 180px;
	min-width: 0
}

.button {
	height: 40px;
	padding: 0 14px;
	border-radius: 10px;
	border: none;
	background: var(--accent);
	color: #fff;
	cursor: pointer;
	font-weight: 600;
	flex: 0 0 auto
}

.ghost {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text)
}

.layout {
	display: grid;
	grid-template-columns: 1fr minmax(260px, 380px);
	gap: 20px;
	padding: 20px;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	align-items: stretch;
}

.chat-area {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	position: relative;
}

.chat-log {
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: linear-gradient(180deg, #fbfdff, #f7f9fc);
}

.msg {
	max-width: 74%;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--card);
	border: 1px solid var(--border);
	box-shadow: 0 3px 10px rgba(11, 15, 21, 0.02);
	word-break: break-word
}

.msg .meta {
	font-size: 12px;
	color: var(--muted);
	margin-bottom: 6px
}

.msg.me {
	margin-left: auto;
	background: linear-gradient(180deg, var(--accent), var(--accent-2));
	color: #fff;
	border: none
}

.msg.me .meta {
	color: rgba(255, 255, 255, 0.85)
}

.composer {
	display: flex;
	gap: 12px;
	padding: 12px 16px;
	border-top: 1px solid var(--border);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.6));
	flex: 0 0 auto;
	position: sticky;
	bottom: 0;
	z-index: 20;
	width: 100%;
	box-shadow: 0 -6px 20px rgba(11, 15, 21, 0.03);
}

.composer input {
	flex: 1;
	min-width: 0;
	height: 44px;
	padding: 0 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	outline: none;
	background: #fff
}

.sidebar {
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-self: start;
	max-height: calc(100vh - 140px);
	overflow: auto;
	min-width: 0;
}

.panel {
	background: var(--card);
	padding: 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	flex: 0 0 auto
}

.label {
	font-size: 12px;
	color: var(--muted);
	font-weight: 600
}

.online {
	font-weight: 700;
	color: var(--accent-2)
}

#toast {
	position: fixed;
	right: 18px;
	bottom: 18px;
	padding: 10px 14px;
	border-radius: 10px;
	background: #111827;
	color: #fff;
	display: none;
	z-index: 999999;
}

.muted {
	color: var(--muted);
	font-size: 13px
}

.row {
	display: flex;
	gap: 8px;
	align-items: center
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0
}

@media (max-width:1100px) {
	.layout {
		grid-template-columns: 1fr 320px
	}

	.title {
		max-width: 160px
	}
}

@media (max-width:900px) {
	.layout {
		grid-template-columns: 1fr;
		padding: 12px
	}

	.sidebar {
		order: -1;
		flex-direction: row;
		overflow-x: auto;
		gap: 12px;
		padding: 10px 0;
		max-height: none
	}

	.panel {
		min-width: 180px;
		flex-shrink: 0
	}

	header.appbar {
		padding: 10px;
		gap: 8px
	}

	.toolbar .input {
		flex: 1 1 140px
	}
}

@media (max-width:600px) {
	header.appbar {
		flex-direction: column;
		align-items: stretch;
		gap: 8px;
		padding: 10px
	}

	.toolbar {
		width: 100%;
		flex-wrap: wrap;
		gap: 8px;
		justify-content: flex-end
	}

	.toolbar .input {
		min-width: 0;
		flex: 1 1 100%
	}

	.input,
	.button {
		height: 38px
	}

	.layout {
		padding: 10px
	}

	.chat-log {
		padding: 14px;
		gap: 10px
	}

	.msg {
		max-width: 90%
	}

	.composer {
		padding: 10px;
		gap: 8px
	}

	.composer input {
		font-size: 15px;
		height: 42px
	}

	.sidebar {
		display: none
	}
}

@media (max-width:400px) {
	.logo {
		width: 38px;
		height: 38px
	}

	.title {
		font-size: 15px
	}

	.msg {
		padding: 10px 12px;
		font-size: 14px
	}
}
