/* DSH Mini App layout. All values come from tokens.css, shared verbatim with the
   Maryam Mini App (source of truth: Work/Maryam/ig-scout/src/miniapp/web/tokens.css).
   Only DSH-specific pieces live here: section control, chat thread, composer, live card, steps,
   gallery, usage bars. Local aliases below are tints mixed from the shared colors. */

:root {
	--btn-soft: color-mix(in srgb, var(--btn) 12%, transparent);
	--danger-soft: color-mix(in srgb, var(--danger) 13%, transparent);
	--good-soft: color-mix(in srgb, var(--good) 14%, transparent);
	--warn-soft: color-mix(in srgb, var(--warn) 14%, transparent);
	--ease: var(--dur) var(--ease-out);
	--safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-b));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
	background: var(--bg);
	color: var(--text);
	font: var(--fs-body)/1.4 var(--font);
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
	overscroll-behavior-y: none;
	min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--link); text-decoration: none; }
[hidden] { display: none !important; }
svg { display: block; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
	* { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- layout */

.screen { padding: calc(10px + var(--safe-t)) var(--page-x) calc(var(--safe-bottom) + 32px); max-width: var(--maxw); margin: 0 auto; animation: enter var(--dur) var(--ease-out); }
.screen.nested { padding-bottom: calc(var(--safe-bottom) + 32px); }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 4px 2px 6px; }
.page-title { font-size: var(--fs-title); line-height: 1.15; font-weight: var(--fw-bold); letter-spacing: -0.02em; margin: 0; flex: 1; min-width: 0; }
.page-sub { color: var(--sub); font-size: var(--fs-sm); margin: -2px 2px 12px; }

.section { margin-top: var(--section-gap); }
.page-head + .section, .page-head + div > .section:first-child { margin-top: 6px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px var(--page-x); }
.section-label { font-size: var(--fs-sm); font-weight: var(--fw-semi); text-transform: uppercase; letter-spacing: 0.04em; color: var(--head); flex: 1; }
.section-count { font-variant-numeric: tabular-nums; }
.section-action { font-size: var(--fs-sm); color: var(--accent); padding: 2px 6px; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px var(--pad-card); }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.empty { background: var(--card); border-radius: var(--radius); padding: 18px var(--pad-card); text-align: center; color: var(--sub); font-size: var(--fs-body); }
.muted { color: var(--hint); }
.small { font-size: var(--fs-sm); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.nums, .num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------------------------------------------------------------- family pieces (as in the Maryam Mini App) */

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 14px; }
.top h1 { font-size: var(--fs-title); line-height: 1.15; letter-spacing: -0.02em; margin: 0; font-weight: var(--fw-bold); }
.top .hello { color: var(--hint); font-size: var(--fs-sm); margin-bottom: 2px; }
.top-btns { display: flex; gap: var(--gap); }
.round { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--accent); background: var(--card); flex: none; transition: transform var(--ease); }
.round:active { transform: scale(0.94); }
.round.danger { color: var(--danger); }
.round.spinning .ic { animation: spin 0.7s linear infinite; }

/* Section navigation: the family's segmented control, sticky under the page title. */
.nav-wrap { position: sticky; top: 0; z-index: 12; background: var(--bg); margin: 0 calc(var(--page-x) * -1); padding: 6px var(--page-x) 8px; transition: box-shadow var(--ease); }
.nav-wrap.scrolled { box-shadow: 0 1px 0 var(--sep); }
body.preview .nav-wrap, body.preview .chat-head { top: 50px; }
.seg .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--btn); color: var(--btn-text); font-size: 11px; line-height: 18px; font-weight: var(--fw-bold); text-align: center; }
.seg .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.run-strip { display: flex; align-items: center; gap: 10px; margin-top: 8px; background: var(--card); border-radius: var(--radius-s); padding: 6px 6px 6px 12px; font-size: 14px; }
.run-strip .grow { color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-strip .btn { min-height: 32px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); padding: 14px 4px 12px; background: var(--card); border-radius: var(--radius); }
.stat { text-align: center; padding: 0 4px; border-left: 1px solid var(--sep); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-size: var(--fs-xl); line-height: 1.1; font-weight: var(--fw-bold); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-s); color: var(--hint); }
.stat.good b { color: var(--good); }
.stat.warn b { color: var(--warn); }
.stat.bad b { color: var(--danger); }
.stats-foot { grid-column: 1 / -1; margin: 12px 10px 0; padding-top: 10px; border-top: 1px solid var(--sep); font-size: var(--fs-sm); color: var(--sub); text-align: center; }

.mgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.m { background: var(--softer); border-radius: var(--radius-s); padding: 10px 11px 9px; min-width: 0; }
.m-label { font-size: var(--fs-s); color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-val { font-size: var(--fs-num); font-weight: var(--fw-bold); letter-spacing: -0.01em; margin-top: 1px; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.m-val .ic { color: var(--good); }
.m.fail .m-val { color: var(--danger); }
.m.fail .m-val .ic { color: var(--danger); }
.m.warn .m-val .ic { color: var(--warn); }
.mbar { position: relative; height: 4px; border-radius: 2px; background: var(--soft); margin: 7px 0 6px; }
.mbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--hint); }
.m.pass .mbar i { background: var(--good); }
.m.warn .mbar i { background: var(--warn); }
.m.fail .mbar i { background: var(--danger); }
.mbar b { position: absolute; top: -3px; width: 2px; height: 10px; border-radius: 1px; background: var(--text); opacity: 0.55; }
.m-cap { font-size: var(--fs-xs); color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notes li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 8px 10px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.notes li .ic { color: var(--warn); margin-top: 1px; }
.notes li.bad { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.notes li.bad .ic { color: var(--danger); }
.card-label { font-size: var(--fs-s); font-weight: var(--fw-semi); text-transform: uppercase; letter-spacing: 0.04em; color: var(--head); margin: 0 0 8px; display: flex; justify-content: space-between; }
.card-label + * { margin-bottom: 0; }
.card .card-label:not(:first-child) { margin-top: 16px; }

.pill { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--btn-text); background: var(--btn); padding: 3px 9px; border-radius: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.good { background: var(--good); }
.pill.warn { background: var(--warn); }
.done-mark { font-size: var(--fs-sm); color: var(--good); display: flex; align-items: center; gap: 4px; font-weight: var(--fw-semi); }
.row-title .tag { margin-left: 6px; vertical-align: 2px; font-weight: var(--fw-semi); }

/* Browser preview (screenshots): stand-ins for Telegram's header and MainButton. */
.fake-head { position: sticky; top: 0; z-index: 30; height: 50px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 12px; background: var(--tg-theme-header-bg-color, var(--bg)); border-bottom: 1px solid var(--sep); }
.fake-head .fh-left button { display: flex; align-items: center; gap: 2px; color: var(--link); font-size: 16px; }
.fake-head .fh-title { text-align: center; line-height: 1.15; }
.fake-head .fh-title b { display: block; font-size: 15px; }
.fake-head .fh-title span { font-size: var(--fs-s); color: var(--hint); }
.fake-head .fh-right { justify-self: end; color: var(--link); letter-spacing: 1px; }
.fake-main { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 8px 14px calc(10px + var(--safe-b)); background: var(--tg-theme-bottom-bar-bg-color, var(--bg)); }
.fake-main button { width: 100%; max-width: var(--maxw); display: flex; align-items: center; justify-content: center; margin: 0 auto; height: var(--tap); border-radius: 12px; background: var(--btn); color: var(--btn-text); font-weight: var(--fw-semi); font-size: 16px; }
.fake-main button[disabled] { opacity: 0.5; }
body.has-main .screen { padding-bottom: calc(var(--tap) + 40px + var(--safe-b)); }

/* ---------------------------------------------------------------- lists */

.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row {
	display: flex; align-items: center; gap: 12px;
	min-height: 56px; padding: var(--row-y) var(--page-x);
	position: relative; width: 100%; text-align: left;
	transition: background var(--ease);
}
.row + .row::before { content: ""; position: absolute; top: 0; left: var(--page-x); right: 0; border-top: 1px solid var(--sep); }
.row.with-lead + .row.with-lead::before { left: 44px; }
button.row:active, .row.tap:active { background: var(--softer); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: var(--fs-m); font-weight: var(--fw-semi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--fs-sm); color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row-sub.multi { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-end { display: flex; align-items: center; gap: 6px; color: var(--hint); font-size: var(--fs-sm); flex-shrink: 0; }
.row .lead { width: 18px; display: flex; justify-content: center; flex-shrink: 0; }
.chev { color: var(--hint); opacity: 0.6; }

/* ---------------------------------------------------------------- status */

.dot { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--hint) 55%, transparent); flex-shrink: 0; }
.dot.ok, .dot.run { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.dot.run { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
	0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 50%, transparent); }
	70% { box-shadow: 0 0 0 7px transparent; }
	100% { box-shadow: 0 0 0 0 transparent; }
}

.tag {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 3px 8px; border-radius: 7px;
	font-size: var(--fs-s); font-weight: var(--fw-semi); white-space: nowrap; line-height: 1.3;
	background: var(--soft); color: var(--sub);
}
.tag.accent { background: var(--btn-soft); color: var(--accent); }
.tag.ok { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- chips, segmented control */

.chips { display: flex; gap: var(--gap); overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--page-x) * -1); padding: 2px var(--page-x) 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
	flex-shrink: 0; padding: 8px 13px; border-radius: var(--radius-pill);
	font-size: 14px; font-weight: var(--fw-medium); white-space: nowrap;
	background: var(--soft); color: var(--text);
	display: inline-flex; align-items: center; gap: 6px;
	transition: background var(--ease), color var(--ease);
}
.chip.on { background: var(--btn); color: var(--btn-text); }
.chip .count { font-variant-numeric: tabular-nums; opacity: 0.6; }
.seg { display: flex; padding: 3px; gap: 3px; background: var(--soft); border-radius: 11px; }
.seg button { flex: 1; height: var(--seg-h); border-radius: 8px; font-weight: var(--fw-semi); font-size: 14px; color: var(--sub); display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.15s, color 0.15s; }
.seg button.on { background: var(--on); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---------------------------------------------------------------- buttons */

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: var(--tap-min); padding: 0 16px; border-radius: var(--radius-btn);
	font-size: var(--fs-m); font-weight: var(--fw-semi);
	background: var(--btn-soft); color: var(--accent);
	transition: opacity var(--ease), transform var(--ease);
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--radius-s); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; gap: var(--gap); margin-top: 12px; }
.btn-row > .btn { flex: 1; }
.icon-btn { width: var(--tap-min); height: var(--tap-min); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; transition: background var(--ease); }
.icon-btn:active { background: var(--softer); }
.icon-btn.plain { color: var(--hint); }
.icon-btn.on { color: var(--warn); }
.link-btn { color: var(--accent); font-size: 14px; padding: 6px 0; }


/* ---------------------------------------------------------------- inputs */

.field { display: block; width: 100%; background: var(--card); border: 0; border-radius: var(--radius-s); padding: 12px 14px; font-size: var(--fs-m); outline: none; }
.field::placeholder { color: var(--hint); }
textarea.field { resize: none; min-height: 120px; line-height: 1.4; border-radius: var(--radius); }
.search { position: relative; }
.search .field { padding-left: 40px; height: 42px; }
.search .s-icon { position: absolute; left: 12px; top: 12px; color: var(--hint); }
.search .clear { position: absolute; right: 0; top: -1px; }
.label { font-size: var(--fs-sm); font-weight: var(--fw-semi); text-transform: uppercase; letter-spacing: 0.04em; color: var(--head); margin: var(--section-gap) 2px 8px var(--page-x); }

/* ---------------------------------------------------------------- home */

.attn { background: var(--card); border-radius: var(--radius); padding: 14px var(--pad-card); animation: enter var(--dur) var(--ease-out); }
.attn + .attn { margin-top: 10px; }
.attn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.attn-head .who { font-weight: var(--fw-semi); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.attn-head .when { color: var(--hint); font-size: var(--fs-s); flex-shrink: 0; }
.attn-body .q-head { font-weight: var(--fw-semi); margin-bottom: 2px; }
.attn .preview { color: var(--sub); font-size: 14px; }
.attn-actions { display: flex; gap: var(--gap); margin-top: 12px; align-items: center; }
.attn-actions .btn { flex: 1; }
.options { display: flex; flex-direction: column; gap: var(--gap); margin-top: 12px; }
.option { text-align: left; padding: 10px 14px; border-radius: var(--radius-s); background: var(--soft); color: var(--text); font-size: var(--fs-body); transition: background var(--ease); }
.option b { color: var(--accent); font-weight: var(--fw-semi); }
.option .desc { display: block; color: var(--sub); font-size: var(--fs-sm); margin-top: 2px; }
.option.on { background: var(--btn); color: var(--btn-text); }
.option.on b, .option.on .desc { color: var(--btn-text); }
.other { margin-top: 8px; display: flex; gap: var(--gap); }
.other .field { background: var(--bg); font-size: var(--fs-body); padding: 10px 12px; }
.reason { white-space: pre-wrap; font-size: var(--fs-sm); color: var(--sub); max-height: 7.5em; overflow: hidden; margin-top: 6px; }
.reason.open { max-height: none; }



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

.chat-head { position: sticky; top: 0; z-index: 10; background: var(--bg); margin: calc(-10px - var(--safe-t)) calc(var(--page-x) * -1) 0; padding: calc(10px + var(--safe-t)) var(--page-x) 10px; border-bottom: 1px solid transparent; transition: border-color var(--ease); }
.chat-head.scrolled { border-bottom-color: var(--sep); }
.chat-title { font-size: var(--fs-l); font-weight: var(--fw-bold); line-height: 1.25; }
.chat-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: var(--fs-sm); color: var(--sub); }
.chat-head .head-row { display: flex; align-items: flex-start; gap: 2px; }

.msgs { display: flex; flex-direction: column; gap: 10px; padding: 10px 0 0; }
.msg { max-width: 100%; }
.msg-time { font-size: var(--fs-xs); color: var(--hint); margin-top: 4px; }
.msg.user { align-self: flex-end; max-width: 86%; }
.msg.user .bubble { background: var(--btn); color: var(--btn-text); border-radius: 18px 18px 6px 18px; padding: 9px 13px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-body); }
.msg.user .msg-time { text-align: right; }
.msg.user .via { opacity: 0.8; }
.msg.user.pending .bubble { opacity: 0.6; }
.msg.agent .bubble { background: var(--card); border-radius: 6px 18px 18px 18px; padding: 12px 14px; overflow-wrap: anywhere; position: relative; }
.msg.agent .bubble.clipped { max-height: 300px; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent); mask-image: linear-gradient(to bottom, #000 78%, transparent); }
.msg .more { font-size: var(--fs-sm); color: var(--accent); padding: 6px 2px 0; }
.msg-tools { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.msg-tools .msg-time { margin-top: 0; }
.load-earlier { align-self: center; }
.day { align-self: center; font-size: var(--fs-s); color: var(--sub); background: var(--soft); padding: 2px 10px; border-radius: var(--radius-pill); margin: 4px 0; }

.live { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: inset 3px 0 0 var(--good); }
.live-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: var(--fw-semi); }
.live-head .grow { font-weight: var(--fw-medium); color: var(--sub); font-size: var(--fs-sm); text-align: right; }
.live-tools { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.tool-line { display: flex; gap: 7px; align-items: baseline; font-size: var(--fs-sm); min-width: 0; }
.tool-line .ti { width: 18px; flex-shrink: 0; text-align: center; }
.tool-line .tl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-line .ts { flex-shrink: 0; font-size: var(--fs-s); color: var(--hint); font-variant-numeric: tabular-nums; }
.tool-line.running .tl { font-weight: var(--fw-medium); }
.tool-line.error .ts { color: var(--danger); }
.thoughts { margin-top: 8px; font-size: var(--fs-sm); color: var(--sub); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9.5em; overflow: hidden; display: flex; flex-direction: column-reverse; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 2.2em); mask-image: linear-gradient(to bottom, transparent, #000 2.2em); }
.thoughts.open { max-height: none; -webkit-mask-image: none; mask-image: none; }

.composer {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
	background: color-mix(in srgb, var(--bg) 88%, transparent);
	-webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
	border-top: 1px solid var(--sep);
	padding: 8px 10px calc(8px + var(--safe-bottom));
}
.composer-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.composer textarea { flex: 1; min-height: 40px; max-height: 148px; resize: none; border: 0; outline: none; border-radius: 20px; padding: 9px 14px; background: var(--card); font-size: var(--fs-m); line-height: 1.4; }
.composer textarea::placeholder { color: var(--hint); }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--btn); color: var(--btn-text); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity var(--ease); }
.send[disabled] { opacity: 0.35; }
.composer-opts { max-width: var(--maxw); margin: 0 auto 6px; display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); color: var(--sub); }
.composer-opts .opt { display: inline-flex; align-items: center; gap: 8px; }
.composer-opts .opt[hidden] { display: none; }
.composer-opts .opt-label { display: inline-flex; align-items: baseline; gap: 6px; }
.composer-opts .opt-sub { color: var(--hint); font-variant-numeric: tabular-nums; }
.ap-mark { color: var(--accent); display: inline-flex; }
.msg.note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 0; }
.note-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 86%; padding: 5px 11px; border-radius: var(--radius-pill); background: var(--soft); color: var(--sub); font-size: var(--fs-s); line-height: 1.3; }
.note-chip .note-emoji { font-size: 16px; }
.msg.note .msg-time { margin: 0; }
.sheet-note { color: var(--sub); font-size: var(--fs-s); line-height: 1.4; padding: 4px 4px 10px; }
/* Model routing card (Overview, System). */
.routing .label.tight { margin: 14px 0 8px; }
.routing-desc { margin-top: 10px; color: var(--sub); font-size: var(--fs-s); line-height: 1.4; }
.routing .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; gap: 6px; }
.routing .chip { padding: 5px 10px; font-size: var(--fs-s); }
.routing .seg.disabled { opacity: 0.55; }
.routing .seg button[disabled] { cursor: default; }
/* Agents & jobs: subagents and background jobs of a chat or of all chats. */
.agents .card-label { margin-bottom: 4px; }
.agent { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--sep); }
.agents .card-label + .agent { border-top: 0; padding-top: 4px; }
.agent-main { flex: 1; min-width: 0; text-align: left; display: block; }
.agent-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.agent-title { flex: 1; min-width: 0; font-weight: var(--fw-semi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-sub { color: var(--sub); font-size: var(--fs-s); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-cmd { color: var(--text); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-tools { margin-top: 6px; display: grid; gap: 3px; }
.agent-thoughts { margin-top: 6px; color: var(--hint); font-size: var(--fs-s); font-style: italic; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agent-out { margin: 6px 0 0; padding: 7px 9px; border-radius: 8px; background: var(--softer); color: var(--sub); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.35; white-space: pre-wrap; word-break: break-all; max-height: 6.2em; overflow: hidden; }
.agent > .btn { flex-shrink: 0; margin-top: 2px; }
.chat-screen.sub { padding-bottom: 40px; }
/* Tasks of a chat: goal, plan (todo_write), Agent Team board; "In progress" rows in Overview. */
.tasks .card-label .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.task-head { display: flex; align-items: center; gap: 8px; }
.goal-text { margin-top: 8px; font-size: var(--fs-m); line-height: 1.4; cursor: pointer; }
.progress { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; }
.progress-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--soft); overflow: hidden; }
.progress-bar i { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.progress-text { flex-shrink: 0; font-size: var(--fs-s); color: var(--sub); }
.todo-list { margin-top: 8px; display: grid; gap: 7px; }
.todo { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; line-height: 1.35; }
.todo-mark { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--hint); display: inline-flex; align-items: center; justify-content: center; }
.todo.completed .todo-mark { border-color: var(--good); background: var(--good); color: #fff; }
.todo.in_progress .todo-mark { border-color: var(--good); box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 8px var(--good); }
.todo-text { flex: 1; min-width: 0; }
.todo.completed .todo-text { color: var(--hint); text-decoration: line-through; }
.todo.in_progress .todo-text { font-weight: var(--fw-semi); }
.team-task { padding-top: 7px; border-top: 1px solid var(--sep); }
.todo-list .team-task:first-child { border-top: 0; padding-top: 0; }
.team-head { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.team-task.completed .todo-text { color: var(--hint); }
.row.work .row-main { min-width: 0; }
.work-step { margin-top: 3px; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.work .progress { margin-top: 6px; }
/* Model and effort: the chip in chat heads and the picker sheet. */
.model-line { margin-top: 6px; }
.model-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--soft); color: var(--accent); font-size: var(--fs-s); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip[hidden] { display: none; }
.model-chip.locked { color: var(--hint); }
.run-strip .model-chip { margin-right: 8px; flex-shrink: 0; }
.model-line .mode-chip { margin-right: 6px; }
.mode-chip { color: var(--sub); }
/* Konrad's status strip is narrow: the mode shows as an icon there, a tap names it. */
.run-strip .mode-chip { padding: 3px 7px; margin-right: 6px; }
.run-strip .mode-chip .model-text { display: none; }
/* Mode sheet: full descriptions, as in DSH's mode menu. */
.preset-row { align-items: flex-start; }
.preset-row .row-sub { white-space: normal; margin-top: 3px; line-height: 1.35; }
.preset-row.off { opacity: 0.45; }
.run-strip > .grow { min-width: 0; }
.run-strip .chat-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-group-head > span:first-child { white-space: nowrap; }
.sheet.tall { max-height: 86vh; overflow-y: auto; overscroll-behavior: contain; }
.sheet-title { font-size: 18px; font-weight: var(--fw-bold); padding: 2px 4px 6px; }
.sheet-sticky { position: sticky; top: -8px; z-index: 1; background: var(--card); margin-top: -8px; padding-top: 8px; border-bottom: 1px solid var(--sep); }
.model-group { margin-top: 12px; }
.model-group-head { display: flex; align-items: baseline; gap: 6px; padding: 0 4px 6px; font-size: 12px; font-weight: var(--fw-semi); text-transform: uppercase; letter-spacing: 0.03em; color: var(--head); }
.model-group-head .why { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--hint); text-align: right; }
.model-group.off .row { opacity: 0.45; }
.paid { color: var(--warn); font-weight: var(--fw-bold); }
.pick-mark { color: var(--accent); display: inline-flex; }
.back-link { display: inline-flex; align-items: center; gap: 2px; margin: 2px 0 6px; }
.chat-screen { padding-bottom: 150px; }
.chat-screen.root .nav-wrap { padding-bottom: 10px; }
.chat-screen.root .msgs { padding-top: 4px; }
.run-strip .dot.ok { background: var(--good); }
.composer .clip { width: 40px; height: 40px; }
.icon-btn.danger { color: var(--danger); }
.attachments { max-width: var(--maxw); margin: 0 auto 8px; display: flex; gap: var(--gap); overflow-x: auto; scrollbar-width: none; }
.attachments::-webkit-scrollbar { display: none; }
.att { flex-shrink: 0; display: flex; align-items: center; gap: 8px; max-width: 220px; background: var(--card); border-radius: var(--radius-s); padding: 6px 4px 6px 6px; }
.att img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.att-name { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.att-x { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--hint); flex-shrink: 0; }

/* ---------------------------------------------------------------- steps */

.step { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.step + .step { margin-top: 8px; }
.step-n { font-size: var(--fs-s); font-weight: var(--fw-semi); color: var(--head); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.step details { margin-bottom: 6px; }
.step summary { font-size: var(--fs-sm); color: var(--accent); cursor: pointer; list-style: none; display: flex; gap: 6px; align-items: center; }
.step summary::-webkit-details-marker { display: none; }
.step details[open] summary .ic { transform: rotate(90deg); }
.step .reasoning { white-space: pre-wrap; font-size: var(--fs-sm); color: var(--sub); margin-top: 6px; overflow-wrap: anywhere; }
.step .note { font-size: 14px; margin: 4px 0 6px; }
.turn-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.turn-nav .grow { text-align: center; font-size: var(--fs-sm); color: var(--sub); }

/* ---------------------------------------------------------------- files */

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; border-radius: var(--radius); overflow: hidden; }
.thumb { aspect-ratio: 1; background: var(--soft); position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.2s ease-out; }
.thumb img.ready { opacity: 1; }
.thumb.broken { background: var(--danger-soft); }
.ext { width: 38px; height: 38px; border-radius: var(--radius-s); background: var(--btn-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: var(--fw-bold); text-transform: uppercase; flex-shrink: 0; }
.viewer-img { width: 100%; border-radius: var(--radius); background: var(--soft); display: block; min-height: 120px; }
.viewer-text { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.viewer-text pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.5 var(--font-mono); }
.strip { display: flex; gap: var(--gap); overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--page-x) * -1); padding: 0 var(--page-x); }
.strip::-webkit-scrollbar { display: none; }
.strip .thumb { width: 84px; flex-shrink: 0; border-radius: var(--radius-s); }

/* ---------------------------------------------------------------- system */

.kv { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px var(--page-x); position: relative; }
.kv + .kv::before { content: ""; position: absolute; top: 0; left: var(--page-x); right: 0; border-top: 1px solid var(--sep); }
.kv .k { flex: 1; min-width: 0; font-size: var(--fs-m); }
.kv .v { color: var(--sub); font-size: 14px; text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.setting { padding: 12px var(--page-x); }
.setting + .setting { border-top: 1px solid var(--sep); }
.setting .s-title { font-weight: var(--fw-semi); margin-bottom: 2px; }
.setting .s-desc { font-size: var(--fs-sm); color: var(--sub); margin-bottom: 10px; }
.switch { width: 40px; height: 24px; border-radius: var(--radius-pill); background: var(--soft); position: relative; flex-shrink: 0; transition: background var(--ease); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform var(--ease); }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(16px); }

.guest-msg { max-width: 86%; padding: 8px 12px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.guest-msg.in { background: var(--card); align-self: flex-start; border-bottom-left-radius: 6px; }
.guest-msg.out { background: var(--btn-soft); align-self: flex-end; border-bottom-right-radius: 6px; }

/* ---------------------------------------------------------------- sheet, toast, states */

.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; background: rgba(0, 0, 0, 0.32); animation: fade var(--dur) ease-out; }
.sheet { width: 100%; max-width: var(--maxw); margin: 0 auto; background: var(--card); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 8px 16px calc(var(--safe-bottom) + 16px); animation: rise var(--dur) var(--ease-out); }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 6px; }
.sheet .list { background: transparent; }
.sheet .row { padding-left: 4px; padding-right: 4px; }
.sheet .row::before { left: 36px !important; }
.sheet .row-title { font-weight: var(--fw-medium); }
.sheet .row.danger { color: var(--danger); }
.sheet .row .lead { color: var(--accent); }
.sheet .row.danger .lead { color: var(--danger); }
.sheet .btn { background: var(--soft); color: var(--text); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }

.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--card); padding: 10px 14px; border-radius: 12px; font-size: 14px; max-width: min(92vw, 420px); text-align: center; animation: toast-in 0.2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
body.has-composer .toast { bottom: calc(118px + var(--safe-b)); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px); } }

.center-state { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 10px; }
.center-state h2 { font-size: var(--fs-xl); margin: 0; }
.center-state p { color: var(--sub); margin: 0; max-width: 300px; }
.banner { background: var(--warn-soft); color: var(--text); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.banner.bad { background: var(--danger-soft); }

.skeleton { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.skel-row { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 var(--page-x); }
.skel-row + .skel-row { border-top: 1px solid var(--sep); }
.skel-bar { height: 10px; border-radius: 5px; background: var(--soft); animation: shimmer 1.2s ease-in-out infinite alternate; }
@keyframes shimmer { from { opacity: 0.55; } to { opacity: 1; } }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--btn-soft); border-top-color: var(--btn); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- markdown */

.md { font-size: var(--fs-body); line-height: 1.45; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 14px 0 6px; line-height: 1.3; }
.md h2 { font-size: var(--fs-l); }
.md h3 { font-size: 17px; }
.md h4, .md h5, .md h6 { font-size: var(--fs-body); }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md blockquote { margin: 0 0 8px; padding: 2px 0 2px 12px; box-shadow: inset 3px 0 0 var(--btn-soft); color: var(--sub); }
.md code { font-family: var(--font-mono); font-size: 0.87em; background: var(--soft); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.md pre { margin: 0 0 8px; background: var(--soft); border-radius: var(--radius-s); padding: 10px 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.5; white-space: pre; overflow-wrap: normal; }
.md hr { border: 0; border-top: 1px solid var(--sep); margin: 12px 0; }
.md a { color: var(--link); overflow-wrap: anywhere; }
.md .path { font-family: var(--font-mono); font-size: 0.87em; color: var(--accent); }
.md .table-wrap { overflow-x: auto; margin: 0 0 8px; border-radius: var(--radius-s); border: 1px solid var(--sep); }
.md table { border-collapse: collapse; font-size: var(--fs-sm); width: max-content; min-width: 100%; }
.md th, .md td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--sep); max-width: 15em; }
.md tr:last-child td { border-bottom: 0; }
.md th { font-weight: var(--fw-semi); background: var(--softer); white-space: nowrap; }
.md .al-c { text-align: center; }
.md .al-r { text-align: right; }
.md .task { display: inline-block; width: 1.1em; color: var(--hint); }
.md .task.done { color: var(--good); }
.md strong { font-weight: var(--fw-semi); }
