/* David Isquick — personal agent */

:root {
	--bg: #f6f5f1;
	--surface: #ffffff;
	--surface-2: #efede7;
	--text: #1d1e20;
	--muted: #6a6c70;
	--line: #e2dfd7;
	--accent: #1f6f5c;
	--accent-ink: #ffffff;
	--accent-soft: #e2efe9;
	--link: #1a6655;
	--online: #2fb37a;
	--shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .04);
	--radius: 18px;
	--font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #16171a;
		--surface: #212226;
		--surface-2: #2a2b30;
		--text: #ecebe7;
		--muted: #9b9ca1;
		--line: #33343a;
		--accent: #3ba486;
		--accent-ink: #0d1512;
		--accent-soft: #1e3530;
		--link: #6fd0b2;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #16171a; --surface: #212226; --surface-2: #2a2b30; --text: #ecebe7; --muted: #9b9ca1;
	--line: #33343a; --accent: #3ba486; --accent-ink: #0d1512; --accent-soft: #1e3530; --link: #6fd0b2;
	--shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

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

html, body { margin: 0; }

body {
	background: var(--bg);
	color: var(--text);
	font: 16px/1.55 var(--font);
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shared content styles (chat bubbles + plain page) ---------- */

.kb h2, .bubble h2 { font-size: 1.12rem; line-height: 1.3; margin: 0 0 .35rem; letter-spacing: -.01em; }
.kb h3, .bubble h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.1rem 0 .35rem; }
.kb p, .bubble p { margin: 0 0 .6rem; }
.kb ul, .bubble ul { margin: 0 0 .6rem; padding-left: 1.15rem; }
.kb li, .bubble li { margin-bottom: .35rem; }
.kicker { font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem !important; }
.lede { font-size: 1.02rem; }
.meta { display: block; color: var(--muted); font-size: .85rem; }
.note { color: var(--muted); font-size: .88rem; }
.bubble > :last-child, .kb > :last-child { margin-bottom: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .75rem !important; }
.tag { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 500; }

.timeline, .files, .links { list-style: none; padding-left: 0 !important; }
.timeline li, .files li { display: flex; flex-direction: column; padding: .55rem 0; border-top: 1px solid var(--line); margin: 0 !important; }
.timeline li:first-child, .files li:first-child { border-top: 0; padding-top: .2rem; }
.timeline span { color: var(--muted); font-size: .88rem; }
.files a { font-weight: 600; }
.files li > span:not(.meta) { font-size: .92rem; margin-top: .15rem; }
.links li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; padding: .45rem 0; border-top: 1px solid var(--line); margin: 0 !important; }
.links li:first-child { border-top: 0; }
.links .meta { display: inline; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: .8rem 0 !important; }
.btn {
	display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px;
	background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .92rem; text-decoration: none;
	border: 1px solid var(--accent);
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--link); border-color: var(--line); }

.hampsters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px; background: #fff; border-radius: 10px; padding: 8px; margin-top: .6rem !important; }
.hampsters img { image-rendering: pixelated; max-width: 100%; height: auto; }

/* ---------- plain page (no JavaScript, crawlers) ---------- */

.kb-page { max-width: 720px; margin: 0 auto; padding: 32px 16px 48px; }
.kb-hero h1 { font-size: 2rem; margin: 0 0 .4rem; letter-spacing: -.02em; }
.kb-hero p { color: var(--muted); margin: 0 0 1rem; }
.kb-hero nav { font-size: .92rem; margin-bottom: 1.5rem; }
.kb { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); scroll-margin-top: 16px; }
.kb-foot { color: var(--muted); font-size: .88rem; text-align: center; }

html.js .kb-page { display: none; }

/* ---------- chat app ---------- */

.app {
	display: flex; flex-direction: column;
	height: 100vh; height: 100dvh;
	max-width: 780px; margin: 0 auto;
}
.app[hidden] { display: none; }

.top {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
	border-bottom: 1px solid var(--line);
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px);
	position: relative; z-index: 2;
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who__name { margin: 0; font-weight: 700; font-size: 1rem; line-height: 1.2; }
.who__status { margin: 0; font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online); box-shadow: 0 0 0 3px color-mix(in srgb, var(--online) 25%, transparent); }

.avatar {
	flex: none; width: 40px; height: 40px; border-radius: 50%;
	display: grid; place-items: center;
	background: var(--accent); color: var(--accent-ink);
	font-weight: 700; font-size: .9rem; letter-spacing: .02em;
}
.avatar--sm { width: 30px; height: 30px; font-size: .68rem; }

.top__actions { display: flex; gap: 6px; }
.icon-btn {
	display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
	border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
	font: 500 .85rem var(--font); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg, .send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.log {
	flex: 1; overflow-y: auto; overscroll-behavior: contain; position: relative;
	padding: 20px 16px 8px;
	display: flex; flex-direction: column; gap: 10px;
	scroll-padding-bottom: 16px;
}

.row { display: flex; align-items: flex-end; gap: 8px; animation: rise .22s ease-out; }
.row--user { justify-content: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bubble {
	max-width: min(560px, 86%);
	padding: 10px 14px; border-radius: var(--radius);
	overflow-wrap: anywhere;
}
.bubble--bot {
	background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
	border-bottom-left-radius: 6px;
}
.bubble--user {
	background: var(--accent); color: var(--accent-ink);
	border-bottom-right-radius: 6px;
}
.row--bot + .row--bot .avatar { visibility: hidden; }

.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .25; transform: none; } 40% { opacity: .9; transform: translateY(-2px); } }

.dock {
	padding: 8px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
	border-top: 1px solid var(--line);
	background: var(--bg);
}

.chips {
	display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px;
	scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
	mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
	flex: none; height: 34px; padding: 0 14px; border-radius: 999px;
	border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--surface); color: var(--text);
	font: 500 .86rem var(--font); cursor: pointer; white-space: nowrap;
	animation: rise .2s ease-out;
}
.chip:hover { background: var(--accent-soft); }
.chip--menu { border-style: dashed; color: var(--muted); }
.chip:last-child { margin-right: 24px; }

.composer {
	display: flex; align-items: center; gap: 8px;
	background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
	padding: 5px 5px 5px 16px; box-shadow: var(--shadow);
}
.composer:focus-within { border-color: var(--accent); }
.composer input {
	flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
	font: 16px var(--font); height: 38px;
}
.composer input::placeholder { color: var(--muted); }
.send {
	flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
	display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.send:hover { filter: brightness(1.08); }

.fineprint { margin: 8px 0 0; text-align: center; font-size: .74rem; color: var(--muted); }
kbd { font: inherit; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); }

/* ---------- topics dialog ---------- */

.topics {
	width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 680px);
	border: 1px solid var(--line); border-radius: 20px; padding: 0;
	background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.topics::backdrop { background: rgba(10, 10, 12, .4); backdrop-filter: blur(2px); }
.topics__head {
	position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
	padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topics__head h2 { margin: 0; font-size: 1.05rem; }
#topics-list { padding: 4px 16px 16px; }
#topics-list h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; }
#topics-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.topic {
	width: 100%; text-align: left; cursor: pointer;
	display: flex; flex-direction: column; gap: 1px;
	padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
	font: .92rem var(--font);
}
.topic span { color: var(--muted); font-size: .84rem; }
.topic:hover { border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 520px) {
	.icon-btn span:not(.visually-hidden) { display: none; }
	.bubble { max-width: 90%; }
	.log { padding-top: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	.row, .chip { animation: none; }
	.typing i { animation: none; }
}
