:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1e6fd9;
  --ok: #148a49;
  --err: #c43d3d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #d7deea;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
}
.topbar h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  min-width: 0;
}
#submitBtn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
.app { padding: 14px; }
.status {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 auto 10px;
  max-width: 980px;
}
.pdf-stage {
  max-width: 980px;
  margin: 0 auto;
  padding: 0;
}
.pdf-pages {
  display: grid;
  gap: 16px;
  justify-content: center;
}
.pdf-page {
  position: relative;
  width: fit-content;
  background: #fff;
  box-shadow: 0 2px 12px rgba(16, 24, 40, 0.14);
}
.pdf-canvas { display: block; }
.field-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.overlay-field-wrap {
  position: absolute;
  pointer-events: auto;
}
.overlay-field {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.2px solid rgba(30, 55, 95, 0.45);
  color: #162238;
  padding: 1px 2px;
  font-size: 11px;
  line-height: 1.2;
  resize: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.overlay-field:focus {
  outline: none;
  border-bottom-color: #245fc4;
  background: rgba(165, 197, 245, 0.12);
}
textarea.overlay-field { overflow: hidden; }

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
  }

  .topbar h1 {
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #submitBtn {
    padding: 9px 10px;
    font-size: 0.84rem;
  }

  .app {
    padding: 8px;
  }

  .status {
    font-size: 0.82rem;
    margin-bottom: 8px;
  }

  .pdf-pages {
    gap: 10px;
  }

  .pdf-page {
    box-shadow: 0 1px 8px rgba(16, 24, 40, 0.12);
  }
}
