/* Search-by-image modal (shared header). All classes are prefixed isx- to avoid clashes. */
.isx { --isx-accent: #2563eb; --isx-accent2: #4f46e5; --isx-ink: #0f172a; --isx-muted: #64748b; --isx-line: #e2e8f0;
	position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 16px;
	font-family: inherit; color: var(--isx-ink); }
.isx[hidden], .isx [hidden] { display: none !important; }
html.isx-lock, html.isx-lock body { overflow: hidden; }

.isx-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: isx-fade .2s ease; }
.isx-panel { position: relative; width: min(960px, 100%); max-height: min(90vh, 880px); display: flex; flex-direction: column;
	background: #fff; border-radius: 22px; box-shadow: 0 30px 80px rgba(15, 23, 42, .35); overflow: hidden; animation: isx-pop .28s cubic-bezier(.2, .9, .3, 1.1); }

/* header */
.isx-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--isx-line); }
.isx-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.isx-title-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff;
	background: linear-gradient(135deg, var(--isx-accent), var(--isx-accent2)); box-shadow: 0 6px 16px rgba(37, 99, 235, .35); }
.isx-title h2 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.2; }
.isx-title p { margin: 2px 0 0; font-size: 13px; color: var(--isx-muted); }
.isx-close { flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1f5f9; color: #334155; display: grid; place-items: center; cursor: pointer; transition: background .15s, transform .15s; }
.isx-close:hover { background: #e2e8f0; transform: rotate(90deg); }

.isx-body { padding: 22px; overflow-y: auto; flex: 1; min-height: 0; }
.isx-stage { animation: isx-fade .25s ease; }

/* buttons */
.isx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 11px 20px; font-size: 14px; font-weight: 600; cursor: pointer; transition: transform .12s, box-shadow .15s, background .15s; }
.isx-btn:active { transform: scale(.97); }
.isx-btn-primary { color: #fff; background: linear-gradient(135deg, var(--isx-accent), var(--isx-accent2)); box-shadow: 0 8px 20px rgba(37, 99, 235, .35); }
.isx-btn-primary:hover { box-shadow: 0 10px 26px rgba(37, 99, 235, .5); }
.isx-btn-ghost { color: #334155; background: #f1f5f9; }
.isx-btn-ghost:hover { background: #e2e8f0; }

/* 1. upload */
.isx-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 44px 20px; cursor: pointer; outline: 0;
	border-radius: 18px; border: 2px dashed #b6c4dc; background: linear-gradient(180deg, #f8fafc, #eef4ff); transition: border-color .2s, background .2s, transform .2s; }
.isx-drop:hover, .isx-drop:focus-visible, .isx-drop.is-over { border-color: var(--isx-accent); background: linear-gradient(180deg, #f3f7ff, #e3edff); }
.isx-drop.is-over { transform: scale(1.01); }
.isx-drop-art { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; color: var(--isx-accent); background: #fff; box-shadow: 0 10px 28px rgba(37, 99, 235, .18); margin-bottom: 10px; animation: isx-float 3.2s ease-in-out infinite; }
.isx-drop-title { margin: 0; font-size: 18px; font-weight: 700; }
.isx-drop-sub { margin: 0 0 14px; color: var(--isx-muted); font-size: 14px; }
.isx-drop-hint { margin: 10px 0 0; font-size: 12px; color: #94a3b8; }
.isx-error, .isx-scan-error p { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: #fef2f2; color: #b42318; font-size: 14px; }

.isx-or { display: flex; align-items: center; gap: 12px; margin: 16px 0 12px; color: #94a3b8; font-size: 13px; }
.isx-or::before, .isx-or::after { content: ""; flex: 1; height: 1px; background: var(--isx-line); }
.isx-cam-open { display: flex; margin: 0 auto; }

/* 1b. live camera */
.isx-cam-stage { display: flex; justify-content: center; background: #0f172a; border-radius: 16px; padding: 10px; }
.isx-cam-stage video { display: block; width: 100%; max-width: 720px; max-height: 58vh; border-radius: 10px; background: #000; object-fit: contain; }

/* 2. crop */
.isx-tip { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--isx-muted); }
.isx-tip b { color: #111827; font-weight: 600; }
.isx-stage-tip { margin: 0 0 12px; font-size: 14px; color: var(--isx-muted); text-align: center; }
.isx-crop-stage { display: flex; justify-content: center; background: #0f172a; border-radius: 16px; padding: 14px; background-image: radial-gradient(#1e293b 1px, transparent 1px); background-size: 14px 14px; }
.isx-crop-wrap { position: relative; display: inline-block; line-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; border-radius: 4px; }
.isx-crop-wrap img { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; pointer-events: none; }
.isx-sel { position: absolute; cursor: move; touch-action: none; box-sizing: border-box; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .62), 0 0 0 1px rgba(37, 99, 235, .9); }
.isx-grid-line { position: absolute; background: rgba(255, 255, 255, .45); pointer-events: none; }
.isx-gl-v1, .isx-gl-v2 { top: 0; bottom: 0; width: 1px; }
.isx-gl-h1, .isx-gl-h2 { left: 0; right: 0; height: 1px; }
.isx-gl-v1 { left: 33.33%; } .isx-gl-v2 { left: 66.66%; } .isx-gl-h1 { top: 33.33%; } .isx-gl-h2 { top: 66.66%; }
.isx-h { position: absolute; width: 16px; height: 16px; background: #fff; border: 2px solid var(--isx-accent); border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transform: translate(-50%, -50%); touch-action: none; }
.isx-h::after { content: ""; position: absolute; inset: -10px; } /* bigger touch target */
.isx-h-nw { left: 0; top: 0; cursor: nwse-resize; } .isx-h-n { left: 50%; top: 0; cursor: ns-resize; } .isx-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.isx-h-e { left: 100%; top: 50%; cursor: ew-resize; } .isx-h-se { left: 100%; top: 100%; cursor: nwse-resize; } .isx-h-s { left: 50%; top: 100%; cursor: ns-resize; }
.isx-h-sw { left: 0; top: 100%; cursor: nesw-resize; } .isx-h-w { left: 0; top: 50%; cursor: ew-resize; }
.isx-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

/* 3. scanning */
.isx-scan { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 0 14px; }
.isx-scan-frame { position: relative; display: inline-block; line-height: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 16px 40px rgba(15, 23, 42, .3); }
.isx-scan-frame img { display: block; max-width: min(100%, 420px); max-height: 46vh; width: auto; height: auto; }
.isx-scan-frame::after { content: ""; position: absolute; inset: 0; background: rgba(37, 99, 235, .12); }
.isx-scan-grid { position: absolute; inset: 0; z-index: 1; background-image: linear-gradient(rgba(255, 255, 255, .18) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .18) 1px, transparent 1px); background-size: 22px 22px; animation: isx-grid 2.4s linear infinite; }
.isx-scan-line { position: absolute; left: 0; right: 0; height: 64px; z-index: 2; top: -64px; background: linear-gradient(180deg, rgba(56, 189, 248, 0), rgba(56, 189, 248, .55)); border-bottom: 2px solid #7dd3fc; box-shadow: 0 8px 26px rgba(56, 189, 248, .8); animation: isx-scan 1.7s cubic-bezier(.45, 0, .55, 1) infinite; }
.isx-corner { position: absolute; z-index: 3; width: 26px; height: 26px; border: 3px solid #fff; filter: drop-shadow(0 0 4px rgba(37, 99, 235, .9)); animation: isx-pulse 1.4s ease-in-out infinite; }
.isx-c-tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.isx-c-tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.isx-c-bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.isx-c-br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.isx-scan-text { margin: 0; font-size: 15px; font-weight: 600; color: #334155; letter-spacing: .2px; }
.isx-scan-text::after { content: ""; display: inline-block; width: 1.4em; text-align: left; animation: isx-dots 1.2s steps(4, end) infinite; }
.isx-scan-error { text-align: center; }

/* 4. results */
.isx-res-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--isx-line); }
.isx-res-head img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; box-shadow: 0 4px 14px rgba(15, 23, 42, .2); }
.isx-res-info { flex: 1; min-width: 140px; }
.isx-res-info h3 { margin: 0; font-size: 17px; font-weight: 700; }
.isx-res-info p { margin: 2px 0 0; font-size: 13px; color: var(--isx-muted); }
.isx-res-actions { display: flex; gap: 8px; }
.isx-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.isx-card { animation: isx-rise .4s ease both; }
.isx-card a { display: block; color: inherit; text-decoration: none; border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--isx-line); transition: transform .18s, box-shadow .18s, border-color .18s; }
.isx-card a:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(15, 23, 42, .16); border-color: #bfd0f5; }
.isx-card-img { display: block; aspect-ratio: 1 / 1; width: 100%; object-fit: contain; background: #f1f5f9; }
.isx-card-name { display: block; padding: 10px 12px 2px; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.isx-card-meta { display: block; padding: 0 12px 11px; font-size: 12px; color: var(--isx-muted); }
.isx-empty { text-align: center; color: var(--isx-muted); padding: 28px 0; }

/* animations */
@keyframes isx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes isx-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes isx-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes isx-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes isx-scan { 0% { top: -64px; } 100% { top: 100%; } }
@keyframes isx-grid { from { background-position: 0 0; } to { background-position: 22px 22px; } }
@keyframes isx-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.92); } }
@keyframes isx-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }

@media (prefers-reduced-motion: reduce) {
	.isx *, .isx *::before, .isx *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* phones: full-screen sheet */
@media (max-width: 640px) {
	.isx { padding: 0; align-items: flex-end; }
	.isx-panel { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
	.isx-head { padding: 14px 16px; }
	.isx-body { padding: 16px; }
	.isx-drop { padding: 34px 14px; }
	.isx-results { grid-template-columns: repeat(2, 1fr); gap: 10px; }
	.isx-res-actions { width: 100%; }
	.isx-res-actions .isx-btn { flex: 1; }
	.isx-actions .isx-btn { flex: 1 1 100%; }
}
