*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

:root {
	--mist: #b5cfac;
	--light: #dae8d2;
	--sage: #7da87a;
	--fern: #4a7a4a;
	--moss: #2d5a36;
	--earth: #1d3322;
	--glow: #6aec78;
	--gold: #e2b84a;
	--amber: #cf9636;
}

html, body {
	height: 100%;
	color: var(--mist);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: clamp(16px, 1.8vw, 18px);
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	background: #0a140c;
}

/* ---- Pixel canvas ---- */
.pixel-bg {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 0;
	display: block;
	pointer-events: none;
}

/* ---- Root ---- */
#root {
	height: 100%;
	position: relative;
	z-index: 1;
	overflow: hidden;
}

.app {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 50%;
	min-width: 340px;
	max-width: 580px;
	flex-shrink: 1;
}

/* ---- Header ---- */
.header {
	padding: clamp(28px, 6vh, 52px) 0 clamp(16px, 3vh, 24px);
	flex-shrink: 0;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 20px;
}

.brand {
	font-family: "Syne", sans-serif;
	font-size: clamp(22px, 3.5vw, 30px);
	font-weight: 700;
	color: var(--light);
	line-height: 1;
	letter-spacing: -0.02em;
	text-shadow:
		0 0 24px rgba(106, 236, 120, 0.3),
		0 0 48px rgba(106, 236, 120, 0.1);
}

.brand .dot {
	color: var(--gold);
	text-shadow:
		0 0 18px rgba(226, 184, 74, 0.5),
		0 0 36px rgba(226, 184, 74, 0.15);
}

.header-right {
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--light);
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
	display: flex;
	align-items: center;
	gap: 6px;
}

.header-right::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #e54;
	box-shadow: 0 0 6px #e54, 0 0 12px rgba(229, 68, 68, 0.4);
	animation: blink 2s infinite;
}

@keyframes blink {
	0% { opacity: 1; }
	5% { opacity: 0.1; }
	50% { opacity: 0.1; }
	55% { opacity: 1; }
	100% { opacity: 1; }
}


/* ---- Messages ---- */
.messages {
	flex: 1;
	overflow-y: auto;
	padding: clamp(16px, 3vh, 28px) 0;
	padding-bottom: 60px;
	scrollbar-width: none;
}

.messages::-webkit-scrollbar {
	display: none;
}

.msg {
	padding: 5px 0;
	opacity: 0;
	animation: appear 0.01s steps(1) forwards;
	animation-delay: 0s;
}

.msg:nth-child(1) { animation-delay: 0s; }
.msg:nth-child(2) { animation-delay: 0.05s; }
.msg:nth-child(3) { animation-delay: 0.1s; }
.msg:nth-child(4) { animation-delay: 0.15s; }
.msg:nth-child(5) { animation-delay: 0.2s; }

.msg-new { animation-delay: 0s !important; }

.msg-who {
	display: inline;
	font-family: "Syne", sans-serif;
	font-size: 0.82em;
	font-weight: 600;
	color: var(--gold);
	margin-right: 10px;
	text-shadow: 0 0 10px rgba(226, 184, 74, 0.18), 0 0 8px rgba(10, 20, 12, 0.9);
}

.msg-self .msg-who {
	color: var(--glow);
	text-shadow: 0 0 10px rgba(106, 236, 120, 0.2), 0 0 8px rgba(10, 20, 12, 0.9);
}

.msg-body {
	display: inline;
	color: var(--light);
	word-wrap: break-word;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9), 0 0 16px rgba(10, 20, 12, 0.6);
}

.msg-self .msg-body {
	color: var(--light);
}

.msg-assistant .msg-who {
	color: var(--amber);
	text-shadow: 0 0 10px rgba(226, 184, 74, 0.25);
}

.msg-assistant .msg-body {
	color: var(--light);
}

/* ---- Empty state ---- */
.empty {
	flex: 1;
	display: flex;
	align-items: flex-end;
	padding-bottom: 18vh;
}

.empty-text {
	font-family: "Syne", sans-serif;
	font-size: clamp(20px, 3.5vw, 28px);
	font-weight: 500;
	color: var(--light);
	line-height: 1.35;
	max-width: 320px;
	text-shadow: 0 0 12px rgba(10, 20, 12, 0.9), 0 0 24px rgba(10, 20, 12, 0.6);
}

/* ---- Compose ---- */
.compose {
	flex-shrink: 0;
	padding: clamp(14px, 2.5vh, 24px) 0 clamp(24px, 5vh, 44px);
	position: relative;
	z-index: 2;
}

.compose-form {
	display: flex;
	align-items: stretch;
}

.name-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

.name-dialog {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 28px;
}

.name-dialog .brand {
	font-size: clamp(20px, 3vw, 28px);
}

.name-dialog-form {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
}

.name-dialog-label {
	color: var(--light);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: clamp(13px, 1.5vw, 15px);
	font-weight: 400;
	letter-spacing: 0.04em;
}

.name-dialog-input {
	background: none;
	border: 1px solid var(--sage);
	border-radius: 6px;
	padding: 10px 16px;
	color: var(--light);
	font-size: clamp(15px, 1.8vw, 18px);
	font-family: "Hanken Grotesk", sans-serif;
	font-weight: 400;
	outline: none;
	text-align: center;
	width: 240px;
}

.name-dialog-input:focus {
	border-color: var(--sage);
}

.name-dialog-input::placeholder {
	color: var(--sage);
	font-weight: 300;
}

.name-dialog-btn {
	background: none;
	border: 1px solid var(--light);
	border-radius: 6px;
	color: var(--light);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 8px 28px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.name-dialog-btn:hover {
	background: var(--sage);
	color: var(--dark);
}

.compose-input {
	flex: 1;
	background: none;
	border: none;
	padding: 14px 0;
	color: var(--light);
	font-size: clamp(14px, 1.6vw, 16px);
	font-family: "Hanken Grotesk", sans-serif;
	font-weight: 400;
	outline: none;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

.compose-input::placeholder {
	color: var(--sage);
	font-weight: 300;
}

.compose-send {
	background: none;
	border: none;
	color: var(--light);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	cursor: pointer;
	padding: 14px 0 14px 16px;
	transition: color 0.1s steps(2);
}

.compose-send:hover {
	color: var(--glow);
	text-shadow: 0 0 12px rgba(106, 236, 120, 0.3);
}

.compose-meta {
	margin-top: 8px;
	font-size: 11px;
	font-weight: 500;
	color: var(--mist);
	letter-spacing: 0.03em;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

@keyframes appear {
	to { opacity: 1; }
}

/* ---- Typing indicator ---- */
.typing-indicator {
	font-size: 0.78em;
	color: var(--sage);
	padding: 2px 0;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
	animation: typing-pulse 2s ease-in-out infinite;
}

@keyframes typing-pulse {
	0%, 100% { opacity: 0.5; }
	50% { opacity: 1; }
}


/* ---- Visitor count ---- */
.visitor-count {
	margin-right: 6px;
	color: var(--sage);
}


.sidebar-label {
	font-family: "Syne", sans-serif;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--light);
	margin-bottom: 20px;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

.sidebar-item {
	display: block;
	width: 100%;
	background: none;
	border: none;
	border-bottom: 1px solid rgba(45, 90, 54, 0.3);
	padding: 16px 0;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s;
}

.sidebar-item:hover {
	border-color: var(--gold);
}

.sidebar-item:first-of-type {
	border-top: 1px solid rgba(45, 90, 54, 0.3);
}

.sidebar-item-title {
	display: block;
	font-family: "Syne", sans-serif;
	font-size: 1.5em;
	font-weight: 600;
	color: var(--light);
	margin-bottom: 8px;
	transition: color 0.15s;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

.sidebar-item:hover .sidebar-item-title {
	color: var(--gold);
	text-shadow: 0 0 12px rgba(226, 184, 74, 0.2);
}

.sidebar-item-desc {
	display: block;
	font-size: 1.05em;
	color: var(--mist);
	line-height: 1.5;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

/* ---- Article page ---- */
.article-page {
	width: 100%;
	height: 100%;
	overflow-y: auto;
	position: relative;
	z-index: 1;
	scrollbar-width: thin;
	scrollbar-color: var(--moss) transparent;
	font-size: clamp(18px, 2vw, 20px);
}

.article-page::-webkit-scrollbar { width: 6px; }
.article-page::-webkit-scrollbar-thumb { background: var(--moss); border-radius: 3px; }
.article-page::-webkit-scrollbar-track { background: transparent; }

.article-page > * {
	max-width: 740px;
	margin-left: auto;
	margin-right: auto;
	padding-left: clamp(20px, 4vw, 40px);
	padding-right: clamp(20px, 4vw, 40px);
}

.article-page > :first-child {
	padding-top: clamp(64px, 12vh, 120px);
}

.article-page > :last-child {
	padding-bottom: clamp(32px, 6vh, 64px);
}

.article-back {
	position: fixed;
	top: clamp(16px, 3vh, 28px);
	left: clamp(16px, 3vw, 28px);
	background: none;
	border: 1px solid var(--moss);
	border-radius: 6px;
	color: var(--light);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.08em;
	cursor: pointer;
	padding: 6px 14px;
	z-index: 10;
	transition: color 0.15s, border-color 0.15s;
}

.article-back:hover {
	color: var(--glow);
	border-color: var(--sage);
}

.article-title {
	font-family: "Syne", sans-serif;
	font-size: clamp(22px, 4vw, 32px);
	font-weight: 700;
	color: var(--light);
	line-height: 1.25;
	margin-bottom: 20px;
	text-shadow: 0 0 24px rgba(106, 236, 120, 0.15);
}

.article-abstract {
	font-size: 0.92em;
	color: var(--mist);
	line-height: 1.6;
	margin-bottom: 36px;
	padding: 20px 24px;
	background: rgba(45, 90, 54, 0.08);
	border-left: 3px solid var(--sage);
	border-radius: 0 6px 6px 0;
}

.article-body {
	color: var(--light);
	line-height: 1.75;
}

.article-body p {
	margin-bottom: 16px;
}

.tex-block {
	margin: 20px 0;
	padding: 16px 0;
	overflow-x: auto;
	text-align: center;
}

.tex-block .katex-display {
	margin: 0;
}

.article-body h2 {
	font-family: "Syne", sans-serif;
	font-size: clamp(18px, 3vw, 24px);
	font-weight: 700;
	color: var(--light);
	margin-top: 40px;
	margin-bottom: 14px;
	padding-top: 20px;
	border-top: 1px solid rgba(45, 90, 54, 0.3);
	text-shadow: 0 0 16px rgba(106, 236, 120, 0.12);
}

.article-body h2:first-child {
	margin-top: 0;
	padding-top: 0;
	border-top: none;
}

.article-body h3 {
	font-family: "Syne", sans-serif;
	font-size: clamp(15px, 2.2vw, 19px);
	font-weight: 600;
	color: var(--light);
	margin-top: 28px;
	margin-bottom: 10px;
}

.article-body h4 {
	font-family: "Syne", sans-serif;
	font-size: clamp(14px, 1.8vw, 16px);
	font-weight: 600;
	color: var(--mist);
	margin-top: 22px;
	margin-bottom: 8px;
}

.article-body ul, .article-body ol {
	margin-bottom: 16px;
	padding-left: 24px;
}

.article-body li {
	margin-bottom: 6px;
}

.article-body table {
	width: 100%;
	border-collapse: collapse;
	margin: 20px 0;
	font-size: 0.9em;
}

.article-body th, .article-body td {
	padding: 8px 12px;
	text-align: left;
	border-bottom: 1px solid rgba(45, 90, 54, 0.4);
}

.article-body th {
	font-family: "Syne", sans-serif;
	font-weight: 600;
	color: var(--light);
	border-bottom: 2px solid var(--sage);
}

.article-body td {
	color: var(--mist);
}

.article-body td strong {
	color: var(--glow);
	font-weight: 700;
}

.article-body code {
	font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
	font-size: 0.85em;
	color: var(--glow);
	background: rgba(106, 236, 120, 0.08);
	padding: 2px 6px;
	border-radius: 4px;
	letter-spacing: 0.02em;
}

.article-body pre {
	background: rgba(10, 20, 12, 0.5);
	border: 1px solid rgba(45, 90, 54, 0.3);
	border-radius: 6px;
	padding: 16px;
	overflow-x: auto;
	margin: 16px 0;
}

.article-body pre code {
	background: none;
	padding: 0;
}

.article-body img {
	max-width: 100%;
	width: 100%;
	height: auto;
	border-radius: 0;
	display: block;
}

.article-body .figure {
	margin: 32px 0;
	background: rgba(255, 255, 255, 0.03);
	border-radius: 0;
	padding: 16px;
	overflow: visible;
}

.article-body .figure-caption {
	font-size: 0.82em;
	color: var(--sage);
	margin-top: 10px;
	line-height: 1.45;
	font-style: italic;
}

.article-body strong {
	color: var(--light);
	font-weight: 600;
}

.article-body em {
	color: var(--mist);
	font-style: italic;
}

.article-body blockquote {
	border-left: 3px solid var(--sage);
	padding-left: 16px;
	margin: 16px 0;
	color: var(--mist);
}

.article-body a {
	color: var(--gold);
	text-decoration: none;
	border-bottom: 1px solid rgba(226, 184, 74, 0.3);
	transition: border-color 0.15s;
}

.article-body a:hover {
	border-color: var(--gold);
}

.article-body .references {
	margin-top: 40px;
	padding-top: 20px;
	border-top: 1px solid rgba(45, 90, 54, 0.3);
}

.article-body .references h2 {
	border-top: none;
	padding-top: 0;
	margin-top: 0;
}

.article-body .ref-list {
	list-style: none;
	padding-left: 0;
}

.article-body .ref-list li {
	padding-left: 2em;
	text-indent: -2em;
	margin-bottom: 12px;
	font-size: 0.88em;
	color: var(--mist);
	line-height: 1.5;
}

.article-body .ref-list .ref-id {
	color: var(--sage);
	font-weight: 600;
	font-size: 0.9em;
}

.article-body .ref-list em {
	color: var(--light);
}

.article-body .cite {
	color: var(--sage);
	font-size: 0.88em;
	cursor: default;
}

/* ---- Home screen ---- */
.home {
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 48px;
	position: relative;
	z-index: 1;
}

.home-brand {
	font-family: "Syne", sans-serif;
	font-size: clamp(28px, 5vw, 44px);
	font-weight: 700;
	color: var(--light);
	line-height: 1;
	letter-spacing: -0.02em;
	text-shadow:
		0 0 24px rgba(106, 236, 120, 0.3),
		0 0 48px rgba(106, 236, 120, 0.1);
}

.home-nav {
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	gap: 20px;
	width: min(520px, 88vw);
	aspect-ratio: 1 / 1;
}

.home-btn {
	background: rgba(10, 20, 12, 0.6);
	border: 1px solid var(--moss);
	border-radius: 10px;
	padding: 20px;
	cursor: pointer;
	text-align: center;
	min-width: 0;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	color: var(--light);
	text-decoration: none;
	font-family: inherit;
	transition: border-color 0.2s, background 0.2s;
}

.home-btn-icon svg {
	width: 46%;
	height: 46%;
	color: var(--light);
}

.home-btn:hover {
	border-color: var(--sage);
	background: rgba(45, 90, 54, 0.15);
}

.home-btn-title {
	display: block;
	font-family: "Syne", sans-serif;
	font-size: clamp(16px, 2.5vw, 20px);
	font-weight: 700;
	color: var(--light);
	margin-bottom: 8px;
	text-shadow: 0 0 12px rgba(10, 20, 12, 0.9);
}

.home-btn-desc {
	display: block;
	font-size: 0.82em;
	color: var(--mist);
	line-height: 1.4;
	text-shadow: 0 0 8px rgba(10, 20, 12, 0.9);
}

/* ---- Nav back button ---- */
.nav-back {
	background: none;
	border: 1px solid var(--moss);
	border-radius: 6px;
	color: var(--light);
	font-family: "Hanken Grotesk", sans-serif;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	padding: 4px 12px;
	margin-right: 14px;
	transition: color 0.15s, border-color 0.15s;
}

.nav-back:hover {
	color: var(--glow);
	border-color: var(--sage);
}

/* ---- Chat layout ---- */
.chat-sandbox {
	height: 100%;
	position: relative;
	z-index: 1;
	contain: layout paint;
	overflow: hidden;
}

.chat-layout {
	display: flex;
	height: 100%;
	width: 100%;
	overflow: hidden;
	padding-left: clamp(24px, 8vw, 14%);
	position: relative;
	z-index: 1;
}

/* ---- Pages view ---- */
.pages-view {
	height: 100%;
	display: flex;
	flex-direction: column;
	position: relative;
	z-index: 1;
	padding: 0 clamp(24px, 8vw, 14%);
}

.pages-view .header {
	display: flex;
	align-items: baseline;
	gap: 0;
}

.pages-list {
	flex: 1;
	overflow-y: auto;
	max-width: 580px;
	scrollbar-width: none;
	margin-top: clamp(24px, 6vh, 60px);
}

.pages-list::-webkit-scrollbar { display: none; }

@media (max-width: 768px) {
	.chat-layout {
		padding-left: 0;
	}

	.app {
		padding: 0 clamp(16px, 5vw, 28px);
		width: 100%;
		max-width: none;
		min-width: 0;
	}

	.pages-view {
		padding: 0 clamp(16px, 5vw, 28px);
	}
}


