/* Klash Forms — conversational form styles. All colours come from CSS variables set per form. */

.klash-form {
	position: relative;
	width: 100%;
	height: var(--kf-height, 600px);
	min-height: 360px;
	overflow: hidden;
	border-radius: 0;
}
.klash-form.kf-mode-fullscreen {
	height: 100vh;
	height: 100dvh;
}
.klash-form.kf-mode-popup {
	height: 100%;
}

.kf-app {
	--kf-pad: clamp(20px, 5vw, 64px);
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	background: var(--kf-bg);
	color: var(--kf-text);
	font-family: var(--kf-font);
	font-size: 16px;
	line-height: 1.4;
	text-align: left;
	-webkit-font-smoothing: antialiased;
	overflow: hidden;
	isolation: isolate;
}
.kf-app *, .kf-app *::before, .kf-app *::after { box-sizing: border-box; }
.kf-app button, .kf-app input, .kf-app textarea { font-family: inherit; color: inherit; letter-spacing: normal; text-transform: none; }
.kf-app img { max-width: 100%; }
.kf-app [hidden] { display: none !important; }

.kf-bg { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; }
.kf-bg-overlay { position: absolute; inset: 0; z-index: -1; }

.kf-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

/* Progress --------------------------------------------------------------- */
.kf-progress { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--kf-answer-mid); z-index: 5; }
.kf-progress span { display: block; height: 100%; width: 0; background: var(--kf-answer); transition: width .5s cubic-bezier(.4, 0, .2, 1); }
.kf-no-progress .kf-progress { display: none; }

/* Screens ---------------------------------------------------------------- */
.kf-stage { position: relative; flex: 1; min-height: 0; }
.kf-screen {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	overscroll-behavior: contain;
	transition: transform .45s cubic-bezier(.4, 0, .2, 1), opacity .45s cubic-bezier(.4, 0, .2, 1);
	outline: none;
}
.kf-inner {
	width: 100%;
	max-width: 760px;
	margin: auto;
	padding: 56px var(--kf-pad) 96px;
}
.kf-enter-up { transform: translateY(60px); opacity: 0; }
.kf-enter-down { transform: translateY(-60px); opacity: 0; }
.kf-leave-up { transform: translateY(-60px); opacity: 0; pointer-events: none; }
.kf-leave-down { transform: translateY(60px); opacity: 0; pointer-events: none; }

.kf-align-center .kf-welcome .kf-inner, .kf-align-center .kf-ending .kf-inner, .kf-align-center .kf-field .kf-inner { text-align: center; }
.kf-align-center .kf-q { justify-content: center; }
.kf-align-center .kf-actions { justify-content: center; }
.kf-align-center .kf-options:not(.kf-options-stack) { justify-content: center; }
.kf-align-center .kf-media { margin-left: auto; margin-right: auto; }
.kf-align-center .kf-scale-row { justify-content: center; }
.kf-welcome .kf-inner, .kf-ending .kf-inner { text-align: center; }
.kf-welcome .kf-actions, .kf-ending .kf-actions { justify-content: center; }

/* Typography ------------------------------------------------------------- */
.kf-app { --kf-title: clamp(22px, 3.2vw, 30px); --kf-answer-size: clamp(20px, 2.8vw, 28px); }
.kf-size-sm { --kf-title: clamp(19px, 2.6vw, 24px); --kf-answer-size: clamp(18px, 2.3vw, 22px); }
.kf-size-lg { --kf-title: clamp(26px, 4vw, 40px); --kf-answer-size: clamp(22px, 3.2vw, 32px); }

.kf-q { display: flex; align-items: baseline; gap: 10px; }
.kf-num { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; color: var(--kf-answer); white-space: nowrap; transform: translateY(-2px); }
.kf-num svg { opacity: .9; }
.kf-app .kf-title { font-family: inherit; font-size: var(--kf-title); line-height: 1.3; font-weight: 500; margin: 0; color: var(--kf-text); letter-spacing: -.01em; overflow-wrap: anywhere; }
.kf-welcome .kf-title, .kf-ending .kf-title { font-size: calc(var(--kf-title) * 1.25); font-weight: 600; }
.kf-req { color: var(--kf-answer); margin-left: 4px; }
.kf-desc { margin-top: 10px; font-size: calc(var(--kf-title) * .62); line-height: 1.5; color: var(--kf-text-soft); }
.kf-desc a { color: var(--kf-answer); }
.kf-recall { font-weight: inherit; }
.kf-recall-empty { opacity: .45; }
.kf-subhint { margin-top: 14px; font-size: 14px; color: var(--kf-answer); }
.kf-media { display: block; max-height: 260px; width: auto; border-radius: var(--kf-radius); margin: 0 0 24px; object-fit: cover; }

/* Controls ---------------------------------------------------------------- */
.kf-control { margin-top: 30px; position: relative; }

.kf-app .kf-input {
	display: block;
	width: 100%;
	border: 0;
	border-bottom: 1px solid var(--kf-answer-line);
	border-radius: 0;
	background: transparent;
	color: var(--kf-answer);
	font-size: var(--kf-answer-size);
	line-height: 1.35;
	padding: 6px 0 9px;
	margin: 0;
	outline: none;
	box-shadow: none;
	transition: border-color .2s, box-shadow .2s;
	-webkit-appearance: none;
	appearance: none;
	min-height: 0;
	height: auto;
}
.kf-app .kf-input::placeholder { color: var(--kf-answer); opacity: .35; }
.kf-app .kf-input:focus { border-bottom-color: var(--kf-answer); box-shadow: 0 2px 0 var(--kf-answer); background: transparent; }
.kf-app .kf-textarea { resize: none; overflow: hidden; min-height: 48px; }
.kf-app .kf-date { max-width: 320px; color-scheme: light dark; }
.kf-app .kf-date::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }

/* Combobox (dropdown + country) */
.kf-combo { position: relative; }
.kf-combo-field { position: relative; display: flex; align-items: center; }
.kf-app .kf-combo-input { padding-right: 76px; cursor: text; }
.kf-app .kf-combo-toggle, .kf-app .kf-combo-clear {
	position: absolute; right: 0; top: 50%; transform: translateY(-50%);
	border: 0; background: transparent; color: var(--kf-answer); padding: 6px; cursor: pointer; line-height: 0; border-radius: 6px;
}
.kf-app .kf-combo-clear { right: 36px; opacity: .7; }
.kf-combo.is-open .kf-combo-toggle svg { transform: rotate(180deg); }
.kf-combo-list {
	list-style: none; margin: 8px 0 0; padding: 4px 4px 4px 0; max-height: 260px; overflow-y: auto; position: relative;
	scrollbar-width: thin;
}
.kf-combo-opt {
	display: flex; align-items: center; gap: 10px; margin: 0 0 6px; padding: 9px 12px;
	border: 1px solid var(--kf-answer-line); border-radius: calc(var(--kf-radius) * .6); background: var(--kf-answer-soft);
	color: var(--kf-answer); cursor: pointer; font-size: 17px; transition: background .15s;
}
.kf-combo-opt svg { margin-left: auto; opacity: 0; flex: none; }
.kf-combo-opt:hover, .kf-combo-opt.is-active { background: var(--kf-answer-mid); }
.kf-combo-opt.is-selected { background: var(--kf-answer-mid); border-color: var(--kf-answer); }
.kf-combo-opt.is-selected svg { opacity: 1; }
.kf-combo-empty { padding: 10px 2px; color: var(--kf-answer); opacity: .7; font-size: 15px; }

/* Phone */
.kf-phone-row { display: flex; align-items: flex-end; gap: 12px; }
.kf-app .kf-phone-country {
	display: inline-flex; align-items: center; gap: 6px; flex: none;
	border: 0; border-bottom: 1px solid var(--kf-answer-line); background: transparent; color: var(--kf-answer);
	font-size: var(--kf-answer-size); line-height: 1.35; padding: 6px 2px 9px; cursor: pointer; border-radius: 0;
}
.kf-app .kf-phone-country:focus-visible { outline: none; border-bottom-color: var(--kf-answer); box-shadow: 0 2px 0 var(--kf-answer); }
.kf-phone-country svg { width: 18px; height: 18px; opacity: .8; }
.kf-flag { font-family: 'Twemoji Country Flags', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.kf-dial { opacity: .85; }
.kf-phone-input { flex: 1; min-width: 0; }
.kf-phone-picker { margin-top: 14px; }
.kf-combo-country .kf-combo-opt .kf-dial { margin-left: auto; font-size: 15px; }
.kf-combo-country .kf-combo-opt svg { display: none; }

/* Option buttons (choices, yes/no, legal, pictures) */
.kf-options { display: inline-flex; flex-wrap: wrap; gap: 10px; flex-direction: column; align-items: stretch; min-width: min(100%, 240px); max-width: 100%; }
.kf-options.kf-options-stack, .kf-options.kf-options-pictures { display: flex; align-items: flex-start; }
.kf-options.kf-options-inline { flex-direction: row; }
.kf-options.kf-options-stack .kf-option { width: 100%; max-width: 520px; }
.kf-app .kf-option {
	position: relative; display: flex; flex-direction: column; min-width: 180px; max-width: 100%;
	border: 1px solid var(--kf-answer-line); background: var(--kf-answer-soft); color: var(--kf-answer);
	border-radius: calc(var(--kf-radius) * .6); padding: 0; margin: 0; cursor: pointer; text-align: left;
	font-size: 18px; line-height: 1.3; font-weight: 400; transition: background .15s, box-shadow .15s; box-shadow: none; text-transform: none;
}
.kf-app .kf-option:hover { background: var(--kf-answer-mid); color: var(--kf-answer); }
.kf-app .kf-option:focus-visible { outline: 2px solid var(--kf-answer); outline-offset: 2px; }
.kf-app .kf-option.is-selected { box-shadow: inset 0 0 0 1px var(--kf-answer); background: var(--kf-answer-mid); }
.kf-option-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 9px; width: 100%; }
.kf-key {
	flex: none; display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; font-size: 12px; font-weight: 600;
	border: 1px solid var(--kf-answer-line); border-radius: 4px; background: var(--kf-bg); color: var(--kf-answer);
}
.kf-option.is-selected .kf-key { background: var(--kf-answer); color: var(--kf-bg); border-color: var(--kf-answer); }
.kf-option-label { flex: 1; overflow-wrap: anywhere; }
.kf-option-check { flex: none; display: inline-flex; opacity: 0; margin-left: 8px; }
.kf-option.is-selected .kf-option-check { opacity: 1; }
.kf-option-other { cursor: text; }

/* Multi-select: a visible checkbox on every option. */
.kf-options-multi .kf-option-check {
	opacity: 1; width: 20px; height: 20px; align-items: center; justify-content: center;
	border: 1.5px solid var(--kf-answer-line); border-radius: 4px; background: var(--kf-bg); color: var(--kf-bg);
}
.kf-options-multi .kf-option-check svg { opacity: 0; width: 14px; height: 14px; }
.kf-options-multi .kf-option.is-selected .kf-option-check { background: var(--kf-answer); border-color: var(--kf-answer); }
.kf-options-multi .kf-option.is-selected .kf-option-check svg { opacity: 1; }
.kf-option-other .kf-option-label { flex: none; }
.kf-app .kf-other-input {
	flex: 1; min-width: 80px; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--kf-answer);
	font-size: 17px; padding: 2px 4px; outline: none; margin: 0; box-shadow: none; height: auto;
}
.kf-app .kf-other-input:focus, .kf-option-other.is-editing .kf-other-input { border-bottom-color: var(--kf-answer-line); background: transparent; box-shadow: none; }
.kf-app .kf-other-input::placeholder { color: var(--kf-answer); opacity: .4; }

.kf-options-pictures { flex-direction: row; }
.kf-app .kf-options-pictures .kf-option { width: calc(33.333% - 7px); min-width: 150px; max-width: 220px; padding: 8px; }
.kf-option-img { display: block; aspect-ratio: 4 / 3; border-radius: calc(var(--kf-radius) * .4); overflow: hidden; background: var(--kf-answer-soft); }
.kf-option-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf-options-pictures .kf-option-row { padding: 10px 2px 2px; }

.kf-blink { animation: kfBlink .35s ease 2; }
@keyframes kfBlink { 50% { background: var(--kf-answer-soft); } }

/* Rating & opinion scale */
.kf-scale-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kf-app .kf-scale-btn {
	flex: 1 1 0; min-width: 40px; max-width: 72px; height: 60px; display: grid; place-items: center; margin: 0; padding: 0;
	border: 1px solid var(--kf-answer-line); background: var(--kf-answer-soft); color: var(--kf-answer);
	border-radius: calc(var(--kf-radius) * .6); cursor: pointer; font-size: 18px; transition: background .15s, transform .15s; box-shadow: none;
}
.kf-app .kf-scale-btn:hover { background: var(--kf-answer-mid); color: var(--kf-answer); }
.kf-app .kf-scale-btn.is-selected { background: var(--kf-answer); color: var(--kf-bg); }
.kf-app .kf-scale-btn:focus-visible { outline: 2px solid var(--kf-answer); outline-offset: 2px; }
.kf-opinion .kf-scale-row { flex-wrap: nowrap; }
.kf-opinion .kf-scale-btn { max-width: none; }
.kf-scale-labels { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; color: var(--kf-answer); gap: 10px; }
.kf-scale-labels span:nth-child(2) { text-align: center; }
.kf-scale-labels span:last-child { text-align: right; }

.kf-rating .kf-scale-row { gap: 4px; }
.kf-app .kf-rating:not(.kf-rating-number) .kf-scale-btn { border: 0; background: transparent; height: auto; flex: 0 0 auto; width: 56px; max-width: none; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.kf-rating-icon svg { width: 44px; height: 44px; fill: transparent; stroke: var(--kf-answer); stroke-width: 1.3; transition: fill .15s, transform .15s; }
.kf-rating-n { font-size: 13px; opacity: .8; }
.kf-app .kf-rating .kf-scale-btn.is-filled .kf-rating-icon svg { fill: var(--kf-answer); }
.kf-app .kf-rating .kf-scale-btn:hover .kf-rating-icon svg { transform: scale(1.08); }
.kf-app .kf-rating:not(.kf-rating-number) .kf-scale-btn.is-selected { background: transparent; color: var(--kf-answer); }

/* File upload */
.kf-file-input { display: none !important; }
.kf-app .kf-dropzone {
	width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 20px; margin: 0;
	border: 1px dashed var(--kf-answer-line); border-radius: var(--kf-radius); background: var(--kf-answer-soft); color: var(--kf-answer);
	cursor: pointer; font-size: 17px; transition: background .15s; box-shadow: none;
}
.kf-app .kf-dropzone:hover, .kf-app .kf-dropzone.is-drag { background: var(--kf-answer-mid); color: var(--kf-answer); }
.kf-drop-meta { font-size: 13px; opacity: .75; }
.kf-file-list { list-style: none; margin: 12px 0 0; padding: 0; }
.kf-file-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 0 0 8px; border: 1px solid var(--kf-answer-line); border-radius: calc(var(--kf-radius) * .6); color: var(--kf-answer); background: var(--kf-answer-soft); }
.kf-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-file-size { font-size: 13px; opacity: .7; }
.kf-app .kf-file-remove { border: 0; background: transparent; color: var(--kf-answer); cursor: pointer; padding: 4px; line-height: 0; margin: 0; }

/* Errors, actions, buttons ---------------------------------------------- */
.kf-error {
	display: none; margin-top: 14px; padding: 6px 12px; border-radius: 4px; font-size: 14px;
	background: #fde8e8; color: #b42318; width: fit-content; max-width: 100%;
}
.kf-error.is-visible { display: inline-block; animation: kfFade .25s ease; }
.kf-shake { animation: kfShake .4s ease; }

.kf-actions { display: flex; align-items: center; gap: 14px; margin-top: 28px; flex-wrap: wrap; }
.kf-app .kf-btn {
	display: inline-flex; align-items: center; gap: 8px; border: 0; margin: 0;
	background: var(--kf-accent); color: var(--kf-button-text); font-size: 18px; font-weight: 600; line-height: 1.2;
	padding: 11px 20px; border-radius: calc(var(--kf-radius) * .6); cursor: pointer; text-decoration: none;
	box-shadow: 0 3px 12px -2px rgba(0, 0, 0, .15); transition: filter .15s, transform .15s; text-transform: none; letter-spacing: normal; min-height: 0;
}
.kf-app .kf-btn:hover { filter: brightness(1.08); color: var(--kf-button-text); background: var(--kf-accent); }
.kf-app .kf-btn:active { transform: translateY(1px); }
.kf-app .kf-btn:focus-visible { outline: 2px solid var(--kf-accent); outline-offset: 3px; }
.kf-app .kf-btn[disabled] { opacity: .7; cursor: progress; }
.kf-welcome .kf-btn { font-size: 20px; padding: 13px 26px; }
.kf-hint { font-size: 13px; color: var(--kf-text-soft); line-height: 1.35; }
.kf-hint small { font-size: 12px; opacity: .8; }
.kf-redirecting { margin-top: 18px; opacity: .6; font-size: 14px; }

/* Bottom navigation ------------------------------------------------------ */
.kf-nav { position: absolute; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 2px; z-index: 4; }
.kf-app .kf-nav-btn {
	width: 38px; height: 34px; display: grid; place-items: center; border: 0; margin: 0; padding: 0;
	background: var(--kf-accent); color: var(--kf-button-text); cursor: pointer; box-shadow: none; min-height: 0;
}
.kf-app .kf-nav-btn:first-of-type { border-radius: calc(var(--kf-radius) * .5) 0 0 calc(var(--kf-radius) * .5); }
.kf-app .kf-nav-btn:last-of-type { border-radius: 0 calc(var(--kf-radius) * .5) calc(var(--kf-radius) * .5) 0; margin-left: 1px; }
.kf-app .kf-nav-btn:hover { filter: brightness(1.1); background: var(--kf-accent); color: var(--kf-button-text); }
.kf-app .kf-nav-btn[disabled] { opacity: .45; cursor: default; filter: none; }
.kf-branding { margin-right: 10px; font-size: 12px; padding: 7px 10px; border-radius: 6px; background: var(--kf-answer-soft); color: var(--kf-text-soft); }

/* Popup ------------------------------------------------------------------- */
.kf-popup-open {
	display: inline-flex; align-items: center; border: 0; cursor: pointer; font-size: 17px; font-weight: 600; padding: 12px 22px; border-radius: 8px;
	background: var(--kf-accent, #2563eb); color: var(--kf-button-text, #fff);
}
.kf-popup { position: fixed; inset: 0; z-index: 999999; display: grid; place-items: center; padding: 20px; }
.kf-popup[hidden] { display: none; }
.kf-popup-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .6); animation: kfFade .2s ease; }
.kf-popup-dialog { position: relative; width: min(960px, 100%); height: min(680px, 100%); border-radius: 12px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); animation: kfPop .3s cubic-bezier(.2, .8, .2, 1); }
.kf-popup-dialog .klash-form { height: 100%; }
.kf-popup-close {
	position: absolute; top: 10px; right: 12px; z-index: 10; width: 36px; height: 36px; border: 0; border-radius: 50%;
	background: rgba(0, 0, 0, .08); color: inherit; font-size: 24px; line-height: 1; cursor: pointer;
}
html.kf-popup-lock { overflow: hidden; }

.kf-full-page .klash-form { height: 100vh; height: 100dvh; }

@keyframes kfFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes kfPop { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes kfShake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Mobile ------------------------------------------------------------------ */
@media (max-width: 600px) {
	.kf-inner { padding-top: 40px; padding-bottom: 88px; }
	.kf-q { flex-direction: column; gap: 4px; }
	.kf-app .kf-option { min-width: 0; width: 100%; }
	.kf-options.kf-options-inline { flex-direction: column; }
	.kf-app .kf-options-pictures .kf-option { width: calc(50% - 5px); min-width: 0; }
	.kf-opinion .kf-scale-row { flex-wrap: wrap; }
	.kf-app .kf-opinion .kf-scale-btn { flex: 1 0 calc(16.66% - 8px); height: 48px; }
	.kf-app .kf-rating:not(.kf-rating-number) .kf-scale-btn { width: 40px; }
	.kf-rating-icon svg { width: 34px; height: 34px; }
	.kf-popup { padding: 0; }
	.kf-popup-dialog { width: 100%; height: 100%; border-radius: 0; }
	.kf-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.kf-screen, .kf-progress span { transition: none; }
	.kf-enter-up, .kf-enter-down, .kf-leave-up, .kf-leave-down { transform: none; }
	.kf-blink, .kf-shake { animation: none; }
}
