#tanal-chat {
	--tc-orange: #E66C2C;
	--tc-gray: #54595F;
	--tc-text: #333333;
	position: fixed;
	right: 20px;
	bottom: 20px;
	right: max(20px, env(safe-area-inset-right));
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 2147483000;
	-webkit-text-size-adjust: 100%;
	--tc-h: 100vh;
	font-family: Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	color: var(--tc-text);
}
#tanal-chat *, #tanal-chat *::before, #tanal-chat *::after { box-sizing: border-box; }
@supports (height: 100dvh) { #tanal-chat { --tc-h: 100dvh; } }

#tanal-chat .tc-toggle {
	width: 58px; height: 58px;
	border: 0; border-radius: 50%;
	background: var(--tc-orange); color: #fff;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
	transition: transform .2s ease, background .2s ease;
	margin-left: auto;
	padding: 0;
}
#tanal-chat .tc-toggle:hover { transform: scale(1.06); background: #d45f22; }
#tanal-chat.tc-open .tc-toggle { display: none; }

#tanal-chat .tc-panel {
	width: 370px;
	max-width: calc(100vw - 24px);
	height: 520px;
	max-height: calc(100vh - 40px);
	width: min(380px, calc(100vw - 24px));
	height: min(560px, calc(var(--tc-vh, var(--tc-h)) - 40px));
	max-height: none;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, .28);
	display: flex; flex-direction: column;
	overflow: hidden;
}
#tanal-chat .tc-panel[hidden] { display: none; }

#tanal-chat .tc-head {
	background: var(--tc-orange); color: #fff;
	padding: 14px 16px;
	display: flex; align-items: center; justify-content: space-between;
}
#tanal-chat .tc-title { display: flex; flex-direction: column; }
#tanal-chat .tc-title strong { font-size: 16px; font-weight: 700; }
#tanal-chat .tc-title span { font-size: 12px; opacity: .9; }
#tanal-chat .tc-close {
	background: transparent; border: 0; color: #fff;
	font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px;
}

#tanal-chat .tc-log {
	flex: 1; overflow-y: auto; min-height: 0;
	overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
	padding: 14px;
	background: #f6f6f6;
	display: flex; flex-direction: column; gap: 8px;
}
#tanal-chat .tc-msg {
	max-width: 85%;
	padding: 9px 12px;
	border-radius: 12px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}
#tanal-chat .tc-bot { background: #fff; align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
#tanal-chat .tc-user { background: var(--tc-orange); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
#tanal-chat .tc-bot a { color: var(--tc-orange); font-weight: 500; text-decoration: underline; }
#tanal-chat .tc-typing { color: var(--tc-gray); animation: tc-pulse 1s infinite; }
@keyframes tc-pulse { 50% { opacity: .35; } }

#tanal-chat .tc-form {
	display: flex; gap: 8px;
	padding: 10px;
	border-top: 1px solid #e4e4e4;
	background: #fff;
}
#tanal-chat .tc-input {
	flex: 1; resize: none;
	border: 1px solid #cfcfcf; border-radius: 8px;
	padding: 9px 10px;
	font: inherit; color: var(--tc-text);
	max-height: 96px;
}
#tanal-chat .tc-input:focus { outline: 2px solid var(--tc-orange); outline-offset: -1px; border-color: transparent; }
#tanal-chat .tc-send {
	border: 0; border-radius: 8px;
	background: var(--tc-orange); color: #fff;
	padding: 0 16px; font: inherit; font-weight: 500; cursor: pointer;
}
#tanal-chat .tc-send:hover:not(:disabled) { background: #d45f22; }
#tanal-chat .tc-send:disabled { opacity: .5; cursor: default; }
#tanal-chat .tc-note {
	font-size: 11px; color: #777; text-align: center;
	padding: 0 10px 6px; background: #fff;
}

/* gumbi za odgovore (obrazci, soglasje) */
#tanal-chat .tc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: stretch; }
#tanal-chat .tc-hint { flex-basis: 100%; font-size: 12px; color: #b3541b; }
#tanal-chat .tc-chip {
	border: 1px solid var(--tc-orange); background: #fff; color: var(--tc-orange);
	border-radius: 18px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
#tanal-chat .tc-chip:hover { background: #fff1e9; }
#tanal-chat .tc-chip.tc-sel, #tanal-chat .tc-chip.tc-go { background: var(--tc-orange); color: #fff; }
#tanal-chat .tc-chip.tc-go:hover, #tanal-chat .tc-chip.tc-sel:hover { background: #d45f22; }
#tanal-chat .tc-chip.tc-cancel { border-color: #bbb; color: #777; }
#tanal-chat .tc-chip.tc-cancel:hover { background: #f0f0f0; }

#tanal-chat .tc-links { display: flex; justify-content: center; gap: 14px; padding: 0 10px 10px; background: #fff; }
#tanal-chat .tc-link { background: none; border: 0; padding: 0; font: inherit; font-size: 12px; color: #777; text-decoration: underline; cursor: pointer; }
#tanal-chat .tc-link:hover { color: var(--tc-orange); }
#tanal-chat .tc-link[hidden] { display: none; }

/* ---------- odzivnost ---------- */

/* velik zaslon: malo večje okno */
@media (min-width: 1200px) and (min-height: 820px) {
	#tanal-chat .tc-panel { width: min(410px, calc(100vw - 40px)); height: min(640px, calc(var(--tc-vh, var(--tc-h)) - 40px)); }
}

/* telefon (pokonci) in nizki zasloni (telefon ležeče): okno čez cel zaslon */
@media (max-width: 600px), (max-height: 500px) {
	#tanal-chat.tc-open { top: var(--tc-vt, 0px); left: 0; right: 0; bottom: auto; width: 100%; height: var(--tc-vh, var(--tc-h)); }
	#tanal-chat.tc-open .tc-panel { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; box-shadow: none; }
	#tanal-chat .tc-head { padding-top: max(14px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
	#tanal-chat .tc-log { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
	#tanal-chat .tc-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
	#tanal-chat .tc-msg { max-width: 90%; }
	/* 16px prepreči samodejni zoom na iOS */
	#tanal-chat .tc-input { font-size: 16px; }
	html.tc-lock, html.tc-lock body { overflow: hidden !important; }
}

/* zelo nizki zasloni (ležeč telefon): kompaktna glava, brez opombe */
@media (max-height: 500px) {
	#tanal-chat .tc-head { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
	#tanal-chat .tc-title span { display: none; }
	#tanal-chat .tc-note { display: none; }
	#tanal-chat .tc-links { padding-bottom: 4px; }
	#tanal-chat .tc-log { padding-top: 8px; padding-bottom: 8px; }
}

/* zelo ozek zaslon */
@media (max-width: 340px) {
	#tanal-chat .tc-msg { max-width: 94%; }
	#tanal-chat .tc-send { padding: 0 12px; }
	#tanal-chat .tc-chip { padding: 6px 10px; }
}

/* dotik: dovolj velike tarče (najmanj 44 px) */
@media (pointer: coarse) {
	#tanal-chat .tc-toggle { width: 60px; height: 60px; }
	#tanal-chat .tc-close { min-width: 44px; min-height: 44px; font-size: 32px; }
	#tanal-chat .tc-chip { min-height: 44px; padding: 8px 16px; }
	#tanal-chat .tc-send { min-height: 44px; min-width: 72px; }
	#tanal-chat .tc-input { min-height: 44px; font-size: 16px; }
	#tanal-chat .tc-link { min-height: 44px; padding: 0 10px; }
	#tanal-chat .tc-links { gap: 6px; padding-bottom: 4px; }
}

/* tipkovnica: viden fokus */
#tanal-chat button:focus-visible, #tanal-chat a:focus-visible { outline: 2px solid var(--tc-orange); outline-offset: 2px; }
#tanal-chat .tc-head button:focus-visible { outline-color: #fff; }

@media (prefers-reduced-motion: reduce) {
	#tanal-chat, #tanal-chat * { animation: none !important; transition: none !important; }
}
@media print { #tanal-chat { display: none !important; } }

/* testni predogled obrazca (samo v testni različici) */
#tanal-chat .tc-msg.tc-preview { background: #f0f0f0; color: #444; font-size: 12.5px; max-width: 100%; border: 1px dashed #bbb; }

/* povezave v sporočilih */
#tanal-chat .tc-msg a { word-break: break-all; }
#tanal-chat .tc-user a { color: #fff; }

#tanal-chat .tc-hint {
	position: absolute; right: 0; bottom: 70px;
	width: max-content; max-width: min(260px, calc(100vw - 40px));
	background: #fff; color: var(--tc-text);
	padding: 12px 34px 12px 14px;
	border-radius: 12px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
	font-size: 14px; line-height: 1.4;
	cursor: pointer;
}
#tanal-chat .tc-hint::after {
	content: ""; position: absolute; right: 22px; bottom: -6px;
	width: 12px; height: 12px; background: #fff;
	transform: rotate(45deg); box-shadow: 3px 3px 4px rgba(0, 0, 0, .08);
}
#tanal-chat .tc-hint-x {
	position: absolute; top: 4px; right: 6px;
	width: 24px; height: 24px; padding: 0; border: 0; background: none;
	font-size: 20px; line-height: 1; color: var(--tc-gray); cursor: pointer;
}
#tanal-chat.tc-open .tc-hint { display: none; }
