:root {
  --bg: #0b1c33;
  --card: rgba(18, 40, 70, 0.88);
  --line: rgba(255, 255, 255, 0.16);
  --text: #e8eef7;
  --muted: #9bb0c9;
  --accent: #38bdf8;
  --accent2: #2563eb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(700px 380px at 90% 10%, rgba(37, 99, 235, 0.16), transparent 50%),
    var(--bg);
}
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.brand { display: flex; gap: 0.75rem; align-items: center; }
.logo {
  width: 2.5rem; height: 2.5rem; border-radius: 0.7rem;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 700;
}
.brand h1 { margin: 0; font-size: 1.25rem; }
.brand p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; }
.status {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.status[data-state="ok"] { color: #86efac; border-color: rgba(134,239,172,.35); }
.status[data-state="warn"] { color: #fde68a; border-color: rgba(253,230,138,.35); }
.status[data-state="bad"] { color: #fca5a5; border-color: rgba(252,165,165,.35); }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.tab.active { color: #fff; background: rgba(56,189,248,0.18); border-color: rgba(56,189,248,0.45); }
.panel {
  display: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 0.9rem;
}
.panel.active { display: block; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.9rem; }
.field { display: block; margin-bottom: 0.75rem; color: var(--muted); font-size: 0.85rem; }
.field input, .field select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  color: var(--text);
}
.file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
  border: 1.5px dashed rgba(125, 211, 252, 0.4);
  border-radius: 0.8rem;
  background: rgba(56, 189, 248, 0.05);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.file:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}
.file input[type="file"] {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file .file-btn {
  flex: 0 0 auto;
  padding: 0.5rem 1.05rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}
.file .file-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.check { display: flex; align-items: center; gap: 0.45rem; margin: 0.5rem 0 0.9rem; color: var(--muted); }
.primary {
  border: 0;
  border-radius: 0.65rem;
  padding: 0.65rem 1.1rem;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.primary:disabled { opacity: 0.55; cursor: wait; }
.progress {
  margin: 0.9rem 0 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(0, 0, 0, 0.2);
}
.progress.hidden { display: none; }
.progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.35s ease;
}
.progress-msg {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}
.cancel {
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.4rem 0.9rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.cancel:hover { color: #fca5a5; border-color: rgba(252,165,165,.45); }
.log {
  min-height: 7rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.28);
  color: #cbd5e1;
  white-space: pre-wrap;
  font-size: 0.82rem;
}
.btn-row { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.pick-btn { display: inline-flex; align-items: center; gap: 0.7rem; cursor: pointer; }
.pick-btn input[type="file"] { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pick-btn .pick-btn-label {
  display: inline-block; padding: 0.6rem 1.1rem; border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
  font-weight: 600; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(56, 189, 248, 0.35);
}
.pick-btn .pick-btn-name { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#panel-ocr { position: relative; padding: 0; }
.ocr-frame-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  overflow: hidden;
  background: var(--bg);
}
.ocr-frame-wrap iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 250px);
  min-height: 620px;
  border: 0;
  background: var(--bg);
}
.ocr-loading {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg); color: var(--muted); font-size: 0.95rem;
}
.ocr-loading .spinner {
  width: 42px; height: 42px;
  border: 3px solid rgba(56, 189, 248, 0.2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#ocrToolsBtn {
  display: none; align-items: center; gap: 0.4rem;
  position: fixed; top: 0.65rem; right: 0.65rem; z-index: 2147482999;
  padding: 0.45rem 0.8rem; border-radius: 8px; cursor: pointer;
  background: rgba(15, 23, 42, 0.92); border: 1px solid rgba(147, 197, 253, 0.45);
  color: #f8fafc; font-size: 0.82rem; font-weight: 600;
}
body.ocr-full #ocrToolsBtn { display: inline-flex; }
body.ocr-full .shell { max-width: 100%; padding: 0; }
body.ocr-full .top,
body.ocr-full .tabs { display: none !important; }
body.ocr-full #panel-ocr { border: 0; border-radius: 0; padding: 0; margin: 0; }
body.ocr-full .ocr-frame-wrap { border: 0; border-radius: 0; }
body.ocr-full .ocr-frame-wrap iframe { height: 100vh; height: 100dvh; min-height: 0; }
@media (max-width: 640px) {
  .ocr-frame-wrap iframe { height: 82vh; }
  body.ocr-full .ocr-frame-wrap iframe { height: 100vh; height: 100dvh; }
}
