/* css/app.css */
:root[data-theme=dark] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --text-dim: #484f58;
  --accent: #58a6ff;
  --accent-dim: #1f3a5c;
  --accent-hover: #79b8ff;
  --green: #3fb950;
  --green-dim: #1a3a24;
  --yellow: #d29922;
  --yellow-dim: #3a2e0a;
  --red: #f85149;
  --red-dim: #3a1a1a;
  --purple: #bc8cff;
  --purple-dim: #2d1f4e;
  --shadow: rgba(0,0,0,0.4);
}
:root[data-theme=light] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-dim: #9198a1;
  --accent: #0969da;
  --accent-dim: #ddf4ff;
  --accent-hover: #0550ae;
  --green: #1a7f37;
  --green-dim: #dafbe1;
  --yellow: #9a6700;
  --yellow-dim: #fff8c5;
  --red: #cf222e;
  --red-dim: #ffebe9;
  --purple: #8250df;
  --purple-dim: #fbefff;
  --shadow: rgba(0,0,0,0.08);
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
:root {
  --mono:
    "JetBrains Mono","Fira Code",ui-monospace,monospace;
  --sans:
    "Inter",system-ui,-apple-system,sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 200;
  box-shadow: 0 1px 4px var(--shadow);
}
.logo {
  width: 32px;
  height: 32px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  font-size: 10px;
  font-family: var(--mono);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.theme-btn:hover {
  background: var(--border);
}
.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-card {
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}
.mode-card:hover {
  border-color: var(--text-muted);
  background: var(--surface2);
}
.mode-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.mode-icon {
  font-size: 20px;
  margin-bottom: 4px;
}
.mode-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.mode-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.mode-card.active .mode-desc {
  color: var(--accent);
}
.api-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.api-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.api-section-header:hover {
  background: var(--surface2);
}
.api-section-title {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex: 1;
}
.api-section-summary {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--green);
  display: none;
}
.api-section.has-key .api-section-summary {
  display: block;
}
.api-section-chevron {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s;
}
.api-section.collapsed .api-section-chevron {
  transform: rotate(-90deg);
}
.api-section-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}
.api-section.collapsed .api-section-body {
  display: none;
}
.api-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.api-row:last-child {
  margin-bottom: 0;
}
.api-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--mono);
  min-width: 80px;
}
.api-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.api-input:focus {
  border-color: var(--accent);
}
.api-input::placeholder {
  color: var(--text-dim);
}
.api-input.valid {
  border-color: var(--green);
}
.api-input.error {
  border-color: var(--red);
}
.api-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-top: 10px;
}
.api-tab {
  padding: 5px 12px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.12s;
}
.api-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.api-status {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.api-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.api-dot.ok {
  background: var(--green);
}
.api-dot.working {
  background: var(--yellow);
  animation: pulse 1s ease-in-out infinite;
}
.api-dot.err {
  background: var(--red);
}
.decrypt-btn {
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: var(--mono);
}
.decrypt-btn:hover {
  background: var(--accent);
  color: var(--bg);
}
.decrypt-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.source-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.section-label {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
}
.source-chip {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.source-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.capture-zone {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.capture-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.capture-placeholder:hover {
  background: var(--surface2);
}
.capture-icon {
  width: 56px;
  height: 56px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-muted);
}
.capture-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.capture-sub {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
#preview-img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
  background: #000;
}
.preview-actions {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
}
.btn:hover {
  background: var(--border);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:disabled {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--text-muted);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-full {
  width: 100%;
  justify-content: center;
}
.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.status-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.status-bar.visible {
  display: flex;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
.results {
  display: none;
}
.results.visible {
  display: block;
}
.score-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.score-num {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
  flex-shrink: 0;
}
.score-track {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.score-fill.high {
  background: var(--green);
}
.score-fill.mid {
  background: var(--yellow);
}
.score-fill.low {
  background: var(--red);
}
.score-label {
  font-size: 12px;
  color: var(--text-muted);
}
.fields-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.field-row {
  display: grid;
  grid-template-columns: 180px 1fr 80px;
  border-bottom: 1px solid var(--border);
}
.field-row:last-child {
  border-bottom: none;
}
.field-key {
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  word-break: break-all;
}
.field-val {
  padding: 9px 12px;
  font-size: 12px;
  color: var(--text);
  word-break: break-word;
  display: flex;
  align-items: center;
}
.field-val.null-val {
  color: var(--text-dim);
  font-style: italic;
}
.field-conf {
  padding: 9px 8px;
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.conf-pill {
  font-size: 10px;
  font-family: var(--mono);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.conf-pill.extracted {
  background: var(--green-dim);
  color: var(--green);
}
.conf-pill.inferred {
  background: var(--yellow-dim);
  color: var(--yellow);
}
.conf-pill.default {
  background: var(--accent-dim);
  color: var(--accent);
}
.conf-pill.missing {
  background: var(--red-dim);
  color: var(--red);
}
.notes-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.notes-block ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 12px;
}
.notes-block li {
  margin-bottom: 3px;
}
.missing-block {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.missing-block h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--yellow);
}
.missing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.missing-tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(210, 153, 34, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(210, 153, 34, 0.3);
}
.hint-panel {
  background: var(--purple-dim);
  border: 1px solid var(--purple);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.hint-header {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(188, 140, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(188, 140, 255, 0.08);
}
.hint-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hint-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
}
.hint-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}
.pyodide-badge {
  font-size: 9px;
  background: rgba(188, 140, 255, 0.15);
  color: var(--purple);
  border: 1px solid rgba(188, 140, 255, 0.4);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
}
.pyodide-status {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
#header-py-status {
  opacity: 0.7;
}
.py-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.py-dot.ready {
  background: var(--green);
}
.py-dot.loading {
  background: var(--yellow);
  animation: pulse 1s ease-in-out infinite;
}
.hint-tabs {
  display: flex;
  border-bottom: 1px solid rgba(188, 140, 255, 0.3);
}
.hint-tab {
  padding: 6px 14px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.12s;
}
.hint-tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}
.hint-body {
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.6;
}
[data-theme=dark] .hint-body {
  color: #c9d1d9;
}
[data-theme=light] .hint-body {
  color: #1f2328;
}
.json-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
.json-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
}
.json-body {
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: pre;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
}
.error-block {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.error-block.visible {
  display: block;
}
#file-camera,
#file-upload {
  display: none;
}
@media (max-width:480px) {
  .field-row {
    grid-template-columns: 120px 1fr 68px;
  }
  .field-key {
    font-size: 10px;
  }
  .api-label {
    min-width: 60px;
    font-size: 10px;
  }
}
