/* Cline Mobile — Android-first dark UI.
   Built with plain CSS so it loads instantly on a phone with no build step. */

:root {
	--bg: #0b0c0e;
	--bg-raised: #14161a;
	--bg-card: #171a1f;
	--border: #262a31;
	--text: #e8eaed;
	--text-dim: #9aa1ac;
	--text-faint: #6b7280;
	--accent: #9d4edd;
	--accent-soft: rgba(157, 78, 221, 0.16);
	--green: #3fb950;
	--amber: #d29922;
	--red: #f85149;
	--radius: 14px;
	--sat: env(safe-area-inset-top, 0px);
	--sab: env(safe-area-inset-bottom, 0px);
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

/* Author `display` rules below would otherwise beat the UA rule for [hidden]. */
[hidden] {
	display: none !important;
}

html,
body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
	overscroll-behavior: none;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	cursor: pointer;
}

code,
pre {
	font-family: var(--mono);
}

.muted {
	color: var(--text-dim);
}

/* ---------------------------------------------------------------- screens */

.screen {
	position: fixed;
	inset: 0;
	display: none;
	flex-direction: column;
	padding-top: var(--sat);
}

.screen.is-active {
	display: flex;
}

/* ---------------------------------------------------------------- connect */

#screen-connect,
#screen-lock {
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: radial-gradient(120% 80% at 50% 0%, #1a1327 0%, var(--bg) 60%);
}

.connect-card {
	width: 100%;
	max-width: 420px;
	text-align: center;
}

.logo {
	width: 64px;
	height: 64px;
	margin: 0 auto 16px;
	border-radius: 18px;
	background: linear-gradient(145deg, var(--accent), #6d28d9);
	display: grid;
	place-items: center;
	font-size: 32px;
	font-weight: 700;
	color: #fff;
}

.connect-card h1 {
	margin: 0 0 8px;
	font-size: 26px;
	letter-spacing: -0.02em;
}

.connect-card p {
	font-size: 14px;
	margin: 0 0 24px;
}

.connect-card code {
	background: var(--bg-card);
	padding: 2px 6px;
	border-radius: 6px;
	font-size: 12px;
	word-break: break-all;
}

.field {
	display: block;
	text-align: left;
	margin-bottom: 16px;
}

.field span {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-faint);
	margin-bottom: 8px;
}

.field input {
	width: 100%;
	padding: 14px 16px;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text);
	font-size: 15px;
	outline: none;
}

.field input:focus {
	border-color: var(--accent);
}

button.primary {
	background: var(--accent);
	color: #fff;
	font-weight: 600;
	padding: 14px 20px;
	border-radius: var(--radius);
	width: 100%;
}

button.primary:active {
	transform: scale(0.99);
}

button.ghost {
	border: 1px solid var(--border);
	color: var(--text);
	padding: 12px 20px;
	border-radius: var(--radius);
}

.error {
	color: var(--red);
	font-size: 13px;
	margin-top: 16px;
}

/* Small print under the lock button. */
.lock-note {
	font-size: 12px;
	margin-top: 14px;
	line-height: 1.45;
}

#lock-password,
#lock-confirm {
	font-size: 17px;
	letter-spacing: 0.08em;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	background: rgba(11, 12, 14, 0.92);
	backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--border);
	flex: 0 0 auto;
	z-index: 5;
}

.grow {
	flex: 1;
	min-width: 0;
}

.topbar-title {
	font-weight: 600;
	font-size: 16px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Laptop picker: a native <select> so Android shows its own touch-friendly sheet. */
.host-row {
	display: flex;
	align-items: center;
	gap: 4px;
	min-width: 0;
}

.host-select {
	flex: 1;
	min-width: 0;
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	border: 0;
	color: var(--text);
	font: inherit;
	font-size: 16px;
	font-weight: 600;
	padding: 0;
	margin: 0;
	text-overflow: ellipsis;
}

.host-caret {
	color: var(--text-faint);
	font-size: 10px;
	flex: 0 0 auto;
}

.topbar-sub {
	font-size: 12px;
	color: var(--text-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.icon-btn {
	width: 40px;
	height: 40px;
	display: grid;
	place-items: center;
	border-radius: 12px;
	color: var(--text-dim);
	font-size: 20px;
}

.icon-btn:active {
	background: var(--bg-raised);
}

.icon-btn.danger {
	color: var(--red);
	border: 1px solid rgba(248, 81, 73, 0.4);
	font-size: 14px;
}

/* Refresh spinner: without it a successful refresh looks identical to a dead button. */
.icon-btn.spinning {
	color: var(--accent);
	animation: spin 0.9s linear infinite;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* --------------------------------------------------------------- sessions */

.list-main {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 12px 12px calc(24px + var(--sab));
}

.session-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.session-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.session-card:active {
	border-color: var(--accent);
}

.session-card-head {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.session-card-title {
	font-size: 15px;
	font-weight: 550;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.session-card-foot {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 12px;
	font-size: 12px;
	color: var(--text-faint);
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 3px 8px;
	border-radius: 999px;
	background: var(--bg-raised);
	color: var(--text-dim);
	white-space: nowrap;
	flex: 0 0 auto;
}

.chip.running {
	background: var(--accent-soft);
	color: #c9a2ff;
}

.chip.pending {
	background: rgba(210, 153, 34, 0.15);
	color: var(--amber);
}

.chip.idle {
	background: rgba(63, 185, 80, 0.12);
	color: var(--green);
}

.chip.failed,
.chip.error {
	background: rgba(248, 81, 73, 0.14);
	color: var(--red);
}

/* Project heading between session groups. */
.group-head {
	list-style: none;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--text-faint);
	padding: 10px 4px 0;
}

.session-list > .group-head:first-child {
	padding-top: 0;
}

.empty {
	text-align: center;
	color: var(--text-faint);
	padding: 48px 24px;
	font-size: 14px;
}

/* Visible only after repeated connection failures (usually: wrong network). */
.hint {
	margin: 0;
	padding: 11px 16px;
	font-size: 13px;
	line-height: 1.45;
	color: #f0d08a;
	background: rgba(210, 153, 34, 0.12);
	border-bottom: 1px solid rgba(210, 153, 34, 0.35);
	flex: 0 0 auto;
}

/* ------------------------------------------------------------ run strip */

.run-strip {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px;
	font-size: 13px;
	color: #c9a2ff;
	background: var(--accent-soft);
	border-bottom: 1px solid rgba(157, 78, 221, 0.25);
	flex: 0 0 auto;
}

.pulse {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--accent);
	animation: pulse 1.4s ease-in-out infinite;
	flex: 0 0 auto;
}

@keyframes pulse {
	0%,
	100% {
		opacity: 0.3;
		transform: scale(0.85);
	}
	50% {
		opacity: 1;
		transform: scale(1.15);
	}
}

/* ---------------------------------------------------------------- stream */

.stream {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 14px 12px 20px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* A column flex container shrinks its children to fit. Combined with
   `overflow: hidden` on a child (which zeroes its automatic min-size) that
   collapses cards into thin slivers, so opt every row out of shrinking. */
.stream > * {
	flex: 0 0 auto;
}

.bubble {
	max-width: 100%;
	padding: 11px 14px;
	border-radius: var(--radius);
	font-size: 14.5px;
	line-height: 1.55;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

.bubble.user {
	align-self: flex-end;
	max-width: 86%;
	background: var(--accent);
	color: #fff;
	border-bottom-right-radius: 5px;
}

.bubble.assistant {
	align-self: flex-start;
	max-width: 96%;
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-bottom-left-radius: 5px;
}

.bubble.assistant.streaming::after {
	content: "▍";
	color: var(--accent);
	animation: blink 1s step-end infinite;
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

.bubble .reasoning {
	color: var(--text-faint);
	font-style: italic;
	font-size: 13px;
}

/* Markdown rendered inside bubbles */
.bubble p {
	margin: 0 0 8px;
}
.bubble p:last-child {
	margin-bottom: 0;
}
.bubble pre {
	background: #0f1115;
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 10px 12px;
	overflow-x: auto;
	font-size: 12.5px;
	line-height: 1.5;
	margin: 8px 0;
	white-space: pre;
}
.bubble code {
	background: #0f1115;
	border-radius: 5px;
	padding: 1px 5px;
	font-size: 12.5px;
}
.bubble pre code {
	background: none;
	padding: 0;
}
.bubble a {
	color: #c9a2ff;
}
.bubble ul,
.bubble ol {
	margin: 6px 0;
	padding-left: 20px;
}
.bubble h1,
.bubble h2,
.bubble h3 {
	font-size: 15px;
	margin: 10px 0 6px;
}

/* ------------------------------------------------------------ tool cards */

.tool {
	align-self: stretch;
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-left: 3px solid var(--accent);
	border-radius: 12px;
	font-size: 13px;
	overflow: hidden;
}

.tool.error {
	border-left-color: var(--red);
}

.tool.pending {
	border-left-color: var(--amber);
}

.tool-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	font-weight: 600;
	color: var(--text-dim);
	font-size: 12.5px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.tool-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text);
	text-transform: none;
	letter-spacing: 0;
	font-family: var(--mono);
	font-size: 12.5px;
	font-weight: 600;
}

.tool-body {
	border-top: 1px solid var(--border);
}

.tool pre {
	margin: 0;
	padding: 10px 12px;
	font-size: 12px;
	line-height: 1.5;
	overflow-x: auto;
	white-space: pre;
	color: var(--text-dim);
	background: #0f1115;
	max-height: 260px;
	overflow-y: auto;
}

.tool-body[hidden] {
	display: none;
}

.summary-note {
	align-self: center;
	font-size: 12px;
	color: var(--text-faint);
	padding: 2px 10px;
	text-align: center;
	max-width: 92%;
}

.metrics-note {
	align-self: flex-end;
	font-size: 11px;
	color: var(--text-faint);
	font-family: var(--mono);
}

/* ----------------------------------------------------------- approvals */

.approval-bar {
	flex: 0 0 auto;
	margin: 0 12px 8px;
	padding: 12px 14px;
	background: rgba(210, 153, 34, 0.12);
	border: 1px solid rgba(210, 153, 34, 0.4);
	border-radius: var(--radius);
}

.approval-text {
	font-size: 13px;
	margin-bottom: 10px;
	color: #f0d08a;
}

.approval-actions {
	display: flex;
	gap: 10px;
}

.approval-actions button {
	flex: 1;
}

/* ------------------------------------------------------------- composer */

.composer {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px calc(10px + var(--sab));
	background: rgba(11, 12, 14, 0.96);
	backdrop-filter: blur(12px);
	border-top: 1px solid var(--border);
}

.composer textarea {
	flex: 1;
	resize: none;
	max-height: 140px;
	min-height: 44px;
	padding: 11px 14px;
	border-radius: 22px;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text);
	font: inherit;
	font-size: 15px;
	line-height: 1.4;
	outline: none;
}

.composer textarea:focus {
	border-color: var(--accent);
}

.mode-btn {
	flex: 0 0 auto;
	height: 44px;
	padding: 0 12px;
	border-radius: 22px;
	border: 1px solid var(--border);
	background: var(--bg-card);
	color: var(--text-dim);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.05em;
}

.mode-btn.plan {
	color: #c9a2ff;
	border-color: var(--accent);
	background: var(--accent-soft);
}

.send-btn {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--accent);
	color: #fff;
	display: grid;
	place-items: center;
}

.send-btn:disabled {
	opacity: 0.4;
}

/* ---------------------------------------------------------------- toast */

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(84px + var(--sab));
	transform: translateX(-50%);
	background: #2a2f37;
	color: var(--text);
	padding: 10px 18px;
	border-radius: 999px;
	font-size: 13px;
	max-width: 88vw;
	text-align: center;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
	z-index: 50;
}

/* Wider screens (tablet / desktop preview) */
@media (min-width: 720px) {
	.stream,
	.list-main,
	.composer,
	.topbar {
		max-width: 760px;
		margin-inline: auto;
		width: 100%;
	}
}

