:root {
  color-scheme: dark;
  --bg: #11131a;
  --panel: rgba(27, 29, 39, .82);
  --panel-strong: rgba(31, 34, 45, .96);
  --panel-soft: rgba(255, 255, 255, .035);
  --border: rgba(205, 214, 244, .10);
  --border-strong: rgba(205, 214, 244, .18);
  --text: #d9dceb;
  --muted: #8e93a8;
  --faint: #686d80;
  --accent: #a9b7e9;
  --accent-strong: #c0c9ef;
  --accent-bg: rgba(169, 183, 233, .12);
  --green: #9fc5aa;
  --yellow: #d7bd8c;
  --red: #d69a9a;
  --shadow: 0 26px 70px rgba(0, 0, 0, .28);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% -10%, rgba(129, 140, 190, .12), transparent 33%),
    radial-gradient(circle at 95% 10%, rgba(114, 156, 155, .08), transparent 29%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E"); }
.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 18, 25, .76);
  backdrop-filter: blur(22px) saturate(120%);
  position: relative;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--panel-soft); border-radius: 11px; }
.brand-mark svg { width: 21px; fill: none; stroke: var(--accent-strong); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brand strong { display: block; letter-spacing: -.02em; font-size: 15px; }
.brand span { display: block; color: var(--muted); font-size: 11px; margin-top: -1px; }
.status-pill { justify-self: center; display: flex; align-items: center; gap: 8px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 6px 11px; background: rgba(255,255,255,.025); font-size: 12px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(215,189,140,.08); }
.status-pill.ready i { background: var(--green); box-shadow: 0 0 0 4px rgba(159,197,170,.08); }
.status-pill.error i { background: var(--red); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.button, button { border: 0; cursor: pointer; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border-radius: 10px; padding: 9px 13px; font-weight: 600; transition: .18s ease; user-select: none; }
.button.secondary, .ghost { border: 1px solid var(--border); background: rgba(255,255,255,.035); }
.button.secondary:hover, .ghost:hover { border-color: var(--border-strong); background: rgba(255,255,255,.065); }
.ghost { padding: 8px 11px; border-radius: 9px; color: var(--muted); }
.button.primary { min-width: 190px; background: var(--accent); color: #161923; box-shadow: 0 8px 26px rgba(143, 156, 210, .13); }
.button.primary:hover:not(:disabled) { background: var(--accent-strong); transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.workspace { height: calc(100vh - 68px); display: grid; grid-template-columns: minmax(235px, 285px) minmax(410px, 1fr) minmax(330px, 430px); gap: 12px; padding: 12px; position: relative; z-index: 1; }
.panel { min-width: 0; min-height: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px) saturate(112%); overflow: hidden; }
.panel-heading { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { font-size: 14px; margin: 1px 0 0; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow { display: block; color: var(--faint); font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .15em; }
.icon-button { height: 31px; min-width: 31px; display: grid; place-items: center; border: 1px solid var(--border); background: rgba(255,255,255,.025); border-radius: 8px; color: var(--muted); padding: 0 8px; }
.icon-button:hover { color: var(--text); border-color: var(--border-strong); }
.icon-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.library-panel { display: flex; flex-direction: column; }
.search-box { margin: 11px 12px 7px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; border: 1px solid var(--border); background: rgba(0,0,0,.10); border-radius: 10px; padding: 0 9px; }
.search-box:focus-within { border-color: rgba(169,183,233,.36); box-shadow: 0 0 0 3px rgba(169,183,233,.06); }
.search-box svg { width: 15px; fill: none; stroke: var(--faint); stroke-width: 1.8; }
.search-box input { height: 36px; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: var(--faint); }
kbd { min-width: 22px; padding: 2px 5px; border: 1px solid var(--border); border-radius: 5px; background: rgba(255,255,255,.03); color: var(--faint); text-align: center; font-size: 10px; font-family: inherit; }
.image-list { flex: 1; min-height: 0; overflow: auto; padding: 4px 7px 10px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.image-item { width: 100%; display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: transparent; text-align: left; border: 1px solid transparent; margin: 2px 0; }
.image-item:hover { background: rgba(255,255,255,.035); }
.image-item.active { background: var(--accent-bg); border-color: rgba(169,183,233,.18); }
.thumb { width: 48px; height: 48px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; background: #0c0e13; }
.image-copy { min-width: 0; }
.image-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.image-copy span { display: block; color: var(--faint); font-size: 10px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.done-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); opacity: .9; }
.empty-state { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 24px; color: var(--muted); }
.empty-state span { max-width: 180px; font-size: 12px; margin-top: 4px; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px dashed var(--border-strong); border-radius: 12px; margin-bottom: 11px; color: var(--accent); font-size: 22px; }
.preview-panel { display: grid; grid-template-rows: 72px minmax(0,1fr) 62px; }
.preview-heading { min-width: 0; }
.preview-heading > div:first-child { min-width: 0; }
.file-meta { display: block; color: var(--faint); font-size: 10px; margin-top: 2px; }
.zoom-controls { display: flex; align-items: center; gap: 5px; }
.zoom-controls span { min-width: 42px; text-align: center; color: var(--faint); font-size: 10px; }
.image-stage { position: relative; min-height: 0; overflow: auto; display: grid; place-items: center; background-color: #0d0f15; background-image: linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.018) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.018) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.018) 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
#previewImage { display: none; max-width: none; max-height: none; transform-origin: center; box-shadow: 0 15px 42px rgba(0,0,0,.42); border: 1px solid rgba(255,255,255,.08); user-select: none; }
.stage-placeholder { display: flex; flex-direction: column; align-items: center; color: var(--faint); }
.stage-placeholder svg { width: 44px; height: 44px; fill: none; stroke: var(--faint); stroke-width: 1.2; margin-bottom: 10px; opacity: .55; }
.stage-placeholder strong { color: var(--muted); font-weight: 600; }
.stage-placeholder span { font-size: 12px; margin-top: 2px; }
.drop-hint { position: absolute; inset: 20px; display: none; place-content: center; text-align: center; z-index: 4; border: 1px dashed rgba(169,183,233,.55); border-radius: 14px; background: rgba(18,20,28,.88); backdrop-filter: blur(12px); color: var(--accent-strong); }
.drop-hint span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.dragging .drop-hint { display: grid; }
.scan-bar { display: flex; align-items: center; gap: 14px; padding: 10px 13px; border-top: 1px solid var(--border); background: rgba(12,14,20,.22); }
.scan-bar .button { margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; user-select: none; cursor: pointer; }
.check input { display: none; }
.check span { width: 15px; height: 15px; border: 1px solid var(--border-strong); border-radius: 5px; background: rgba(0,0,0,.14); position: relative; }
.check input:checked + span { background: var(--accent); border-color: var(--accent); }
.check input:checked + span::after { content: ""; position: absolute; width: 7px; height: 4px; border-left: 1.6px solid #151823; border-bottom: 1.6px solid #151823; transform: rotate(-45deg); left: 3px; top: 3px; }
.scan-hint { color: var(--faint); font-size: 10px; }
.button-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(20,23,32,.28); border-top-color: #151820; border-radius: 50%; animation: spin .75s linear infinite; }
.scanning .button-spinner { display: block; }
.scanning .button-label { opacity: .75; }
.result-panel { display: grid; grid-template-rows: 72px 42px minmax(0,1fr) 36px; }
.result-heading { padding-right: 10px; }
.tab-switcher { display: flex; gap: 2px; padding: 3px; background: rgba(0,0,0,.13); border: 1px solid var(--border); border-radius: 8px; }
.tab-switcher button { padding: 5px 8px; border-radius: 5px; background: transparent; color: var(--faint); font-size: 10px; }
.tab-switcher button.active { color: var(--text); background: rgba(255,255,255,.07); }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); color: var(--faint); font-size: 10px; }
.result-toolbar > div { display: flex; gap: 3px; }
.text-button { background: transparent; color: var(--muted); padding: 5px 6px; border-radius: 5px; font-size: 10px; }
.text-button:hover:not(:disabled) { background: rgba(255,255,255,.05); color: var(--text); }
.text-button.accent { color: var(--accent); }
.text-button:disabled { opacity: .35; cursor: default; }
.result-content { min-height: 0; position: relative; background: rgba(6,8,12,.28); }
#jsonEditor, #rawOutput { width: 100%; height: 100%; margin: 0; padding: 14px; border: 0; outline: 0; resize: none; overflow: auto; background: transparent; color: #cdd1e1; font: 11.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; tab-size: 2; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
#jsonEditor::placeholder { color: #555a6b; }
#jsonEditor:focus { box-shadow: inset 0 0 0 1px rgba(169,183,233,.16); }
#rawOutput { white-space: pre-wrap; word-break: break-word; }
.result-footer { display: flex; justify-content: space-between; align-items: center; padding: 0 12px; border-top: 1px solid var(--border); color: var(--faint); font-size: 9px; }
.bootstrap { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); z-index: 20; transition: .35s ease; }
.bootstrap.hidden { opacity: 0; transform: translate(-50%, -12px); pointer-events: none; }
.bootstrap-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--border-strong); border-radius: 14px; padding: 12px 14px; background: rgba(30,32,43,.94); box-shadow: 0 18px 60px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.loader-ring { width: 25px; height: 25px; border: 2px solid rgba(169,183,233,.16); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; grid-row: span 2; }
.bootstrap-copy { min-width: 0; }
.bootstrap-copy strong, .bootstrap-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bootstrap-copy strong { font-size: 12px; }
.bootstrap-copy span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.progress-track { height: 3px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.06); }
.progress-track div { width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.progress-value { grid-row: span 2; color: var(--muted); font: 10px ui-monospace, monospace; }
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--panel-strong); box-shadow: 0 14px 40px rgba(0,0,0,.35); animation: toast-in .2s ease; }
.toast strong { display: block; font-size: 11px; }
.toast span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.toast.error { border-color: rgba(214,154,154,.32); }
.hidden { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 980px) {
  body { overflow: auto; }
  .workspace {
    height: auto;
    min-height: calc(100vh - 68px);
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: minmax(560px, calc(100vh - 90px)) minmax(480px, 70vh);
  }
  .result-panel { grid-column: 1 / -1; min-height: 480px; }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; }
  .status-pill { display: none; }
  .header-actions .ghost { display: none; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 260px minmax(520px, 72vh) minmax(500px, 72vh);
  }
  .result-panel { grid-column: 1; }
  .scan-hint { display: none; }
}
