:root {
	--bg: #0f1117;
	--surface: #1a1d27;
	--surface-2: #232735;
	--border: #2e3344;
	--text: #e6e8ee;
	--text-dim: #9aa0b0;
	--accent: #6c8cff;
	--accent-hover: #5a7bf0;
	--user-bubble: #2a3550;
	--assistant-bubble: #1f2430;
	--danger: #ff6b6b;
	--radius: 14px;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	background: var(--bg);
	color: var(--text);
	height: 100vh;
	display: flex;
	flex-direction: column;
}

header {
	padding: 1rem 1.5rem;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: var(--surface);
}
header h1 {
	font-size: 1.1rem;
	margin: 0;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
header h1 .dot {
	width: 9px; height: 9px; border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 8px var(--accent);
}
header .subtitle {
	font-size: 0.8rem;
	color: var(--text-dim);
	margin-top: 2px;
}

#resetBtn {
	background: transparent;
	border: 1px solid var(--border);
	color: var(--text-dim);
	padding: 0.45rem 0.9rem;
	border-radius: 8px;
	font-size: 0.85rem;
	cursor: pointer;
	transition: all 0.15s;
}
#resetBtn:hover:not(:disabled) {
	border-color: var(--accent);
	color: var(--text);
}
#resetBtn:disabled { opacity: 0.4; cursor: not-allowed; }

#chatLog {
	flex: 1;
	overflow-y: auto;
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	scroll-behavior: smooth;
}
#chatLog::-webkit-scrollbar { width: 8px; }
#chatLog::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.empty-hint {
	margin: auto;
	text-align: center;
	color: var(--text-dim);
	font-size: 0.9rem;
	line-height: 1.6;
	max-width: 360px;
}
.empty-hint .big {
	font-size: 2rem;
	margin-bottom: 0.5rem;
	opacity: 0.6;
}

.msg {
	max-width: 78%;
	padding: 0.7rem 0.95rem;
	border-radius: var(--radius);
	line-height: 1.55;
	font-size: 0.93rem;
	white-space: pre-wrap;
	word-wrap: break-word;
	animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: translateY(0); }
}
.msg.user {
	align-self: flex-end;
	background: var(--user-bubble);
	border-bottom-right-radius: 4px;
}
.msg.assistant {
	align-self: flex-start;
	background: var(--assistant-bubble);
	border: 1px solid var(--border);
	border-bottom-left-radius: 4px;
}
.msg .role {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.55;
	display: block;
	margin-bottom: 0.3rem;
}

/* Indikator mengetik */
.typing {
	display: inline-flex;
	gap: 4px;
	padding: 0.15rem 0;
}
.typing span {
	width: 6px; height: 6px;
	border-radius: 50%;
	background: var(--text-dim);
	animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
	0%, 60%, 100% { opacity: 0.25; }
	30% { opacity: 1; }
}

footer {
	padding: 1rem 1.5rem 1.25rem;
	border-top: 1px solid var(--border);
	background: var(--surface);
}
.input-row {
	display: flex;
	gap: 0.6rem;
	align-items: center;
}
#promptInput {
	flex: 1;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 0.75rem 1rem;
	border-radius: 10px;
	font-size: 0.95rem;
	outline: none;
	transition: border-color 0.15s;
}
#promptInput:focus { border-color: var(--accent); }
#promptInput:disabled { opacity: 0.5; }
#promptInput::placeholder { color: var(--text-dim); }

#sendBtn {
	background: var(--accent);
	border: none;
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.1s;
	flex-shrink: 0;
}
#sendBtn:hover:not(:disabled) { background: var(--accent-hover); }
#sendBtn:active:not(:disabled) { transform: scale(0.95); }
#sendBtn:disabled { opacity: 0.4; cursor: not-allowed; }
#sendBtn svg { width: 18px; height: 18px; }

/* Overlay loader */
#overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 17, 23, 0.92);
	backdrop-filter: blur(6px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1.2rem;
	z-index: 100;
	transition: opacity 0.4s ease, visibility 0.4s;
}
#overlay.hidden {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}
.spinner {
	width: 48px;
	height: 48px;
	border: 4px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#overlayText {
	color: var(--text);
	font-size: 0.95rem;
	text-align: center;
	max-width: 320px;
	line-height: 1.5;
}
#overlaySubtext {
	color: var(--text-dim);
	font-size: 0.8rem;
	margin-top: -0.6rem;
}
#retryBtn {
	display: none;
	background: var(--accent);
	border: none;
	color: #fff;
	padding: 0.6rem 1.4rem;
	border-radius: 8px;
	font-size: 0.9rem;
	cursor: pointer;
}
#retryBtn:hover { background: var(--accent-hover); }
#overlay.error .spinner { display: none; }
#overlay.error #retryBtn { display: inline-block; }
#overlay.error #overlayText { color: var(--danger); }