/* Hindi English OCR Toolkit */
.heocr {
	--bg: #f4f6fb;
	--card: #ffffff;
	--text: #1c2333;
	--muted: #667085;
	--line: #e3e8f2;
	--brand: #5b5bf0;
	--brand-2: #8b5cf6;
	--brand-ink: #ffffff;
	--ok: #12a36b;
	--danger: #e5484d;
	--chip: #eef0ff;
	--shadow: 0 10px 30px rgba(28, 35, 51, .08);
	--radius: 18px;
	--hi-font: "Noto Sans Devanagari", "Nirmala UI", "Mangal", "Kohinoor Devanagari", "Lohit Devanagari", "Mukta", "Hind", sans-serif;
	--out-size: 17px;
	font-family: "Inter", "Noto Sans Devanagari", "Nirmala UI", "Mangal", "Kohinoor Devanagari", "Lohit Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--text);
	background: var(--bg);
	padding: clamp(14px, 3vw, 30px);
	border-radius: 24px;
	line-height: 1.55;
	box-sizing: border-box;
	position: relative;
}
.heocr *, .heocr *::before, .heocr *::after { box-sizing: border-box; }

.heocr[data-theme="dark"] {
	--bg: #0f1424; --card: #171d33; --text: #e8ecf8; --muted: #9aa4c0;
	--line: #262e4a; --chip: #232b4a; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
	.heocr[data-theme="auto"] {
		--bg: #0f1424; --card: #171d33; --text: #e8ecf8; --muted: #9aa4c0;
		--line: #262e4a; --chip: #232b4a; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
	}
}

/* Hero */
.heocr-hero {
	display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
	background: linear-gradient(135deg, var(--brand), var(--brand-2));
	color: #fff; border-radius: var(--radius); padding: clamp(18px, 3vw, 30px);
	box-shadow: var(--shadow); margin-bottom: 20px;
}
.heocr-badge {
	display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .04em;
	background: rgba(255, 255, 255, .2); padding: 4px 12px; border-radius: 999px; margin-bottom: 10px;
}
.heocr-title { margin: 0 0 6px; font-size: clamp(22px, 4vw, 34px); line-height: 1.2; color: #fff; font-weight: 700; }
.heocr-title__hi { font-weight: 500; opacity: .9; font-size: .72em; display: inline-block; }
.heocr-sub { margin: 0; max-width: 62ch; opacity: .92; font-size: clamp(14px, 2vw, 16px); color: #fff; }

.heocr-iconbtn {
	flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer;
	background: rgba(255, 255, 255, .2); color: #fff; display: grid; place-items: center; transition: background .2s;
}
.heocr-iconbtn:hover { background: rgba(255, 255, 255, .32); }

/* Layout */
.heocr-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .heocr-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; } }

.heocr-card {
	background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
	padding: clamp(14px, 2.4vw, 22px); box-shadow: var(--shadow);
}

/* Drop zone */
.heocr-drop {
	display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
	padding: 30px 16px; border: 2px dashed var(--line); border-radius: 16px; cursor: pointer;
	color: var(--muted); transition: border-color .2s, background .2s, transform .2s;
}
.heocr-drop svg { color: var(--brand); margin-bottom: 6px; }
.heocr-drop strong { color: var(--text); font-size: 17px; }
.heocr-drop:hover, .heocr-drop:focus-visible, .heocr-drop.is-over {
	border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, transparent); outline: none;
}
.heocr-drop.is-over { transform: scale(1.01); }
.heocr-drop kbd {
	background: var(--chip); border: 1px solid var(--line); border-bottom-width: 2px;
	border-radius: 6px; padding: 0 6px; font-size: 12px; font-family: inherit; color: var(--text);
}

/* File list */
.heocr-files { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.heocr-files li {
	display: flex; align-items: center; gap: 10px; padding: 8px 10px;
	border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.heocr-files .thumb {
	flex: none; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--chip);
	display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--brand);
}
.heocr-files .meta { flex: 1; min-width: 0; }
.heocr-files .name { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heocr-files .size { font-size: 12px; color: var(--muted); }
.heocr-files .rm {
	border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 8px;
}
.heocr-files .rm:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Form bits */
.heocr-row { margin-top: 16px; }
.heocr-field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.heocr select, .heocr input[type="text"] {
	width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
	background: var(--bg); color: var(--text); font: inherit; font-size: 14px; min-height: 42px;
}
.heocr select:focus, .heocr input[type="text"]:focus, .heocr-text:focus {
	outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; border-color: var(--brand);
}
.heocr-checks { display: grid; gap: 8px; margin-top: 14px; font-size: 13.5px; }
.heocr-checks label, .heocr-inline { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.heocr-checks em { color: var(--muted); font-style: normal; font-size: 12px; }
.heocr input[type="checkbox"] { accent-color: var(--brand); margin-top: 3px; width: 16px; height: 16px; flex: none; }

/* Buttons */
.heocr-btn {
	font: inherit; font-weight: 600; font-size: 14px; border-radius: 12px; border: 1px solid var(--line);
	background: var(--card); color: var(--text); padding: 10px 18px; cursor: pointer; min-height: 42px;
	transition: transform .12s, box-shadow .2s, background .2s, opacity .2s;
}
.heocr-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(28, 35, 51, .12); }
.heocr-btn:disabled { opacity: .45; cursor: not-allowed; }
.heocr-btn--primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; flex: 1; }
.heocr-btn--danger { background: var(--danger); color: #fff; border-color: transparent; }
.heocr-btn--ghost { background: transparent; }
.heocr-btn--sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
.heocr-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.heocr [hidden] { display: none !important; }

/* Progress */
.heocr-progress { margin-top: 16px; }
.heocr-progress__bar { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.heocr-progress__bar span {
	display: block; height: 100%; width: 0; border-radius: inherit;
	background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand));
	background-size: 200% 100%; animation: heocr-slide 1.4s linear infinite; transition: width .25s ease;
}
@keyframes heocr-slide { to { background-position: -200% 0; } }
.heocr-progress__meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Output */
.heocr-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.heocr-text {
	width: 100%; min-height: 320px; resize: vertical; padding: 14px; border-radius: 14px;
	border: 1px solid var(--line); background: var(--bg); color: var(--text);
	font-family: var(--hi-font) !important; font-size: var(--out-size) !important; line-height: 1.8 !important;
	letter-spacing: 0 !important; word-spacing: normal !important; text-transform: none !important;
	font-variant-ligatures: common-ligatures; font-feature-settings: "liga" 1, "clig" 1, "akhn" 1, "half" 1, "blwf" 1, "pstf" 1, "vatu" 1;
	text-rendering: optimizeLegibility;
}
.heocr-fontbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; }
.heocr-fontbar label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.heocr-fontbar select { width: auto; min-height: 36px; padding: 6px 10px; }
.heocr-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 2px 4px; font-size: 13px; color: var(--muted); }
.heocr-stats b { color: var(--text); }

/* Tools */
.heocr-tools { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.heocr-tools summary { cursor: pointer; font-weight: 700; font-size: 15px; padding: 4px 0; }
.heocr-toolgroup { margin-top: 12px; }
.heocr-toolgroup h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.heocr-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.heocr-chip {
	font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 999px; border: 0;
	background: var(--chip); color: var(--brand); cursor: pointer; transition: transform .12s, filter .2s;
}
.heocr[data-theme="dark"] .heocr-chip { color: #b6b6ff; }
.heocr-chip:hover { filter: brightness(.96); transform: translateY(-1px); }
.heocr-fr { display: grid; gap: 8px; grid-template-columns: 1fr; align-items: center; }
@media (min-width: 640px) { .heocr-fr { grid-template-columns: 1fr 1fr auto auto; } }

/* History */
.heocr-history { margin-top: 20px; }
.heocr-history__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.heocr-history h3 { margin: 0; font-size: 16px; }
.heocr-history h3 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.heocr-hist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .heocr-hist { grid-template-columns: 1fr 1fr; } }
.heocr-hist li {
	border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 12px;
	cursor: pointer; transition: border-color .2s, transform .12s;
}
.heocr-hist li:hover { border-color: var(--brand); transform: translateY(-1px); }
.heocr-hist .t { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heocr-hist .d { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.heocr-hist .s {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	font-size: 13px; color: var(--muted);
}
.heocr-empty { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Toast + notice */
.heocr-toast {
	position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
	background: #111827; color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .3); transition: .25s; z-index: 99999; max-width: 90vw; text-align: center;
}
.heocr-toast.show { opacity: 1; transform: translate(-50%, 0); }
.heocr-notice { padding: 16px 20px; border: 1px solid #e3e8f2; border-radius: 14px; background: #f8f9ff; }

@media (max-width: 480px) {
	.heocr-hero { flex-direction: column-reverse; align-items: stretch; }
	.heocr-iconbtn { align-self: flex-end; }
	.heocr-toolbar .heocr-btn { flex: 1 1 calc(50% - 8px); }
	.heocr-text { min-height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
	.heocr * { animation: none !important; transition: none !important; }
}
