/* Saathi help widget: Saptapadi colours, mobile-first, keyboard friendly. */
.saathi-root {
	--s-wine: #8b1e3f;
	--s-wine-dark: #6d1631;
	--s-gold: #c99a2e;
	--s-ink: #2b2024;
	--s-muted: #6f6266;
	--s-line: #e7dcdf;
	--s-bg: #fbf7f5;
	--s-card: #fff;
	--s-warn-bg: #fdf3dc;
	--s-warn: #7a5200;
	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 9990;
	font: 15px/1.5 "Segoe UI", "Nirmala UI", system-ui, sans-serif;
	color: var(--s-ink);
}
.saathi-root *, .saathi-root *::before, .saathi-root *::after { box-sizing: border-box; }
.saathi-root[lang="mr"] { font-family: "Nirmala UI", "Mukta", "Segoe UI", sans-serif; }
.saathi-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Launcher */
.saathi-launcher {
	display: inline-flex; align-items: center; gap: .5rem;
	min-height: 52px; padding: 0 1.1rem 0 .95rem; border: 0; border-radius: 999px; cursor: pointer;
	background: var(--s-wine); color: #fff; font: inherit; font-weight: 700;
	box-shadow: 0 6px 20px rgba(60, 10, 25, .28);
	float: right;
}
.saathi-launcher svg { width: 24px; height: 24px; flex: none; }
.saathi-launcher:hover { background: var(--s-wine-dark); }
.saathi-root button:focus-visible, .saathi-root a:focus-visible, .saathi-root textarea:focus-visible, .saathi-log:focus-visible {
	outline: 3px solid var(--s-gold); outline-offset: 2px;
}
.saathi-root.is-open .saathi-launcher { display: none; }
@media (max-width: 600px) {
	.saathi-launcher { min-height: 48px; width: 48px; padding: 0; justify-content: center; }
	.saathi-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
	/* Step aside while a page form field has focus (keyboard open), so it never covers a form. */
	.saathi-root.saathi-yield:not(.is-open) { opacity: 0; pointer-events: none; }
}

/* Panel */
.saathi-panel {
	display: flex; flex-direction: column;
	width: min(390px, calc(100vw - 32px));
	height: min(600px, calc(100dvh - 32px));
	background: var(--s-card); border: 1px solid var(--s-line); border-radius: 16px; overflow: hidden;
	box-shadow: 0 18px 50px rgba(60, 10, 25, .28);
}
.saathi-panel[hidden] { display: none; }
@media (max-width: 600px) {
	.saathi-root.is-open { left: 0; right: 0; bottom: 0; }
	.saathi-panel { width: 100vw; height: min(88dvh, 640px); border-radius: 16px 16px 0 0; border-bottom: 0; }
}

.saathi-head { display: flex; gap: .5rem; align-items: center; justify-content: space-between; padding: .7rem .75rem .6rem 1rem; background: var(--s-wine); color: #fff; }
.saathi-name { margin: 0; font: 700 1.05rem/1.2 Georgia, "Nirmala UI", serif; color: #fff; }
.saathi-tag { margin: 0; font-size: .78rem; opacity: .9; }
.saathi-tools { display: flex; align-items: center; gap: .25rem; flex: none; }
.saathi-langs { display: inline-flex; border: 1px solid rgba(255, 255, 255, .5); border-radius: 999px; overflow: hidden; margin-right: .2rem; }
.saathi-lang { border: 0; background: transparent; color: #fff; font: inherit; font-size: .8rem; font-weight: 700; padding: .3rem .6rem; min-height: 32px; cursor: pointer; }
.saathi-lang[aria-pressed="true"] { background: #fff; color: var(--s-wine); }
.saathi-icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; }
.saathi-icon-btn:hover { background: rgba(255, 255, 255, .15); }
.saathi-icon-btn svg { width: 20px; height: 20px; }

.saathi-disclosure { margin: 0; padding: .5rem 1rem; font-size: .78rem; color: var(--s-muted); background: var(--s-bg); border-bottom: 1px solid var(--s-line); }

.saathi-log { flex: 1; overflow-y: auto; padding: .9rem .9rem .5rem; background: var(--s-bg); scroll-behavior: smooth; overscroll-behavior: contain; }
.saathi-msg { max-width: 88%; margin: 0 0 .7rem; padding: .6rem .8rem; border-radius: 14px; overflow-wrap: anywhere; }
.saathi-msg p { margin: 0 0 .45rem; }
.saathi-msg p:last-child { margin-bottom: 0; }
.saathi-bot { background: #fff; border: 1px solid var(--s-line); border-top-left-radius: 4px; }
.saathi-me { margin-left: auto; background: var(--s-wine); color: #fff; border-top-right-radius: 4px; }
.saathi-kind-typing { color: var(--s-muted); font-style: italic; }
.saathi-kind-safety { border-left: 4px solid var(--s-gold); }
.saathi-kind-error { border-color: #f0c2c6; background: #fff7f7; }
.saathi-draft { margin-top: .4rem !important; padding: .2rem .5rem; border-radius: 6px; font-size: .74rem; background: var(--s-warn-bg); color: var(--s-warn); }

.saathi-links { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.saathi-link { display: inline-block; padding: .3rem .7rem; border-radius: 999px; background: var(--s-wine); color: #fff !important; font-size: .82rem; font-weight: 600; text-decoration: none; }
.saathi-link:hover { background: var(--s-wine-dark); }
.saathi-related { margin-top: .6rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.saathi-related-label { width: 100%; margin: 0 0 .1rem !important; font-size: .78rem; color: var(--s-muted); }
.saathi-chip { border: 1px solid var(--s-line); background: #fff; color: var(--s-wine); border-radius: 999px; padding: .32rem .7rem; min-height: 34px; font: inherit; font-size: .84rem; text-align: left; cursor: pointer; }
.saathi-chip:hover { border-color: var(--s-wine); background: #fbeef2; }

.saathi-form { display: flex; gap: .5rem; align-items: flex-end; padding: .6rem .7rem; border-top: 1px solid var(--s-line); background: #fff; }
.saathi-input { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: .6rem .75rem; border: 1px solid var(--s-line); border-radius: 12px; font: inherit; color: var(--s-ink); background: #fff; }
.saathi-send { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--s-wine); color: #fff; cursor: pointer; }
.saathi-send:disabled { opacity: .5; cursor: wait; }
.saathi-send svg { width: 20px; height: 20px; }
.saathi-count { display: block; padding: 0 .9rem .35rem; font-size: .72rem; color: var(--s-muted); text-align: right; background: #fff; min-height: 0; }
.saathi-count:empty { display: none; }

@media (prefers-reduced-motion: reduce) { .saathi-log { scroll-behavior: auto; } }
@media print { .saathi-root { display: none !important; } }
